Message ID | 20240207050545.2727923-2-namhyung@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-55971-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2009537dyb; Tue, 6 Feb 2024 21:06:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGg12lH6A8jtloLjtcACetGH1S1n3NhpdYGBLPL8DXfc2KwNzUBpcCg8AQc2Tb1TYwc+nPe X-Received: by 2002:a05:6102:b0b:b0:46d:3931:580b with SMTP id b11-20020a0561020b0b00b0046d3931580bmr2248388vst.23.1707282388153; Tue, 06 Feb 2024 21:06:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707282388; cv=pass; d=google.com; s=arc-20160816; b=tgQjxKa5gDcqt9c5eGCjsrl18rxUVGA8fWLXibXkDI+ZPdpKSkam8SN2gaLa8gJr/8 ycVF6mF+kuFdkOMYZpY/VY0GK4vKb1/WwsiMtrSSkgjx9F8qTAZIqwAZWHFMJpbgffAr /eUrXoRHgiM+V6oBqvxEXlyLeJNUw7pZfdWl7At4P2w3vaWolTAwg2qjZW9zWfUZd/vk aGKF2EwJHMQowS9vAONNt3/Wpd65M6J3ZiaN8PoTQlfCpDJHXL9mr54Kq4KNMs3VC5Dv qPrA4Ylwa6J/0WN9Ij3tH4VI5bOm5W5p5oGgyno1EmVa7gKMNOj4oj7a2JhPRUYr9LOq EFdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PXIT4bII8yv8Vl8RtQbXG0bjjq7fZWj4JtXBam3pMwY=; fh=ndAeDuO/f0PPvojqWxrwdBC7WbMexnpcCCVQjUj+vs0=; b=tIZm/pvJ2E/v0I/CeYStzvudeetL/QUEvCUQnS/FOcH5kxoG4thD1SNzAArh4z60ZT podQDy9yUeUaI2/13DT4x6HPBSREwE1+9UQLAZ3Tir6zVxu2fu13m1fZfU+OJ70hZtHd ywgPbHKB6fu/fy9qrg4e9dVBSdjXrQ42zt97LwVfF3o7CJxBgcRt7hLOilCgO3N4GjJF autHS6Z0oitjfwEjJzPJ1sx/2YIVe7A0WeLtycj2Ak5C73U6IwXujykrFaPpqw18bQFJ qfSxMVYyK6zV4qddTEPyyHJ8958CzKPD5kDyJ0WnxJdOCIMsWnlbYCTcW0ABRgIBn03D YPIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bAWCn+j+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXOyU7L+9kRvVXfpgdee0HKFkHPenDlnGlb90ljozJnE8G7DsHCODI1ulWKFT8JhJbmywVhcQz2fjvrj54PbNj2c47tng== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b7-20020a05622a020700b0042c2c06dcbcsi448619qtx.719.2024.02.06.21.06.28 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 21:06:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bAWCn+j+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55971-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55971-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EC4FF1C24DBE for <ouuuleilei@gmail.com>; Wed, 7 Feb 2024 05:06:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F0031CFA0; Wed, 7 Feb 2024 05:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bAWCn+j+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A1151BF2A for <linux-kernel@vger.kernel.org>; Wed, 7 Feb 2024 05:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707282348; cv=none; b=j0/C8pUpUEx5eEBjWzEaaf6xe6FuALyvyynz6tF46dY8FW7vab92WqdM4Eg4T+5uiOtqCkUp6TkzAuIVJumDxNz6dc6ArE5V1RRj1KF8A1lMOxw121w/6QsgHqdvmv2IMuDKWcsCHxLQBKscF6oo4wnw5GNmVEJNyjqN7AP487c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707282348; c=relaxed/simple; bh=kszq7JTJ0izFmA3dEnHIYYpS4Gc5cJ814paQQQK3LdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fa+2p+MwJwGtc2/zVWz01xC5yckUJ4ZBtstuav7RWh+yfs0lDKtREgnEHAbazlqtfLQxPAQ9y4oZN6ScWIMRJ2zq6r4jUATS8+GARa1Y9vRipNa6EcwRSaqhy9lm3xp0uyz5gBdTUmYgfGFKtNwZTj6rdd0SXz2fFxa0NmrBwFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bAWCn+j+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F1C0C433B2; Wed, 7 Feb 2024 05:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707282348; bh=kszq7JTJ0izFmA3dEnHIYYpS4Gc5cJ814paQQQK3LdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bAWCn+j+L1BWHH13FMmywdVETL8buIVosxRSzgI11eOwAlxLd44oeJN9G5ySGB0Ac E76K3MNjOIJt8zTzUmgfWDqvwLSG2FPY6UestKKjQZdHS8CWs1drqVdTcb+5jXQddd bryoNNDgf2/GafEo7IfQ5mJv1jFGgj/RMnyanwRG8PSLdUaARFxozQTiug54DCEcDj ejP3QeL1JBjW60YIeh9UaI6NRLGZObI5GjVQ/WqfBHNMX4U6gSNXNOIY1Cd/vLS8Wk 7LBO40dkNwb36eltl7FBnMgu4/cbAKOOi4EkUg1uRdNQz9MKd9tomLzU5gowQ/Kzyb uiRukxKTM84Vg== From: Namhyung Kim <namhyung@kernel.org> To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, Kan Liang <kan.liang@linux.intel.com>, LKML <linux-kernel@vger.kernel.org>, Mingwei Zhang <mizhang@google.com> Subject: [PATCH v3 2/2] perf/core: Reduce PMU access to adjust sample freq Date: Tue, 6 Feb 2024 21:05:45 -0800 Message-ID: <20240207050545.2727923-2-namhyung@kernel.org> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog In-Reply-To: <20240207050545.2727923-1-namhyung@kernel.org> References: <20240207050545.2727923-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790215337763476737 X-GMAIL-MSGID: 1790215337763476737 |
Series |
[v3,1/2] perf/core: Update perf_adjust_freq_unthr_context()
|
|
Commit Message
Namhyung Kim
Feb. 7, 2024, 5:05 a.m. UTC
In perf_adjust_freq_unthr_context(), it first starts the event and then stop unnecessarily to adjust the sampling frequency if the event is throttled. For a throttled non-frequency event, it doesn't have a freq so no need to adjust. Just starting the event would be ok. For a frequency event, whether it's throttled or not, it needs to stop before adjusting the frequency. That means it should not start the even if it was throttled. I tried to skip calling the stop callback, but it didn't work well since the event count might not be up to date. It should call the stop callback with PERF_EF_UPDATE anyway. However not calling start would prevent unnecessary MSR accesses (which can be costly) for already stopped events as stop state is saved in the hw config. Reviewed-by: Ian Rogers <irogers@google.com> Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- Ian and Kan, I decided to leave your Reviewed-by here since it's the basically same. Please tell me if you don't agree. kernel/events/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c index e9ce79c8c145..940c3a5b57b7 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -4121,7 +4121,8 @@ static void perf_adjust_freq_unthr_events(struct list_head *event_list) if (hwc->interrupts == MAX_INTERRUPTS) { hwc->interrupts = 0; perf_log_throttle(event, 1); - event->pmu->start(event, 0); + if (!event->attr.freq || !event->attr.sample_freq) + event->pmu->start(event, 0); } if (!event->attr.freq || !event->attr.sample_freq)