From patchwork Wed Jun 28 11:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 13295589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 266AEEB64DC for ; Wed, 28 Jun 2023 11:27:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbjF1L1H (ORCPT ); Wed, 28 Jun 2023 07:27:07 -0400 Received: from dggsgout12.his.huawei.com ([45.249.212.56]:11136 "EHLO dggsgout12.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbjF1L1D (ORCPT ); Wed, 28 Jun 2023 07:27:03 -0400 Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4QrfS16RqMz4f3tCg; Wed, 28 Jun 2023 19:26:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgBn0LP_GJxk+A_oMg--.17043S4; Wed, 28 Jun 2023 19:26:57 +0800 (CST) From: Hou Tao To: bpf@vger.kernel.org, Martin KaFai Lau , Alexei Starovoitov Cc: Andrii Nakryiko , Song Liu , Hao Luo , Yonghong Song , Daniel Borkmann , KP Singh , Stanislav Fomichev , Jiri Olsa , John Fastabend , "Paul E . McKenney" , rcu@vger.kernel.org, houtao1@huawei.com Subject: [PATCH bpf-next v7 0/2] Add benchmark for bpf memory allocator Date: Wed, 28 Jun 2023 19:59:08 +0800 Message-Id: <20230628115910.3817966-1-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBn0LP_GJxk+A_oMg--.17043S4 X-Coremail-Antispam: 1UD129K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-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: Hou Tao Hi, Beside adding a simple prepare patch, v7 mainly addresses suggestions from Alexei. As ususal, comments and suggestions are always welcome. Change Log: v7: * Rename name of producer threads to avoid confusion * Make the comments in producer threads more clear * Remove unnecessary check of ctx->from in bpf program * Split add_del_on_diff bpf program to two bpf program for clarity v6: https://lore.kernel.org/bpf/20230613080921.1623219-1-houtao@huaweicloud.com/ * add fix patches for benchmark framework * updates for htab-mem benchmark (Most of updates are suggested by Alexei) * remove --full and --max-entries and use a fixed 8k size for htab * remove op_factor and increase op_cnt correctly * use -a instead of --prod-affinity in run_bench_htab_mem.sh * use $RUN_BENCH in run_bench_htab_mem.sh * call cleanup_cgroup_environment() at the end of htab_mem_report_final() v5: https://lore.kernel.org/bpf/ff4b2396-48aa-28f1-c91b-7c8a4b9510bb@huaweicloud.com/ * send the benchmark patch alone (suggested by Alexei) * limit the max number of touched elements per-bpf-program call to 64 (from Alexei) * show per-producer performance (from Alexei) * handle the return value of read() (from BPF CI) * do cleanup_cgroup_environment() in htab_mem_report_final() v4: https://lore.kernel.org/bpf/20230606035310.4026145-1-houtao@huaweicloud.com/ Hou Tao (2): selftests/bpf: Add min() and max() macros in bpf_util.h selftests/bpf: Add benchmark for bpf memory allocator tools/testing/selftests/bpf/Makefile | 3 + tools/testing/selftests/bpf/bench.c | 4 + .../selftests/bpf/benchs/bench_htab_mem.c | 345 ++++++++++++++++++ .../bpf/benchs/run_bench_htab_mem.sh | 40 ++ tools/testing/selftests/bpf/bpf_util.h | 7 + .../selftests/bpf/progs/htab_mem_bench.c | 105 ++++++ 6 files changed, 504 insertions(+) create mode 100644 tools/testing/selftests/bpf/benchs/bench_htab_mem.c create mode 100755 tools/testing/selftests/bpf/benchs/run_bench_htab_mem.sh create mode 100644 tools/testing/selftests/bpf/progs/htab_mem_bench.c