samples/arch/smp/pktqueue/README.html · samples/arch/smp/pktqueue/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · SMP

SMP pktqueue

여러 queue와 thread가 IPv4 header CRC를 검증하고 SMP core 확장에 따른 처리 시간을 측정합니다.

Official pathsamples/arch/smp/pktqueue/README.html
Source filesamples/arch/smp/pktqueue/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

IPv4 header 32-bit layout, CRC16 field, queue·thread parameter와 qemu_x86_64 처리 결과를 보존합니다.

Protocol

RFC 1812 · IPv4

Workload

CRC16 · Packet queue

Scale

Queues · Threads · Cores

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 FCC7AF2CB51E1F47E9737A553746B048D348CD7F763D625AE699ED50BC544502
.. _smp_pktqueue:

SMP pktqueue
############

Overview
********

This sample application performs a simplified network layer forwarding function
(essentially checksum calculation from IP Header Validation) of the Internet protocol
suite specified in RFC1812 "Requirements for IP Version 4 Routers" which
can be found at http://www.faqs.org/rfcs/rfc1812.html. This application
provides an indication of the potential performance of a microprocessor in an
IP router system.

At the beginning of the application the array (size defined in SIZE_OF_QUEUE)
of packet headers is initialized. Each header contains some random data of size
defined in SIZE_OF_HEADER and calculated crc16 header checksum
in appropriate field defined by CRC_BYTE_1 and CRC_BYTE_2. The contents of
header follows:

   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | 0 - 3 | 4 - 7 |     8 - 15    |            16 - 31            |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Time to Live |    Protocol   |         Header Checksum       |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                       Source Address                          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Destination Address                        |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Options                    |    Padding    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The headers then are stored in multiple "sender" queues (the number is defined
in QUEUE_NUM). After that for each pair of "sender"/"receiver" queues one thread
is created, which will control "sender" queue processing.

Then in each queue-related thread several(defined in THREADS_NUM) threads are created. Each
of them first pick the header from "sender" queue, calculates crc and if
crc is correct put the header to "receiver" queue. Only one thread in a
time can access to sender or receiver queue.

As soon as all headers in each pair of queues are moved from "sender" to
"receiver" queue the execution of threads(related to pair) are terminated.

By changing the value of CONFIG_MP_MAX_NUM_CPUS on SMP systems, you
can see that using more cores takes almost linearly less time
to complete the computational task.

You can also edit the sample source code to change the
number of parallel executed pairs of queues(``QUEUE_NUM``),
the number of threads per pair of queues(``THREADS_NUM``),
the number of headers in queue (``SIZE_OF_QUEUE``), and
size of header in bytes (``SIZE_OF_HEADER``).

Building and Running
********************

This project outputs total time required for processing all packet headers.
It can be built and executed on QEMU as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/arch/smp/pktqueue
   :host-os: unix
   :board: qemu_x86_64
   :goals: run
   :compact:

Sample Output
=============

.. code-block:: console

    Simulating IP header validation on multiple cores.
    Each of 2 parallel queues is processed by 3 threads on 2 cores and contain 5000 packet headers.
    Bytes in packet header: 24

    RESULT: OK
    Application ran successfully.
    All 20000 packet headers were processed in 89 msec

Part 3

한국어 전문 번역

개요

이 sample application은 RFC 1812 Requirements for IP Version 4 Routers가 규정한 Internet protocol suite의 간소화된 network-layer forwarding 기능, 본질적으로 IP Header Validation의 checksum 계산을 수행합니다. IP router system에서 microprocessor가 낼 수 있는 잠재적 성능을 보여줍니다.

Application 시작 시 SIZE_OF_QUEUE로 크기를 정한 packet header 배열을 초기화합니다. 각 header에는 SIZE_OF_HEADER 크기의 random data가 들어가며, 계산한 CRC16 header checksum을 CRC_BYTE_1과 CRC_BYTE_2가 지정한 field에 저장합니다. Header 구성은 다음과 같습니다.

IPv4 packet header의 32-bit field 배치
Bit 0-3Bit 4-7Bit 8-15Bit 16-31
VersionIHLType of ServiceTotal Length
IdentificationFlagsFragment Offset
Time to LiveProtocolHeader Checksum
Source Address
Destination Address
OptionsPadding

그다음 header를 여러 sender queue에 저장하며 queue 수는 QUEUE_NUM이 정합니다. 각 sender/receiver queue 쌍마다 sender queue 처리를 제어할 thread 하나를 만듭니다.

각 queue 관련 thread는 다시 THREADS_NUM으로 정한 수만큼 thread를 만듭니다. 각 thread는 sender queue에서 header를 꺼내 CRC를 계산하고, CRC가 올바르면 receiver queue에 넣습니다. Sender 또는 receiver queue에는 한 번에 thread 하나만 접근할 수 있습니다.

각 queue 쌍의 모든 header가 sender에서 receiver queue로 이동하면 그 queue 쌍과 관련된 thread 실행을 종료합니다.

SMP system에서 CONFIG_MP_MAX_NUM_CPUS 값을 바꾸면 core를 더 많이 사용할수록 계산 task 완료 시간이 거의 선형으로 줄어드는 것을 확인할 수 있습니다.

Sample source code를 편집해 병렬 실행할 queue 쌍 수 QUEUE_NUM, queue 쌍마다 사용할 thread 수 THREADS_NUM, queue의 header 수 SIZE_OF_QUEUE, byte 단위 header 크기 SIZE_OF_HEADER를 변경할 수 있습니다.

Build와 실행

이 project는 모든 packet header를 처리하는 데 필요한 전체 시간을 출력합니다. 다음 명령으로 QEMU에서 build하고 실행합니다.

west build -b qemu_x86_64 samples/arch/smp/pktqueue
west build -t run

Sample 출력

Simulating IP header validation on multiple cores.
Each of 2 parallel queues is processed by 3 threads on 2 cores and contain 5000 packet headers.
Bytes in packet header: 24

RESULT: OK
Application ran successfully.
All 20000 packet headers were processed in 89 msec

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.