Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2379954pxb; Mon, 23 Aug 2021 20:10:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytWM8pAoYGjTPHGilrDMFt+RfGsd9WXdsNEZvQqNkM5Ms2qtmbsq7mYts6b3fOutV6ccoY X-Received: by 2002:a05:6402:3512:: with SMTP id b18mr9729833edd.240.1629774632319; Mon, 23 Aug 2021 20:10:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629774632; cv=none; d=google.com; s=arc-20160816; b=V/QJmXfw35K15s8v9f0Z2bf3Q90MaZloBeW7VnbwRJn55p6ulzS4pzq7flpLWj0BGB 2evdureEcS6EhlK17B87xEAL6CYZ0MxjRpSuBAYFcPzxDCYu9ozYBc2A8FcrUvYRaJtK NZA8zwgNHZcBkOMi/uqN2yc0Ok4qN/AdMba4/yQS1eFLmmHmzKqa9PxiYqTS09DRvqw3 m7x9cWy/iw7MP5gPbHsWIb73ZuN1p2S5OM+FtFavVdQ4Rq9KZ6PBKNT+ZJbPxR2NbPSc 4VSdTpf/akjtfksSfhf+Ytj6m560sgu5p+c1iffXa1g09OsuhF7MhVnTDjbTiWSd+CwO 9TPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=3K5WkCJm2vhG2KMhzn9hz+2nOFDsMk0gmBP/y8FqLH8=; b=TT2gzAJdU3rX/yanS0qUw0itWwQVScdKxzeldX5w55KQ3675UY48p0e7NpbGbx5E0g 1tgRLVakC1hhCaBROm29bjnrCx3rVzaNY/IA2v3d+x9ONukoSG1IWnsFhbzCnjWnreCs UadZ5MPnND9qxhnAj1rUJXB91zizc9SsnfB1IU9+BjDwAmMUxPpjRdi8CCquPoebGHBj IjXgVKk3rWOrmFYX0LLqYHVFPmLugJoWSdL/9vyzvTYBoXK+FleyVdLimSRrcnRvQgwV /sv2H7PRYtkHR/RKlJo/oxpxUEPY/uDdZih8CiOSxeMErq0XNP+MlmhE1rIs7mY3e9RC uAng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pk9si16565771ejb.46.2021.08.23.20.10.09; Mon, 23 Aug 2021 20:10:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234426AbhHXDIU (ORCPT + 99 others); Mon, 23 Aug 2021 23:08:20 -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-TRANSID: AQAAf9Dxv0PjYCRhtVU0AA--.4468S2 X-Coremail-Antispam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2x3gn0dqz5rrqw2lrqou0/ 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