[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200316133916.GD12561@hirez.programming.kicks-ass.net>
Date: Mon, 16 Mar 2020 14:39:16 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Ling Ma <ling.ma.program@...il.com>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
"ling.ma" <ling.ml@...fin.com>, viro@...iv.linux.org.uk
Subject: Re: [RFC PATCH] locks:Remove spinlock in unshare_files
On Mon, Mar 16, 2020 at 09:25:42PM +0800, Ling Ma wrote:
> Any comments ?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
Also, it probably helps to Cc the right people.
> <ling.ma.program@...il.com> 于2020年3月13日周五 上午11:09写道:
> >
> > From: Ma Ling <ling.ml@...fin.com>
> >
> > Processor support atomic operation for long/int/short/char type,
> > we use the feature to avoid spinlock, which cost hundreds cycles.
> >
> > Appreciate your comments
> > Ling
> >
> > Signed-off-by: Ma Ling <ling.ml@...fin.com>
> > ---
> > kernel/fork.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/kernel/fork.c b/kernel/fork.c
> > index 60a1295..fe54600 100644
> > --- a/kernel/fork.c
> > +++ b/kernel/fork.c
> > @@ -3041,9 +3041,7 @@ int unshare_files(struct files_struct **displaced)
> > return error;
> > }
> > *displaced = task->files;
> > - task_lock(task);
> > - task->files = copy;
> > - task_unlock(task);
> > + WRITE_ONCE(task->files, copy);
> > return 0;
> > }
AFAICT this is completely and utterly buggered.
IFF task->files was lockless, like say RCU, then you'd still need
smp_store_release(). But if we look at fs/file.c then everything uses
task_lock() and removing it like the above is actively broken.
Powered by blists - more mailing lists