From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Stephane Eranian <eranian@google.com>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Yang Jihong <yangjihong1@huawei.com>,
Kan Liang <kan.liang@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6 03/30] perf evlist: Avoid frequency mode for the dummy event
Date: Mon, 6 Nov 2023 14:03:21 +0100 [thread overview]
Message-ID: <20231106130258.025945192@linuxfoundation.org> (raw)
In-Reply-To: <20231106130257.903265688@linuxfoundation.org>
6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <irogers@google.com>
[ Upstream commit f9cdeb58a9cf46c09b56f5f661ea8da24b6458c3 ]
Dummy events are created with an attribute where the period and freq
are zero. evsel__config will then see the uninitialized values and
initialize them in evsel__default_freq_period. As fequency mode is
used by default the dummy event would be set to use frequency
mode. However, this has no effect on the dummy event but does cause
unnecessary timers/interrupts. Avoid this overhead by setting the
period to 1 for dummy events.
evlist__add_aux_dummy calls evlist__add_dummy then sets freq=0 and
period=1. This isn't necessary after this change and so the setting is
removed.
>From Stephane:
The dummy event is not counting anything. It is used to collect mmap
records and avoid a race condition during the synthesize mmap phase of
perf record. As such, it should not cause any overhead during active
profiling. Yet, it did. Because of a bug the dummy event was
programmed as a sampling event in frequency mode. Events in that mode
incur more kernel overheads because on timer tick, the kernel has to
look at the number of samples for each event and potentially adjust
the sampling period to achieve the desired frequency. The dummy event
was therefore adding a frequency event to task and ctx contexts we may
otherwise not have any, e.g.,
perf record -a -e cpu/event=0x3c,period=10000000/.
On each timer tick the perf_adjust_freq_unthr_context() is invoked and
if ctx->nr_freq is non-zero, then the kernel will loop over ALL the
events of the context looking for frequency mode ones. In doing, so it
locks the context, and enable/disable the PMU of each hw event. If all
the events of the context are in period mode, the kernel will have to
traverse the list for nothing incurring overhead. The overhead is
multiplied by a very large factor when this happens in a guest kernel.
There is no need for the dummy event to be in frequency mode, it does
not count anything and therefore should not cause extra overhead for
no reason.
Fixes: 5bae0250237f ("perf evlist: Introduce perf_evlist__new_dummy constructor")
Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20230916035640.1074422-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
tools/perf/util/evlist.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 7ef43f72098e0..c779b9f2e6220 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -251,6 +251,9 @@ static struct evsel *evlist__dummy_event(struct evlist *evlist)
.type = PERF_TYPE_SOFTWARE,
.config = PERF_COUNT_SW_DUMMY,
.size = sizeof(attr), /* to capture ABI version */
+ /* Avoid frequency mode for dummy events to avoid associated timers. */
+ .freq = 0,
+ .sample_period = 1,
};
return evsel__new_idx(&attr, evlist->core.nr_entries);
@@ -277,8 +280,6 @@ struct evsel *evlist__add_aux_dummy(struct evlist *evlist, bool system_wide)
evsel->core.attr.exclude_kernel = 1;
evsel->core.attr.exclude_guest = 1;
evsel->core.attr.exclude_hv = 1;
- evsel->core.attr.freq = 0;
- evsel->core.attr.sample_period = 1;
evsel->core.system_wide = system_wide;
evsel->no_aux_samples = true;
evsel->name = strdup("dummy:u");
--
2.42.0
next prev parent reply other threads:[~2023-11-06 13:08 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 13:03 [PATCH 6.6 00/30] 6.6.1-rc1 review Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 01/30] drm/amd/display: Dont use fsleep for PSR exit waits Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 02/30] power: supply: core: Use blocking_notifier_call_chain to avoid RCU complaint Greg Kroah-Hartman
2023-11-06 13:03 ` Greg Kroah-Hartman [this message]
2023-11-06 13:03 ` [PATCH 6.6 04/30] tracing: Have trace_event_file have ref counters Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 05/30] eventfs: Remove "is_freed" union with rcu head Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 06/30] eventfs: Save ownership and mode Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 07/30] eventfs: Delete eventfs_inode when the last dentry is freed Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 08/30] eventfs: Use simple_recursive_removal() to clean up dentries Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 09/30] ALSA: usb-audio: add quirk flag to enable native DSD for McIntosh devices Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 10/30] PCI: Prevent xHCI driver from claiming AMD VanGogh USB3 DRD device Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 11/30] usb: storage: set 1.50 as the lower bcdDevice for older "Super Top" compatibility Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 12/30] usb: typec: tcpm: Add additional checks for contaminant Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 13/30] usb: typec: tcpm: Fix NULL pointer dereference in tcpm_pd_svdm() Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 14/30] usb: raw-gadget: properly handle interrupted requests Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 15/30] Bluetooth: hci_bcm4377: Mark bcm4378/bcm4387 as BROKEN_LE_CODED Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 16/30] tty: n_gsm: fix race condition in status line change on dead connections Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 17/30] tty: 8250: Remove UC-257 and UC-431 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 18/30] tty: 8250: Add support for additional Brainboxes UC cards Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 19/30] tty: 8250: Add support for Brainboxes UP cards Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 20/30] tty: 8250: Add support for Intashield IS-100 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 21/30] tty: 8250: Fix port count of PX-257 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 22/30] tty: 8250: Fix up PX-803/PX-857 Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 23/30] tty: 8250: Add support for additional Brainboxes PX cards Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 24/30] tty: 8250: Add support for Intashield IX cards Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 25/30] tty: 8250: Add Brainboxes Oxford Semiconductor-based quirks Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 26/30] dt-bindings: serial: rs485: Add rs485-rts-active-high Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 27/30] misc: pci_endpoint_test: Add deviceID for J721S2 PCIe EP device support Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 28/30] serial: core: Fix runtime PM handling for pending tx Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 29/30] ALSA: hda: intel-dsp-config: Fix JSL Chromebook quirk detection Greg Kroah-Hartman
2023-11-06 13:03 ` [PATCH 6.6 30/30] ASoC: SOF: sof-pci-dev: Fix community key " Greg Kroah-Hartman
2023-11-06 17:25 ` [PATCH 6.6 00/30] 6.6.1-rc1 review SeongJae Park
2023-11-06 18:21 ` Florian Fainelli
2023-11-06 19:01 ` Allen Pais
2023-11-07 2:12 ` Rudi Heitbaum
2023-11-07 5:04 ` Bagas Sanjaya
2023-11-07 8:47 ` Ron Economos
2023-11-07 11:02 ` Takeshi Ogasawara
2023-11-07 15:27 ` Shuah Khan
2023-11-07 17:15 ` Ricardo B. Marliere
2023-11-07 18:55 ` Guenter Roeck
2023-11-07 19:18 ` Naresh Kamboju
2023-11-08 9:50 ` Jon Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231106130258.025945192@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=adrian.hunter@intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=namhyung@kernel.org \
--cc=patches@lists.linux.dev \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yangjihong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox