[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200918104824.GA23469@redhat.com>
Date: Fri, 18 Sep 2020 12:48:24 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: peterz@...radead.org
Cc: Jan Kara <jack@...e.cz>, Boaz Harrosh <boaz@...xistor.com>,
Hou Tao <houtao1@...wei.com>, Ingo Molnar <mingo@...hat.com>,
Will Deacon <will@...nel.org>, Dennis Zhou <dennis@...nel.org>,
Tejun Heo <tj@...nel.org>, Christoph Lameter <cl@...ux.com>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [RFC PATCH] locking/percpu-rwsem: use this_cpu_{inc|dec}() for
read_count
On 09/18, Peter Zijlstra wrote:
>
> On Fri, Sep 18, 2020 at 12:01:12PM +0200, peterz@...radead.org wrote:
> > + u64 sum = per_cpu_sum(*(u64 *)sem->read_count);
>
> Moo, that doesn't work, we have to do two separate sums.
Or we can re-introduce "atomic_t slow_read_ctr".
percpu_up_read_irqsafe(sem)
{
preempt_disable();
atomic_dec_release(&sem->slow_read_ctr);
if (!rcu_sync_is_idle(&sem->rss))
rcuwait_wake_up(&sem->writer);
preempt_enable();
}
readers_active_check(sem)
{
unsigned int sum = per_cpu_sum(*sem->read_count) +
(unsigned int)atomic_read(&sem->slow_read_ctr);
if (sum)
return false;
...
}
Of course, this assumes that atomic_t->counter underflows "correctly", just
like "unsigned int".
But again, do we really want this?
Oleg.
Powered by blists - more mailing lists