Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3101162pxb; Tue, 24 Aug 2021 15:22:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLrezn38YOX3DjguVBKWcguVWDXOejunrFZVZi9R+ucRTOi/WFkn8WI/deK/q6HVLqzn4e X-Received: by 2002:a17:906:1742:: with SMTP id d2mr27823307eje.53.1629843720465; Tue, 24 Aug 2021 15:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629843720; cv=none; d=google.com; s=arc-20160816; b=o3+gQ13aB0QMaPZgACKWyVYYPULrKF6UGzAV8G/KYNdcFCVxdFvyhPkOcNcxiOr1/t ptuLOpThCw0K+Lf4oQZCSev7c9awuPIAX8q9jTN26p7teaSOKzYNIhNuy44GrLcgjcyO Nb4QarSzRKshlsS9911CQjSmtr6TZl2WOcv1NiO2rHs7h063s/njVzye2ATV99KczvXQ r7FRl0YH18nb5jLuAKqjfzB8d2mp9oz7vSMty04mYg1KxdPHp4nwqoIHllH9Uhk40O14 dJkiFPXW4Hr0pKuP48GSpM1Mo/NQbNRY707wLNIOWottyYpsoucR0yQrv+wt+qe/m7/O 7fGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1s9ly3AV9m2sRQyA6TMhsemhhhr5uERchfWnHFSTqgA=; b=H8Oq/Vp1/ADNCp+0LyVsqrYX8gL9KwdZbQj+arkiiQGww1KrOI41/bNGM7HEPlq4IO OLFRGyaMeP9ac+VjKL1UAGIxEjkqTaAKimBrrhXO3NYQofIHDkipTbBz4t+6ayI7xSqp y8cSLcSaybCFzbBIpq3sTPpzyKicoT/3kUqHEdPMnGJNkNy8Dq98ihgOJLrXqCAKSq7V mM0o2rmu00QAxrD0SMW/YmTaWoZsNH+nKgADOojC9BsLl4c6TzEG+yhkUQCVn3Af9NQn AfPVzJm6QqKzL5PqotQOXnaVij2zmIW3+F8OLLXCX9TEno7HEPUn4745DRTgP5lLHoSs seJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ki9v+Tp4; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du4si812155ejc.696.2021.08.24.15.21.36; Tue, 24 Aug 2021 15:22:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ki9v+Tp4; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238797AbhHXWU7 (ORCPT + 99 others); Tue, 24 Aug 2021 18:20:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbhHXWU6 (ORCPT ); Tue, 24 Aug 2021 18:20:58 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A5F2C061757; Tue, 24 Aug 2021 15:20:14 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id om1-20020a17090b3a8100b0017941c44ce4so2796925pjb.3; Tue, 24 Aug 2021 15:20:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1s9ly3AV9m2sRQyA6TMhsemhhhr5uERchfWnHFSTqgA=; b=Ki9v+Tp4RIF7iikzg3iQbG3QTaAwPJlx3zzBojiVvHlkB5nfPNFlfS46mJQQtnRD3f k0564Qehjv+G9AoGHKgVxPyOsDb8JhyrlokVeAUxZfTJX2Z0/JHEkbnyExH1iwQIzQ7H byFHt/qGU3zB94C/xkXkNGLfBUp3Lu3aY4oBxCsCGH3JLwOELK8ZEFsIC9gx0lvbmXWV 0kzLNSpC/xCar5DCMkar1iCfkFDvpzGBvhVX20/BPeD9XJb4bZg1XLI4nI0d5E6ZFBIa 8maWcjxpv4OfulRnyZxAK8yfbiD2W7b8kzQpHsxYpXKSIEDHZbkh1la2YqKc9ckZSdF5 PLFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1s9ly3AV9m2sRQyA6TMhsemhhhr5uERchfWnHFSTqgA=; b=D7NaZLYHnRmig9X7H/MPEJFIJRFOedros0cRHE4HZvNdlyjZCthQvXJ2kCUWn0f1ds N6lh99xPezizpYQP0odoWXyO2wPRXW/jazWDXdPOgz7mlQKNDSA2KHXV+R9XwIujkFVC FSJcIV1i0uTw8B7mh61YI2GdLe4I6f9303uJWH8B15GuAcHTqcb340Tkyj9PgEmiQIhA b+iS8TtlMn438PPT3hoKc+hfVKFLn+plyFWF5ESmVrDKWO+DzWxB3Rxs1TyCGcNYNsen 0jXDdqOolmurnlgVcIsjUuImPfykVTDqa3fmMRaOBaEHGrFi2ttKNYMtj0K7VmeVy2By Sbvg== X-Gm-Message-State: AOAM5323oFdSJkDbm5CN8iObECUSr+lPxTxlNoX7c6OqjpFChSGwbkyL Qxw5ICYGr7kdKHFfqz9qRT7D11oWJR5RGlXNkdo= X-Received: by 2002:a17:902:8c90:b0:12f:699b:27 with SMTP id t16-20020a1709028c9000b0012f699b0027mr28777516plo.28.1629843613701; Tue, 24 Aug 2021 15:20:13 -0700 (PDT) MIME-Version: 1.0 References: <1629774050-4048-1-git-send-email-yangtiezhu@loongson.cn> In-Reply-To: <1629774050-4048-1-git-send-email-yangtiezhu@loongson.cn> From: Alexei Starovoitov Date: Tue, 24 Aug 2021 15:20:02 -0700 Message-ID: Subject: Re: [PATCH bpf-next v2] bpf: test_bpf: Print total time of test in the summary To: Tiezhu Yang Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Network Development , bpf , LKML , Xuefeng Li Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 23, 2021 at 8:00 PM Tiezhu Yang wrote: > > 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); I think it only adds noise. Pls use dedicated runners like selftests/bpf/bench for performance measurements. test_bpf.ko also does some.