Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp241473pxh; Wed, 10 Nov 2021 00:50:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNA02dYB61RnWk4enC8uHXV6OfDgCQy/TiQL2jGGeRiwxqygI/BJaYL9K66SH4k+L9jZg2 X-Received: by 2002:a05:6402:4401:: with SMTP id y1mr19163797eda.225.1636534253480; Wed, 10 Nov 2021 00:50:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636534253; cv=none; d=google.com; s=arc-20160816; b=zSDQy70l9qZ3XYIrM6IiFZcVTVUaTma3esTqr6bjKOebBVv4cE5Blewh96Osr18Ueb uzv4WvpS3pqwyY0WyPBnZ/n2pgQBKOu/EShQ0FGV/9yQpiMp785SfPG7WMb6iFVnPBob ELAYeib2AwXAoUC6KGk2zF3q8rQJb9NgTU8f4dqlMOmoYAV1lew8uKfC06jZaTocLpBE z6XRljXgFGq2lr0izu9fTXyTTmbDaFechZc1bTLJq1vF0zOP5jHwC+QsKDUqXBc4Fkap WPhcJbpK4y7wMoJcGPc3ngEGHWTXspB02vdjdIuhEy70DXH/YuNG4P9h1pide3VLRvXs Bg9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8Ho5EXRGYh8IyL3hxtihj/uWe5GBsevOzHdhzQOn+II=; b=iv6p2fB8zQzE3sVk2pTymsfW4CzJs7ZtGZ1rfi/u6Zxy2Y/1b5iqUrJyF+tvcuDfap Pv7oKrN8w4+YTxtCSwpWSAPGmSCgeIxaaoDDWeT0dX6rUV6pbIXl7StkLx7BcnuLn1mj 4fLhMrhHMEvYk4Qdo3hGXtjkFecEVT+YuJ8wQXAY4BhqeRU6LEqs+MxPXO4CDmX5Jnig K9yA7amkCDAZ9PG7ZMdrz+TNvQEFKoHtFyV7I26NJ1mBqGFDzYcMk6zl8APfvrC1+Y3t 6MB/wtbEkwQsOMUQxosFHi6tHEKCYyTTu6f3soWxu2K1RDXBYVRNPybzJzZUWguUCPWa ciNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bRkPSp5H; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ne38si47283702ejc.97.2021.11.10.00.50.29; Wed, 10 Nov 2021 00:50:53 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=bRkPSp5H; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230381AbhKJIsj (ORCPT + 99 others); Wed, 10 Nov 2021 03:48:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22255 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbhKJIsi (ORCPT ); Wed, 10 Nov 2021 03:48:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636533951; 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=8Ho5EXRGYh8IyL3hxtihj/uWe5GBsevOzHdhzQOn+II=; b=bRkPSp5HZtOTVKxD98gBWy/0c3sF9zf5+oNNOVnZnA5FOMjs4gf3UxWTGJZN/0ECir2Xal xIZxoYpOB7IECCzqa8gcUX9clQNUZ7WEguqolyTJNs9iRgxOOLmYeh+iiIRwnOfnwO73XK fHOW39GilXq0FV/tlgvPUkSOFJ/yIQY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-267-zUKwAXdiNEWNvMGUIlN-Tw-1; Wed, 10 Nov 2021 03:45:50 -0500 X-MC-Unique: zUKwAXdiNEWNvMGUIlN-Tw-1 Received: by mail-wm1-f69.google.com with SMTP id m18-20020a05600c3b1200b0033283ea5facso953342wms.1 for ; Wed, 10 Nov 2021 00:45:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8Ho5EXRGYh8IyL3hxtihj/uWe5GBsevOzHdhzQOn+II=; b=NZ8/p7DfPjTa127TS3Xh2ZFpdVYXurVRWCXkArS1CN+fKHBVs7FOczgIUMCjveu1L4 j2aKC2UEnOuBIbks6jY7uvXtNaMG7AnANBR+0PP8RDNlJNVY0QAc6WhyiBuD0AK63SKW qDoCs8jAifz0Ggr0FGXDxsUF2LTWiOxoPCoOqLO+r8IyIcG09GO8Qfy9etKC68CE1lJu 4itr9V4cguQ4ASPU6ttI9ch6QbzpjxsYerJ+twFaeBX4K5W1ld0sGtRo6tT/1WWoFfi/ no2rZipxOX+FiY20TJODwaYOSNEKsp1m5hv0ADxlbsdZRZlu4q/zzNjjJ15p1MSK5Wm8 akrw== X-Gm-Message-State: AOAM5332uelI0kH+26+mEX5ua7Equzb5l2dYJrm6tyKMfS5yvqzlVgul 3QnrKGIiPT9FTFxid4WoarkW0X0EgceMw+qjKzICBQZxjMtPuqhzH02Hl4dpY8wp/mFaQsSrUSp lhzxE3yAcO4F3FdQRVR8Zh/+L X-Received: by 2002:a7b:c351:: with SMTP id l17mr14797991wmj.120.1636533948854; Wed, 10 Nov 2021 00:45:48 -0800 (PST) X-Received: by 2002:a7b:c351:: with SMTP id l17mr14797972wmj.120.1636533948663; Wed, 10 Nov 2021 00:45:48 -0800 (PST) Received: from krava (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id l4sm21365520wrv.94.2021.11.10.00.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 00:45:48 -0800 (PST) Date: Wed, 10 Nov 2021 09:45:47 +0100 From: Jiri Olsa To: Andrii Nakryiko Cc: Ian Rogers , Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , "linux-perf-use." , Andrii Nakryiko Subject: Re: [PATCH 1/2] perf tools: Add more weak libbpf functions Message-ID: References: <20211109140707.1689940-1-jolsa@kernel.org> <20211109140707.1689940-2-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 09, 2021 at 03:33:04PM -0800, Andrii Nakryiko wrote: > On Tue, Nov 9, 2021 at 10:50 AM Ian Rogers wrote: > > > > On Tue, Nov 9, 2021 at 6:07 AM Jiri Olsa wrote: > > > > > > We hit the window where perf uses libbpf functions, that did not > > > make it to the official libbpf release yet and it's breaking perf > > > build with dynamicly linked libbpf. > > > > > > Fixing this by providing the new interface as weak functions which > > > calls the original libbpf functions. Fortunatelly the changes were > > > just renames. > > > > Could we just provide these functions behind a libbpf version #if ? > > Weak symbols break things in subtle ways, under certain circumstances > > the weak symbol is preferred over the strong due to lazy object file > > resolution: > > https://maskray.me/blog/2021-06-20-symbol-processing#archive-processing > > This bit me last week, but in general you get away with it as the lazy > > object file will get processed in an archive exposing the strong > > symbol. With an #if you either get a linker error for 2 definitions or > > 0 definitions, and it's clear what is broken. > > > > In the past we had problems due to constant propagation from weak > > const variables, where #if was the solution: > > https://lore.kernel.org/lkml/20191001003623.255186-1-irogers@google.com/ > > > > There was some recent conversation on libbpf version for pahole here: > > https://lore.kernel.org/bpf/CAP-5=fUc3LtU0WYg-Py9Jf+9picaWHJdSw=sdOMA54uY3p1pdw@mail.gmail.com/T/ > > https://lore.kernel.org/bpf/20211021183330.460681-1-irogers@google.com/ > > > > Thanks, > > Ian > > > > > Signed-off-by: Jiri Olsa > > > --- > > > tools/perf/util/bpf-event.c | 27 +++++++++++++++++++++++++++ > > > 1 file changed, 27 insertions(+) > > > > > > diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c > > > index 4d3b4cdce176..ceb96360fd12 100644 > > > --- a/tools/perf/util/bpf-event.c > > > +++ b/tools/perf/util/bpf-event.c > > > @@ -33,6 +33,33 @@ struct btf * __weak btf__load_from_kernel_by_id(__u32 id) > > > return err ? ERR_PTR(err) : btf; > > > } > > > > > > +struct bpf_program * __weak > > > +bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev) > > > +{ > > > +#pragma GCC diagnostic push > > > +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" > > > + return bpf_program__next(prev, obj); > > > +#pragma GCC diagnostic pop > > > +} > > > + > > > +struct bpf_map * __weak > > > +bpf_object__next_map(const struct bpf_object *obj, const struct bpf_map *prev) > > > +{ > > > +#pragma GCC diagnostic push > > > +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" > > > + return bpf_map__next(prev, obj); > > > +#pragma GCC diagnostic pop > > > +} > > > + > > > +const void * __weak > > > +btf__raw_data(const struct btf *btf_ro, __u32 *size) > > > +{ > > > +#pragma GCC diagnostic push > > > +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" > > > + return btf__get_raw_data(btf_ro, size); > > you can still use old variants for the time being, if you want. Were > new APIs used accidentally? Libbpf maintains a guarantee that if some > API is deprecated in favor of the new one, there will be at least one > full libbpf release where both APIs are available and not marked as > deprecated. we could use old api instead of btf__raw_data, we could just revert the perf change but bpf_object__next_program and bpf_object__next_map are used through macros like bpf_object__for_each_map or bpf_object__for_each_program, so we'd need to define 'old versions' of them jirka > > > > > +#pragma GCC diagnostic pop > > > +} > > > + > > > static int snprintf_hex(char *buf, size_t size, unsigned char *data, size_t len) > > > { > > > int ret = 0; > > > -- > > > 2.31.1 > > > >