Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp772332rwe; Fri, 14 Apr 2023 09:30:12 -0700 (PDT) X-Google-Smtp-Source: AKy350at9HgyGvkYzpGTpoS3Zhw9DNrchZ/4FCKSjbx75wBo0gexu/XCpvOElZyJBq2KnXvcC3sL X-Received: by 2002:a05:6a00:1ad1:b0:635:5b1c:64de with SMTP id f17-20020a056a001ad100b006355b1c64demr6492064pfv.2.1681489811736; Fri, 14 Apr 2023 09:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681489811; cv=none; d=google.com; s=arc-20160816; b=k36Ur5806thVvrNN26oMX6bWrnocZc39pP2BKqbRusszs6ifQgPZj3Xtajgz2coLlq 3DqVgB40RZYofJyPzrjIJx80yjw/neWLvfW6kOHmVQXjE/lSdGLAeXtqM/yCd8LwqUwB LeH7TOMi9zniP8dk5jjTspA93A3RHgnQOemOBH6b95jqO6Id/Q9nzUll5bkhGhs7WMhB nDtm2uN72r3yi6mdvTi1Zt2UY75vaq6HhqHKrFG9qsovl53dJ7eR6OSYkFHz3Myg8tSo 7hNeJTdgKKTuR5ySkpeHqIwaG7uNm09YltRs8ChFX358WMJwxyDnGPeutkt4829B0LAQ OfsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=XBtDfb7jrlKGDQ2eVProntazDKuZT+KOi2I9EHj7SZo=; b=vNtUzG7LZ+EJ+VKVph/rNdpghw06lWnJzr5oXpcWhamA555j5N2Z+sro9uh5C4tCao EXeXzrr3tsGHGKkcbuYwGJMUkXp14Z2tqeL6YtWG6eWxh8FKw9Qb4CkUZiQas8CTQwW2 OzTl/tOg44YMKPsilmTOQEGCsgpl+d27Kuj+neCY53aiEoVeMxC31ZAp8YhSKTzIoHQ9 9uLP5hg5B5uRBK6Iixt5Bq80tp4RuxipaRi2+tcBch2bxWFgPihnxrGcluCSAtDqnr9L ODht+5j2u+XxgalCi7twTjGuXbvQ0KaWljeIOTNZlGpS5jq6Nm9M3BEgSlKsRzYKQls0 Y7LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=xhUG7FJZ; dkim=neutral (no key) header.i=@suse.de; 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=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i35-20020a635863000000b00518a23e2181si4701428pgm.358.2023.04.14.09.29.59; Fri, 14 Apr 2023 09:30:11 -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=@suse.de header.s=susede2_rsa header.b=xhUG7FJZ; dkim=neutral (no key) header.i=@suse.de; 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=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbjDNQ22 (ORCPT + 99 others); Fri, 14 Apr 2023 12:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjDNQ21 (ORCPT ); Fri, 14 Apr 2023 12:28:27 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2FE07EF8; Fri, 14 Apr 2023 09:28:25 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A225B21A1F; Fri, 14 Apr 2023 16:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681489703; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XBtDfb7jrlKGDQ2eVProntazDKuZT+KOi2I9EHj7SZo=; b=xhUG7FJZpNqXddRbmzJvU5YT702axMW5edjK5s2+awqOAOtiPOjFcajJw/gGfzL+efk9Cc 5zdTGLjOyUXw2+4Q/Clw1ZlrbuSpjrkMC4Q5G4fTZ8oFagAHnP8ofnjXeQa/qG7ILbRLB3 frzRUMMFc0UF7TGznTTwQ6J42h8fcJY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681489703; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XBtDfb7jrlKGDQ2eVProntazDKuZT+KOi2I9EHj7SZo=; b=1W4HBUZZtQ2kqd5S+T/vbB5E5c0bhJOrszNYZrIxVZ4HP/scTFJGVBCvXmUht5X4TkI33g gG1qj1B1uT+3IyBg== Received: from kunlun.suse.cz (unknown [10.100.128.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 566D82C143; Fri, 14 Apr 2023 16:28:23 +0000 (UTC) Date: Fri, 14 Apr 2023 18:28:21 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Alexander Lobakin Cc: Alexander Lobakin , Alexei Starovoitov , Shung-Hsi Yu , Daniel Borkmann , Andrii Nakryiko , Maciej Fijalkowski , Song Liu , Kumar Kartikeya Dwivedi , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 bpf 02/11] bpftool: define a local bpf_perf_link to fix accessing its fields Message-ID: <20230414162821.GK63923@kunlun.suse.cz> References: <20220421003152.339542-1-alobakin@pm.me> <20220421003152.339542-3-alobakin@pm.me> <20230414095457.GG63923@kunlun.suse.cz> <9952dc32-f464-c85a-d812-946d6b0ac734@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9952dc32-f464-c85a-d812-946d6b0ac734@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Fri, Apr 14, 2023 at 05:18:27PM +0200, Alexander Lobakin wrote: > From: Michal Such?nek > Date: Fri, 14 Apr 2023 11:54:57 +0200 > > > Hello, > > Hey-hey, > > > > > On Thu, Apr 21, 2022 at 12:38:58AM +0000, Alexander Lobakin wrote: > >> When building bpftool with !CONFIG_PERF_EVENTS: > >> > >> skeleton/pid_iter.bpf.c:47:14: error: incomplete definition of type 'struct bpf_perf_link' > >> perf_link = container_of(link, struct bpf_perf_link, link); > >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >> tools/bpf/bpftool/bootstrap/libbpf/include/bpf/bpf_helpers.h:74:22: note: expanded from macro 'container_of' > >> ((type *)(__mptr - offsetof(type, member))); \ > >> ^~~~~~~~~~~~~~~~~~~~~~ > >> tools/bpf/bpftool/bootstrap/libbpf/include/bpf/bpf_helpers.h:68:60: note: expanded from macro 'offsetof' > >> #define offsetof(TYPE, MEMBER) ((unsigned long)&((TYPE *)0)->MEMBER) > >> ~~~~~~~~~~~^ > >> skeleton/pid_iter.bpf.c:44:9: note: forward declaration of 'struct bpf_perf_link' > >> struct bpf_perf_link *perf_link; > >> ^ > >> > >> &bpf_perf_link is being defined and used only under the ifdef. > >> Define struct bpf_perf_link___local with the `preserve_access_index` > >> attribute inside the pid_iter BPF prog to allow compiling on any > >> configs. CO-RE will substitute it with the real struct bpf_perf_link > >> accesses later on. > >> container_of() is not CO-REd, but it is a noop for > >> bpf_perf_link <-> bpf_link and the local copy is a full mirror of > >> the original structure. > >> > >> Fixes: cbdaf71f7e65 ("bpftool: Add bpf_cookie to link output") > > > > This does not solve the problem completely. Kernels that don't have > > CONFIG_PERF_EVENTS in the first place are also missing the enum value > > BPF_LINK_TYPE_PERF_EVENT which is used as the condition for handling the > > cookie. > > Sorry, I haven't been working with my home/private stuff for more than a > year already. I may get back to it some day when I'm tired of Lua (curse > words, sorry :D), but for now the series is "a bit" abandoned. This part still appllies and works for me with the caveat that BPF_LINK_TYPE_PERF_EVENT also needs to be defined. > I think there was alternative solution proposed there, which promised to > be more flexible. But IIRC it also doesn't touch the enum (was it added > recently? Because it was building just fine a year ago on config without > perf events). It was added in 5.15. Not sure there is a kernel.org LTS kernel usable for CO-RE that does not have it, technically 5.4 would work if it was built monolithic, it does not have module BTF, only kernel IIRC. Nonetheless, the approach to handling features completely missing in the running kernel should be figured out one way or another. I would be surprised if this was the last feature to be added that bpftool needs to know about. Thanks Michal