public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: gregkh@linuxfoundation.org
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>,
	Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.9 21/78] powerpc/perf: Record counter overflow always if SAMPLE_IP is unset
Date: Mon, 15 Mar 2021 14:51:44 +0100	[thread overview]
Message-ID: <20210315135212.763259976@linuxfoundation.org> (raw)
In-Reply-To: <20210315135212.060847074@linuxfoundation.org>

From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

[ Upstream commit d137845c973147a22622cc76c7b0bc16f6206323 ]

While sampling for marked events, currently we record the sample only
if the SIAR valid bit of Sampled Instruction Event Register (SIER) is
set. SIAR_VALID bit is used for fetching the instruction address from
Sampled Instruction Address Register(SIAR). But there are some
usecases, where the user is interested only in the PMU stats at each
counter overflow and the exact IP of the overflow event is not
required. Dropping SIAR invalid samples will fail to record some of
the counter overflows in such cases.

Example of such usecase is dumping the PMU stats (event counts) after
some regular amount of instructions/events from the userspace (ex: via
ptrace). Here counter overflow is indicated to userspace via signal
handler, and captured by monitoring and enabling I/O signaling on the
event file descriptor. In these cases, we expect to get
sample/overflow indication after each specified sample_period.

Perf event attribute will not have PERF_SAMPLE_IP set in the
sample_type if exact IP of the overflow event is not requested. So
while profiling if SAMPLE_IP is not set, just record the counter
overflow irrespective of SIAR_VALID check.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
[mpe: Reflow comment and if formatting]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1612516492-1428-1-git-send-email-atrajeev@linux.vnet.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/powerpc/perf/core-book3s.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 1f1ac446ace9..f2d8f35c181f 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2010,7 +2010,17 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
 			left += period;
 			if (left <= 0)
 				left = period;
-			record = siar_valid(regs);
+
+			/*
+			 * If address is not requested in the sample via
+			 * PERF_SAMPLE_IP, just record that sample irrespective
+			 * of SIAR valid check.
+			 */
+			if (event->attr.sample_type & PERF_SAMPLE_IP)
+				record = siar_valid(regs);
+			else
+				record = 1;
+
 			event->hw.last_period = event->hw.sample_period;
 		}
 		if (left < 0x80000000LL)
@@ -2028,9 +2038,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
 	 * MMCR2. Check attr.exclude_kernel and address to drop the sample in
 	 * these cases.
 	 */
