Re: question about spinlocks on UP

Savochkin Andrey Vladimirovich (saw@msu.ru)
Thu, 16 Jul 1998 17:41:19 +0400


--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii

On Wed, Jul 15, 1998 at 06:41:12PM +0200, Andi Kleen wrote:
> On Wed, Jul 15, 1998 at 06:09:26PM +0200, Savochkin Andrey Vladimirovich wrote:
> >
> > I don't think that a certain number of spinlock_t variables are
> > worth the time needed to fix all missing declarations when
> > you decide to debug something.
>
> The problem are static spinlock variables. If you don't reference them,
> and don't #ifdef them out then gcc will always spew out an ugly warning.
>
> It seems to be the Linux kernel consensus that all code should compile
> warning free, and just making all spinlocks global would be a serious
> namespace pollution and a mainteance nightmare on the long run.
>
> The concept of a spinlock is meaningless on UP anyways, so I don't
> think you should do that. Spinlocks have to be NOPs on UP.
>
> You could always use a SMP compiled kernel on a UP machine, but of course
> such spinlock "testing" would be fairly useless, because the spinlocks are
> never exercised.

I suppose I need to clarify my opinion.

1. For i386 UP kernel spinlocks are defined as `struct { } ' and don't
use space.

2. i386 UP spinlocks have debug features.
If you define DEBUG_SPINLOCKS in include/asm-i386/spinlocks.h
and build UP kernel you will be able
to track down deadlocks very easily. And I consider the testing
as _very usefull_.

Certainly, compilation with enabled DEBUG_SPINLOCKS will fail
in all places where people decided to arrange their
spinlocks by #ifdef __SMP__ or any other amusements.

3. I don't think that unnecessary __SMP__ conditions are
good things (tm). Such conditions should be present only
when they are really needed (like in sched.c).

4. If you are worried about warnings they can be easily cured by
the attached patch referencing the argument of spin* macros.
The patch has the additional advantage: you may verify
that a declared spinlock is really used even on UP kernel.

Best regards
Andrey V.
Savochkin

--VbJkn9YxBvnuCH5J
Content-Type: application/x-gunzip
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="spinlock.patch.gz"

H4sIAL0CrjUCA+2cbW/aSBCAP8OvmFO/kAABG8yLc5XSd7WXNyXt9U46yXJhSVYxtru2Q6NT
//ut1wTwsovXkKhpb6UIJ+zM7OywnnmyGjz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Le
MwcjwZRzNSdCcRJSo/8BPJv3yQleAAA=

--VbJkn9YxBvnuCH5J--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html