From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Sasha Levin <sashal@kernel.org>, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 08/21] powerpc/perf: Record counter overflow always if SAMPLE_IP is unset Date: Tue, 2 Mar 2021 06:58:22 -0500 [thread overview] Message-ID: <20210302115835.63269-8-sashal@kernel.org> (raw) In-Reply-To: <20210302115835.63269-1-sashal@kernel.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 70de13822828..091bdeaf02a3 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -2046,7 +2046,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) @@ -2064,9 +2074,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
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin <sashal@kernel.org>, Athira Rajeev <atrajeev@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 08/21] powerpc/perf: Record counter overflow always if SAMPLE_IP is unset Date: Tue, 2 Mar 2021 06:58:22 -0500 [thread overview] Message-ID: <20210302115835.63269-8-sashal@kernel.org> (raw) In-Reply-To: <20210302115835.63269-1-sashal@kernel.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 70de13822828..091bdeaf02a3 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -2046,7 +2046,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) @@ -2064,9 +2074,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
next prev parent reply other threads:[~2021-03-02 14:00 UTC|newest] Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-02 11:58 [PATCH AUTOSEL 4.19 01/21] i2c: rcar: optimize cacheline to minimize HW race condition Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 02/21] udf: fix silent AED tagLocation corruption Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 03/21] mmc: mxs-mmc: Fix a resource leak in an error handling path in 'mxs_mmc_probe()' Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 04/21] mmc: sdhci-of-dwcmshc: set SDHCI_QUIRK2_PRESET_VALUE_BROKEN Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 05/21] mmc: mediatek: fix race condition between msdc_request_timeout and irq Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 06/21] powerpc/pci: Add ppc_md.discover_phbs() Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 07/21] powerpc: improve handling of unrecoverable system reset Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` Sasha Levin [this message] 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 08/21] powerpc/perf: Record counter overflow always if SAMPLE_IP is unset Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 09/21] sparc32: Limit memblock allocation to low memory Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 10/21] sparc64: Use arch_validate_flags() to validate ADI flag Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 11/21] x86, build: use objtool mcount Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 12/21] PCI: xgene-msi: Fix race in installing chained irq handler Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 13/21] misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 14/21] PCI: mediatek: Add missing of_node_put() to fix reference leak Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 15/21] drm/msm/a5xx: Remove overwriting A5XX_PC_DBG_ECO_CNTL register Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 16/21] PCI: Fix pci_register_io_range() memory leak Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 17/21] i40e: Fix memory leak in i40e_probe Sasha Levin 2021-03-02 11:58 ` [Intel-wired-lan] " Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 18/21] s390/smp: __smp_rescan_cpus() - move cpumask away from stack Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 19/21] scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 20/21] scsi: target: core: Add cmd length set before cmd complete Sasha Levin 2021-03-02 11:58 ` Sasha Levin 2021-03-02 11:58 ` [PATCH AUTOSEL 4.19 21/21] scsi: target: core: Prevent underflow for service actions Sasha Levin
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=20210302115835.63269-8-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=atrajeev@linux.vnet.ibm.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.