Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37850245rwd; Tue, 11 Jul 2023 22:15:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2cA4KBEY3afCqBCY26VJkW3bWPzUEHpRwp1EVPHDrs/VEFOC5IvhPsjG5O8ig4IJshEsw X-Received: by 2002:a05:6808:138b:b0:3a4:243d:dc76 with SMTP id c11-20020a056808138b00b003a4243ddc76mr1903506oiw.21.1689138949998; Tue, 11 Jul 2023 22:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689138949; cv=none; d=google.com; s=arc-20160816; b=ClqIf6HaCUAkJWOF583ryFKIh0bIk3k0Wy9Gf4GN9KBnlPdPcLBaLydMKLZkc0J5KE WuNYfKDlYSMufLt92i5QMH9cyaquuh42SLKBN50T35ThldYG/Wm9zNzZzwGxRoaEKONq tEumSOpgw40rASruLmhsjC7H1Nwy+5GN6ataz2GPSx29LPlU2Gz3HMquQpsvI7DHQFoh WZgiil9geqg49TsY0wH/tWFL/KLBry/4wiO3lO+BpSO1/yaytUFzF39kP5rCRaMSEBfY zvkXCTrJXDOsUritmfKumIP3/DHDxHm9yrpxr+QGDzRpNlg1WS8OPHDwjIrYlxSRxlQ6 f3VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KwPc8BS7NtCm9mMgLjXyO4ZiPUAKVIu/YEVpLeQJeCM=; fh=EVqzeQdXh2nms73ZYd6Gqs3ngCd2kfgjPO6FuLuD7O4=; b=pXwdubGcgLAre+aikgRwIVSRYciq0+RS0eYrCCBFKDZyCXgGwO5HS6MktQtCQX4YR9 71ofuvjamsCZAZ0hB1G7wUcCGyLBkfLmL4mwZL8W+1MqZ9Es02mrdbQrHY5cFRHh/uRi zp2SY55TF76LOYHEhatCuz7JuLb9OpGdXsyJfJvn4NYz4JcyxyRVewfYZZDZJAjOkRXZ uDwaumW0kHoHcEKzOx+kAzjcLx+zalddqz0HO/NPi67zFgD+fVu9MPRqMv3vKxER3Gap Yjbdi1KU03oknH27tk/MK7/YITCUX9rFkQ7qn4PoimWvb7OR7b7Pi6Kv9RCgUsp0O7hj x/qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=d4QyILDU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fc8-20020a056a002e0800b00670db3b5032si2701232pfb.333.2023.07.11.22.15.31; Tue, 11 Jul 2023 22:15:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=d4QyILDU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230504AbjGLErf (ORCPT + 99 others); Wed, 12 Jul 2023 00:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbjGLEre (ORCPT ); Wed, 12 Jul 2023 00:47:34 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13180100; Tue, 11 Jul 2023 21:47:33 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b734aea34aso13492621fa.0; Tue, 11 Jul 2023 21:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689137251; x=1691729251; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=KwPc8BS7NtCm9mMgLjXyO4ZiPUAKVIu/YEVpLeQJeCM=; b=d4QyILDU2VZw1RN1/Gj/iMRIjLyksBxC8gZZc6G8syRMMufhV4/wCUunj2SMAoxRUd JGxRRMu4VT6L/1nZLf2cVp5PvQscMjqhoXymmjfrFXbUukQAu/uPaBztZK8kexm0OXua HKUTNPjMqYMVKfIDahHjiP4uyePHJvNf4uqlnLi7j7kmX4zH7IjhMAmD4S7ZMsd7JuEy 8ukojGkkYAIkmgI4IAn1FdNXOVBKeLmLGyFcKJKlZ/DdJ2/OIGG0uYQzy11Z2Q3b1Kmp ZiJfQFvmtEYT8+y5uwXsxesqy5f7T6TUdnMxv2Wb1afB331jj96B+hmCuh8zLqzQ5nXO 8Vsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689137251; x=1691729251; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KwPc8BS7NtCm9mMgLjXyO4ZiPUAKVIu/YEVpLeQJeCM=; b=GZkmQPrcdz/ZLS+nczW7cH9owS4/wv6hSnAR1zSX2KmMt41NWf4DhmQ7NXvmCHMFMA ZzS3jmX+3xpSPGcFMnVoKV0YdiqdZvfPOarObFi+iRd/LgvqJ11dwXOcPpAm3ecUG7as r84NlnwKAy/QHVcY/bW0+5/U+2RJY3K3cQROR5UhcTVjA6xyGdrEQr5V8uBtAG8KG4N3 tUatmeKKdfIPNh0r7t385jixmtB/HXwNTXsBlUbS8GQYfEUDi4OCPnAL66iSjEmXse8T 5jp+Xzj0pDadBNH51JKyFyoHNBuRjVEPnFbjzwBkoCcYwkohA6g9lhC4YIbu9NxE1dpu S6Yw== X-Gm-Message-State: ABy/qLYC4cxhxkoLpb9GytJIQTas2TUpaSPnNyniwLM8WCYhi7fyqrps II8n+pKKLD+hBvd/1OY6O17qs2nd4n+zLhl6+xwgE1Cq04g= X-Received: by 2002:ac2:5b83:0:b0:4f9:cd02:4aec with SMTP id o3-20020ac25b83000000b004f9cd024aecmr14085028lfn.29.1689137250886; Tue, 11 Jul 2023 21:47:30 -0700 (PDT) MIME-Version: 1.0 References: <20230710104834.947884-1-imagedong@tencent.com> <20230710104834.947884-4-imagedong@tencent.com> <20230711232522.54dbqdxkfbjvbvgi@macbook-pro-8.dhcp.thefacebook.com> In-Reply-To: From: Alexei Starovoitov Date: Tue, 11 Jul 2023 21:47:19 -0700 Message-ID: Subject: Re: [PATCH RESEND bpf-next v8 3/3] selftests/bpf: add testcase for TRACING with 6+ arguments To: Menglong Dong Cc: Yonghong Song , Daniel Borkmann , Alexei Starovoitov , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , David Ahern , Jiri Olsa , X86 ML , bpf , LKML , linux-arm-kernel , Menglong Dong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 11, 2023 at 9:00=E2=80=AFPM Menglong Dong wrote: > > On Wed, Jul 12, 2023 at 7:25=E2=80=AFAM Alexei Starovoitov > wrote: > > > > On Mon, Jul 10, 2023 at 06:48:34PM +0800, menglong8.dong@gmail.com wrot= e: > > > From: Menglong Dong > > > > > > Add fentry_many_args.c and fexit_many_args.c to test the fentry/fexit > > > with 7/11 arguments. As this feature is not supported by arm64 yet, w= e > > > disable these testcases for arm64 in DENYLIST.aarch64. We can combine > > > them with fentry_test.c/fexit_test.c when arm64 is supported too. > > > > > > Correspondingly, add bpf_testmod_fentry_test7() and > > > bpf_testmod_fentry_test11() to bpf_testmod.c > > > > > > Meanwhile, add bpf_modify_return_test2() to test_run.c to test the > > > MODIFY_RETURN with 7 arguments. > > > > > > Add bpf_testmod_test_struct_arg_7/bpf_testmod_test_struct_arg_7 in > > > bpf_testmod.c to test the struct in the arguments. > > > > > > And the testcases passed on x86_64: > > > > > > ./test_progs -t fexit > > > Summary: 5/14 PASSED, 0 SKIPPED, 0 FAILED > > > > > > ./test_progs -t fentry > > > Summary: 3/2 PASSED, 0 SKIPPED, 0 FAILED > > > > > > ./test_progs -t modify_return > > > Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED > > > > > > ./test_progs -t tracing_struct > > > Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED > > > > > > Signed-off-by: Menglong Dong > > > Acked-by: Yonghong Song > > > --- > > > v8: > > > - split the testcases, and add fentry_many_args/fexit_many_args to > > > DENYLIST.aarch64 > > > v6: > > > - add testcases to tracing_struct.c instead of fentry_test.c and > > > fexit_test.c > > > v5: > > > - add testcases for MODIFY_RETURN > > > v4: > > > - use different type for args in bpf_testmod_fentry_test{7,12} > > > - add testcase for grabage values in ctx > > > v3: > > > - move bpf_fentry_test{7,12} to bpf_testmod.c and rename them to > > > bpf_testmod_fentry_test{7,12} meanwhile > > > - get return value by bpf_get_func_ret() in > > > "fexit/bpf_testmod_fentry_test12", as we don't change ___bpf_ctx_ca= st() > > > in this version > > > --- > > > net/bpf/test_run.c | 23 ++++++-- > > > tools/testing/selftests/bpf/DENYLIST.aarch64 | 2 + > > > .../selftests/bpf/bpf_testmod/bpf_testmod.c | 49 ++++++++++++++++- > > > .../selftests/bpf/prog_tests/fentry_test.c | 43 +++++++++++++-- > > > .../selftests/bpf/prog_tests/fexit_test.c | 43 +++++++++++++-- > > > .../selftests/bpf/prog_tests/modify_return.c | 20 ++++++- > > > .../selftests/bpf/prog_tests/tracing_struct.c | 19 +++++++ > > > .../selftests/bpf/progs/fentry_many_args.c | 39 ++++++++++++++ > > > .../selftests/bpf/progs/fexit_many_args.c | 40 ++++++++++++++ > > > .../selftests/bpf/progs/modify_return.c | 40 ++++++++++++++ > > > .../selftests/bpf/progs/tracing_struct.c | 54 +++++++++++++++++= ++ > > > 11 files changed, 358 insertions(+), 14 deletions(-) > > > create mode 100644 tools/testing/selftests/bpf/progs/fentry_many_arg= s.c > > > create mode 100644 tools/testing/selftests/bpf/progs/fexit_many_args= .c > > > > > > diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c > > > index 63b11f7a5392..1c59fa60077b 100644 > > > --- a/net/bpf/test_run.c > > > +++ b/net/bpf/test_run.c > > > @@ -565,6 +565,13 @@ __bpf_kfunc int bpf_modify_return_test(int a, in= t *b) > > > return a + *b; > > > } > > > > > > +__bpf_kfunc int bpf_modify_return_test2(int a, int *b, short c, int = d, > > > + void *e, char f, int g) > > > +{ > > > + *b +=3D 1; > > > + return a + *b + c + d + (long)e + f + g; > > > +} > > > + > > > int noinline bpf_fentry_shadow_test(int a) > > > { > > > return a + 1; > > > @@ -600,9 +607,13 @@ __diag_pop(); > > > > > > BTF_SET8_START(bpf_test_modify_return_ids) > > > BTF_ID_FLAGS(func, bpf_modify_return_test) > > > +BTF_ID_FLAGS(func, bpf_modify_return_test2) > > > BTF_ID_FLAGS(func, bpf_fentry_test1, KF_SLEEPABLE) > > > BTF_SET8_END(bpf_test_modify_return_ids) > > > > > > +BTF_ID_LIST(bpf_modify_return_test_id) > > > +BTF_ID(func, bpf_modify_return_test) > > > + > > > static const struct btf_kfunc_id_set bpf_test_modify_return_set =3D = { > > > .owner =3D THIS_MODULE, > > > .set =3D &bpf_test_modify_return_ids, > > > @@ -665,9 +676,15 @@ int bpf_prog_test_run_tracing(struct bpf_prog *p= rog, > > > goto out; > > > break; > > > case BPF_MODIFY_RETURN: > > > - ret =3D bpf_modify_return_test(1, &b); > > > - if (b !=3D 2) > > > - side_effect =3D 1; > > > + if (prog->aux->attach_btf_id =3D=3D *bpf_modify_return_= test_id) { > > > + ret =3D bpf_modify_return_test(1, &b); > > > + if (b !=3D 2) > > > + side_effect =3D 1; > > > + } else { > > > + ret =3D bpf_modify_return_test2(1, &b, 3, 4, (v= oid *)5, 6, 7); > > > + if (b !=3D 2) > > > + side_effect =3D 1; > > > > Patches 1 and 2 look good, but I don't like where this check will lead = us: > > attach_btf_id =3D=3D *bpf_modify_return_test_id... > > > > Yeah, I don't like it either, which makes the code weak. > > > When Jiri did a conversion of all test func into bpf_testmod.ko I forgo= t > > why we couldn't move fmod_ret tests as well. > > Whatever it was the extra attach_btf_id check will make it worse. > > > > I think it's because the side effect can't be verified > by the BPF program, which makes it have to be run by > bpf_prog_test_run_opts(). > > > For now please think of a way to test fmod_ret when bpf_prog_test_run_t= racing() > > does something unconditional like: > > ret =3D bpf_modify_return_test(1, &b); > > if (b !=3D 2) > > side_effect++; > > ret =3D bpf_modify_return_test2(1, &b, 3, 4, (void *)5, 6, 7); > > Should it be like this? > > ret +=3D bpf_modify_return_test2(1, &b, 3, 4, (void *)5, 6, 7); > > Or the return of bpf_modify_return_test() can't be verified. Fine by me. As long as attach_btf_id check is removed. It's good.