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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 65FB1C47423 for ; Thu, 1 Oct 2020 20:57:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2763F20848 for ; Thu, 1 Oct 2020 20:57:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="V8gpdcJC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733006AbgJAU5Y (ORCPT ); Thu, 1 Oct 2020 16:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732836AbgJAU5U (ORCPT ); Thu, 1 Oct 2020 16:57:20 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06802C0613D0 for ; Thu, 1 Oct 2020 13:57:20 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id q13so10069902ejo.9 for ; Thu, 01 Oct 2020 13:57:19 -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=6mFddp8qBk6Dwzi45sa2KHPnDPIBia0gy5sbwiCZZ4U=; b=V8gpdcJCL4n24CdIUlhIogI1Kr8L0/sHHo1SRLxtsQimGtRodzS5ANhq5V1w/h6TQH 1MqLPAHckyqP4X520v9hcxx4vu5D5julIwvlEq/7s7YnsssC0zEOtmWIjdt77pYC8NJ+ aKqFJ47Z9ZMEyquRdMjZm5N5JLRCyJUd19MFPThpUl8d6Gi9+4MUWaTcB/th1zhO9AWh TAc2tHEI6Yt8AVI2A84UB7GRmQTrVegpYI30C9/rr+1G+I1KrEcTV2a8SsPJkew8YxzY GkTGaMKsuKelI9/YBQYg8C+stVy4IsbPLzKldCt8/TtAkOb1VDD80Qm1SndfV/3L8IB0 NqPw== 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=6mFddp8qBk6Dwzi45sa2KHPnDPIBia0gy5sbwiCZZ4U=; b=rgf+H+phQc9tk8C0ZkIop55+oAD2HXwFAxz0fvf+nR67nmnWMsd3rz3sfJscp7HBun 2Egk7owKx0zUa6qmJTwyzacIGzkBFxNZqftMHuWTGOhKcWlvWKFQgOiQ7eOQHrheDCCL OfpftrUGKb0DCqBt8CbM+K61pjDqISNblvVG2Yb/XJeLUYBEW30p3hnFozzqaLQi7ZCI Zsv0x/vBmCwFpmmtGDlyOou9rlhuRQuEChShvFnCRcD8fsDqyexjHE+ZuJyZA5BleZfM 5N4/0KOKvqxlbh+AfKEPfS9UGqV6WFamUm6hZ/uUKSaYdJs4qfHFTKf40ckPCkuMwFlR OeNw== X-Gm-Message-State: AOAM533xxpFawxoOJLEXyr9w1xv5SEenHtaRMfvi3YobNbYGNcJ1TWhu qWbN1wvaITi3iLSBdLXld4EBKyrSwo96KCmDC0LQ4w== X-Google-Smtp-Source: ABdhPJyILKNDDwnF8/LRvPkwAgOxc6s2EDCd+Sw/kzTT82uGzpTazX0XnVNm/wY5/5KrPn93zIRyYAy7Tyn8LcEKRKU= X-Received: by 2002:a17:906:70d4:: with SMTP id g20mr10500338ejk.413.1601585838413; Thu, 01 Oct 2020 13:57:18 -0700 (PDT) MIME-Version: 1.0 References: <20200825004523.1353133-1-haoluo@google.com> <20200826131143.GF1059382@kernel.org> <20201001182415.GA101623@kernel.org> <20201001202729.GA105734@kernel.org> In-Reply-To: <20201001202729.GA105734@kernel.org> From: Hao Luo Date: Thu, 1 Oct 2020 13:57:07 -0700 Message-ID: Subject: Re: [PATCH v1] btf_encoder: Handle DW_TAG_variable that has DW_AT_specification To: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , dwarves@vger.kernel.org, Yonghong Song , bpf Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: dwarves@vger.kernel.org Arnaldo, thanks for the update. In that case, I think on the kernel side I need to skip encoding percpu vars for this pahole release, and re-enable for the next pahole release. (assuming the flag for opt-out is in this release). Alexei, do you have any better idea? Hao On Thu, Oct 1, 2020 at 1:27 PM Arnaldo Carvalho de Melo wrote: > > Em Thu, Oct 01, 2020 at 11:40:25AM -0700, Hao Luo escreveu: > > Thanks! > > I must just apologise not having this in an officially released version > yet, getting constantly postponed due to bug reports about corner cases > and some features I got carried away working on, I'll fast pace a new > version to avoid getting in the way of the larger eBPF effort. > > - Arnaldo > > > On Thu, Oct 1, 2020 at 11:24 AM Arnaldo Carvalho de Melo > > wrote: > > > > > > Em Thu, Oct 01, 2020 at 08:47:51AM -0700, Alexei Starovoitov escreveu: > > > > Arnaldo, > > > > > > > > ping. > > > > Is anything blocking this fix from merging? > > > > The kernel patches are stalled waiting on the pahole. > > > > > > Applied locally, testing now, will push to the main branch ASAP. > > > > > > - Arnaldo > > > > > > > Thanks > > > > On Tue, Sep 29, 2020 at 11:52 PM Hao Luo wrote: > > > > > > > > > > Arnaldo, > > > > > > > > > > Is this patch ready to be merged into Pahole's master branch? Alexei > > > > > is testing the kernel patches that need this patch. Please let me know > > > > > if there is anything I can do to help merging. > > > > > > > > > > Thank you, > > > > > Hao > > > > > > > > > > On Wed, Aug 26, 2020 at 6:56 PM Arnaldo Carvalho de Melo > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > On August 26, 2020 3:35:17 PM GMT-03:00, Hao Luo wrote: > > > > > > >Arnaldo, > > > > > > > > > > > > > >On Wed, Aug 26, 2020 at 6:12 AM Arnaldo Carvalho de Melo > > > > > > > wrote: > > > > > > >> > > > > > > >> Em Mon, Aug 24, 2020 at 05:45:23PM -0700, Hao Luo escreveu: > > > > > > >> > It is found on gcc 8.2 that global percpu variables generate the > > > > > > >> > following dwarf entry in the cu where the variable is defined[1]. > > > > > > >> > > > > > > > >> > Take the global variable "bpf_prog_active" defined in > > > > > > >> > kernel/bpf/syscall.c as an example. The debug info for syscall.c > > > > > > >> > has two dwarf entries for "bpf_prog_active". > > > > > > >> > > > > > > > >[...] > > > > > > >> > > > > > > >> Interesting, here I get, with binutils' readelf: > > > > > > >> > > > > > > >> [root@quaco perf]# readelf -wi > > > > > > >../build/v5.8-rc5+/kernel/bpf/syscall.o | grep bpf_prog_active > > > > > > >> DW_AT_name : (indirect string, offset: 0xb70d): > > > > > > >bpf_prog_active > > > > > > >> [root@quaco perf]# > > > > > > >> > > > > > > >> Just one, as: > > > > > > >> > > > > > > >> [root@quaco perf]# readelf -wi > > > > > > >../build/v5.8-rc5+/kernel/bpf/syscall.o | grep bpf_prog_active -B1 -A8 > > > > > > >> <1>: Abbrev Number: 103 (DW_TAG_variable) > > > > > > >> DW_AT_name : (indirect string, offset: 0xb70d): > > > > > > >bpf_prog_active > > > > > > >> DW_AT_decl_file : 11 > > > > > > >> DW_AT_decl_line : 1008 > > > > > > >> DW_AT_decl_column : 1 > > > > > > >> DW_AT_type : <0xcf> > > > > > > >> DW_AT_external : 1 > > > > > > >> DW_AT_declaration : 1 > > > > > > >> <1>: Abbrev Number: 103 (DW_TAG_variable) > > > > > > >> DW_AT_name : (indirect string, offset: 0x3a5d): > > > > > > >bpf_stats_enabled_mutex > > > > > > >> [root@quaco perf]# > > > > > > >> > > > > > > >> I get what you have when I use elfutils' readelf: > > > > > > >> > > > > > > >> [root@quaco perf]# eu-readelf -winfo > > > > > > >../build/v5.8-rc5+/kernel/bpf/syscall.o | grep bpf_prog_active > > > > > > >> name (strp) "bpf_prog_active" > > > > > > >> [ 0] addr .data..percpu+0 > > > > > > >> [root@quaco perf]# > > > > > > >> > > > > > > >> [root@quaco perf]# eu-readelf -winfo > > > > > > >../build/v5.8-rc5+/kernel/bpf/syscall.o | grep -B1 -A8 > > > > > > >\"bpf_prog_active\" > > > > > > >> [ f6a0] variable abbrev: 103 > > > > > > >> name (strp) "bpf_prog_active" > > > > > > >> decl_file (data1) bpf.h (11) > > > > > > >> decl_line (data2) 1008 > > > > > > >> decl_column (data1) 1 > > > > > > >> type (ref4) [ cf] > > > > > > >> external (flag_present) yes > > > > > > >> declaration (flag_present) yes > > > > > > >> [ f6ad] variable abbrev: 103 > > > > > > >> name (strp) "bpf_stats_enabled_mutex" > > > > > > >> [root@quaco perf]# > > > > > > >> > > > > > > >> And: > > > > > > >> > > > > > > >> [root@quaco perf]# eu-readelf -winfo > > > > > > >../build/v5.8-rc5+/kernel/bpf/syscall.o | grep -B5 \ > > > > > > >> [ 1bdf5] variable abbrev: 212 > > > > > > >> specification (ref4) [ f6a0] > > > > > > >> decl_file (data1) syscall.c (1) > > > > > > >> decl_line (data1) 43 > > > > > > >> location (exprloc) > > > > > > >> [ 0] addr .data..percpu+0 > > > > > > >> [root@quaco perf]# > > > > > > >> > > > > > > > > > > > > > >In binutils readelf, there is a extra entry > > > > > > > > > > > > Not here, tomorrow I'll triple check. > > > > > > > > > > > > > > > > > > > > <1><1b24c>: Abbrev Number: 195 (DW_TAG_variable) > > > > > > > <1b24e> DW_AT_specification: <0xf335> > > > > > > > <1b252> DW_AT_decl_file : 1 > > > > > > > <1b253> DW_AT_decl_line : 43 > > > > > > > <1b254> DW_AT_location : 9 byte block: 3 0 0 0 0 0 0 0 0 > > > > > > > (DW_OP_addr: 0) > > > > > > > > > > > > > >which points to > > > > > > > > > > > > > > <1>: Abbrev Number: 95 (DW_TAG_variable) > > > > > > > DW_AT_name : (indirect string, offset: 0xb37a): > > > > > > >bpf_prog_active > > > > > > > > > > > > > >It just doesn't have the string 'bpf_prog_active', annotating entry. > > > > > > >So eu-readelf and binutils readelf have the same results. > > > > > > > > > > > > > >> > Note that second DW_TAG_variable entry contains specification that > > > > > > >> > points to the first entry. > > > > > > >> > > > > > > >> So you are not considering the first when encoding since it is just a > > > > > > >> DW_AT_declaration, considers the second, as it should be, and then > > > > > > >needs > > > > > > >> to go see its DW_AT_specification, right? > > > > > > >> > > > > > > >> Sounds correct, applying, will test further and then push out, > > > > > > >> > > > > > > > > > > > > > >Yes, exactly. The var tags to be considered are those that either have > > > > > > >DW_AT_specification or not have DW_AT_declaration. This makes sure > > > > > > >btf_encoder works correctly on both old and new gcc. > > > > > > > > > > > > > >> Thanks, > > > > > > >> > > > > > > >> - Arnaldo > > > > > > > > > > > > > >Suggested by Yonghong, I tested this change on a larger set of > > > > > > >compilers this time and works correctly. See below. > > > > > > > > > > > > > >Could you also add 'Reported-by: Yonghong Song '? I should > > > > > > >have done that when sending out this patch. The credit goes to > > > > > > >Yonghong. > > > > > > > > > > > > Sure, and I'll add your results with different computers, for the record. > > > > > > > > > > > > Thanks, > > > > > > > > > > > > - Arnaldo > > > > > > > > > > > > > >Thank you, > > > > > > >Hao > > > > > > > > > > > > > > clang 10: > > > > > > > [67] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [20168] VAR 'bpf_prog_active' type_id=67, linkage=global-alloc > > > > > > > > > > > > > > clang 9: > > > > > > > [64] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [19789] VAR 'bpf_prog_active' type_id=64, linkage=global-alloc > > > > > > > > > > > > > > gcc 10.2 > > > > > > > [18] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [20319] VAR 'bpf_prog_active' type_id=18, linkage=global-alloc > > > > > > > > > > > > > > gcc 9.3: > > > > > > > [21] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [21085] VAR 'bpf_prog_active' type_id=21, linkage=global-alloc > > > > > > > > > > > > > > gcc 8 > > > > > > > [21] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [21084] VAR 'bpf_prog_active' type_id=21, linkage=global-alloc > > > > > > > > > > > > > > gcc 6.2 > > > > > > > [22] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [21083] VAR 'bpf_prog_active' type_id=22, linkage=global-alloc > > > > > > > > > > > > > > gcc 4.9 > > > > > > > [17] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED > > > > > > > [20410] VAR 'bpf_prog_active' type_id=17, linkage=global-alloc > > > > > > > > > > > > -- > > > > > > Sent from my Android device with K-9 Mail. Please excuse my brevity. > > > > > > -- > > > > > > - Arnaldo > > -- > > - Arnaldo