Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1090291rwe; Fri, 26 Aug 2022 23:56:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7l/QIdgwoVScfalKMduQMquYP36avfMZIjNRsgN3xJEkgjDopUsJjCd7W+6q39EVFlx59c X-Received: by 2002:a17:902:8f92:b0:172:e476:f9e with SMTP id z18-20020a1709028f9200b00172e4760f9emr7100409plo.82.1661583381643; Fri, 26 Aug 2022 23:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661583381; cv=none; d=google.com; s=arc-20160816; b=xmifSUP7vsJdEw6Y9jEW53eB0OHiN8PJatUEZiVv+U4A18vCJqQfGZjAWl+qxVAkL6 WdmCTohQBhCLIYA7QSOe0aYpNJ5y4kGtht1TZdnnphTklj1kCMfkfiPey5aFE5VSJMmj cigiPkzNR3aPf4BOvnk3dq4F9ogtdwH1HrsC2AvufIEpdcJSZfwfHKdfDZa/Qvq0UI5U AswQ+YXb2O6sD3++BfSZ7J3V57I32We46r+o3kTV8glQU3oJSQVXJZQM45TO5PO7HGek f1RiIz76vPrvKSi/3TT9fNFf4tKpSu9aCTioqzN876lgd3wKj6TPhfwRPL/Q87VV9UyZ PCiA== 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=2yfUK9kjN+Dqp0bNFYpyDAHMQSTacHZ/w4+QO9mpOhA=; b=tkFBCTsO+eIGp6XE6YCHWObJPOo7Oz4vc8bRCDunymlIUM81DetyewCybxHJyTaVVK LuyhE84ecqIp+lN8NW+UtZq1HESkqvR6Ml/y6X1zl2I2QeTSy3aSBzcL9K3niMP0fj8h rKWJPsggBekvCTWNdfNcUQ0OjGJTIrbY6IctaBiS82dvcvmE+hHF2vYNxVADrIY+ihnp 1DSnVZDe5jsKOeoJCyKRZZqJ0TTJ12WtgQeEooTtp/pmMA5Fb0H6wcuZqSLvb635BRca FEZ7CQ5qrvwTF7SpFvNB4PBPUBkOwumZjFsUO1azzeHOuyZd+yEWFSm0FakyBNygGhUH ravQ== 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 r4-20020a63ce44000000b00420bdc28d4asi3533719pgi.355.2022.08.26.23.56.09; Fri, 26 Aug 2022 23:56: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; 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 S232194AbiH0GZq (ORCPT + 99 others); Sat, 27 Aug 2022 02:25:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiH0GZo (ORCPT ); Sat, 27 Aug 2022 02:25:44 -0400 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F4E4DCFF0; Fri, 26 Aug 2022 23:25:44 -0700 (PDT) Received: by mail-ot1-f48.google.com with SMTP id r1-20020a056830418100b0063938f634feso2413911otu.8; Fri, 26 Aug 2022 23:25:44 -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=2yfUK9kjN+Dqp0bNFYpyDAHMQSTacHZ/w4+QO9mpOhA=; b=WQtjB597wo7aIJ1c5WsR4KfnXTHWp+NRtBEYGn/CkdJ35zsYrjvyQeo+isSRGoIh+7 tFGfpRA5QRTp1UPc6Wr7uCBnaphHt5P5JT+nBsLrjjYXtu8Dfi4fnNDNCDDZ5bCawtdK d4xSeDFBwEQKqxE+Hmc9n8E6NNyWsitaw2lPQ1ZlJLO0Ts8wCm73BBTFE2rAivFbjZJC FoHd6lMEjknsjy4Owc2eYxJhuc/WYc18YmV5+kO1rgI0PhTOkconFc4EVEUdatB4yaeL MCUYlMrlPjhWdswYY+TgIKvLAbhGkHLCgU3okwQbaJmWQ2yg0s35Hk+RZf5w04KHxS7r 7Niw== X-Gm-Message-State: ACgBeo0gvH4WdotwnmaIwdUvvBE07uu93a3EcKSCg7bb9EQUGlH0rTpj TUoj5bCWAJXPRLbWjXMy79HsSrip/tjcerpk06A= X-Received: by 2002:a9d:6f18:0:b0:638:b4aa:a546 with SMTP id n24-20020a9d6f18000000b00638b4aaa546mr2612244otq.124.1661581543464; Fri, 26 Aug 2022 23:25:43 -0700 (PDT) MIME-Version: 1.0 References: <20220823210354.1407473-1-namhyung@kernel.org> <1CA3FC40-BC8D-4836-B3E7-0EB196DE6E66@fb.com> In-Reply-To: <1CA3FC40-BC8D-4836-B3E7-0EB196DE6E66@fb.com> From: Namhyung Kim Date: Fri, 26 Aug 2022 23:25:32 -0700 Message-ID: Subject: Re: [PATCH bpf-next] bpf: Add bpf_read_raw_record() helper To: Song Liu Cc: Song Liu , Andrii Nakryiko , 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_H3,RCVD_IN_MSPIKE_WL,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 On Fri, Aug 26, 2022 at 2:26 PM Song Liu wrote: > > > > > On Aug 26, 2022, at 2:12 PM, Namhyung Kim wrote: > > > > On Fri, Aug 26, 2022 at 1:59 PM Song Liu wrote: > >> > >> > >> > >>> On Aug 26, 2022, at 12:30 PM, Namhyung Kim wrote: > >>> > >>> On Fri, Aug 26, 2022 at 11:45 AM Song Liu wrote: > >>> > >>>>> And actually, we can just read ctx->data and get the raw record, > >>>>> right..? > >>>> > >>>> Played with this for a little bit. ctx->data appears to be not > >>>> reliable sometimes. I guess (not 100% sure) this is because we > >>>> call bpf program before event->orig_overflow_handler. We can > >>>> probably add a flag to specify we want to call orig_overflow_handler > >>>> first. > >>> > >>> I'm not sure. The sample_data should be provided by the caller > >>> of perf_event_overflow. So I guess the bpf program should see > >>> a valid ctx->data. > >> > >> Let's dig into this. Maybe we need some small changes in > >> pe_prog_convert_ctx_access. > > > > Sure, can you explain the problem in detail and share your program? > > I push the code to > > https://git.kernel.org/pub/scm/linux/kernel/git/song/linux.git/log/?h=test-perf-event > > The code is in tools/bpf/perf-test/. > > The problem is we cannot get reliable print of data->cpu_entry in > /sys/kernel/tracing/trace. Ah, right. I've realized that the sample data is passed before full initialized. Please see perf_sample_data_init(). The other members are initialized right before written to the ring buffer in the orig_overflow_handler (__perf_event_output). That explains why pe_prog_convert_ctx_access() handles data and period specially. We need to handle it first. Thanks, Namhyung