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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.0905011302150.20374@gandalf.stny.rr.com>
Date:	Fri, 1 May 2009 13:11:17 -0400 (EDT)
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Ingo Molnar <mingo@...e.hu>
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


On Fri, 1 May 2009, Ingo Molnar wrote:
> > 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.

I'm confused :-/ This throws out all that I learned in multi threaded 
programming.

If I have a shared variable used by two threads, the adding and 
subtracting of that variable does not need to be atomic?

        CPU0                 CPU1
        ----                 ----
	load A               load A
	sub  1, A            sub 1, A
	store A              store A

can work??

BTW, how expensive is an LOCK operation on a cache line that is not 
shared by other CPUs?  As long as a reader is not running, the updating of 
the variable is not shared.

Also, if this becomes a problem, I can just nuke the field. I like knowing 
the number of entries in the buffer, as well as the number of overruns. 
But these are more for debugging purposes. The overruns should probably be 
kept, because that is the only way a tracer can know if a overrun 
occurred. The number of entries in the buffer is not as important.

-- Steve
--
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