From patchwork Thu Jan 12 21:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 42834 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4122076wrt; Thu, 12 Jan 2023 13:51:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvuTNGJdBL6vP0JoZm5EyTv1979324tsjnsiHnKK2V1RLlrKneX2m+nPydLBCjgyiCQ8ePA X-Received: by 2002:a05:6402:c44:b0:48e:ac4e:7bfa with SMTP id cs4-20020a0564020c4400b0048eac4e7bfamr15264316edb.2.1673560281429; Thu, 12 Jan 2023 13:51:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673560281; cv=none; d=google.com; s=arc-20160816; b=fiXIG3z0fau+fadAhSmMz66S5BIAAtNVrAENbJh7c8zwp//8iuJm3ekAI+E4Er6l1t 8hEdkV81f/8FNM4cV+79ic3aTs1TBFBGCgzHazpsXBnF6l9S3qJ0zOQhmFZ7DBDXsOVv mfBAoureXUSG2YkGyR/Gtmr0Lmxt4oGq3xMdJf/K41npu65f+mIDpUGd1YjI3wTvWR+t 04KafW432mwmC4Fwb/hpUEAOrS1TmKi4vys9NpUBWT7PIaAC4kbfBEpQyjVbGr7ewl0+ WP9iFX31KvZDK3uZgVEe9T/b37Nm1OPDbnnPCq4qMZWTXPBUMns5n4rbFFpEG++KE0cq vxaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=hw1JZT4caRKOkdMu9I0bZSzXZiCQYqiKX0Yt62R8CcM=; b=GuqlZbpRw1B/JmGrCJFEWpkuJD7SBPXosjzBvf0S7Hhogbrdia2FgO4wZUslJ/sh8g 4Ll3/ljO+d9ICDsAO1iiXNigdRnmpputNvUC5P6h3k2yPnxmjUvns71pEctIsdTkACqH C/xt1rF6O/HOjyevhaY6ss+8bpHw061VsjXzZW60eF0WavYHjTX/0G1TXIyLoMr0dbrH Bl78pjvPHfLrg0ZZVJBkC3mLL+Ml0BoQjcs12FLWiSej/8ESSuL6+tPB/msX3IU2Uxwn K7OMGAMsl9A4sDSR0TbjeV4OLMBJg4elBfuTzASQkCiSn5IZT8HHRqrCVIaIJ2w7ef/y Ad1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RcFJQebs; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a056402078800b0048a316518f9si8185412edy.320.2023.01.12.13.50.54; Thu, 12 Jan 2023 13:51:21 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=RcFJQebs; 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 S234657AbjALVtI (ORCPT + 99 others); Thu, 12 Jan 2023 16:49:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240782AbjALVrh (ORCPT ); Thu, 12 Jan 2023 16:47:37 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D223434756; Thu, 12 Jan 2023 13:40:29 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id a184so14781571pfa.9; Thu, 12 Jan 2023 13:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=hw1JZT4caRKOkdMu9I0bZSzXZiCQYqiKX0Yt62R8CcM=; b=RcFJQebsL1oo93IC8w4Oxta1bemGsbrJW5pMa303hyHmzRNvU7QBOBjeX85vkrLEMI Sk8rvxoUTPBaDeQKT680TOM72ra1sjElMwvEJgEJg0Ixa1MHLja3gUAB5dX2sqdGdS+B 2Ftg662VuXT/wTPCOj17BJlqy3JKqPcihaJF9+HMrbcRO0NM+nDcEmtBjx/IFreBBKcV hEYBr7jIEVgn3SgMffwhKIVJvoRsqwkc4pY6hlH3ftDgyMONnAebid7/JZlnztEwWDRL MZtAQtFWAI5VqoXoV9cSAyctDSmahTV6wIziVVoFz8qE/VCP3fHp+HqVMDhDeyg/RYwW YUJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hw1JZT4caRKOkdMu9I0bZSzXZiCQYqiKX0Yt62R8CcM=; b=xZZErkY3MCSEchY1+UfF4tsyDHjS/ACCM/gc7dyESV00VoHFtHow9BV1NIDHJ4hY8R wuePVcJpNEtaEt2NxTW690K6XTba6a/War6jjz83vKpu9OgSd3H10L8Xa5eIV0J/rQ1Y r8UH8uBvw8RFoOmucELfMnDyvaPqiXfvu7fyNFWE1Mne85ENP/N59LWGnLYJjPuTRof/ d/KJTbIDG+wkzs19C4LC2MypVhFldICGf9jfDr09YpcsfY5o7lXCjDg672YIBWsPvYMC ADOdl8pITXyaKTbm15IU1YsrCLbimL0sAwlSu2mO6pfal0tOb1dTCwGhH+PtHpv13X1i azfg== X-Gm-Message-State: AFqh2kpq7KwigFDN92GKJ8ZYmFn20s9PNMV8JM6IVtJNGKlmIzZyjKoH G8t7U4V+paN23YwCzzpAel8= X-Received: by 2002:a62:f211:0:b0:581:68ea:50 with SMTP id m17-20020a62f211000000b0058168ea0050mr56865082pfh.26.1673559629520; Thu, 12 Jan 2023 13:40:29 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:b71e:23d4:aa6a:47c0]) by smtp.gmail.com with ESMTPSA id q20-20020aa79834000000b0058134d2df41sm11344605pfl.146.2023.01.12.13.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 13:40:29 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra Cc: Ingo Molnar , Mark Rutland , Alexander Shishkin , Arnaldo Carvalho de Melo , Jiri Olsa , LKML , Song Liu , bpf@vger.kernel.org Subject: [PATCH 8/8] perf/core: Call perf_prepare_sample() before running BPF Date: Thu, 12 Jan 2023 13:40:15 -0800 Message-Id: <20230112214015.1014857-9-namhyung@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112214015.1014857-1-namhyung@kernel.org> References: <20230112214015.1014857-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754855145650806758?= X-GMAIL-MSGID: =?utf-8?q?1754855145650806758?= As BPF can access sample data, it needs to populate the data. Also remove the logic to get the callchain specifically as it's covered by the perf_prepare_sample() now. Cc: Song Liu Cc: bpf@vger.kernel.org Signed-off-by: Namhyung Kim Acked-by: Song Liu --- kernel/events/core.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5c4f3fa3d2b7..af8365fb639a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10363,13 +10363,7 @@ static void bpf_overflow_handler(struct perf_event *event, rcu_read_lock(); prog = READ_ONCE(event->prog); if (prog) { - if (prog->call_get_stack && - (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN) && - !(data->sample_flags & PERF_SAMPLE_CALLCHAIN)) { - data->callchain = perf_callchain(event, regs); - data->sample_flags |= PERF_SAMPLE_CALLCHAIN; - } - + perf_prepare_sample(data, event, regs); ret = bpf_prog_run(prog, &ctx); } rcu_read_unlock();