Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1698027rwl; Fri, 7 Apr 2023 23:28:18 -0700 (PDT) X-Google-Smtp-Source: AKy350b94m7/m+8BnWmkvm7hwwlUIwBnZGCjqvmmJFVzrztkbM53HAUryVMhxZYQI/mSZWXVZILh X-Received: by 2002:a17:906:8a62:b0:931:91a:fa4f with SMTP id hy2-20020a1709068a6200b00931091afa4fmr1837183ejc.41.1680935298177; Fri, 07 Apr 2023 23:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680935298; cv=none; d=google.com; s=arc-20160816; b=n+Y0ARXc+bvWe6qvOJakS6VGIgSN4wHr9lDfpTm1DUcZl9DhfWPo63bj++vTTdnRaa +jL8hyBa784BF6dOuPiSCHR1tbb87pR3SkLpsNTMgtR0ihvA6RYGDBedBQuZzxDUjcdP 4xXb9adQ4n4ov5zR3k2jkI4alVcu355bh/g80cA+DlX08Li3JujgrXlTZcb4x+IbsmLc LICRk+6lZ62lVtzFd+s5bF5Eb60w7gYZiVD+V+FxihdDKrQ1e297WORTNBnFfTqBcRl0 dH6o30dO/+9v3QPcAsKuccnlYc//ZDj37XYHygdX4qQ5UZB8dtxYWp8QrqY+GdhUhvYA Jebw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=z2dWon3rHJ1nD139lVaQ1WrnfCqCvaQvEhPXDcZYjwM=; b=H0jb0L56bMKrMpegGA6CJh45jXe6z1vodAbO0xF37445MfomxWhu9ygpUpkBYr33SL LES4H/btyuFxv0YkogFEptAj5w+dT3Vda1lJRCzY+E0Dqu5iu15mZ81pJdEn+SBQjN2l MPvFuxEpgUl3iJe5ITtEmHsI3qtJNSeFdQXd61U2fChwpIuMx4ARGZkuRcN7YGIawvww leaKDqpPubFeoLRFO5lQisRu8UXsUXGq3PRV7DigusAGypD8CgS+kkc1LiCPpAVGF1Qc jTc5p3TmOLJwsNJgQnQBMDrHqZRqqiFcfYRyQrqw+PftmB7hJvX8P8J+PJ9aQaLVaiHG YsRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=T4kCWB3J; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n8-20020a170906840800b0093229a6bc5dsi4565812ejx.264.2023.04.07.23.27.53; Fri, 07 Apr 2023 23:28:18 -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=@google.com header.s=20210112 header.b=T4kCWB3J; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbjDHFyD (ORCPT + 99 others); Sat, 8 Apr 2023 01:54:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbjDHFwQ (ORCPT ); Sat, 8 Apr 2023 01:52:16 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011876580 for ; Fri, 7 Apr 2023 22:52:14 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id c67-20020a254e46000000b00b88f1fd158fso15973295ybb.17 for ; Fri, 07 Apr 2023 22:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680933134; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=z2dWon3rHJ1nD139lVaQ1WrnfCqCvaQvEhPXDcZYjwM=; b=T4kCWB3JooK6L8NchDif5VHk4VQ5lliH7Lz9Ifuwebm2kE6RsdT8Fvu7FrnnUI4Twb w8xWnsMr9cHk+6Gw43Fcov8QfAOXzSaORpROP+WxtHVeAQ+Y8BBI13RWv6DjQgj8h+iI aPzBV0PV9cOgVOoMvGjAlAHXyf2ToqnvCkAcHvJQ62O/XI1zRCjaU709aLtFRTHUr2ss +O0NSJbTj8wKI47aaEL+nm/UnpB+eiFyXlQC6noLORyr9g8TyW88UJOVYECivc0QxE7x UGEwPwn/pE5Pd2rrdcSQCjUMMrrmAAvXZm3IhSIrqJPSv4KThFWM98XtuY6cnl+bwIIT Pfqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680933134; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z2dWon3rHJ1nD139lVaQ1WrnfCqCvaQvEhPXDcZYjwM=; b=NtmifY+KrO3V4H+uorYlklh6+pZyxZEmoyO/qEI0GuTT+GMtRcIiLjDIDY4ucC1iV2 JuHPDLwWp9YfHf+k+077jc68ymNeM9crsj/pK+TiW2TK3zuH661f5c5ZjVKjoc4k/bKD vuSJUfxvs9pWJnL6x+o8zgycj025z8E0b1wJeTnu0USz5AvIDsUGOypaTaQA6Kb04f2z 6y8GuFV+WgB3yvI71JEwK0xkSk1J/BRqlMDik9MbLYrukj9A05DlRTu7bPL2oj1je2A7 O9ZWah2/WfybJdrnXEBU7QRGBc7A+xLoUSofy1WxqUUObqiECcsR/3zrTNf5wiClEuQB HVkw== X-Gm-Message-State: AAQBX9eANq84q9zEWRzvosorRX47vGknw8xquIx4VPJNaswkwLw1ZuT/ BCVFHbOkA34S+VU37a2b71gH3yv+ICUs X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:b240:9cdf:7861:b23e]) (user=irogers job=sendgmr) by 2002:a25:d988:0:b0:997:c919:4484 with SMTP id q130-20020a25d988000000b00997c9194484mr651735ybg.6.1680933134194; Fri, 07 Apr 2023 22:52:14 -0700 (PDT) Date: Fri, 7 Apr 2023 22:52:08 -0700 In-Reply-To: <20230408055208.1283832-1-irogers@google.com> Message-Id: <20230408055208.1283832-2-irogers@google.com> Mime-Version: 1.0 References: <20230408055208.1283832-1-irogers@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Subject: [PATCH v1 2/2] perf bpf filter: Support pre-5.16 kernels From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 The mem_hops bits were added in 5.16 with no prior equivalent. Signed-off-by: Ian Rogers --- 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