[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <597B109EC20B76429F71A8A97770610D12A52669@ALA-MBD.corp.ad.wrs.com>
Date: Fri, 8 Mar 2019 00:07:41 +0000
From: "Liu, Yongxin" <Yongxin.Liu@...driver.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-rt-users@...r.kernel.org" <linux-rt-users@...r.kernel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"rostedt@...dmis.org" <rostedt@...dmis.org>,
"dan.j.williams@...el.com" <dan.j.williams@...el.com>,
"pagupta@...hat.com" <pagupta@...hat.com>,
"Gortmaker, Paul" <Paul.Gortmaker@...driver.com>,
"linux-nvdimm@...ts.01.org" <linux-nvdimm@...ts.01.org>
Subject: RE: [PATCH RT] nvdimm: make lane acquirement RT aware
> -----Original Message-----
> From: linux-kernel-owner@...r.kernel.org [mailto:linux-kernel-
> owner@...r.kernel.org] On Behalf Of Sebastian Andrzej Siewior
> Sent: Thursday, March 7, 2019 22:34
> To: Liu, Yongxin
> Cc: linux-kernel@...r.kernel.org; linux-rt-users@...r.kernel.org;
> tglx@...utronix.de; rostedt@...dmis.org; dan.j.williams@...el.com;
> pagupta@...hat.com; Gortmaker, Paul; linux-nvdimm@...ts.01.org
> Subject: Re: [PATCH RT] nvdimm: make lane acquirement RT aware
>
> On 2019-03-06 17:57:09 [+0800], Yongxin Liu wrote:
> > In this change, we replace get_cpu/put_cpu with local_lock_cpu/
> > local_unlock_cpu, and introduce per CPU variable "ndl_local_lock".
> > Due to preemption on RT, this lock can avoid race condition for the
> > same lane on the same CPU. When CPU number is greater than the lane
> > number, lane can be shared among CPUs. "ndl_lock->lock" is used to
> > protect the lane in this situation.
>
> so what was the reason that get_cpu() can't be replaced with
> raw_smp_processor_id()?
>
> Sebastian
The lane is critical resource which needs to be protected. One CPU can use only one
lane. If CPU number is greater than the number of total lane, the lane can be shared
among CPUs.
In non-RT kernel, get_cpu() disable preemption by calling preempt_disable() first.
Only one thread on the same CPU can get the lane.
In RT kernel, if we only use raw_smp_processor_id(), this doesn't protect the lane.
Thus two threads on the same CPU can get the same lane at the same time.
In this patch, two-level lock can avoid race condition for the lane.
CPU A CPU B (B == A % num_lanes)
task A1 task A2 task B1 task B2
| | | |
|__________| |__________|
| |
ndl_local_lock ndl_local_lock
| |
|______________________|
|
|
ndl_lock->lock
|
|
lane
Thanks,
Yongxin
Powered by blists - more mailing lists