Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp204802rwb; Wed, 28 Sep 2022 01:17:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6J2/HUEHjaAb0LKRj96OgTPajgOqy2BGKKySKJg7ThoCPqpvdVUKJTVTfynwoB6fphcOJI X-Received: by 2002:a17:902:7b87:b0:179:ec0a:7239 with SMTP id w7-20020a1709027b8700b00179ec0a7239mr7455224pll.139.1664353043838; Wed, 28 Sep 2022 01:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664353043; cv=none; d=google.com; s=arc-20160816; b=uYfFOxX65J+L7l5bQC4mBQg9G9hkMIZzaOU2jwW+cZJgUzHhM9/G/JcsDT8NlHI8HC jGE8OhlZQEmdHIbuFbDGctr6iyDgbCQaFIJcGSmc6manVrepGjaik+bwdnujUvbXGBFu tpNxAZWVcvhoJqZfbL8wIYbeGRj6Pq9BHjPG1QVx6rpIs33Fd0/2DBTc5uMtsSfMsQNU 3//NLU+wNOUNkWJb09YT0t0U1qQ/72W3UATZLPIs28NWvyb7wUsBHlbjHdUoKjZaqAcO D9NwgJVA2fwq8+zWZVCzq+Eajf1EnJz+45XmiSel9tsJq76oPcjT9xa5azNllfe+KfqI pPMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=o0Y1yQ9BhuRCSCMO1panr5YNLkexoW/peOxW4bcpB1A=; b=fA22cONixRDtASqwutaE14zrIrM53u12VQYf2iWpCsXGu/R5uL3wnL+mf9lthWmCQM S6W1MxDkizmGE2pCR7RWEZImdhZK2YvdASHLECVEi3o7LLFtHD+O5/4lIAutuqgT2sQD 8KKrWjKYsUgGE5U545+P7gXu8FjVh0tjWjbMerWIJFKVt24w6/z2EEyAkkR2xuUIo1PU 2fr6UKA/f5tqNP+HeJQAlzxXCj0GZhSrSArEr0qdy8rX1z46xaVvIDSxCcO1C3PqY1mh HJPYgdAliAFvuo0mTVWvH0M4i2Dkkjo6DUFjn1nEsNrKQLx1Gs0vMsf748ZbpjuC3ChE VGYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ggPvGTw7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg2-20020a17090b1e0200b002038e75bdccsi1595165pjb.173.2022.09.28.01.17.12; Wed, 28 Sep 2022 01:17:23 -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=@linutronix.de header.s=2020 header.b=ggPvGTw7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232333AbiI1G6D (ORCPT + 99 others); Wed, 28 Sep 2022 02:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233448AbiI1G53 (ORCPT ); Wed, 28 Sep 2022 02:57:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCFF19E68C; Tue, 27 Sep 2022 23:57:25 -0700 (PDT) Date: Wed, 28 Sep 2022 06:57:22 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1664348243; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o0Y1yQ9BhuRCSCMO1panr5YNLkexoW/peOxW4bcpB1A=; b=ggPvGTw7JX26D5si9ADHi1U0uV1V9m6hf2Kf0plmGLNZ1N8uJmbFgkQ1q8zhjcv9bdW9gO R3xXralDmrlSS2ShtMogRflcfg/m+c4SlnR/bRqv12DzCRMm1Yokjv615A9Hwdx+PXTXyd gj4rafmNa4XJZXcTVSJJVJy8qCFSh/9kDUYoyjzC3CnDkhsWHESPld8j0tYOVtRoAKuU26 KarqpsKvY1BYUzW89fmQlnZ9unmQO8DaxxpGk0PHeawij1GCH0wkrojcQ16WP/ChdUySsb ErQsPWmzhOEoVJxsB2o4p3zyoQ4E6qa1VSScyJLdcg0tFhjvC69xdUa/mCORrg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1664348243; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o0Y1yQ9BhuRCSCMO1panr5YNLkexoW/peOxW4bcpB1A=; b=ZkfBD8mG/9AmPKnsUYwdpVbWN42hOEWgHguntZ3p9muGCZFAh0WvqPATq4VD8tINceiRV6 KLMimonlbLhnwPDQ== From: "tip-bot2 for Namhyung Kim" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf: Use sample_flags for addr Cc: Namhyung Kim , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220921220032.2858517-1-namhyung@kernel.org> References: <20220921220032.2858517-1-namhyung@kernel.org> MIME-Version: 1.0 Message-ID: <166434824254.401.581163246945360838.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 following commit has been merged into the perf/core branch of tip: Commit-ID: 7b084630153152239d84990ac4540c2dd360186f Gitweb: https://git.kernel.org/tip/7b084630153152239d84990ac4540c2dd360186f Author: Namhyung Kim AuthorDate: Wed, 21 Sep 2022 15:00:31 -07:00 Committer: Peter Zijlstra CommitterDate: Tue, 27 Sep 2022 22:50:24 +02:00 perf: Use sample_flags for addr Use the new sample_flags to indicate whether the addr field is filled by the PMU driver. As most PMU drivers pass 0, it can set the flag only if it has a non-zero value. And use 0 in perf_sample_output() if it's not filled already. Signed-off-by: Namhyung Kim Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220921220032.2858517-1-namhyung@kernel.org --- arch/x86/events/intel/ds.c | 8 ++++++-- include/linux/perf_event.h | 8 ++++++-- kernel/events/core.c | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 4ba6ab6..d2e9ff1 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1621,8 +1621,10 @@ static void setup_pebs_fixed_sample_data(struct perf_event *event, if ((sample_type & PERF_SAMPLE_ADDR_TYPE) && - x86_pmu.intel_cap.pebs_format >= 1) + x86_pmu.intel_cap.pebs_format >= 1) { data->addr = pebs->dla; + data->sample_flags |= PERF_SAMPLE_ADDR; + } if (x86_pmu.intel_cap.pebs_format >= 2) { /* Only set the TSX weight when no memory weight. */ @@ -1783,8 +1785,10 @@ static void setup_pebs_adaptive_sample_data(struct perf_event *event, data->sample_flags |= PERF_SAMPLE_DATA_SRC; } - if (sample_type & PERF_SAMPLE_ADDR_TYPE) + if (sample_type & PERF_SAMPLE_ADDR_TYPE) { data->addr = meminfo->address; + data->sample_flags |= PERF_SAMPLE_ADDR; + } if (sample_type & PERF_SAMPLE_TRANSACTION) { data->txn = intel_get_tsx_transaction(meminfo->tsx_tuning, diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 368bdc4..f4a1357 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1028,7 +1028,6 @@ struct perf_sample_data { * minimize the cachelines touched. */ u64 sample_flags; - u64 addr; struct perf_raw_record *raw; u64 period; @@ -1040,6 +1039,7 @@ struct perf_sample_data { union perf_sample_weight weight; union perf_mem_data_src data_src; u64 txn; + u64 addr; u64 type; u64 ip; @@ -1079,9 +1079,13 @@ static inline void perf_sample_data_init(struct perf_sample_data *data, { /* remaining struct members initialized in perf_prepare_sample() */ data->sample_flags = 0; - data->addr = addr; data->raw = NULL; data->period = period; + + if (addr) { + data->addr = addr; + data->sample_flags |= PERF_SAMPLE_ADDR; + } } /* diff --git a/kernel/events/core.c b/kernel/events/core.c index c07e9a3..a91f74d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7414,6 +7414,11 @@ void perf_prepare_sample(struct perf_event_header *header, if (filtered_sample_type & PERF_SAMPLE_TRANSACTION) data->txn = 0; + if (sample_type & (PERF_SAMPLE_ADDR | PERF_SAMPLE_PHYS_ADDR | PERF_SAMPLE_DATA_PAGE_SIZE)) { + if (filtered_sample_type & PERF_SAMPLE_ADDR) + data->addr = 0; + } + if (sample_type & PERF_SAMPLE_REGS_INTR) { /* regs dump ABI info */ int size = sizeof(u64);