From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: jmerkey@wolfmountaingroup.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [ANNOUNCE] mdb-2.6.27-rc2-ia32-08-07-08.patch
Date: Thu, 07 Aug 2008 17:49:47 +0200 [thread overview]
Message-ID: <489B199B.40305@s5r6.in-berlin.de> (raw)
In-Reply-To: <1300.69.2.248.210.1218119365.squirrel@webmail.wolfmountaingroup.com>
jmerkey@wolfmountaingroup.com wrote:
> The mdb-rc2 patch was posted this morning with the changes for a modular
> kernel debugger using kprobes.
>
> ftp://ftp.wolfmountaingroup.org/pub/mdb/mdb-2.6.27-rc2-ia32-08-07-08.patch
>
> Jeffrey Vernon Merkey
Quoting from this patch:
> +typedef struct _RLOCK
> +{
> +#if defined(CONFIG_SMP)
> + spinlock_t lock;
> +#endif
> + unsigned long flags;
> + unsigned long processor;
> + unsigned long count;
> +} rlock_t;
Is this something along the lines of a counting semaphore? As far as I
understand its accessor functions, an rlock
- can be taken by one CPU multiple times,
- will block the other CPUs as long as the first CPU hasn't unlocked
the rlock as many times as it locked it.
The accessors rspin_lock() and rspin_try_lock() peek into spinlock_t and
may therefore not be fully portable. Also, they and rspin_unlock()
don't look SMP safe:
> +//
> +// returns 0 - atomic lock occurred, processor assigned
> +// 1 - recusive count increased
> +//
> +
> +unsigned long rspin_lock(volatile rlock_t *rlock)
> +{
> +#if defined(CONFIG_SMP)
> + register unsigned long proc = get_processor_id();
> + register unsigned long retCode;
> +
> + if (rlock->lock.raw_lock.slock && rlock->processor == proc)
> + {
> + rlock->count++;
> + retCode = 1;
> + }
> + else
> + {
> + spin_lock_irqsave((spinlock_t *)&rlock->lock, rlock->flags);
> + rlock->processor = proc;
> + retCode = 0;
> + }
> + return retCode;
> +#else
> + return 0;
> +#endif
> +}
In general, a lot can happen between the access to
rlock->lock.raw_lock.slock and the access to rlock->processor.
Even rlock->count++ in itself can go wrong.
The usage of "volatile" here looks a lot like DWIM to me.
> +volatile unsigned long debuggerActive;
> +volatile unsigned long ProcessorHold[MAX_PROCESSORS];
> +volatile unsigned long ProcessorState[MAX_PROCESSORS];
> +volatile unsigned long ProcessorMode[MAX_PROCESSORS];
Are these datasets shared between CPUs and do you access them without
lock protection? (It looks like that from a quick glance.) If yes,
instead of the volatile qualifier, can't you use memory barriers in
order to define the access semantics more clearly (and more effective)
than volatile can?
If there are interdependencies in these datasets, with which mechanisms
if not locks do you serialize critical sections?
> +void MDBInitializeDebugger(void)
> +{
...
> + for (i=0; i < MAX_PROCESSORS; i++)
> + {
> + BreakMask[i] = 0;
> + ProcessorHold[i] = 0;
> + ProcessorState[i] = 0;
> + ProcessorMode[i] = 0;
> + }
Not necessary, because static (and extern) variables are already
implicitly initialized to zero.
--
Stefan Richter
-=====-==--- =--- --===
http://arcgraph.de/sr/
next prev parent reply other threads:[~2008-08-07 15:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-07 14:29 [ANNOUNCE] mdb-2.6.27-rc2-ia32-08-07-08.patch jmerkey
2008-08-07 15:49 ` Stefan Richter [this message]
2008-08-07 15:59 ` Stefan Richter
2008-08-07 15:56 ` jmerkey
2008-08-07 16:46 ` Stefan Richter
2008-08-07 16:33 ` jmerkey
2008-08-07 17:19 ` Stefan Richter
2008-08-07 17:33 ` Stefan Richter
2008-08-07 17:52 ` jmerkey
2008-08-07 17:52 ` jmerkey
2008-08-07 16:04 ` jmerkey
2008-08-09 5:07 ` Jeremy Fitzhardinge
2008-08-09 8:04 ` Stefan Richter
2008-08-09 14:44 ` jmerkey
2008-08-08 2:18 ` Parag Warudkar
-- strict thread matches above, loose matches on Subject: below --
2008-08-08 4:33 Parag Warudkar
2008-08-08 13:11 ` jmerkey
[not found] ` <37357.166.70.238.45.1218201115.squirrel@webmail.wolfmountaingroup.com >
2008-08-08 13:23 ` jmerkey
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=489B199B.40305@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=jmerkey@wolfmountaingroup.com \
--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