lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090501165258.GA26143@elte.hu>
Date:	Fri, 1 May 2009 18:52:58 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Frederic Weisbecker <fweisbec@...il.com>
Subject: Re: [PATCH 3/3] ring-buffer: make cpu buffer entries counter atomic


* Steven Rostedt <rostedt@...dmis.org> wrote:

> 
> On Fri, 1 May 2009, Ingo Molnar wrote:
> > > > > > the counter too. This would cause missing entries to be added.
> > > > > 
> > > > > > -	unsigned long			entries;
> > > > > > +	atomic_t			entries;
> > > > > 
> > > > > Hm, that's not really good as atomics can be rather expensive and 
> > > > > this is the fastpath.
> > > > 
> > > > Actually, it could be local_t. I used that in a lot of the other places.
> > > > The race is with on CPU not other CPUs, and on archs like x86 there
> > > > is not cost of the "LOCK".
> > > 
> > > Ug, it must be atomic_t. It is also modified by the reader. Thus 
> > > it is not only a race with a single CPU but also multiple CPUs.
> > > 
> > > This means that interrupts disabled is not the only proctection it 
> > > needs. It must either be an atomic, or protected by a spinlock.
> > 
> > Trace buffers are rather fundamentally per cpu. Where's the 
> > problem?
> 
> The entries keeps track of the number of entries in the buffer. A 
> writer (producer) adds to the counter and readers (consumers) 
> subtract from them. A writer can subtract them if it overwrites a 
> page before the producer consumes it.
> 
> Only the writers are pinned to a CPU, the readers happen on any 
> CPU.

But that does not require atomicity. It requires careful use of 
barriers, but otherwise atomicity is not needed. Update of machine 
word variables (if they are aligned to a machine word) is guaranteed 
to be atomic, even without atomic_t overhead.

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