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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1C2FC6FA91 for ; Tue, 6 Sep 2022 16:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233093AbiIFQhH (ORCPT ); Tue, 6 Sep 2022 12:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233442AbiIFQgp (ORCPT ); Tue, 6 Sep 2022 12:36:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 248CF13F5D for ; Tue, 6 Sep 2022 09:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662480777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kg2ZD8/t1Jr30+S6ZmV5Vng3X+mccbhRQidJGUyOJ8o=; b=Hdx2jw3IDZlrCLAi90onICEn5UaRBMqVRZJzny7HB2pFOFn6WF38JxMq5cL7qF3ntLY+AH 0Chj4OdzwUj9kPiqaa2oiuhA+Noj6Wbv73sL/O/6ob24LMJsq7hvGSTdnWog0X69XmLRBF BEsVFCTgRjNyiBXYgtk8YiFOIs7jLJg= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-60-ZtiQweRhOZaAjFxTmIQstA-1; Tue, 06 Sep 2022 12:12:56 -0400 X-MC-Unique: ZtiQweRhOZaAjFxTmIQstA-1 Received: by mail-pj1-f71.google.com with SMTP id g11-20020a17090a4b0b00b001fb5f1e195fso5081238pjh.6 for ; Tue, 06 Sep 2022 09:12:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=kg2ZD8/t1Jr30+S6ZmV5Vng3X+mccbhRQidJGUyOJ8o=; b=3sIScvy0D5r0GroiOcVdxDTla2K5PLEdarrdyaVCj748sDDR40XFG5HtcqULSOFZAX vIAn9T3hNwEm+0MiwmU34uhvaxNwEec9bf3X82xtCeWRx44bMrg3Z8f/ecYwB6fcffpY gC6wZbi6WhgwWgSyfmJg+txElY2HBd6IgSg6Zw9PK5sxnp1AxQXnZKLaS3HiQ1qbQ127 mfCEOz5jWWc9kEfzyBIPpPFuEIFzWqph9n/2csB5Ia6t8MyMtYg8hkiy9LT3WB7u+jdI e6LK9ULQnMT27/amFcHzsTHuUJ4iu5wcLDualm2Gu0TreiJeYgb8w7c+6IW9ja07I9qW G4ow== X-Gm-Message-State: ACgBeo2pLAqPq2OlZ9TEvnNEQHz9sGNeVTqJO3yzixrM9PdXxoUwCqMj MvWPL/G9U8XkD4aauUHaUdJQYerekIsDztknZfkqSIr30m5a1+EaI34EhcTG05yzwLhd08MKuj9 DEqAzxQu/YB8Pt9Ytisntkk1mB8CISQLoLaElSkU= X-Received: by 2002:a17:90a:4485:b0:1fa:cc1f:a7a with SMTP id t5-20020a17090a448500b001facc1f0a7amr25979385pjg.45.1662480774582; Tue, 06 Sep 2022 09:12:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR62clyvFNxfvYwrm+zhQNaRY46JYdBxaA8PGMyTRlTBTbWPbc89Y4U7LekV45n04MZzTad6xPl3cyc04nZan6E= X-Received: by 2002:a17:90a:4485:b0:1fa:cc1f:a7a with SMTP id t5-20020a17090a448500b001facc1f0a7amr25979368pjg.45.1662480774362; Tue, 06 Sep 2022 09:12:54 -0700 (PDT) MIME-Version: 1.0 References: <20220902132938.2409206-1-benjamin.tissoires@redhat.com> <20220902132938.2409206-2-benjamin.tissoires@redhat.com> In-Reply-To: From: Benjamin Tissoires Date: Tue, 6 Sep 2022 18:12:43 +0200 Message-ID: Subject: Re: [PATCH bpf-next v10 01/23] selftests/bpf: regroup and declare similar kfuncs selftests in an array To: Kumar Kartikeya Dwivedi Cc: Greg KH , Jiri Kosina , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Shuah Khan , Dave Marchevsky , Joe Stringer , Jonathan Corbet , Tero Kristo , lkml , "open list:HID CORE LAYER" , Networking , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Doc Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On Tue, Sep 6, 2022 at 3:50 PM Benjamin Tissoires wrote: > > On Tue, Sep 6, 2022 at 5:27 AM Kumar Kartikeya Dwivedi wrote: > > > > On Tue, 6 Sept 2022 at 05:25, Kumar Kartikeya Dwivedi wrote: > > > > > > On Fri, 2 Sept 2022 at 15:29, Benjamin Tissoires > > > wrote: > > > > > > > > Similar to tools/testing/selftests/bpf/prog_tests/dynptr.c: > > > > we declare an array of tests that we run one by one in a for loop. > > > > > > > > Followup patches will add more similar-ish tests, so avoid a lot of copy > > > > paste by grouping the declaration in an array. > > > > > > > > To be able to call bpf_object__find_program_by_name(), we need to use > > > > plain libbpf calls, and not light skeletons. So also change the Makefile > > > > to not generate light skeletons. > > > > > > > > Signed-off-by: Benjamin Tissoires > > > > > > > > --- > > > > > > I see your point, but this is also a test so that we keep verifying > > > kfunc call in light skeleton. > > > Code for relocating both is different in libbpf (we generate BPF ASM > > > for light skeleton so it is done inside a loader BPF program instead > > > of userspace). > > > > Err, hit send too early. > > We can probably use a macro to hide how program is called, then do > > X(prog1) > > X(prog2) > > in a series, won't look too bad and avoids duplication at the same time. > > > > > You might then be able to make it work for both light and normal skeleton. > > > > > WDYT? > > > > On this patch alone, I concede the benefit is minimum. But if you look > at 6/23, I must confess I definitely prefer having just an array of > tests at the beginning instead of crippling the tests functions with > calls or macros. > > The actual reason for me to ditch light skeletons was because I was > using bpf_object__find_program_by_name(). > > But I can work around that by relying on the offsetof() macro, and > make the whole thing working for *both* light skeleton and libbpf: > +struct kfunc_test_params { > + const char *prog_name; > + unsigned long int lskel_prog_desc_offset; > + int retval; > +}; > + > +#define TC_TEST(name,__retval) \ > + { \ > + .prog_name = #name, \ > + .lskel_prog_desc_offset = offsetof(struct > kfunc_call_test_lskel, progs.name), \ > + .retval = __retval, \ > + } > + > +static struct kfunc_test_params kfunc_tests[] = { > + TC_TEST(kfunc_call_test1, 12), > + TC_TEST(kfunc_call_test2, 3), > + TC_TEST(kfunc_call_test_ref_btf_id, 0), > +}; > + > +static void verify_success(struct kfunc_test_params *param) > { > [...] > + struct bpf_prog_desc *lskel_prog = (struct bpf_prog_desc > *)((char *)lskel + param->lskel_prog_desc_offset); > > However, for failing tests, I can not really rely on light skeletons > because we can not dynamically set the autoload property. > So either I split every failed test in its own file, or I only test > the ones that are supposed to load, which don't add a lot IMO. > > I'll repost the bpf-core changes only so you can have a better idea of > what I am saying. > FWIW, I have now sent them at [0] and dropped all of the people not in get_maintainers.pl. Cheers, Benjamin [0] https://lore.kernel.org/all/20220906151303.2780789-1-benjamin.tissoires@redhat.com/T/#u