-	if (event->attr.exclude_kernel && record)
-		if (is_kernel_addr(mfspr(SPRN_SIAR)))
-			record = 0;
+	if (event->attr.exclude_kernel &&
+	    (event->attr.sample_type & PERF_SAMPLE_IP) &&
+	    is_kernel_addr(mfspr(SPRN_SIAR)))
+		record = 0;
 
 	/*
 	 * Finally record data if requested.
-- 
2.30.1




  parent reply	other threads:[~2021-03-15 13:55 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 13:51 [PATCH 4.9 00/78] 4.9.262-rc1 review gregkh
2021-03-15 13:51 ` [PATCH 4.9 01/78] uapi: nfnetlink_cthelper.h: fix userspace compilation error gregkh
2021-03-15 13:51 ` [PATCH 4.9 02/78] ethernet: alx: fix order of calls on resume gregkh
2021-03-15 13:51 ` [PATCH 4.9 03/78] ath9k: fix transmitting to stations in dynamic SMPS mode gregkh
2021-03-15 13:51 ` [PATCH 4.9 04/78] net: Fix gro aggregation for udp encaps with zero csum gregkh
2021-03-15 13:51 ` [PATCH 4.9 05/78] net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0 gregkh
2021-03-15 13:51 ` [PATCH 4.9 06/78] can: skb: can_skb_set_owner(): fix ref counting if socket was closed before setting skb ownership gregkh
2021-03-15 13:51 ` [PATCH 4.9 07/78] can: flexcan: assert FRZ bit in flexcan_chip_freeze() gregkh
2021-03-15 13:51 ` [PATCH 4.9 08/78] can: flexcan: enable RX FIFO after FRZ/HALT valid gregkh
2021-03-15 13:51 ` [PATCH 4.9 09/78] netfilter: x_tables: gpf inside xt_find_revision() gregkh
2021-03-15 13:51 ` [PATCH 4.9 10/78] cifs: return proper error code in statfs(2) gregkh
2021-03-15 13:51 ` [PATCH 4.9 11/78] Revert "mm, slub: consider rest of partial list if acquire_slab() fails" gregkh
2021-03-15 13:51 ` [PATCH 4.9 12/78] net/mlx4_en: update moderation when config reset gregkh
2021-03-15 13:51 ` [PATCH 4.9 13/78] net: sched: avoid duplicates in classes dump gregkh
2021-03-15 13:51 ` [PATCH 4.9 14/78] net: lapbether: Remove netif_start_queue / netif_stop_queue gregkh
2021-03-15 13:51 ` [PATCH 4.9 15/78] net: davicom: Fix regulator not turned off on failed probe gregkh
2021-03-15 13:51 ` [PATCH 4.9 16/78] net: davicom: Fix regulator not turned off on driver removal gregkh
2021-03-15 13:51 ` [PATCH 4.9 17/78] media: usbtv: Fix deadlock on suspend gregkh
2021-03-15 13:51 ` [PATCH 4.9 18/78] udf: fix silent AED tagLocation corruption gregkh
2021-03-15 13:51 ` [PATCH 4.9 19/78] mmc: mxs-mmc: Fix a resource leak in an error handling path in mxs_mmc_probe() gregkh
2021-03-15 13:51 ` [PATCH 4.9 20/78] mmc: mediatek: fix race condition between msdc_request_timeout and irq gregkh
2021-03-15 13:51 ` gregkh [this message]
2021-03-15 13:51 ` [PATCH 4.9 22/78] PCI: xgene-msi: Fix race in installing chained irq handler gregkh
2021-03-15 13:51 ` [PATCH 4.9 23/78] s390/smp: __smp_rescan_cpus() - move cpumask away from stack gregkh
2021-03-15 13:51 ` [PATCH 4.9 24/78] scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling gregkh
2021-03-15 13:51 ` [PATCH 4.9 25/78] ALSA: hda/hdmi: Cancel pending works before suspend gregkh
2021-03-15 13:51 ` [PATCH 4.9 26/78] ALSA: hda: Avoid spurious unsol event handling during S3/S4 gregkh
2021-03-15 13:51 ` [PATCH 4.9 27/78] ALSA: usb-audio: Fix "cannot get freq eq" errors on Dell AE515 sound bar gregkh
2021-03-15 13:51 ` [PATCH 4.9 28/78] s390/dasd: fix hanging DASD driver unbind gregkh
2021-03-15 13:51 ` [PATCH 4.9 29/78] mmc: core: Fix partition switch time for eMMC gregkh
2021-03-15 13:51 ` [PATCH 4.9 30/78] scripts/recordmcount.{c,pl}: support -ffunction-sections .text.* section names gregkh
2021-03-15 13:51 ` [PATCH 4.9 31/78] Goodix Fingerprint device is not a modem gregkh
2021-03-15 13:51 ` [PATCH 4.9 32/78] usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot gregkh
2021-03-15 13:51 ` [PATCH 4.9 33/78] usb: renesas_usbhs: Clear PIPECFG for re-enabling pipe with other EPNUM gregkh
2021-03-15 13:51 ` [PATCH 4.9 34/78] xhci: Improve detection of device initiated wake signal gregkh
2021-03-15 13:51 ` [PATCH 4.9 35/78] USB: serial: io_edgeport: fix memory leak in edge_startup gregkh
2021-03-15 13:51 ` [PATCH 4.9 36/78] USB: serial: ch341: add new Product ID gregkh
2021-03-15 13:52 ` [PATCH 4.9 37/78] USB: serial: cp210x: add ID for Acuity Brands nLight Air Adapter gregkh
2021-03-15 13:52 ` [PATCH 4.9 38/78] USB: serial: cp210x: add some more GE USB IDs gregkh
2021-03-15 13:52 ` [PATCH 4.9 39/78] usbip: fix stub_dev to check for stream socket gregkh
2021-03-15 13:52 ` [PATCH 4.9 40/78] usbip: fix vhci_hcd " gregkh
2021-03-15 13:52 ` [PATCH 4.9 41/78] usbip: fix vudc " gregkh
2021-03-15 13:52 ` [PATCH 4.9 42/78] usbip: fix stub_dev usbip_sockfd_store() races leading to gpf gregkh
2021-03-15 13:52 ` [PATCH 4.9 43/78] usbip: fix vhci_hcd attach_store() " gregkh
2021-03-15 13:52 ` [PATCH 4.9 44/78] staging: rtl8192u: fix ->ssid overflow in r8192_wx_set_scan() gregkh
2021-03-15 13:52 ` [PATCH 4.9 45/78] staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() gregkh
2021-03-15 13:52 ` [PATCH 4.9 46/78] staging: rtl8712: unterminated string leads to read overflow gregkh
2021-03-15 13:52 ` [PATCH 4.9 47/78] staging: rtl8188eu: fix potential memory corruption in rtw_check_beacon_data() gregkh
2021-03-15 13:52 ` [PATCH 4.9 48/78] staging: ks7010: prevent buffer overflow in ks_wlan_set_scan() gregkh
2021-03-15 13:52 ` [PATCH 4.9 49/78] staging: rtl8712: Fix possible buffer overflow in r8712_sitesurvey_cmd gregkh
2021-03-15 13:52 ` [PATCH 4.9 50/78] staging: rtl8192e: Fix possible buffer overflow in _rtl92e_wx_set_scan gregkh
2021-03-15 13:52 ` [PATCH 4.9 51/78] staging: comedi: addi_apci_1032: Fix endian problem for COS sample gregkh
2021-03-15 13:52 ` [PATCH 4.9 52/78] staging: comedi: addi_apci_1500: Fix endian problem for command sample gregkh
2021-03-15 13:52 ` [PATCH 4.9 53/78] staging: comedi: adv_pci1710: Fix endian problem for AI command data gregkh
2021-03-15 13:52 ` [PATCH 4.9 54/78] staging: comedi: das6402: " gregkh
2021-03-15 13:52 ` [PATCH 4.9 55/78] staging: comedi: das800: " gregkh
2021-03-15 13:52 ` [PATCH 4.9 56/78] staging: comedi: dmm32at: " gregkh
2021-03-15 13:52 ` [PATCH 4.9 57/78] staging: comedi: me4000: " gregkh
2021-03-15 13:52 ` [PATCH 4.9 58/78] staging: comedi: pcl711: " gregkh
2021-03-15 13:52 ` [PATCH 4.9 59/78] staging: comedi: pcl818: " gregkh
2021-03-15 13:52 ` [PATCH 4.9 60/78] sh_eth: fix TRSCER mask for R7S72100 gregkh
2021-03-15 13:52 ` [PATCH 4.9 61/78] NFSv4.2: fix return value of _nfs4_get_security_label() gregkh
2021-03-15 13:52 ` [PATCH 4.9 62/78] block: rsxx: fix error return code of rsxx_pci_probe() gregkh
2021-03-15 13:52 ` [PATCH 4.9 63/78] configfs: fix a use-after-free in __configfs_open_file gregkh
2021-03-15 13:52 ` [PATCH 4.9 64/78] prctl: fix PR_SET_MM_AUXV kernel stack leak gregkh
2021-03-15 13:52 ` [PATCH 4.9 65/78] alpha: add $(src)/ rather than $(obj)/ to make source file path gregkh
2021-03-15 13:52 ` [PATCH 4.9 66/78] alpha: merge build rules of division routines gregkh
2021-03-15 13:52 ` [PATCH 4.9 67/78] alpha: make short build log available for " gregkh
2021-03-15 13:52 ` [PATCH 4.9 68/78] alpha: Package string routines together gregkh
2021-03-15 13:52 ` [PATCH 4.9 69/78] alpha: switch __copy_user() and __do_clean_user() to normal calling conventions gregkh
2021-03-15 13:52 ` [PATCH 4.9 70/78] powerpc/64s: Fix instruction encoding for lis in ppc_function_entry() gregkh
2021-03-15 13:52 ` [PATCH 4.9 71/78] binfmt_misc: fix possible deadlock in bm_register_write gregkh
2021-03-15 13:52 ` [PATCH 4.9 72/78] hwmon: (lm90) Fix max6658 sporadic wrong temperature reading gregkh
2021-03-15 13:52 ` [PATCH 4.9 73/78] KVM: arm64: Fix exclusive limit for IPA size gregkh
2021-03-15 13:52 ` [PATCH 4.9 74/78] iio: imu: adis16400: release allocated memory on failure gregkh
2021-03-15 13:52 ` [PATCH 4.9 75/78] iio: imu: adis16400: fix memory leak gregkh
2021-03-15 13:52 ` [PATCH 4.9 76/78] xen/events: reset affinity of 2-level event when tearing it down gregkh
2021-03-15 13:52 ` [PATCH 4.9 77/78] xen/events: dont unmask an event channel when an eoi is pending gregkh
2021-03-15 13:52 ` [PATCH 4.9 78/78] xen/events: avoid handling the same event on two cpus at the same time gregkh
2021-03-15 20:42 ` [PATCH 4.9 00/78] 4.9.262-rc1 review Florian Fainelli
2021-03-17 15:18   ` Greg KH
2021-03-28 20:37   ` Ben Hutchings
2021-03-15 21:29 ` Guenter Roeck
2021-03-15 22:57 ` Jason Self
2021-03-16 12:02 ` Naresh Kamboju

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=20210315135212.763259976@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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