Raspberry Pi で DPDK が使えるか?

かなり以前に Raspberry Pi で DPDK を走らせようとして挫折したのですが

それから7年も経っているし、状況は変わっているでしょう。再挑戦してみます。

前回設定した、じろ君に今回も頑張ってもらいます。作業を始めてすぐに気づくのは 64bit OS が普通に出回っていること。当時は 64bit 版の Raspberry PI OS はなくて OS 探しから始めなくてはなりませんでしたが、今はそこは楽になりました。じろ君が 64bit OS を走らせているので、さっさと作業開始しましょう。

DPDK のビルドに必要なソフトウェアをインストールしていきます。python のモジュールは念のため virtual env の中でインストールします。

sudo apt install git build-essential python3-pip ninja-build
python3 -m venv venv-dpdk
. venv-dpdk/bin/activate
pip3 install meson pyelftools
Bash

dpdk のソースコードをダウンロードして設定、ビルドします。ここで一つ用心。ビルドは時間がかかりますが、途中なにかのトラブルで SSH セッションが切れてしまうかもしれません。セッションが切れてもビルドを継続するために screen の中でビルドを行います。本当に切れても screen 上でビルドは継続しますし、切れたセッションは screen に入り直せば取り戻せます(本当に切れました)。

screen
. venv-dpdk/bin/activate  # activate the virtual env again
git clone https://github.com/DPDK/dpdk.git
cd dpdk
meson setup -Dmax_numa_nodes=1 build
cd build
ninja 2>&1 | tee ../build.log
Bash

以前とビルドの仕方が変わりましたがまあ OK。

ninja 実行中の htop 画面はこんなでした。CPU を使い切っています。ninja の得意技
猛暑の中 CPU 全開で頑張るじろ君

ビルドは無事に終わりました。インストラクションに従って DPDK のサンプルプログラムを動かしてみます。

(venv-dpdk) naoki@jiro:~/workspace/dpdk/examples/helloworld $ export RTE_SDK=$HOME/DPDK
(venv-dpdk) naoki@jiro:~/workspace/dpdk/examples/helloworld $ export RTE_TARGET=aarch64-native-linuxapp-gcc
(venv-dpdk) naoki@jiro:~/workspace/dpdk/examples/helloworld $ make
cc -O3 -I/usr/local/include -include rte_config.h -mcpu=cortex-a72  -DALLOW_EXPERIMENTAL_API main.c -o build/helloworld-shared  -Wl,--as-needed -L/usr/local/lib/aarch64-linux-gnu -lrte_node -lrte_graph -lrte_pipeline -lrte_table -lrte_pdump -lrte_port -lrte_fib -lrte_pdcp -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_mldev -lrte_regexdev -lrte_rawdev -lrte_power -lrte_pcapng -lrte_member -lrte_lpm -lrte_latencystats -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_gpudev -lrte_dispatcher -lrte_eventdev -lrte_efd -lrte_dmadev -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bpf -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_argparse -lrte_kvargs -lrte_log
ln -sf helloworld-shared build/helloworld
(venv-dpdk) naoki@jiro:~/workspace/dpdk/examples/helloworld $ build/helloworld
EAL: Detected CPU lcores: 4
EAL: Detected NUMA nodes: 1
EAL: Detected shared linkage of DPDK
EAL: Multi-process socket /run/user/1000/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: Cannot open directory /sys/kernel/mm/hugepages to read system hugepage info
EAL: FATAL: Cannot get hugepage information.
EAL: Cannot get hugepage information.
EAL: PANIC in main():
Cannot init EAL
0: /usr/local/lib/aarch64-linux-gnu/librte_eal.so.25 (rte_dump_stack+0x20) [7f9ed6f560]
1: /usr/local/lib/aarch64-linux-gnu/librte_eal.so.25 (__rte_panic+0x98) [7f9ed4dbbc]
2: build/helloworld (5557360000+0x974) [5557360974]
3: /lib/aarch64-linux-gnu/libc.so.6 (7f9eb90000+0x27780) [7f9ebb7780]
4: /lib/aarch64-linux-gnu/libc.so.6 (__libc_start_main+0x98) [7f9ebb7858]
5: build/helloworld (5557360000+0x9b0) [55573609b0]
Aborted
Bash

おや、Aborted? /sys/kernel/mm/hugepages が読めないとな?

(venv-dpdk) naoki@jiro:~/workspace/dpdk/examples/helloworld $ ls /sys/kernel/mm
lru_gen  swap
Bash

ほんとだ、ありません。どうやら、Raspberry Pi OS は初期状態では DPDK で必須の hugepages に対応していないらしいです。これはちょっとおおごと

というわけで続きます

Comments

No comments yet. Why don’t you start the discussion?

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.