public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Reiser <jreiser@BitWagon.com>
To: Jeff Dike <jdike@karaya.com>
Cc: linux-kernel@vger.kernel.org,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	Julian Seward <jseward@acm.org>
Subject: Re: Valgrind meets UML
Date: Sat, 21 Dec 2002 06:40:44 -0800	[thread overview]
Message-ID: <3E047D6C.1030702@BitWagon.com> (raw)
In-Reply-To: 200212200241.VAA04202@ccure.karaya.com

In order to prevent races between valgrind for UML and kernel allocators which
valgrind does not "know", then the VALGRIND_* declarations being added to kernel
allocators should allow for expressing the concept "atomically change state in
both allocator and valgrind".  One example might be
	VALGRIND_STORE_AND_UPDATE(ptr, value, n, ranges)
with semantics
	struct vg_update {
		void const *addr;  /* valgrind itself never changes the contents */
		unsigned length;
		enum {vg_na, vg_w, vg_rw, vg_ro} new_state;
	} *ranges;

	valgrind_lock();
	*ptr = value;
	valgrind_update(n, ranges);  /* ranges should not overlap */
	valgrind_unlock();

In general there is a need for such a primitive for each kind of atomic
operation performed by an allocator: on x86, anything with an explicit or
implicit LOCK prefix (INC, DEC, ADD, SUB, AND, OR, XOR, BTR, BTS, BTC, XADD,
XCHG, CMPXCHG are the most likely).  Of course, most actual allocators
already use an explicit software lock which in some cases can subsume the
valgrind lock.  But there are lockless allocators; a circular buffer between
consumer and producer is the simplest.  Also, there are allocators which use
a hardware device as part of the lock: UART FIFO, circular buffer with
hardware on one side, SCSI command queue, etc.

-- 
John Reiser, jreiser@BitWagon.com


  parent reply	other threads:[~2002-12-21 14:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-20  2:41 Valgrind meets UML Jeff Dike
2002-12-20 15:26 ` John Reiser
2002-12-20 22:58   ` Jeff Dike
2002-12-20 23:32     ` John Reiser
2002-12-21  2:49       ` Jeff Dike
2002-12-21  7:32         ` Jeremy Fitzhardinge
2002-12-21 16:05           ` Jeff Dike
2002-12-21 14:40 ` John Reiser [this message]
2002-12-21 16:07   ` Jeff Dike
2002-12-21 16:15     ` John Reiser
2002-12-21 18:57       ` Jeff Dike
2002-12-21 19:07   ` Jeremy Fitzhardinge

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=3E047D6C.1030702@BitWagon.com \
    --to=jreiser@bitwagon.com \
    --cc=jdike@karaya.com \
    --cc=jeremy@goop.org \
    --cc=jseward@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    /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