From: sashiko-bot@kernel.org
To: "Anthony Krowiak" <akrowiak@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org,
"Christian Borntraeger" <borntraeger@linux.ibm.vom>,
kvm@vger.kernel.org
Subject: Re: [PATCH v2 02/16] s390/vfio-ap: Provide access to queue objects and related info
Date: Thu, 13 Aug 2026 23:40:45 +0000 [thread overview]
Message-ID: <20260813234046.F12B61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260407205100.331150-3-akrowiak@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Inefficient O(N*M) loop to calculate the number of queues instead of a constant-time weight calculation.
--
--- Patch [2]: [PATCH v2 02/16] s390/vfio-ap: Provide access to queue objects and related info ---
commit ead4ee761bf33471a8b6bc2e8080a705110bd528
Author: Anthony Krowiak <akrowiak@linux.ibm.com>
s390/vfio-ap: Provide access to queue objects and related info
This commit provides functions to access vfio_ap_queue objects and to return
the number of queues passed through to a guest. It makes an existing queue
retrieval function non-static, adds a lockdep assertion, and introduces a
new function to count the total queues.
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index ef3101f6865e5..cd85866b81a05 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
[ ... ]
> @@ -2098,6 +2098,20 @@ static void vfio_ap_mdev_request(struct vfio_device *vdev, unsigned int count)
> release_update_locks_for_mdev(matrix_mdev);
> }
>
> +int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix)
> +{
> + unsigned long apid, apqi;
> + int num_queues = 0;
> +
> + lockdep_assert_held(&matrix_dev->mdevs_lock);
> +
> + for_each_set_bit_inv(apid, ap_matrix->apm, AP_DEVICES)
> + for_each_set_bit_inv(apqi, ap_matrix->aqm, AP_DOMAINS)
> + num_queues++;
[Severity: Medium]
Since the total number of AP queues is determined by the Cartesian product of
the set bits in these two matrices, could this be calculated more efficiently
without a nested loop?
For example, utilizing bitmap_weight() would avoid the iterations entirely:
bitmap_weight(ap_matrix->apm, AP_DEVICES) * bitmap_weight(ap_matrix->aqm, AP_DOMAINS)
The current nested loop executes an iteration for every set bit combination
while holding the mdevs_lock, whereas the bitmap_weight approach would achieve
the same result in a few word-level popcount operations.
> +
> + return num_queues;
> +}
> +
> static int vfio_ap_mdev_get_device_info(unsigned long arg)
> {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260407205100.331150-1-akrowiak@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-08-13 23:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 20:50 [PATCH v2 00/16] s390/vfio-ap: Add live guest migration support Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 01/16] s390/vfio-ap: Store queue hardware info when probed Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 02/16] s390/vfio-ap: Provide access to queue objects and related info Anthony Krowiak
2026-08-13 23:40 ` sashiko-bot [this message]
2026-04-07 20:50 ` [PATCH v2 03/16] s390/vfio-ap: Data structures for facilitating vfio device migration Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 04/16] s390/vfio-ap: Initialize/release vfio device migration data Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 05/16] s390-vfio-ap: Callback to set vfio device mig state during guest migration Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 06/16] s390/vfio-ap: Transition guest migration state from STOP to STOP_COPY Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 07/16] s390/vfio-ap: File ops called to save the vfio device migration state Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 08/16] s390/vfio-ap: Transition device migration state from STOP to RESUMING Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 09/16] s390/vfio-ap: File ops called to resume the vfio device migration Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 10/16] s390/vfio-ap: Transition device migration state from RESUMING to STOP Anthony Krowiak
2026-08-13 23:53 ` sashiko-bot
2026-04-07 20:50 ` [PATCH v2 11/16] s390/vfio-ap: Transition device migration state from STOP_COPY " Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 12/16] s390/vfio-ap: Transition device migration state from STOP to RUNNING and vice versa Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 13/16] s390-vfio-ap: Callback to get the current vfio device migration state Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 14/16] s390/vfio-ap: Callback to get the size of data to be migrated during guest migration Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 15/16] s390/vfio-ap: Add 'migratable' feature to sysfs 'features' attribute Anthony Krowiak
2026-04-07 20:50 ` [PATCH v2 16/16] s390/vfio-ap: Add live guest migration chapter to vfio-ap.rst Anthony Krowiak
2026-04-09 14:23 ` [PATCH v2 00/16] s390/vfio-ap: Add live guest migration support Anthony Krowiak
2026-04-14 14:09 ` Anthony Krowiak
2026-04-21 18:34 ` Anthony Krowiak
2026-04-28 13:10 ` Anthony Krowiak
2026-04-28 13:56 ` Christian Borntraeger
2026-04-28 18:31 ` Anthony Krowiak
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=20260813234046.F12B61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=borntraeger@linux.ibm.vom \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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