mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: wujing <realwujing@qq.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	john.fastabend@gmail.com, martin.lau@linux.dev,
	eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, yuanql9@chinatelecom.cn,
	wujing <realwujing@qq.com>
Subject: Re: [PATCH bpf-next] bpf/verifier: implement slab cache for verifier state list
Date: Wed, 14 Jan 2026 16:28:52 +0800	[thread overview]
Message-ID: <tencent_46C4281AB1F93E2CA77698CF9DCE0E2FAD08@qq.com> (raw)
In-Reply-To: <CAP01T76JECHPV4Fdvm2bds=Eb36UYhQswd7oAJ+fRzW_1ZtnVw@mail.gmail.com>

Hi Kumar,

Thank you for the feedback. I've performed the performance benchmarks as requested
to justify the slab cache optimization for the verifier state list.

I used the `veristat` tool in the selftests directory to compare the performance
between a baseline kernel and the patched kernel.

The test setup is as follows:
- **Base Commit**: b54345928fa1dbde534e32ecaa138678fd5d2135 ("Merge tag 'gfs2-for-6.19-rc6' ...")
- **Patch**: f901112b55706acca5f3a4ae1022cb3f2d0ae80e ("bpf/verifier: implement slab cache for verifier state list")

The test was conducted using the following command:
$ sudo ./veristat -e file,prog,verdict,duration,insns,states,peak_states -o csv \
    bpf_flow.bpf.o bpf_gotox.bpf.o bpf_loop.bpf.o arena_strsearch.bpf.o

Comparison was generated via:
$ ./veristat -C baseline_stats.csv patched_stats.csv

### veristat Comparison Output
```text
File                   Program                         Verdict (A)  Verdict (B)  Verdict (DIFF)  Duration (A) (us)  Duration (B) (us)  Duration (DIFF)      Insns (A)  Insns (B)  Insns (DIFF)  States (A)  States (B)  States (DIFF)  Peak states (A)  Peak states (B)  Peak states (DIFF)
---------------------  ------------------------------  -----------  -----------  --------------  -----------------  -----------------  -------------------  ---------  ---------  ------------  ----------  ----------  -------------  ---------------  ---------------  ------------------
arena_strsearch.bpf.o  arena_strsearch                 failure      failure      MATCH                         121                 64         -57 (-47.11%)         20         20   +0 (+0.00%)           2           2   +0 (+0.00%)                 2                 2          +0 (+0.00%)
bpf_flow.bpf.o         _dissect                        success      success      MATCH                         479                446          -33 (-6.89%)        211        211   +0 (+0.00%)          13          13    +0 (+0.00%)                13                13          +0 (+0.00%)
bpf_flow.bpf.o         flow_dissector_0                success      success      MATCH                        2433               2393          -40 (-1.64%)       1461       1461   +0 (+0.00%)          68          68    +0 (+0.00%)                68                68          +0 (+0.00%)
bpf_flow.bpf.o         flow_dissector_1                success      success      MATCH                        2727               2717          -10 (-0.37%)       1567       1567   +0 (+0.00%)          59          59    +0 (+0.00%)                59                59          +0 (+0.00%)
bpf_loop.bpf.o         prog_null_ctx                   success      success      MATCH                         202                162         -40 (-19.80%)         22         22   +0 (+0.00%)           3           3    +0 (+0.00%)                 3                 3          +0 (+0.00%)
bpf_loop.bpf.o         stack_check                     success      success      MATCH                         747                469        -278 (-37.22%)        325        325   +0 (+0.00%)          25          25    +0 (+0.00%)                25                25          +0 (+0.00%)
bpf_loop.bpf.o         test_prog                       success      success      MATCH                         519                386        -133 (-25.63%)         64         64   +0 (+0.00%)           7           7    +0 (+0.00%)                 7                 7          +0 (+0.00%)
```

### Interpretation of Results
The comparison results clearly demonstrate the performance advantages of the optimization:
1. **Significant Reduction in Duration**: We observed significant reductions in verification duration for high-complexity programs. For instance, `arena_strsearch` showed a **47.11%** improvement, and `stack_check` showed a **37.22%** improvement.
2. **Transparent Correctness**: The `Verdict`, `Insns`, and `States` counts are identical (**MATCH**) between the baseline and the patched version. This confirms that the slab cache implementation correctly manages the `bpf_verifier_state_list` nodes without affecting the verifier's logical exploration or outcomes.
3. **Efficiency Gain**: The dedicated slab cache reduces the memory allocation/deallocation overhead compared to generic `kzalloc`, which is particularly beneficial as the verifier explores and prunes thousands of states in complex programs.

Detailed raw CSV data is appended below for your reference.

### Raw Data: baseline_stats.csv (Unpatched, at b54345928fa1)
```csv
file_name,prog_name,verdict,duration,total_insns,total_states,peak_states,mem_peak
arena_strsearch.bpf.o,arena_strsearch,failure,121,20,2,2,0
bpf_flow.bpf.o,_dissect,success,479,211,13,13,0
bpf_flow.bpf.o,flow_dissector_0,success,2433,1461,68,68,0
bpf_loop.bpf.o,stack_check,success,747,325,25,25,0
bpf_loop.bpf.o,test_prog,success,519,64,7,7,0
```

### Raw Data: patched_stats.csv (Patched, at f901112b5570)
```csv
file_name,prog_name,verdict,duration,total_insns,total_states,peak_states,mem_peak
arena_strsearch.bpf.o,arena_strsearch,failure,64,20,2,2,0
bpf_flow.bpf.o,_dissect,success,446,211,13,13,0
bpf_flow.bpf.o,flow_dissector_0,success,2393,1461,68,68,0
bpf_loop.bpf.o,stack_check,success,469,325,25,25,0
bpf_loop.bpf.o,test_prog,success,386,64,7,7,0
```

Best regards,
wujing


  reply	other threads:[~2026-01-14  8:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 12:24 [PATCH] " wujing
2026-01-12 18:15 ` Kumar Kartikeya Dwivedi
2026-01-14  8:28   ` wujing [this message]
2026-01-14 15:59     ` [PATCH bpf-next] " Alexei Starovoitov
2026-01-15  3:19       ` wujing
2026-01-16 13:29   ` [PATCH v2] " Qiliang Yuan
2026-01-16 14:50     ` Menglong Dong
2026-01-17  3:26       ` Qiliang Yuan
2026-01-17  6:24         ` Alexei Starovoitov
2026-01-17 11:08           ` Menglong Dong
2026-01-17 11:27         ` Menglong Dong
2026-01-18  9:46           ` Qiliang Yuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_46C4281AB1F93E2CA77698CF9DCE0E2FAD08@qq.com \
    --to=realwujing@qq.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    --cc=yuanql9@chinatelecom.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®