From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0105C432BE for ; Tue, 24 Aug 2021 03:07:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0145600D3 for ; Tue, 24 Aug 2021 03:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234910AbhHXDIa (ORCPT ); Mon, 23 Aug 2021 23:08:30 -0400 Received: from mail.loongson.cn ([114.242.206.163]:55966 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234677AbhHXDB4 (ORCPT ); Mon, 23 Aug 2021 23:01:56 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxv0PjYCRhtVU0AA--.4468S2; Tue, 24 Aug 2021 11:00:52 +0800 (CST) From: Tiezhu Yang To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH bpf-next v2] bpf: test_bpf: Print total time of test in the summary Date: Tue, 24 Aug 2021 11:00:50 +0800 Message-Id: <1629774050-4048-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-T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vjDU0xZFpf9x0JUa0PhUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The total time of test is useful to compare the performance when bpf_jit_enable is 0 or 1, so print it in the summary. Signed-off-by: Tiezhu Yang --- lib/test_bpf.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 830a18e..37f49b7 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -8627,9 +8627,10 @@ static int __run_one(const struct bpf_prog *fp, const void *data, return ret; } -static int run_one(const struct bpf_prog *fp, struct bpf_test *test) +static int run_one(const struct bpf_prog *fp, struct bpf_test *test, u64 *run_one_time) { int err_cnt = 0, i, runs = MAX_TESTRUNS; + u64 time = 0; for (i = 0; i < MAX_SUBTESTS; i++) { void *data; @@ -8663,8 +8664,12 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test) test->test[i].result); err_cnt++; } + + time += duration; } + *run_one_time = time; + return err_cnt; } @@ -8944,9 +8949,11 @@ static __init int test_bpf(void) { int i, err_cnt = 0, pass_cnt = 0; int jit_cnt = 0, run_cnt = 0; + u64 total_time = 0; for (i = 0; i < ARRAY_SIZE(tests); i++) { struct bpf_prog *fp; + u64 run_one_time; int err; cond_resched(); @@ -8971,7 +8978,7 @@ static __init int test_bpf(void) if (fp->jited) jit_cnt++; - err = run_one(fp, &tests[i]); + err = run_one(fp, &tests[i], &run_one_time); release_filter(fp, i); if (err) { @@ -8981,10 +8988,12 @@ static __init int test_bpf(void) pr_cont("PASS\n"); pass_cnt++; } + + total_time += run_one_time; } - pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n", - pass_cnt, err_cnt, jit_cnt, run_cnt); + pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed] in %llu nsec\n", + pass_cnt, err_cnt, jit_cnt, run_cnt, total_time); return err_cnt ? -EINVAL : 0; } @@ -9192,6 +9201,7 @@ static __init int test_tail_calls(struct bpf_array *progs) { int i, err_cnt = 0, pass_cnt = 0; int jit_cnt = 0, run_cnt = 0; + u64 total_time = 0; for (i = 0; i < ARRAY_SIZE(tail_call_tests); i++) { struct tail_call_test *test = &tail_call_tests[i]; @@ -9220,10 +9230,12 @@ static __init int test_tail_calls(struct bpf_array *progs) pr_cont("ret %d != %d FAIL", ret, test->result); err_cnt++; } + + total_time += duration; } - pr_info("%s: Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n", - __func__, pass_cnt, err_cnt, jit_cnt, run_cnt); + pr_info("%s: Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed] in %llu nsec\n", + __func__, pass_cnt, err_cnt, jit_cnt, run_cnt, total_time); return err_cnt ? -EINVAL : 0; } -- 2.1.0