Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp4099736rwa; Tue, 23 Aug 2022 16:25:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5MI0wI38S20S1UAvJ9+eg7nSQhuqUDYx9Jq7QW7rNDR1vZbybUcsfR91Bmn5FzcSBpFgWl X-Received: by 2002:a63:4b07:0:b0:422:e1a4:50bf with SMTP id y7-20020a634b07000000b00422e1a450bfmr22475422pga.295.1661297111013; Tue, 23 Aug 2022 16:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661297111; cv=none; d=google.com; s=arc-20160816; b=VDCdEOi+1jPsZ4KEnEvEQ6Kkd5NZCM0D0xMpeOjWco9L1qQFEUdSQOmR+NNnhq//Gc sVdyMDmxhsImu8LvNwJr3nwYK9DfRqto+kO0xx6EIQzdTofrp2HIHQcCAOHDCX7YpuJI naQvbkiFkSy3UVBK7SFWACx7LAN4vy8ZBluMJZYKkp4dqkyDmjbAiZ6w2D2KOjiwDT2R nr3wY6rz5sEdu+HzYGzXqcJJJ7KWj5hEZ5OBSM8JQsNxmYgv1hm9KryTHNTsVbY/kuHj JURpj/iNEUaLTFGo8Kq/UzYSNPFN4Y456NE29K7uz086KjDzpbUdDT7R7VfBTPy6hOfO UR1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=oHodqhGQVJUpYZFLY/dKxJcLvNCw1wll2BgbUR8IyRA=; b=G4a8mQ6Q1Blurbby5sMBUjC9PJhShXETzUNMCSVfhwAFj6FS7SSxoXJSx0Ic+Yf7Dr 37cfYkeORNOJvovrqwdOQ/gpF3gPjdwkkLu4zXPyn22y3wklbeGYDNu4gWLo9WCyZz/x 562U2z7rrXJQzXGLvbysuFA0guJ2Z0IFvpZK4k93JULVskvzRBpSO1rT+I4a7tZBZGuV 7OX4IH0xszK9RiDawQuSGiepNnUL/8VypwtWMF7gSAlBa0osR0eQful7Yws7AHKWdRqD hyrvrtKcErXmnSr9HSCuzsuNb0YYEzbzCt21fVCBMUHKFlIv529VpQ3/paso0rLr53le Vadw== ARC-Authentication-Results: i=1; mx.google.com; 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 qb4-20020a17090b280400b001fb57e4ae38si502081pjb.188.2022.08.23.16.25.00; Tue, 23 Aug 2022 16:25:10 -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; 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 S232145AbiHWWpk (ORCPT + 99 others); Tue, 23 Aug 2022 18:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbiHWWpg (ORCPT ); Tue, 23 Aug 2022 18:45:36 -0400 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F40B57FFAB; Tue, 23 Aug 2022 15:45:35 -0700 (PDT) Received: by mail-oi1-f176.google.com with SMTP id o184so17688494oif.13; Tue, 23 Aug 2022 15:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=oHodqhGQVJUpYZFLY/dKxJcLvNCw1wll2BgbUR8IyRA=; b=ur63j5doB31+aKQ7n01E5tE7nrAOum/teo2y5QRmkBIkaZaVUiI8sfPftA2VGQZf6F zHlrQlU8jd7TyK6neOoN0YlsOOWsXR32tuSbmhHaCpFPNk9+0kSItUsuK/NKDqCPJvND EAmyJ8rqx0ikle4TSHPW95/bDJzXWMHBSzmF92VO+8toqUk08vqNy2S/WNtVDcpemwyk pXYasoEFBEvnvd16gZH3CkL5O0lv9D8YHPf/yubXmP8ZQ+E8ruVBbZHye28aSlqCDMau 5gtMCM/NXYdG90hagbaF0sunDOd5sXHve1idMJcM2EALMmHOCG+/UXcq9rpE6S636sdc Hcgw== X-Gm-Message-State: ACgBeo1ysCiuXaxdRFmHpKjy65StvjUsvyy5iF8if1dGvm+DI1PS+niP QK7go8jo01XYCpiR+ALQBqfcptjg6Hp0NVtuXYQ= X-Received: by 2002:aca:ba86:0:b0:33a:c6f7:3001 with SMTP id k128-20020acaba86000000b0033ac6f73001mr2215025oif.5.1661294735248; Tue, 23 Aug 2022 15:45:35 -0700 (PDT) MIME-Version: 1.0 References: <20220823210354.1407473-1-namhyung@kernel.org> <95708205-66EA-4622-A580-FD234E6CE2DA@fb.com> In-Reply-To: <95708205-66EA-4622-A580-FD234E6CE2DA@fb.com> From: Namhyung Kim Date: Tue, 23 Aug 2022 15:45:24 -0700 Message-ID: Subject: Re: [PATCH bpf-next] bpf: Add bpf_read_raw_record() helper To: Song Liu Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Steven Rostedt , Peter Zijlstra , Ingo Molnar , "bpf@vger.kernel.org" , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Song, On Tue, Aug 23, 2022 at 3:19 PM Song Liu wrote: > > > > > On Aug 23, 2022, at 2:03 PM, Namhyung Kim wrote: > > > > The helper is for BPF programs attached to perf_event in order to read > > event-specific raw data. I followed the convention of the > > bpf_read_branch_records() helper so that it can tell the size of > > record using BPF_F_GET_RAW_RECORD flag. > > > > The use case is to filter perf event samples based on the HW provided > > data which have more detailed information about the sample. > > > > Note that it only reads the first fragment of the raw record. But it > > seems mostly ok since all the existing PMU raw data have only single > > fragment and the multi-fragment records are only for BPF output attached > > to sockets. So unless it's used with such an extreme case, it'd work > > for most of tracing use cases. > > > > Signed-off-by: Namhyung Kim > > --- > > I don't know how to test this. As the raw data is available on some > > hardware PMU only (e.g. AMD IBS). I tried a tracepoint event but it was > > rejected by the verifier. Actually it needs a bpf_perf_event_data > > context so that's not an option IIUC. > > Can we add a software event that generates raw data for testing? Ok, now I think that I can use a bpf-output sw event. It would need another BPF program to write data to the event and the test program can read it from BPF using this helper. :) Thanks, Namhyung