page_pool: import Jesper's page_pool benchmark
Subsystems (3)
PATCH v5 1/1 page_pool: import Jesper's page_pool benchmark
From: Jesper Dangaard Brouer <[email protected]>
We frequently consult with Jesper's out-of-tree page_pool benchmark to evaluate page_pool changes.
Import the benchmark into the upstream linux kernel tree so that (a) we're all running the same version, (b) pave the way for shared improvements, and (c) maybe one day integrate it with nipa, if possible.
Import bench_page_pool_simple from commit 35b1716d0c30 ("Add page_bench06_walk_all"), from this repository:
https://github.com/netoptimizer/prototype-kernel.git
Changes done during upstreaming:
- Fix checkpatch issues.
- Remove the tasklet logic not needed.
- Move under tools/testing
- Create ksft for the benchmark.
- Changed slightly how the benchmark gets build. Out of tree, time_bench is built as an independent .ko. Here it is included in bench_page_pool.ko
Steps to run:
``` mkdir -p /tmp/run-pp-bench make -C ./tools/testing/selftests/net/bench make -C ./tools/testing/selftests/net/bench install INSTALL_PATH=/tmp/run-pp-bench rsync --delete -avz --progress /tmp/run-pp-bench mina@$SERVER:~/ ssh mina@$SERVER << EOF cd ~/run-pp-bench && sudo ./test_bench_page_pool.sh EOF ```
Note that by default, the Makefile will build the benchmark for the currently installed kernel in /lib/modules/$(shell uname -r)/build. To build against the current tree, do:
make KDIR=$(pwd) -C ./tools/testing/selftests/net/bench
Output (from Jesper):
``` sudo ./test_bench_page_pool.sh (benchmark dmesg logs snipped) Fast path results: no-softirq-page_pool01 Per elem: 23 cycles(tsc) 6.571 ns ptr_ring results: no-softirq-page_pool02 Per elem: 60 cycles(tsc) 16.862 ns slow path results: no-softirq-page_pool03 Per elem: 265 cycles(tsc) 73.739 ns ```
Output (from me):
``` sudo ./test_bench_page_pool.sh (benchmark dmesg logs snipped) Fast path results: no-softirq-page_pool01 Per elem: 11 cycles(tsc) 4.177 ns ptr_ring results: no-softirq-page_pool02 Per elem: 51 cycles(tsc) 19.117 ns slow path results: no-softirq-page_pool03 Per elem: 168 cycles(tsc) 62.469 ns ```
Results of course will vary based on hardware/kernel/configs, and some variance may be there from run to run due to some noise.
---
v5: https://lore.kernel.org/netdev/[email protected]/
- Update results in the commit message
- Update to build against current tree
v4: https://lore.kernel.org/netdev/[email protected]/
- Fix more checkpatch and coccicheck issues (Jakub)
v3:
- Non RFC
- Collect Signed-off-by from Jesper and Acked-by Ilias.
- Move test_bench_page_pool.sh to address nipa complaint.
- Remove static inline in .c files to address nipa complaint.
v2:
- Move under tools/selftests (Jakub)
- Create ksft for it.
- Remove the tasklet logic no longer needed (Jesper + Toke)
RFC discussion points:
- Desirable to import it?
- Can the benchmark be imported as-is for an initial version? Or needs lots of modifications?
- Code location. I retained the location in Jesper's tree, but a path like net/core/bench/ may make more sense.
--- tools/testing/selftests/net/bench/Makefile | 7 + .../selftests/net/bench/page_pool/Makefile | 17 + .../bench/page_pool/bench_page_pool_simple.c | 276 ++++++++++++ .../net/bench/page_pool/time_bench.c | 394 ++++++++++++++++++ .../net/bench/page_pool/time_bench.h | 238 +++++++++++ .../net/bench/test_bench_page_pool.sh | 32 ++ 6 files changed, 964 insertions(+) create mode 100644 tools/testing/selftests/net/bench/Makefile create mode 100644 tools/testing/selftests/net/bench/page_pool/Makefile create mode 100644 tools/testing/selftests/net/bench/page_pool/bench_page_pool_simple.c create mode 100644 tools/testing/selftests/net/bench/page_pool/time_bench.c create mode 100644 tools/testing/selftests/net/bench/page_pool/time_bench.h create mode 100755 tools/testing/selftests/net/bench/test_bench_page_pool.sh
tools/testing/selftests/net/bench/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 + +TEST_GEN_MODS_DIR := page_pool + +TEST_PROGS += test_bench_page_pool.sh + +include ../../lib.mk
tools/testing/selftests/net/bench/page_pool/Makefile new file +17 -0
@@ -0,0 +1,17 @@ +BENCH_PAGE_POOL_SIMPLE_TEST_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +KDIR ?= /lib/modules/$(shell uname -r)/build + +ifeq ($(V),1) +Q = +else +Q = @ +endif + +obj-m += bench_page_pool.o +bench_page_pool-y += bench_page_pool_simple.o time_bench.o + +all: + +$(Q)make -C $(KDIR) M=$(BENCH_PAGE_POOL_SIMPLE_TEST_DIR) modules + +clean: + +$(Q)make -C $(KDIR) M=$(BENCH_PAGE_POOL_SIMPLE_TEST_DIR) clean
tools/testing/selftests/net/bench/page_pool/bench_page_pool_simple.c new file +276 -0
276 lines not on this page · raw message
tools/testing/selftests/net/bench/page_pool/time_bench.c new file +394 -0
394 lines not on this page · raw message
tools/testing/selftests/net/bench/page_pool/time_bench.h new file +238 -0
238 lines not on this page · raw message
tools/testing/selftests/net/bench/test_bench_page_pool.sh new file +32 -0
@@ -0,0 +1,32 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# + +set -e + +DRIVER="./page_pool/bench_page_pool.ko" +result="" + +function run_test() +{ + rmmod "bench_page_pool.ko" || true + insmod $DRIVER > /dev/null 2>&1 + result=$(dmesg | tail -10) + echo "$result" + + echo + echo "Fast path results:" + echo "${result}" | grep -o -E "no-softirq-page_pool01 Per elem: ([0-9]+) cycles\(tsc\) ([0-9]+\.[0-9]+) ns" + + echo + echo "ptr_ring results:" + echo "${result}" | grep -o -E "no-softirq-page_pool02 Per elem: ([0-9]+) cycles\(tsc\) ([0-9]+\.[0-9]+) ns" + + echo + echo "slow path results:" + echo "${result}" | grep -o -E "no-softirq-page_pool03 Per elem: ([0-9]+) cycles\(tsc\) ([0-9]+\.[0-9]+) ns" +} + +run_test + +exit 0
base-commit: afc783fa0aab9cc093fbb04871bfda406480cf8d
Signature · 1 line
2.50.0.rc2.701.gf1e915cc24-goog
Quoted 75 lines · Mina Almasry
From: Jesper Dangaard Brouer <[email protected]>
We frequently consult with Jesper's out-of-tree
page_poolbenchmark to evaluatepage_poolchanges.Import the benchmark into the upstream linux kernel tree so that (a) we're all running the same version, (b) pave the way for shared improvements, and (c) maybe one day integrate it with nipa, if possible.
Import
bench_page_pool_simplefrom commit35b1716d0c30("Addpage_bench06_walk_all"), from this repository:
https://github.com/netoptimizer/prototype-kernel.gitChanges done during upstreaming:
- Fix checkpatch issues.
- Remove the tasklet logic not needed.
- Move undertools/testing
- Create ksft for the benchmark.
- Changed slightly how the benchmark gets build. Out of tree,time_benchis built as an independent .ko. Here it is included in bench_page_pool.koSteps to run:
``` mkdir -p /tmp/run-pp-bench make -C ./tools/testing/selftests/net/bench make -C ./tools/testing/selftests/net/bench install INSTALL_PATH=/tmp/run-pp-bench rsync --delete -avz --progress /tmp/run-pp-bench mina@$SERVER:~/ ssh mina@$SERVER << EOF cd ~/run-pp-bench && sudo ./test_bench_page_pool.sh EOF ```Note that by default, the
Makefilewill build the benchmark for the currently installed kernel in /lib/modules/$(shell uname -r)/build. To build against the current tree, do:make KDIR=$(pwd) -C
./tools/testing/selftests/net/benchOutput (from Jesper):
``` sudo ./test_bench_page_pool.sh (benchmark dmesg logs snipped) Fast path results: no-softirq-page_pool01 Per elem: 23 cycles(tsc) 6.571 ns ptr_ring results: no-softirq-page_pool02 Per elem: 60 cycles(tsc) 16.862 ns slow path results: no-softirq-page_pool03 Per elem: 265 cycles(tsc) 73.739 ns ```Output (from me):
``` sudo ./test_bench_page_pool.sh (benchmark dmesg logs snipped) Fast path results: no-softirq-page_pool01 Per elem: 11 cycles(tsc) 4.177 ns ptr_ring results: no-softirq-page_pool02 Per elem: 51 cycles(tsc) 19.117 ns slow path results: no-softirq-page_pool03 Per elem: 168 cycles(tsc) 62.469 ns ```Results of course will vary based on hardware/kernel/configs, and some variance may be there from run to run due to some noise.
Quoted 8 lines
Cc Jesper Dangaard Brouer <[email protected]>Cc Ilias Apalodimas <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Toke Høiland-Jørgensen <[email protected]>Signed-off-by Mina Almasry <[email protected]>Acked-by Ilias Apalodimas <[email protected]>Signed-off-by Jesper Dangaard Brouer <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 19 Jun 2025 18:15:18 +0000 you wrote:
From: Jesper Dangaard Brouer <[email protected]>
We frequently consult with Jesper's out-of-tree
page_poolbenchmark to evaluatepage_poolchanges.Import the benchmark into the upstream linux kernel tree so that (a) we're all running the same version, (b) pave the way for shared improvements, and (c) maybe one day integrate it with nipa, if possible.
[...]
Here is the summary with links:
- [net-next,v5] page_pool: import Jesper's page_pool benchmark
https://git.kernel.org/netdev/net-next/c/cccfe0982208
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Quoted 18 lines · On Mon, Jun 23, 2025 at 6:19 PM <[email protected]> wrote:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 19 Jun 2025 18:15:18 +0000 you wrote:
From: Jesper Dangaard Brouer <[email protected]>
We frequently consult with Jesper's out-of-tree
page_poolbenchmark to evaluatepage_poolchanges.Import the benchmark into the upstream linux kernel tree so that (a) we're all running the same version, (b) pave the way for shared improvements, and (c) maybe one day integrate it with nipa, if possible.
[...]
Quoted 10 lines
Here is the summary with links:
- [net-next,v5]page_pool: import Jesper'spage_poolbenchmarkhttps://git.kernel.org/netdev/net-next/c/cccfe0982208You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thank you for merging this. Kinda of a noob question: does this merge mean that nipa will run this on new submitted patches already? Or do I/someone need to do something to enable that? I've been clicking on the contest for new patches like so:
https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2025-06-25--21-00
But I don't see this benchmark being run anywhere. I looked for docs that already cover this but I couldn't find any.
Signature · 2 lines
Thanks, Mina
Jakub Kicinski
maintainerQuoted 9 lines · On Wed, 25 Jun 2025 16:45:49 -0700 Mina Almasry wrote:
Thank you for merging this. Kinda of a noob question: does this merge mean that nipa will run this on new submitted patches already? Or do I/someone need to do something to enable that? I've been clicking on the contest for new patches like so:
https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2025-06-25--21-00
But I don't see this benchmark being run anywhere. I looked for docs that already cover this but I couldn't find any.
Right now to add a new TARGET one needs to have SSH access to the systems that run the tests :( The process of adding a runner is not automated. But this will probably need even more work because it's a performance test. We'd need some way of tracking numerical values and detecting regressions?
We have a vague plan of moving NIPA out of Meta owned systems. We may want to wait for that before we tackle performance-like tests.
Quoted 9 lines · Jakub Kicinski
Quoted 7 lines · On Wed, 25 Jun 2025 16:45:49 -0700 Mina Almasry wrote:
Thank you for merging this. Kinda of a noob question: does this merge mean that nipa will run this on new submitted patches already? Or do I/someone need to do something to enable that? I've been clicking on the contest for new patches like so:
https://netdev.bots.linux.dev/contest.html?pw-n=0&branch=net-next-2025-06-25--21-00
Quoted 9 lines
Quoted 2 lines
But I don't see this benchmark being run anywhere. I looked for docs that already cover this but I couldn't find any.
Right now to add a new TARGET one needs to have SSH access to the systems that run the tests :( The process of adding a runner is not automated. But this will probably need even more work because it's a performance test. We'd need some way of tracking numerical values and detecting regressions?
I actually did what you suggested earlier, I have the test report the perf numbers but succeed always.
What I'm hoping to do is:
1. Have nipa run the benchmark always (or at least on patches that touch pp code, if that's possible), and always succeed.
2. The pp reviewers can always check the contest results to manually see if there is a regression. That's still great because it saves us the time of cherry-pick series and running the tests ourselves (or asking submitters to do that).
3. If we notice that the results between runs are stable, then we can change the test to actually fail/warn if it detects a regression (if fast path is > # of instructions, fail).
4. If we notice that the results have too much noise, then we can improve the now merged benchmark to somehow make it more consistent.
FWIW, when I run the benchmark, I get very repeatable results across runs, especially when measuring the fast path, but nipa's mileage may vary.
Signature · 2 lines
Thanks, Mina
Jakub Kicinski
maintainerQuoted 11 lines · On Wed, 25 Jun 2025 17:22:56 -0700 Mina Almasry wrote:
What I'm hoping to do is:
1. Have nipa run the benchmark always (or at least on patches that touch pp code, if that's possible), and always succeed.
2. The pp reviewers can always check the contest results to manually see if there is a regression. That's still great because it saves us the time of cherry-pick series and running the tests ourselves (or asking submitters to do that).
3. If we notice that the results between runs are stable, then we can change the test to actually fail/warn if it detects a regression (if fast path is > # of instructions, fail).
That's fine. I don't think putting the data on a graphs would be much work, and clicking old results out of old runs will be a PITA. Just a little parsing in the runner to propagate it into JSON. And a fairly trivial bit of charts.js to fetch the runs and render UI.
Quoted 6 lines
4. If we notice that the results have too much noise, then we can improve the now merged benchmark to somehow make it more consistent.
FWIW, when I run the benchmark, I get very repeatable results across runs, especially when measuring the fast path, but nipa's mileage may vary.
100% on board. But someone with Meta credentials needs to add a runner and babysit it, I have enough CI wrangling as is.
Or we wait a couple of months until we migrate to a more public setup.
Quoted 22 lines · Jakub Kicinski
Quoted 11 lines · On Wed, 25 Jun 2025 17:22:56 -0700 Mina Almasry wrote:
What I'm hoping to do is:
1. Have nipa run the benchmark always (or at least on patches that touch pp code, if that's possible), and always succeed.
2. The pp reviewers can always check the contest results to manually see if there is a regression. That's still great because it saves us the time of cherry-pick series and running the tests ourselves (or asking submitters to do that).
3. If we notice that the results between runs are stable, then we can change the test to actually fail/warn if it detects a regression (if fast path is > # of instructions, fail).That's fine. I don't think putting the data on a graphs would be much work, and clicking old results out of old runs will be a PITA. Just a little parsing in the runner to propagate it into JSON. And a fairly trivial bit of charts.js to fetch the runs and render UI.
Quoted 3 lines
4. If we notice that the results have too much noise, then we can improve the now merged benchmark to somehow make it more consistent.
Quoted 7 lines
Quoted 3 lines
FWIW, when I run the benchmark, I get very repeatable results across runs, especially when measuring the fast path, but nipa's mileage may vary.
100% on board. But someone with Meta credentials needs to add a runner and babysit it, I have enough CI wrangling as is.
Of course! If someone with the credentials volunteers that would be great, if not, no big deal really. We can always get the runs manually in the meantime. The volume of pp patches isn't that much anyway.
Quoted 1 line
Or we wait a couple of months until we migrate to a more public setup.
Yes, I'll take a look when/if that happens (I'll watch out for an announcement).
Thanks!
Signature · 2 lines
Thanks, Mina