From: Omar Elghoul <oelghoul@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev, linux-s390@vger.kernel.org,
kvm@vger.kernel.org
Cc: Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Niklas Schnelle <schnelle@linux.ibm.com>,
Farhan Ali <alifm@linux.ibm.com>,
Gerd Bayer <gbayer@linux.ibm.com>
Subject: Re: [PATCH v11 3/5] s390/pci: Reuse FMB buffer across enable and disable cycles
Date: Wed, 28 Oct 2026 12:15:33 -0400 [thread overview]
Message-ID: <72ddf1a4-d672-4d9f-a205-07aec3db1248@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-188110@kernel.org>
On 10/28/26 11:59 AM, sashiko-bot@kernel.org wrote:
[...]
>
> [Severity: Medium]
> Can keeping zdev->fmb non-NULL when zpci_mod_fc() fails in zpci_fmb_enable()
> leave the FMB enablement state inconsistent?
Valid concern, but unfortunately I think this is a tradeoff we are going
to have to accept. Based on this discussion [1] under a previous version
of the series, we can accept these stale reads because as Niklas said,
the firmware-written sample includes a timestamp of the last write. So
we're already transparent about giving the user stale data, and in the
unlikely event that this happens, the user will be able to recover by
disabling and re-enabling statistics via debugfs or simply re-enabling
it directly via vfio.
Thanks
[1]
https://lore.kernel.org/all/a24337bd66864dd70ae61e28d86590052ac0fc5d.camel@linux.ibm.com/
>
> zdev->statistics_on is initialized to true in zpci_create_device(). When
> pcibios_enable_device() or zpci_reenable_device() calls zpci_fmb_enable(),
> the return value is ignored and zdev->statistics_on remains true:
>
> arch/s390/pci/pci.c:pcibios_enable_device() {
> ...
> mutex_lock(&zdev->fmb_lock);
> if (zdev->statistics_on)
> zpci_fmb_enable(zdev);
> mutex_unlock(&zdev->fmb_lock);
> ...
> }
>
> arch/s390/pci/pci.c:zpci_reenable_device() {
> ...
> guard(mutex)(&zdev->fmb_lock);
> if (zdev->statistics_on)
> zpci_fmb_enable(zdev);
> ...
> }
>
> Previously, zpci_fmb_enable() freed zdev->fmb and reset it to NULL on
> zpci_mod_fc() failure, and zpci_fmb_disable() reset zdev->fmb to NULL on
> disable. With zdev->fmb kept allocated both across disable/re-enable cycles
> and when zpci_mod_fc() fails (or if zpci_reenable_device() returns early on an
> error after a prior allocation), both zdev->statistics_on and zdev->fmb remain
> non-zero even though hardware measurement is not active.
>
> In arch/s390/pci/pci_debug.c, pci_perf_show() checks whether FMB is disabled
> using both fields:
>
> arch/s390/pci/pci_debug.c:pci_perf_show() {
> ...
> mutex_lock(&zdev->fmb_lock);
> if (!zdev->statistics_on || !zdev->fmb) {
> mutex_unlock(&zdev->fmb_lock);
> seq_puts(m, "FMB statistics disabled\n");
> return 0;
> }
> ...
> }
>
> Similarly, the later commit "vfio-pci/zdev: Add VFIO FMB device features"
> relies on the same (!zdev->statistics_on || !zdev->fmb) check in
> vfio_pci_zdev_feature_fmb_read(), and zpci_fmb_request_on() rejects subsequent
> enable attempts with -EINVAL when zdev->statistics_on is still true.
>
> Would this cause pci_perf_show() to report zeroed or stale FMB counters instead
> of "FMB statistics disabled" when enabling FMB fails?
>
next prev parent reply other threads:[~2026-10-28 16:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 15:43 [PATCH v11 0/5] vfio-pci/zdev: Improved zPCI Function Measurement Support Omar Elghoul
2026-10-28 15:43 ` [PATCH v11 1/5] s390/pci: Hold fmb_lock when enabling or disabling PCI devices Omar Elghoul
2026-10-28 15:54 ` sashiko-bot
2026-10-28 15:43 ` [PATCH v11 2/5] s390/pci: Improve function measurement state management Omar Elghoul
2026-10-28 15:57 ` sashiko-bot
2026-10-28 21:05 ` Niklas Schnelle
2026-10-28 15:43 ` [PATCH v11 3/5] s390/pci: Reuse FMB buffer across enable and disable cycles Omar Elghoul
2026-10-28 15:59 ` sashiko-bot
2026-10-28 16:15 ` Omar Elghoul [this message]
2026-10-28 21:12 ` Niklas Schnelle
2026-10-29 12:27 ` Omar Elghoul
2026-10-28 15:43 ` [PATCH v11 4/5] s390/pci: Fence FMB enable/disable via debugfs for passthrough devices Omar Elghoul
2026-10-28 15:47 ` sashiko-bot
2026-10-28 15:43 ` [PATCH v11 5/5] vfio-pci/zdev: Add VFIO FMB device features Omar Elghoul
2026-10-28 15:59 ` sashiko-bot
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=72ddf1a4-d672-4d9f-a205-07aec3db1248@linux.ibm.com \
--to=oelghoul@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gbayer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=schnelle@linux.ibm.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