Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Tyrel Datwyler <tyreld@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v10 1/9] scsi: ibmvfc: add basic FPIN support
Date: Mon, 21 Sep 2026 13:23:43 -0700	[thread overview]
Message-ID: <c53d3fa9-3e66-4010-87a4-e9cd61789381@linux.ibm.com> (raw)
In-Reply-To: <20260911060658.68FDC1F000FF@smtp.kernel.org>

On 9/10/26 11:06 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Medium] The KUnit test `ibmvfc_async_fpin_test` leaks references to the `Scsi_Host` and the `fc_rport` device on its successful completion path.
> - [Medium] Unordered workqueue allows FPIN events to be processed concurrently, causing data races in FC transport statistics and FPIN event reordering.
> --
> 
> commit 79377784bc96c798354f5b0f5ce5007a8d857d16
> Author: Dave Marquardt <davemarq@linux.ibm.com>
>     
> scsi: ibmvfc: add basic FPIN support
>     
> This commit implements support for a basic level of Fabric Performance Impact
> Notifications (FPIN) in the ibmvfc driver. It adds an async event handler that
> offloads FPIN processing to a dedicated workqueue and passes the converted
> messages to the FC transport layer. A KUnit test module is also introduced to
> validate the FPIN event handling and statistics updates.
> 
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> @@ -3547,6 +3547,56 @@ static void ibmvfc_process_async_work(struct work_struct *work)
> [ ... ]
>> +	if (fpin) {
>> +		fc_host_fpin_rcv(tgt->vhost->host,
>> +				 sizeof(*fpin) + be32_to_cpu(fpin->desc_len),
>> +				 (char *)fpin, 0);
>> +		kfree(fpin);
>> +	} else
>     
> [Severity: Medium]
> Can the lockless modifications to fpin_stats in the FC transport layer here
> cause data races and lost statistic counts?
>     
> Multiple FPIN events arriving rapidly from the adapter are queued to the
> fpin_workq. Because the workqueue is created below as WQ_UNBOUND with
> max_active=0, these events can be processed concurrently.

Makes sense. See response below.
>     
> Furthermore, since FPIN events are stateful (e.g., congestion detected vs
> cleared), could concurrent processing deliver events out of order to the
> midlayer and userspace, leaving the system reflecting an incorrect state?
> 
> [ ... ]
>> @@ -7135,6 +7135,15 @@ static int ibmvfc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
> [ ... ]
>> +	vhost->fpin_workq = alloc_workqueue("%s-fpin-workq-%u", WQ_UNBOUND, 0,
>> +						 IBMVFC_NAME, shost->host_no);
>     
> [Severity: Medium]
> By setting the max_active parameter to 0, which defaults to 256 concurrent
> execution threads, does this allow the unordered processing that triggers
> the data races mentioned above?

I think max_active should be set to 1 here to enforce ordered processing.

>     
> [ ... ]
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>> --- /dev/null
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c
>> @@ -0,0 +1,148 @@
> [ ... ]
>> +static void ibmvfc_async_fpin_test(struct kunit *test)
>> +{
> [ ... ]
>> +	vhost = ibmvfc_get_first_vhost();
>> +	if (!vhost)
> [ ... ]
>> +	rport = tgt->rport;
>> +	get_device(&rport->dev);
> [ ... ]
>> +	KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED],
>> +			post[IBMVFC_AE_FPIN_CONGESTION_CLEARED]);
>> +
>> +	kref_put(&tgt->kref, ibmvfc_release_tgt);
>> +}
>     
> [Severity: Medium]
> Does this code leak the references to the Scsi_Host and the fc_rport device
> on the successful completion path?
>     
> The setup code earlier in this test acquires references via
> ibmvfc_get_first_vhost (which takes the host reference) and get_device, but
> this success path fails to drop them before returning. This could potentially
> prevent the driver from unloading after running the KUnit test module.
> 

If we are going to bother to take a reference might as well drop it.

-Tyrel


  reply	other threads:[~2026-09-21 20:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  5:48 [PATCH v10 0/9] scsi: ibmvfc: make ibmvfc support FPIN messages Tyrel Datwyler
2026-09-11  5:48 ` [PATCH v10 1/9] scsi: ibmvfc: add basic FPIN support Tyrel Datwyler
2026-09-11  6:00   ` Tyrel Datwyler
2026-09-11  6:06   ` sashiko-bot
2026-09-21 20:23     ` Tyrel Datwyler [this message]
2026-09-22 16:27       ` Dave Marquardt
2026-09-11  5:48 ` [PATCH v10 2/9] scsi: ibmvfc: add NOOP command support Tyrel Datwyler
2026-09-11  6:00   ` sashiko-bot
2026-09-11  5:48 ` [PATCH v10 3/9] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Tyrel Datwyler
2026-09-11  6:01   ` sashiko-bot
2026-09-11  5:48 ` [PATCH v10 4/9] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Tyrel Datwyler
2026-09-11  5:48 ` [PATCH v10 5/9] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Tyrel Datwyler
2026-09-11  5:48 ` [PATCH v10 6/9] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Tyrel Datwyler
2026-09-21 20:41   ` Tyrel Datwyler
2026-09-11  5:48 ` [PATCH v10 7/9] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Tyrel Datwyler
2026-09-11  6:03   ` sashiko-bot
2026-09-11  5:48 ` [PATCH v10 8/9] scsi: ibmvfc: register and use asynchronous sub CRQ for events Tyrel Datwyler
2026-09-11  6:02   ` sashiko-bot
2026-09-22 23:19   ` Tyrel Datwyler
2026-09-11  5:48 ` [PATCH v10 9/9] scsi: ibmvfc: handle extended FPIN events Tyrel Datwyler

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=c53d3fa9-3e66-4010-87a4-e9cd61789381@linux.ibm.com \
    --to=tyreld@linux.ibm.com \
    --cc=linux-scsi@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