public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Ling Ma <ling.ma.program@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	"ling.ma" <ling.ml@antfin.com>,
	viro@zeniv.linux.org.uk
Subject: Re: [RFC PATCH] locks:Remove spinlock in unshare_files
Date: Mon, 16 Mar 2020 14:39:16 +0100	[thread overview]
Message-ID: <20200316133916.GD12561@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <CAOGi=dNniSgkUtJPfaYLAbR+_8DMFdU59mx7hf8Otj_VjDF_dQ@mail.gmail.com>

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@gmail.com> 于2020年3月13日周五 上午11:09写道:
> >
> > From: Ma Ling <ling.ml@antfin.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@antfin.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.


  reply	other threads:[~2020-03-16 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13  3:10 [RFC PATCH] locks:Remove spinlock in unshare_files ling.ma.program
2020-03-16 13:25 ` Ling Ma
2020-03-16 13:39   ` Peter Zijlstra [this message]
2020-03-16 18:35     ` Al Viro

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=20200316133916.GD12561@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=ling.ma.program@gmail.com \
    --cc=ling.ml@antfin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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