From: Yicong Yang <yangyicong@huawei.com>
To: <mathieu.poirier@linaro.org>, <suzuki.poulose@arm.com>,
<jonathan.cameron@huawei.com>, <corbet@lwn.net>,
<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>
Cc: <alexander.shishkin@linux.intel.com>, <helgaas@kernel.org>,
<linux-pci@vger.kernel.org>, <prime.zeng@huawei.com>,
<linuxarm@huawei.com>
Subject: [PATCH 1/4] hwtracing: hisi_ptt: Make cpumask only present online CPUs
Date: Wed, 15 Mar 2023 17:43:13 +0800 [thread overview]
Message-ID: <20230315094316.26772-2-yangyicong@huawei.com> (raw)
In-Reply-To: <20230315094316.26772-1-yangyicong@huawei.com>
From: Yicong Yang <yangyicong@hisilicon.com>
perf will try to start PTT trace on every CPU presented in cpumask sysfs
attribute and it will fail to start on offline CPUs(see the comments in
perf_event_open()). But the driver is using cpumask_of_node() to export
the available cpumask which may include offline CPUs and may fail the
perf unintendedly. Fix this by only export the online CPUs of the node.
Fixes: ff0de066b463 ("hwtracing: hisi_ptt: Add trace function support for HiSilicon PCIe Tune and Trace device")
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
drivers/hwtracing/ptt/hisi_ptt.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/ptt/hisi_ptt.c b/drivers/hwtracing/ptt/hisi_ptt.c
index 30f1525639b5..0a10c7ec46ad 100644
--- a/drivers/hwtracing/ptt/hisi_ptt.c
+++ b/drivers/hwtracing/ptt/hisi_ptt.c
@@ -487,9 +487,18 @@ static ssize_t cpumask_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct hisi_ptt *hisi_ptt = to_hisi_ptt(dev_get_drvdata(dev));
- const cpumask_t *cpumask = cpumask_of_node(dev_to_node(&hisi_ptt->pdev->dev));
+ cpumask_var_t mask;
+ ssize_t n;
- return cpumap_print_to_pagebuf(true, buf, cpumask);
+ if (!alloc_cpumask_var(&mask, GFP_KERNEL))
+ return 0;
+
+ cpumask_and(mask, cpumask_of_node(dev_to_node(&hisi_ptt->pdev->dev)),
+ cpu_online_mask);
+ n = cpumap_print_to_pagebuf(true, buf, mask);
+ free_cpumask_var(mask);
+
+ return n;
}
static DEVICE_ATTR_RO(cpumask);
--
2.24.0
next prev parent reply other threads:[~2023-03-15 9:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 9:43 [PATCH 0/4] Improve PTT filter interface and some fixes Yicong Yang
2023-03-15 9:43 ` Yicong Yang [this message]
2023-03-28 16:24 ` [PATCH 1/4] hwtracing: hisi_ptt: Make cpumask only present online CPUs Jonathan Cameron
2023-03-30 3:53 ` Yicong Yang
2023-03-30 8:34 ` Jonathan Cameron
2023-03-15 9:43 ` [PATCH 2/4] hwtracing: hisi_ptt: Add support for dynamically updating the filter list Yicong Yang
2023-03-28 16:51 ` Jonathan Cameron
2023-03-29 12:52 ` Yicong Yang
2023-03-15 9:43 ` [PATCH 3/4] hwtracing: hisi_ptt: Export available filters through sysfs Yicong Yang
2023-03-28 17:02 ` Jonathan Cameron
2023-03-29 12:54 ` Yicong Yang
2023-03-15 9:43 ` [PATCH 4/4] hwtracing: hisi_ptt: Advertise PERF_PMU_CAP_NO_EXCLUDE for PTT PMU Yicong Yang
2023-03-28 16:53 ` Jonathan Cameron
2023-03-27 10:49 ` [PATCH 0/4] Improve PTT filter interface and some fixes Yicong Yang
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=20230315094316.26772-2-yangyicong@huawei.com \
--to=yangyicong@huawei.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=corbet@lwn.net \
--cc=helgaas@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mathieu.poirier@linaro.org \
--cc=prime.zeng@huawei.com \
--cc=suzuki.poulose@arm.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
all inboxes | Powered by JetHome®