From: Bjorn Helgaas <helgaas@kernel.org>
To: Shuai Xue <xueshuai@linux.alibaba.com>
Cc: rostedt@goodmis.org, lukas@wunner.de, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org,
linux-trace-kernel@vger.kernel.org,
ilpo.jarvinen@linux.intel.com, mattc@purestorage.com,
Jonathan.Cameron@huawei.com, bhelgaas@google.com,
tony.luck@intel.com, bp@alien8.de, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, oleg@redhat.com,
naveen@kernel.org, davem@davemloft.net,
anil.s.keshavamurthy@intel.com, mark.rutland@arm.com,
peterz@infradead.org, tianruidong@linux.alibaba.com
Subject: Re: [PATCH v9 2/2] PCI: trace: Add a RAS tracepoint to monitor link speed changes
Date: Fri, 25 Jul 2025 16:09:21 -0500 [thread overview]
Message-ID: <20250725210921.GA3131414@bhelgaas> (raw)
In-Reply-To: <20250723033108.61587-3-xueshuai@linux.alibaba.com>
On Wed, Jul 23, 2025 at 11:31:08AM +0800, Shuai Xue wrote:
> PCIe link speed degradation directly impacts system performance and
> often indicates hardware issues such as faulty devices, physical layer
> problems, or configuration errors.
>
> To this end, add a RAS tracepoint to monitor link speed changes,
> enabling proactive health checks and diagnostic analysis.
>
> The output is like below:
>
> $ echo 1 > /sys/kernel/debug/tracing/events/pci/pci_link_event/enable
> $ cat /sys/kernel/debug/tracing/trace_pipe
> cat /sys/kernel/debug/tracing/trace_pipe
> <...>-119 [002] ..... 125.776171: pci_hp_event: 0000:00:03.0 slot:30, event:CARD_PRESENT
>
> <...>-119 [002] ..... 125.776197: pci_hp_event: 0000:00:03.0 slot:30, event:LINK_UP
>
> irq/57-pciehp-119 [002] ..... 125.904335: pcie_link_event: 0000:00:03.0 type:4, reason:4, cur_bus_speed:2.5 GT/s PCIe, max_bus_speed:16.0 GT/s PCIe, width:1, flit_mode:0, status:DLLLA
>
> irq/57-pciehp-119 [002] ..... 125.907051: pcie_link_event: 0000:00:03.0 type:4, reason:0, cur_bus_speed:2.5 GT/s PCIe, max_bus_speed:16.0 GT/s PCIe, width:1, flit_mode:0, status:DLLLA
I guess this example would actually require both of these enables, right?
echo 1 > /sys/kernel/debug/tracing/events/pci/pci_hp_event/enable
echo 1 > /sys/kernel/debug/tracing/events/pci/pci_link_event/enable
> Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
I don't think I've suggested anything that really warrants this ;)
> ...
> @@ -292,7 +292,7 @@ int pciehp_check_link_status(struct controller *ctrl)
> {
> struct pci_dev *pdev = ctrl_dev(ctrl);
> bool found;
> - u16 lnk_status, linksta2;
> + u16 lnk_status;
>
> if (!pcie_wait_for_link(pdev, true)) {
> ctrl_info(ctrl, "Slot(%s): No link\n", slot_name(ctrl));
> @@ -319,8 +319,7 @@ int pciehp_check_link_status(struct controller *ctrl)
> return -1;
> }
>
> - pcie_capability_read_word(pdev, PCI_EXP_LNKSTA2, &linksta2);
> - __pcie_update_link_speed(ctrl->pcie->port->subordinate, lnk_status, linksta2);
> + pcie_update_link_speed(ctrl->pcie->port->subordinate, PCIE_HOTPLUG);
It kind of bugs me that the hot-add flow reads LNKSTA three times and
generates both pci_hp_event LINK_UP and link_event tracepoints:
pciehp_handle_presence_or_link_change
link_active = pciehp_check_link_active()
pcie_capability_read_word(PCI_EXP_LNKSTA)
if (link_active)
ctrl_info(ctrl, "Slot(%s): Link Up\n")
trace_pci_hp_event(PCI_HOTPLUG_LINK_UP)
pciehp_enable_slot
__pciehp_enable_slot
board_added
pciehp_check_link_status
pcie_capability_read_word(PCI_EXP_LNKSTA)
pcie_update_link_speed
pcie_capability_read_word(PCI_EXP_LNKSTA)
pcie_capability_read_word(PCI_EXP_LNKSTA2)
trace_pcie_link_event(<REASON>)
Maybe there are good reasons for reading LNKSTA three times, but it
does make me raise my eyebrows. Not that this is a performance path,
but it just offends my sense of propriety.
And maybe we need both a bare LINK_UP event and a link_event with all
the details, but again it seems a little weird to me that there are
two tracepoints when there's really only one event and we know all the
link_event information from the very first LNKSTA read.
Bjorn
next prev parent reply other threads:[~2025-07-25 21:09 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-23 3:31 [PATCH v9 0/2] add PCI hotplug and PCIe link tracepoint Shuai Xue
2025-07-23 3:31 ` [PATCH v9 1/2] PCI: trace: Add a generic RAS tracepoint for hotplug event Shuai Xue
2025-07-25 21:09 ` Bjorn Helgaas
2025-07-28 9:05 ` Shuai Xue
2025-07-23 3:31 ` [PATCH v9 2/2] PCI: trace: Add a RAS tracepoint to monitor link speed changes Shuai Xue
2025-07-23 14:05 ` Steven Rostedt
2025-07-25 2:11 ` Shuai Xue
2025-07-25 2:25 ` Steven Rostedt
2025-07-25 2:59 ` Shuai Xue
2025-07-25 3:06 ` Steven Rostedt
2025-07-25 3:15 ` Shuai Xue
2025-07-23 19:30 ` kernel test robot
2025-07-24 14:06 ` Steven Rostedt
2025-07-25 2:31 ` Shuai Xue
2025-07-25 2:57 ` Steven Rostedt
2025-07-25 3:18 ` Shuai Xue
2025-07-25 21:09 ` Bjorn Helgaas [this message]
2025-07-26 7:51 ` Lukas Wunner
2025-07-28 9:28 ` Shuai Xue
2025-07-28 9:17 ` Shuai Xue
2025-09-18 23:06 ` [PATCH v9 0/2] add PCI hotplug and PCIe link tracepoint Bjorn Helgaas
2025-09-19 1:40 ` Shuai Xue
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=20250725210921.GA3131414@bhelgaas \
--to=helgaas@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=davem@davemloft.net \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mattc@purestorage.com \
--cc=mhiramat@kernel.org \
--cc=naveen@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tianruidong@linux.alibaba.com \
--cc=tony.luck@intel.com \
--cc=xueshuai@linux.alibaba.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