From: Dave <kilroyd@googlemail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: mingo@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org,
a.p.zijlstra@chello.nl, tglx@linutronix.de,
linux-tip-commits@vger.kernel.org
Subject: Re: [tip:core/locking] locking: Check spinlock_t/rwlock_t argument type on non-SMP builds too
Date: Mon, 03 Aug 2009 20:52:31 +0100 [thread overview]
Message-ID: <4A773FFF.7050106@gmail.com> (raw)
In-Reply-To: <20090803113929.GA25828@elte.hu>
Ingo Molnar wrote:
> * tip-bot for David Kilroy <kilroyd@googlemail.com> wrote:
>
>> Commit-ID: 8d19bd347e1073e7f1ef9f8057c560a5f6be63d7
>> Gitweb: http://git.kernel.org/tip/8d19bd347e1073e7f1ef9f8057c560a5f6be63d7
>> Author: David Kilroy <kilroyd@googlemail.com>
>> AuthorDate: Sun, 2 Aug 2009 19:41:05 +0100
>> Committer: Ingo Molnar <mingo@elte.hu>
>> CommitDate: Sun, 2 Aug 2009 21:29:07 +0200
>>
>> locking: Check spinlock_t/rwlock_t argument type on non-SMP builds too
>>
>> When writing code for UP without CONFIG_DEBUG_SPINLOCK it's
>> easy to get the first argument to the spinlock/rwlock functions
>> wrong. This is because the parameter is not actually used in
>> this configuration.
>>
>> Typically you will only find out it's wrong:
>>
>> * by rebuilding with CONFIG_SMP or CONFIG_DEBUG_SPINLOCK
>> * after you've submitted your beautiful patch series
>>
>> The first means a long wait, and the latter is a bit late.
>>
>> Change the intermediate macros into inline functions.
>>
>> -v2: Use C inlines instead of in-macro type-checks
>> -v3: Correct bug in _spin_trylock_bh
>
> x86 works fine now - but this patch broke architecture builds, such
> as the build on Alpha:
>
> In file included from
> /home/mingo/tip/arch/alpha/kernel/sys_sable.c:25:
> /home/mingo/tip/arch/alpha/include/asm/core_t2.h: In function
> 't2_readb':
> /home/mingo/tip/arch/alpha/include/asm/core_t2.h:451: error:
> '_spin_lock_irqsave' is static but used in inline function
> 't2_readb' which is not static
I tried a couple things (see below), but don't see a nice simple way
forward. One option I didn't investigate is copying what SMP does.
I'm inclined to recommend v1 of the patch.
Regards,
Dave.
---
Switching to extern inline on x86 leads to:
/usr/src/linux-current/wireless-testing/include/linux/spinlock_api_up.h:
In function '_spin_lock_irq':
/usr/src/linux-current/wireless-testing/include/linux/spinlock_api_up.h:73:
warning: 'raw_local_irq_disable' is static but used in inline function
'_spin_lock_irq' which is not static
...
/usr/src/linux-current/wireless-testing/include/linux/spinlock_api_up.h:139:
warning: 'current_thread_info' is static but used in inline function
'_write_unlock_irqrestore' which is not static
Looks like one for each of the functions. Seems to link OK.
-> cascade the extern inline into raw versions of functions? on all archs?
---
Plain old inline (and __attribute__((gnu_inline)) ) on x86 leads to:
LD init/mounts.o
init/do_mounts_rd.o: In function `_write_unlock_irqrestore':
do_mounts_rd.c:(.text+0x0): multiple definition of
`_write_unlock_irqrestore'
init/do_mounts.o:do_mounts.c:(.text+0x1b5): first defined here
...
init/do_mounts_initrd.o: In function `_spin_lock':
do_mounts_initrd.c:(.text+0x298): multiple definition of `_spin_lock'
init/do_mounts.o:do_mounts.c:(.text+0x44d): first defined here
make[2]: *** [init/mounts.o] Error 1
make[1]: *** [init] Error 2
make: *** [sub-make] Error 2
-> clever linker solution?
---
The statistics (2.6.31-rc4ish) show a strong preference for static inline:
$ find include -name "*.h" | xargs grep "static inline" | wc -l
6461
$ find include -name "*.h" | xargs grep "extern inline" | wc -l
2
$ find arch -name "*.h" | xargs grep "extern inline" | wc -l
125
$ find arch -name "*.h" | xargs grep "static inline" | wc -l
7058
$ find arch -name "*.h" | xargs grep "extern inline" | sed
"s?^\(.*\):.*\$?\1?" | sort | uniq
arch/alpha/include/asm/core_apecs.h
arch/alpha/include/asm/core_cia.h
arch/alpha/include/asm/core_irongate.h
arch/alpha/include/asm/core_lca.h
arch/alpha/include/asm/core_marvel.h
arch/alpha/include/asm/core_mcpcia.h
arch/alpha/include/asm/core_polaris.h
arch/alpha/include/asm/core_t2.h
arch/alpha/include/asm/core_titan.h
arch/alpha/include/asm/core_tsunami.h
arch/alpha/include/asm/core_wildfire.h
arch/alpha/include/asm/io.h
arch/alpha/include/asm/jensen.h
arch/alpha/include/asm/mmu_context.h
arch/alpha/include/asm/pci.h
arch/alpha/include/asm/pgtable.h
arch/alpha/include/asm/processor.h
arch/alpha/include/asm/system.h
arch/alpha/include/asm/tlbflush.h
arch/alpha/include/asm/uaccess.h
arch/blackfin/include/asm/string.h
arch/m68k/include/asm/sbus.h
arch/microblaze/include/asm/cacheflush.h
arch/microblaze/include/asm/delay.h
arch/microblaze/include/asm/pgalloc.h
arch/microblaze/include/asm/processor.h
next prev parent reply other threads:[~2009-08-03 19:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-02 18:44 [PATCH] check spinlock_t/rwlock_t argument type on non-SMP builds David Kilroy
2009-07-03 7:38 ` Ingo Molnar
2009-07-03 19:02 ` Dave
2009-07-18 12:14 ` Ingo Molnar
2009-07-22 18:11 ` [PATCH v2] " David Kilroy
2009-08-02 13:14 ` [tip:core/locking] locking: Check spinlock_t/rwlock_t argument type on non-SMP builds too tip-bot for David Kilroy
2009-08-02 13:40 ` Ingo Molnar
2009-08-02 16:45 ` Dave
2009-08-02 18:05 ` Ingo Molnar
2009-08-02 18:41 ` [PATCH v3] locking: check " David Kilroy
2009-08-02 19:30 ` [tip:core/locking] locking: Check " tip-bot for David Kilroy
2009-08-03 11:39 ` Ingo Molnar
2009-08-03 19:52 ` Dave [this message]
2009-08-04 3:05 ` Mike Frysinger
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=4A773FFF.7050106@gmail.com \
--to=kilroyd@googlemail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).