Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4678395rwl; Mon, 10 Apr 2023 15:13:21 -0700 (PDT) X-Google-Smtp-Source: AKy350Z0+rcIe7q6Q1ajzNwHY81/QNKZ5QTycgYUY6mqFIshqLRt6htOLh23JjFvKAiJx4O7Da7T X-Received: by 2002:a05:6a20:bb25:b0:cc:63c6:8d3a with SMTP id fc37-20020a056a20bb2500b000cc63c68d3amr431873pzb.41.1681164801236; Mon, 10 Apr 2023 15:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681164801; cv=none; d=google.com; s=arc-20160816; b=pHqWraY85SzY8MxJx2Q3lZmuc6CT7o8rkzywqCiteA6QGbqeb8mpZwaFr/ogWL8yrl E6/BLEwfyGGfZqWtTktW6EyM4w54jSeBq82fcgRZezakd67f86rr/49WPe/O9tYgNhgF BB06Bv6C/rIcyXNbilldXDxolk1PbiM8MPR3hY0KWWplpcSE4Csz2vnxxTVfi2404R1n mARHD6KeqlEAfy/iH/D3fF9N5shVhTFTxYxU2fPp2K3ig8fokXD41ffbGUvBtpjK9lgN ELTO9AaPGscCbVCd9YJSfNLIfwH+9jkArLwmBkPMbvSmube0is7QMlBqMK0jjWHSKTB7 wacg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9/xtNDnYS6Gsf+s52LM5YWTdBNnlRHlRqLfqJ4Xqo6M=; b=CExqjY3MkhCwpnasEVuoYdh+qGrVCISKvS5kBd8Yb22+36Ucq9v74fRLm9VDMDoTYj k1qqSB/Sp6Vrz1/B4BHGg41M55mZR6bPxztSIoc86W0avdayw6aqoIOTjetLFU8ZB0KE v7SEvUJG4LnsnnneBw9OfE4QkGgxkikruQ3JtExcstTHs5PY+/xkP17owwRJC1Qk5PMr KvYUYBMItn/CAIJvUd1ZIVxEIYquB3HwSxoyy04Wc9XFbqrqJFOSN6Ay2IQtKDP+2MuI +jvxciKn+E9WjYkSTgopOW00pKqZA3BKh2xndn2M7oWpFqp7ON218Z7bL7iem/z2g35h 4WQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="j/u0EhT2"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h190-20020a636cc7000000b0051357720307si11767238pgc.305.2023.04.10.15.13.08; Mon, 10 Apr 2023 15:13:21 -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=@kernel.org header.s=k20201202 header.b="j/u0EhT2"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229902AbjDJWMN (ORCPT + 99 others); Mon, 10 Apr 2023 18:12:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbjDJWMK (ORCPT ); Mon, 10 Apr 2023 18:12:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56C2AE51; Mon, 10 Apr 2023 15:12:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E309761D7E; Mon, 10 Apr 2023 22:12:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18506C433D2; Mon, 10 Apr 2023 22:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681164728; bh=/TPxAtqlCZXdR7Jc9aAW9VHcy3i/AR+zzMOBcwWYNdA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j/u0EhT2v0AX2+0HJys8DAeRDMMBjMen1IgPCEf1B7FHY3ilnjoOYhVBrHwwzutwU CsX513lT6QfBwSNWHC94MVNfElceEQzQ3E65CntSzm00xeBLulBA8Xd9I+0fNHvrEy rW5E9exio9pZMgKdvfFrGRO+8ZNwWxZYD25eoHj+msY1bUTt4BUYz1B4ahqjX53N45 SXd6OA4zuOKlZGtJCyLWLUTGFPHYXDB2OgvnaOLxQ6YtjCGSmUmnVVzDqeuU94nB1s RMFu14ZwJ9daSEjegWZvkQfonR1KC1gtUS+GcPkoaSN+P6NB7mOr/eqWqCy2v1yCKa MPVFWSrJTlF4A== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id ABFCD40009; Mon, 10 Apr 2023 19:12:03 -0300 (-03) Date: Mon, 10 Apr 2023 19:12:03 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v1 2/2] perf bpf filter: Support pre-5.16 kernels Message-ID: References: <20230408055208.1283832-1-irogers@google.com> <20230408055208.1283832-2-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Em Mon, Apr 10, 2023 at 08:34:34AM -0700, Namhyung Kim escreveu: > On Fri, Apr 7, 2023 at 10:52 PM Ian Rogers wrote: > > > > The mem_hops bits were added in 5.16 with no prior equivalent. > > > > Signed-off-by: Ian Rogers > > Acked-by: Namhyung Kim Both applied, thanks, - Arnaldo > Thanks, > Namhyung > > > > --- > > tools/perf/util/bpf_skel/sample_filter.bpf.c | 28 ++++++++++++++++++-- > > 1 file changed, 26 insertions(+), 2 deletions(-) > > > > diff --git a/tools/perf/util/bpf_skel/sample_filter.bpf.c b/tools/perf/util/bpf_skel/sample_filter.bpf.c > > index 57e3c67d6d37..cffe493af1ed 100644 > > --- a/tools/perf/util/bpf_skel/sample_filter.bpf.c > > +++ b/tools/perf/util/bpf_skel/sample_filter.bpf.c > > @@ -24,6 +24,24 @@ struct perf_sample_data___new { > > __u64 sample_flags; > > } __attribute__((preserve_access_index)); > > > > +/* new kernel perf_mem_data_src definition */ > > +union perf_mem_data_src__new { > > + __u64 val; > > + struct { > > + __u64 mem_op:5, /* type of opcode */ > > + mem_lvl:14, /* memory hierarchy level */ > > + mem_snoop:5, /* snoop mode */ > > + mem_lock:2, /* lock instr */ > > + mem_dtlb:7, /* tlb access */ > > + mem_lvl_num:4, /* memory hierarchy level number */ > > + mem_remote:1, /* remote */ > > + mem_snoopx:2, /* snoop mode, ext */ > > + mem_blk:3, /* access blocked */ > > + mem_hops:3, /* hop level */ > > + mem_rsvd:18; > > + }; > > +}; > > + > > /* helper function to return the given perf sample data */ > > static inline __u64 perf_get_sample(struct bpf_perf_event_data_kern *kctx, > > struct perf_bpf_filter_entry *entry) > > @@ -89,8 +107,14 @@ static inline __u64 perf_get_sample(struct bpf_perf_event_data_kern *kctx, > > return kctx->data->data_src.mem_dtlb; > > if (entry->part == 7) > > return kctx->data->data_src.mem_blk; > > - if (entry->part == 8) > > - return kctx->data->data_src.mem_hops; > > + if (entry->part == 8) { > > + union perf_mem_data_src__new *data = (void *)&kctx->data->data_src; > > + > > + if (bpf_core_field_exists(data->mem_hops)) > > + return data->mem_hops; > > + > > + return 0; > > + } > > /* return the whole word */ > > return kctx->data->data_src.val; > > default: > > -- > > 2.40.0.577.gac1e443424-goog > > -- - Arnaldo