All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Miloslav Trmac <mitr@redhat.com>
Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@suse.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	James Morris <jmorris@namei.org>, Alan Cox <alan@linux.intel.com>,
	Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Balbir Singh <balbir@linux.vnet.ibm.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Renaud Lottiaux <renaud.lottiaux@kerlabs.com>,
	Louis Rilling <louis.rilling@kerlabs.com>,
	David Howells <dhowells@redhat.com>,
	Stanislaw Gruszka <sgruszka@redhat.com>,
	Veaceslav Falico <vfalico@redhat.com>
Subject: Re: [PATCH v2 4/4] copy_signal cleanup: clean tty_audit_fork()
Date: Mon, 7 Dec 2009 13:54:27 +0100	[thread overview]
Message-ID: <20091207125427.GA4843@redhat.com> (raw)
In-Reply-To: <2003788136.1223211260112670844.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com>

On 12/06, Miloslav Trmac wrote:
>
> ----- "Oleg Nesterov" <oleg@redhat.com> wrote:
> > On 12/05, Miloslav Trmac wrote:
> > > > Off-topic question to this who understands this code.
> > > >
> > > > But afaics we can also remove ->siglock from this helper and make
> > > > it really trivial for being inline. ->siglock buys nothing, we just
> > > > read a boolean. In fact, after the quick grep I do not understand
> > > > how ->siglock is connected to ->audit_tty. OK, it protects
> > > > tty_audit_buf,
> > > > but why we always take ->siglock to access ->audit_tty ?
> > > AFAIK there is no explicit documentation of the atomicity semantics
> > > expected by the Linux kernel (both from the hardware and from the compiler),
> > > so every access to the boolean is protected by a lock, to be on the safe side.
> >
> > Not sure I understand, but the kernel relies on fact it is always safe
> > to load/store a word.
> And is "word" an "unsigned", "unsigned long" or "intptr_t"?  Must it be
> suitably aligned, and if so, what is "suitably"?

Sure, it must be aligned.

> Where is this documented?

Perhaps nowhere, I do not know. If this is not documented, probably
it would be nice to add a note.

> > What atomicity semantics do you mean and how ->siglock can help?
> At the very least, "any access will read the last value stored and not result
> in undefined behavior, even if other threads attempt to access the value".
> In user-space, per POSIX, the only way to guarantee this is using explicit
> synchronization primitives.

We have numerous examples in kernel code which rely on this fact.

If we are talking about copy_process() pathes, please look at, say,
sched_fork(). Say, we read current->normal_prio lockless, while another
thread could change ->normal_prio in parallel.

Oleg.


  reply	other threads:[~2009-12-07 13:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1536386836.1223191260112270565.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com>
2009-12-06 15:17 ` [PATCH v2 4/4] copy_signal cleanup: clean tty_audit_fork() Miloslav Trmac
2009-12-07 12:54   ` Oleg Nesterov [this message]
2009-12-01 22:10 [PATCH 1/4] copy_signal cleanup: use zalloc and remove initializations Veaceslav Falico
2009-12-02 13:57 ` Oleg Nesterov
2009-12-04 14:30   ` [PATCH v2 4/4] copy_signal cleanup: clean tty_audit_fork() Veaceslav Falico
2009-12-05 16:58     ` Oleg Nesterov
2009-12-05 20:04       ` Miloslav Trmac
2009-12-06 14:49         ` Oleg Nesterov

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=20091207125427.GA4843@redhat.com \
    --to=oleg@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@linux.intel.com \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=dhowells@redhat.com \
    --cc=gregkh@suse.de \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis.rilling@kerlabs.com \
    --cc=mingo@elte.hu \
    --cc=mitr@redhat.com \
    --cc=peterz@infradead.org \
    --cc=renaud.lottiaux@kerlabs.com \
    --cc=sgruszka@redhat.com \
    --cc=vfalico@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.