Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3971625pxb; Tue, 25 Jan 2022 00:19:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlqDt2e+kwu/51Ysk11jhlgpkIPKFFwc6zhrivsCyfgh1zYizkja15N5NDDR3ekuaINez2 X-Received: by 2002:a17:90b:1c12:: with SMTP id oc18mr2352100pjb.172.1643098739914; Tue, 25 Jan 2022 00:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098739; cv=none; d=google.com; s=arc-20160816; b=XQ7iCqH/xL3zBscv/4wGnDq+0L55nzLNG/5fyKwUoR5v4jkCnTHo5JG0/uN7n10aH9 +YiEOfa4vsACRjF+bGR0+ZqdSP252p+ivka6y9yltRwl4eDvm7kv9LnFHVr6G6wFvZzK jQtvvWIP71h5nluaU1zfs/JG2IptlUgKnDknoRgQY5wG1cEWsxdrCswbW7i82Su1gdGl DR3739M/3+vF8oRdc+2JCd0VISMP9WStHozdkSwa1pyJJtgiH+BMhEEqhmOm2h1io+0z +H3qfiMEegBXmIJ8A1dZr+sVEv5XSdUV2ythwDliGTw58vEq1kFTgsMXfD4rKkKrwKjO edXg== 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=yOtsoimLstxpDsMPzwHzv2+dXa9eeyjg3Dg79TGHniQ=; b=gN23aXw67hqj5TFWky22Khmx4hlsyyGl/1wSQSILekk/bex7NFjmHjFpwXsjw1FEcU ctu7T25oXeFpzpmHnTLM0/1/3da2KbAcHEJj8gcBtwm0jYq4HqzyDzLcHq81vF2PC6xA bVCO5wBqKcDG3jF5/+qHz70qDvTDZuqOxxZ3Ql4mEIzLBzDm1cYpZOqhQhdSRNptLVk+ zZB4OiLwYAJs2xvPicFgaC+1a2Az9D2BpmbzrDV4tCjpWLAym/n0zSrimzIlqN9fi6/J MCAXpcJI4IRyt5ecJWF1hJeZSUc8aO1OQM7M4RBkZ4j4B0fW1TPV68ybZxfjuAFI1TnW tYVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nymYwyfv; 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 u3si14865363pgk.198.2022.01.25.00.18.47; Tue, 25 Jan 2022 00:18:59 -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=nymYwyfv; 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 S3412909AbiAYAh7 (ORCPT + 99 others); Mon, 24 Jan 2022 19:37:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2364073AbiAXXqo (ORCPT ); Mon, 24 Jan 2022 18:46:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C400C0613B2; Mon, 24 Jan 2022 13:42:01 -0800 (PST) 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 0C15F6150E; Mon, 24 Jan 2022 21:42:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0449C340E4; Mon, 24 Jan 2022 21:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060520; bh=bZB8LXzuRpRqd1OdmxiHwhFIwlaujiAsLxkUGVGfxqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nymYwyfvy6p62pEdV4oxB9yEl7aA72qMZTqyki7Vu8K9OL9yk8q8tieh5cGHg+hLD apqBqd6b25oesLzGaR9TW4ExBYCPIjDM/5xPaRWN1ZHyFAxMr09Xqm5Ym8AYzwvil3 +HdgwuNVxgtlVT6o4+0h3h9S3oxbsvBVRgJ5dFho= 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.16 0943/1039] perf evsel: Override attr->sample_period for non-libpfm4 events Date: Mon, 24 Jan 2022 19:45:32 +0100 Message-Id: <20220124184156.987692281@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 @@ -1064,6 +1064,17 @@ void __weak arch_evsel__fixup_new_cycles { } +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: * @@ -1130,14 +1141,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.