linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: martin.petersen@oracle.com, jejb@linux.ibm.com, hare@suse.de,
	tglx@linutronix.de, linux-scsi@vger.kernel.org,
	linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	Davidlohr Bueso <dbueso@suse.de>
Subject: Re: [PATCH 1/3] scsi/libfc: Remove get_cpu() semantics in fc_exch_em_alloc()
Date: Wed, 17 Nov 2021 08:25:41 +0100	[thread overview]
Message-ID: <20211117072541.fpgp23twyaawiool@linutronix.de> (raw)
In-Reply-To: <20211117025956.79616-2-dave@stgolabs.net>

On 2021-11-16 18:59:54 [-0800], Davidlohr Bueso wrote:
> The get_cpu() in fc_exch_em_alloc() was introduced in:
> 
>     f018b73af6db ([SCSI] libfc, libfcoe, fcoe: use smp_processor_id() only when preempt disabled)
> 
> for no other reason than to simply use smp_processor_id()
> without getting a warning, because everything is done with
> the pool->lock held anyway. However, get_cpu(), by disabling
> preemption, does not play well with PREEMPT_RT, particularly
> when acquiring a regular (and thus sleepable) spinlock.
> 
> Therefore remove the get_cpu() and just use the unstable value
> as we will have CPU locality guarantees next by taking the lock.
> The window of migration, as noted by Sebastian, is small and
> even if it happens the result is correct.
> 
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

> diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
> index 841000445b9a..be37bfb2814d 100644
> --- a/drivers/scsi/libfc/fc_exch.c
> +++ b/drivers/scsi/libfc/fc_exch.c
> @@ -825,10 +825,9 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
>  	}
>  	memset(ep, 0, sizeof(*ep));
>  
> -	cpu = get_cpu();
> +	cpu = raw_smp_processor_id();
>  	pool = per_cpu_ptr(mp->pool, cpu);
>  	spin_lock_bh(&pool->lock);
> -	put_cpu();

The `cpu' variable is later ORed into ep->oxid. I haven't figured out
why this is important/ required. The ep variable/ `fc_exch' is allocated
from a per-CPU memory pool and is later released to the same pool but
the pool's CPU number is not obtained from fc_exch::oxid but there is a
pointer to its pool stored in fc_exch::em. 
So it remains a mystery to why the CPU number is stored here.

>  	/* peek cache of free slot */
>  	if (pool->left != FC_XID_UNKNOWN) {

Sebastian

  reply	other threads:[~2021-11-17  7:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17  2:59 [PATCH -next 0/3] scsi/fcoe: Play nicer with PREEMPT_RT Davidlohr Bueso
2021-11-17  2:59 ` [PATCH 1/3] scsi/libfc: Remove get_cpu() semantics in fc_exch_em_alloc() Davidlohr Bueso
2021-11-17  7:25   ` Sebastian Andrzej Siewior [this message]
2021-11-17  2:59 ` [PATCH 2/3] scsi/fcoe: Add a local_lock to fcoe_percpu Davidlohr Bueso
2021-11-17  7:50   ` Sebastian Andrzej Siewior
2021-11-17  2:59 ` [PATCH 3/3] scsi/fcoe: Add a local_lock to percpu localport statistics Davidlohr Bueso
2021-11-17  8:34   ` Sebastian Andrzej Siewior

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=20211117072541.fpgp23twyaawiool@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=dave@stgolabs.net \
    --cc=dbueso@suse.de \
    --cc=hare@suse.de \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).