Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3618118pxb; Mon, 24 Jan 2022 13:38:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBwVq68fWZpQW+PbNCd2EhHUUaxa1N66h8tPh1FLOMUPFsBUjVQNArLyVMOrXygulEfMUH X-Received: by 2002:a17:90a:de10:: with SMTP id m16mr189849pjv.157.1643060289331; Mon, 24 Jan 2022 13:38:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060289; cv=none; d=google.com; s=arc-20160816; b=JlXIw3f7bFa7awu28YdzjOXzxeajzvysNgAeHhLLU02xXeuAMSC2JL8hIH/MCztNk4 52DXLowJtm9TrxFc2rM8nYPLTrKi18qKGvUj7MtNV6hiQbGAccg1yitTQrPyPiaF3WJs +tTcEPuB+XFmk1XJFhzfrD3tiou6WIUapNzYOI4E+7pXU9e0IIcttPX4gPb2vMnS3389 0RENG1/OKM/9UfLcavixKwbiN5usPKsLvwzxcRd1FBVmQOoLA48NR697a35qR+CnoCOc MyEn7nEn0flfB8UHaXfcAxpgc3yq6ASv2Mi+UaG1czYJz14Sjhz95WiktwvwdV3H9hfl BTag== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qpfCIpsKSBf9zbGCM1fzLTptIlLLO2cjemjet9OPA7A=; b=wRWQ+84kzdNYoYHa/G15+4UbHuFbbWHaFNSObvr3/d1tlU1H9+SLKnRztsXrqbZA1x 3rdokUI+TXVmTKlqr7lbCWLbb2R2EK1DD8zRks0qjptHBFkwjXDx5mZzi5fuyO3MGTjh mXAX4+wl8G3JZf18RhptzTjHzzyVcbuhUtW3gHlq1ELr84b99Y3Eu6DiJZ+Wwgq5/pVU lafX6Y1UvPOux7p6fpU3LirpsnsomhER6uclMydq2AWOBTxS70Faxp1huaIeu+DEJSJN 8GPrp9dGuIkR4+BSGbTpxGHvYnsGyjjvAH0Gy4EkAcaPT2u5veCMvznHldAJ7TIJKae6 IpNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mDdknbIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si15219716pgj.124.2022.01.24.13.37.57; Mon, 24 Jan 2022 13:38:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mDdknbIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1449486AbiAXVPi (ORCPT + 99 others); Mon, 24 Jan 2022 16:15:38 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:42268 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1391681AbiAXUsW (ORCPT ); Mon, 24 Jan 2022 15:48:22 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A9A5760C3E; Mon, 24 Jan 2022 20:48:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 623B1C340E5; Mon, 24 Jan 2022 20:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057301; bh=eipPTW4zUA2Y7C6/tT/Xx48Qu8AVSVvCdWRcAwJbjbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mDdknbIGQysdIcgik43P379chCn2IYSxtxjZ/H+yf2L3x8UfDGw3662PxvrwaTwIn YsLCeGmwsPDraojRWxDj2WZ2Rv5A7UaQ2OuCuf28OylHrRyGCVjdo6Fr/hI9kwS950 q3mY5ejd8JOElUJayRiepTn6t8AEXvva2dLQJNMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chase Conklin , German Gomez , Alexander Shishkin , Ian Rogers , Jiri Olsa , John Fastabend , KP Singh , Mark Rutland , Martin KaFai Lau , Namhyung Kim , Song Liu , Stephane Eranian , Yonghong Song , bpf@vger.kernel.org, netdev@vger.kernel.org, Arnaldo Carvalho de Melo Subject: [PATCH 5.15 768/846] perf evsel: Override attr->sample_period for non-libpfm4 events Date: Mon, 24 Jan 2022 19:44:45 +0100 Message-Id: <20220124184127.452102489@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: German Gomez commit 3606c0e1a1050d397ad759a62607e419fd8b0ccb upstream. A previous patch preventing "attr->sample_period" values from being overridden in pfm events changed a related behaviour in arm-spe. Before said patch: perf record -c 10000 -e arm_spe_0// -- sleep 1 Would yield an SPE event with period=10000. After the patch, the period in "-c 10000" was being ignored because the arm-spe code initializes sample_period to a non-zero value. This patch restores the previous behaviour for non-libpfm4 events. Fixes: ae5dcc8abe31 (“perf record: Prevent override of attr->sample_period for libpfm4 events”) Reported-by: Chase Conklin Signed-off-by: German Gomez Cc: Alexander Shishkin Cc: Ian Rogers Cc: Jiri Olsa Cc: John Fastabend Cc: KP Singh Cc: Mark Rutland Cc: Martin KaFai Lau Cc: Namhyung Kim Cc: Song Liu Cc: Stephane Eranian Cc: Yonghong Song Cc: bpf@vger.kernel.org Cc: netdev@vger.kernel.org Link: http://lore.kernel.org/lkml/20220118144054.2541-1-german.gomez@arm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/evsel.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1047,6 +1047,17 @@ void __weak arch_evsel__set_sample_weigh evsel__set_sample_bit(evsel, WEIGHT); } +static void evsel__set_default_freq_period(struct record_opts *opts, + struct perf_event_attr *attr) +{ + if (opts->freq) { + attr->freq = 1; + attr->sample_freq = opts->freq; + } else { + attr->sample_period = opts->default_interval; + } +} + /* * The enable_on_exec/disabled value strategy: * @@ -1113,14 +1124,12 @@ void evsel__config(struct evsel *evsel, * We default some events to have a default interval. But keep * it a weak assumption overridable by the user. */ - if (!attr->sample_period) { - if (opts->freq) { - attr->freq = 1; - attr->sample_freq = opts->freq; - } else { - attr->sample_period = opts->default_interval; - } - } + if ((evsel->is_libpfm_event && !attr->sample_period) || + (!evsel->is_libpfm_event && (!attr->sample_period || + opts->user_freq != UINT_MAX || + opts->user_interval != ULLONG_MAX))) + evsel__set_default_freq_period(opts, attr); + /* * If attr->freq was set (here or earlier), ask for period * to be sampled.