From: "jianchao.wang" <jianchao.w.wang@oracle.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: linux-kernel@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Kent Overstreet <kent.overstreet@gmail.com>,
linux-block@vger.kernel.org
Subject: Re: [PATCH] percpu-refcount: relax limit on percpu_ref_reinit()
Date: Tue, 11 Sep 2018 09:48:15 +0800 [thread overview]
Message-ID: <e91ee38e-3ea2-a003-2aac-8a8cc5c8f04a@oracle.com> (raw)
In-Reply-To: <20180910161135.GA27430@ming.t460p>
Hi Ming
On 09/11/2018 12:11 AM, Ming Lei wrote:
> Hi Jianchao,
>
> On Mon, Sep 10, 2018 at 09:40:35AM +0800, jianchao.wang wrote:
>> Hi Ming
>>
>> On 09/09/2018 08:58 PM, Ming Lei wrote:
>>> Now percpu_ref_reinit() can only be done on one percpu refcounter
>>> when it drops zero. And the limit shouldn't be so strict, and it
>>> is quite straightforward that percpu_ref_reinit() can be done when
>>> this counter is at atomic mode.
>>
>> As we know, when the percpu_ref is switched to atomic mode, the values
>> of the per cpu will be sumed up to the atomic conter in percpu_ref_switch_to_atomic_rcu.
>
> Right.
>
>>
>> However, the tricky part is:
>> when we switch back to percpu mode, how can we know the exact value of the value of every cpu ?
>
> The exact value of each CPU is zero at the exact time:
>
> 1) when percpu mode is switched from atomic mode
>
> percpu_ref_switch_to_atomic_rcu() is the point where no any percpu inc/dec
> can happen any more. And in this function the percpu count is sumed up to
> the atomic counter, meantime this patch clears the percpu value. It means
> once the refcount is switched to atomic mode, the percpu value is always
> zero, doesn't it?
>
> 2) when the percpu-refcount is initialized at percpu mode
>
> the percpu value is zero too.
What we want to get is to switch the percpu refcounter to percpu mode from atomic mode when
the refcounter has _not_ been drained to zero, instead of just to discard the warning, right ?
When we have sumed the values of every cpu's refcounter to a global atomic counter, how can
we give the values back to the refcounter of every cpu ?
Thanks
Jianchao
>
>>
>> Draining the percpu refcounter to zero before switch it back to percpu mode should be relatively
>> easy to implement. And also, this is the initial intention of percpu refcounter, only switch
>
> No, I don't think so, we can extend the percpu-refcount implementation to
> cover the NVMe timeout case easily. Then no necessary to reinvent a new wheel
> to address that issue.
>
>> to atomic mode when want to drain the refcounter.
>
>
> Thanks,
> Ming
>
next prev parent reply other threads:[~2018-09-11 1:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-09 12:58 Ming Lei
2018-09-09 18:46 ` Bart Van Assche
2018-09-09 23:59 ` Ming Lei
2018-09-10 1:40 ` jianchao.wang
2018-09-10 16:11 ` Ming Lei
2018-09-11 1:48 ` jianchao.wang [this message]
2018-09-11 4:03 ` Ming Lei
2018-09-11 4:40 ` jianchao.wang
2018-09-11 8:20 ` Ming Lei
2018-09-11 14:22 ` jianchao.wang
2018-09-11 13:44 ` Tejun Heo
2018-09-11 14:13 ` jianchao.wang
2018-09-10 1:54 ` jianchao.wang
2018-09-10 16:49 ` Tejun Heo
2018-09-11 0:00 ` Ming Lei
2018-09-11 13:48 ` Tejun Heo
2018-09-11 15:45 ` Ming Lei
2018-09-11 15:49 ` Tejun Heo
2018-09-11 16:05 ` Ming Lei
2018-09-11 16:30 ` Tejun Heo
2018-09-11 16:34 ` Ming Lei
2018-09-11 16:38 ` Tejun Heo
2018-09-12 1:52 ` Ming Lei
2018-09-12 15:53 ` Tejun Heo
2018-09-12 22:11 ` Ming Lei
2018-09-18 12:49 ` Tejun Heo
2018-09-19 2:51 ` Ming Lei
2018-09-19 20:36 ` Tejun Heo
2018-09-18 3:21 ` jianchao.wang
2018-09-18 7:34 ` Ming Lei
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=e91ee38e-3ea2-a003-2aac-8a8cc5c8f04a@oracle.com \
--to=jianchao.w.wang@oracle.com \
--cc=kent.overstreet@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=tj@kernel.org \
/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
Powered by JetHome