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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE8D0C433DF for ; Fri, 15 May 2020 17:00:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9FE58206C0 for ; Fri, 15 May 2020 17:00:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ccbWLnUt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726248AbgEORAK (ORCPT ); Fri, 15 May 2020 13:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726144AbgEORAK (ORCPT ); Fri, 15 May 2020 13:00:10 -0400 Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2046C05BD09 for ; Fri, 15 May 2020 10:00:09 -0700 (PDT) Received: by mail-yb1-xb43.google.com with SMTP id s37so1451531ybe.13 for ; Fri, 15 May 2020 10:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7FCtnhxXRkcL3anwH9mEdDuKXNzEgQcRUlM4mCBSwPs=; b=ccbWLnUtUwiKAn842+6hU4C8edxHHnDZVhGAcXJ4MHD2aPM6Y9mOFtesaLH/exfbRt V8+JUSsPRZGS6hqOjAIdFZfjzoqsQd2EFR1KpOCWVsK8DeNYUfpVPeuX+Bc1ljak+GmK IXRcsBaTgrtooRn0FHSrLzePzaHbEIPHqyT7MivD7o8WNzJZAywU2+W4FDZ/61x78tN+ ijTVdyvNlGULn23pBqyFlg5XtYzRLEJRj2EC4Bv5rvQILYRVWMtK3yB6og4PdN3nWygU YUR1czuWUDExyXOofEPeqN2USbyL9tKoOXk+6h7oEeUKlWH/11Da1+aoBE84Br767RNx 08XA== 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=7FCtnhxXRkcL3anwH9mEdDuKXNzEgQcRUlM4mCBSwPs=; b=j1+SxAhP6/kJwsHDyvBLjKSiaUJxBN6ExlF/HjiG0o54zluydedR3o5tWi64YKEQ0W oys6HQDPck+HWSeXddJP1XNJZXWq6tixg7LrgX7J2Xq55wn+F4NBCR7k+KcKDO3bnPQz RiLpaQR+LyZUuX4cAyYeaOImVUphDM2B0NcVPOmjwwgDL3935GRFy1x7NSKTN4/odhQC I1w5ssUjA4D3Yeccg/G8HrJpPfGUni0II+QVajr4TpAJ/WAEZSIJv/6fQq3Iwv+srkg1 cNCIT3gJCfVSXfrnXAtpyifrP2Y0Sg84/3rzxAV4Jc9dVo448cBm0NH/c0HiaUlJUy9v Lrdw== X-Gm-Message-State: AOAM533aGrdB8snc3JpeGf3thgtXv4+e2Bjag9864OWnzRZOpfs0tfJY CLm5N8mb2koB+VhcRa0stxzITVf7rbeZZolRI18yqw== X-Google-Smtp-Source: ABdhPJyH3+hVuoWG26jUdXOuiqO06AU3SHQ71fqWw7wtANcrcWD7kOBFVq4nqnjQ0Txo9ZKUonn51mDqXlP2DLGicIk= X-Received: by 2002:a25:c08b:: with SMTP id c133mr7057333ybf.286.1589562008534; Fri, 15 May 2020 10:00:08 -0700 (PDT) MIME-Version: 1.0 References: <20200515065624.21658-1-irogers@google.com> <20200515065624.21658-5-irogers@google.com> <20200515091707.GC3511648@krava> <20200515142917.GT5583@kernel.org> <20200515163146.GA9335@kernel.org> In-Reply-To: <20200515163146.GA9335@kernel.org> From: Ian Rogers Date: Fri, 15 May 2020 09:59:57 -0700 Message-ID: Subject: Re: [PATCH 4/8] libbpf hashmap: Localize static hashmap__* symbols To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , Andi Kleen , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , Adrian Hunter , Leo Yan , LKML , Networking , bpf , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 9:31 AM Arnaldo Carvalho de Melo wrote: > > Em Fri, May 15, 2020 at 07:53:33AM -0700, Ian Rogers escreveu: > > On Fri, May 15, 2020 at 7:29 AM Arnaldo Carvalho de Melo > > wrote: > > > > > > Em Fri, May 15, 2020 at 11:17:07AM +0200, Jiri Olsa escreveu: > > > > On Thu, May 14, 2020 at 11:56:20PM -0700, Ian Rogers wrote: > > > > > Localize the hashmap__* symbols in libbpf.a. To allow for a version in > > > > > libapi. > > > > > > > > > > Before: > > > > > $ nm libbpf.a > > > > > ... > > > > > 000000000002088a t hashmap_add_entry > > > > > 000000000001712a t hashmap__append > > > > > 0000000000020aa3 T hashmap__capacity > > > > > 000000000002099c T hashmap__clear > > > > > 00000000000208b3 t hashmap_del_entry > > > > > 0000000000020fc1 T hashmap__delete > > > > > 0000000000020f29 T hashmap__find > > > > > 0000000000020c6c t hashmap_find_entry > > > > > 0000000000020a61 T hashmap__free > > > > > 0000000000020b08 t hashmap_grow > > > > > 00000000000208dd T hashmap__init > > > > > 0000000000020d35 T hashmap__insert > > > > > 0000000000020ab5 t hashmap_needs_to_grow > > > > > 0000000000020947 T hashmap__new > > > > > 0000000000000775 t hashmap__set > > > > > 00000000000212f8 t hashmap__set > > > > > 0000000000020a91 T hashmap__size > > > > > ... > > > > > > > > > > After: > > > > > $ nm libbpf.a > > > > > ... > > > > > 000000000002088a t hashmap_add_entry > > > > > 000000000001712a t hashmap__append > > > > > 0000000000020aa3 t hashmap__capacity > > > > > 000000000002099c t hashmap__clear > > > > > 00000000000208b3 t hashmap_del_entry > > > > > 0000000000020fc1 t hashmap__delete > > > > > 0000000000020f29 t hashmap__find > > > > > 0000000000020c6c t hashmap_find_entry > > > > > 0000000000020a61 t hashmap__free > > > > > 0000000000020b08 t hashmap_grow > > > > > 00000000000208dd t hashmap__init > > > > > 0000000000020d35 t hashmap__insert > > > > > 0000000000020ab5 t hashmap_needs_to_grow > > > > > 0000000000020947 t hashmap__new > > > > > 0000000000000775 t hashmap__set > > > > > 00000000000212f8 t hashmap__set > > > > > 0000000000020a91 t hashmap__size > > > > > ... > > > > > > > > I think this will break bpf selftests which use hashmap, > > > > we need to find some other way to include this > > > > > > > > either to use it from libbpf directly, or use the api version > > > > only if the libbpf is not compiled in perf, we could use > > > > following to detect that: > > > > > > > > CFLAGS += -DHAVE_LIBBPF_SUPPORT > > > > $(call detected,CONFIG_LIBBPF) > > > > > > And have it in tools/perf/util/ instead? > > > *sigh* > > > $ make -C tools/testing/selftests/bpf test_hashmap > > make: Entering directory > > '/usr/local/google/home/irogers/kernel-trees/kernel.org/tip/tools/testing/s > > elftests/bpf' > > BINARY test_hashmap > > /usr/bin/ld: /tmp/ccEGGNw5.o: in function `test_hashmap_generic': > > /usr/local/google/home/irogers/kernel-trees/kernel.org/tip/tools/testing/selftests/bpf/test_hashmap. > > c:61: undefined reference to `hashmap__new' > > ... > > > My preference was to make hashmap a sharable API in tools, to benefit > > That is my preference as well, I'm not defending having it in > tools/perf/util/, just saying that that is a possible way to make > progress with the current situation... Thanks, it'd be nice to be expedient as both Jiri and myself are changing code in this area. v2 is up for review here: https://lore.kernel.org/lkml/20200515165007.217120-8-irogers@google.com/ An ifdef when the hashmap.h is used, and one in the build. It could be worse. Thanks, Ian > > not just perf but say things like libsymbol, libperf, etc. Moving it > > into perf and using conditional compilation is kinda gross but having > > libbpf tests depend on libapi also isn't ideal I guess. It is tempting > > to just cut a hashmap from fresh cloth to avoid this and to share > > among tools/. I don't know if the bpf folks have opinions? > > > > I'll do a v2 using conditional compilation to see how bad it looks. > > Cool, lets see how it looks. > > - Arnaldo