All of lore.kernel.org
 help / color / mirror / Atom feed
* [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
@ 2013-06-08 10:08 ` Chen Gang
  0 siblings, 0 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-08 10:08 UTC (permalink / raw)
  To: rth, ink, mattst88, dhowells, tony.luck, fenghua.yu, yasutake.koichi
  Cc: linux-alpha, linux-kernel, linux-ia64, linux-am33-list, Linux-Arch

Hello Maintainers:


Several architectures have different __set_bit() API to others, in
standard API, 2nd param of __set_bit() is 'unsigned long *', but:

  in 'min10300', it is 'unsigned char *',
  in 'ia64' and 'alpha', they are 'int' or 'unsigned int'.

If another sub-systems did not notice it, it may lead them to make
mistakes.

It seems related maintainer intended to implement it like that.

So could related maintainers provide the reason for it, so more guys
(e.g. me) can learn about it (at least can avoid related mistakes).


The related information in arch sub-system:

using 'unsigned char *':
  ./mn10300/include/asm/bitops.h:28:#define __set_bit(nr, addr)					\

using 'unsigned int *', implicitly: 
  ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)

using 'int *', implicitly: (need use 'unsigned', at least)
  ./alpha/include/asm/bitops.h:49:__set_bit(unsigned long nr, volatile void * addr)

using 'unsigned long *' implicitly:
  ./frv/include/asm/bitops.h:164:static inline void __set_bit(unsigned long nr, volatile void *addr)
  
standard API:  
  ./h8300/include/asm/bitops.h:74:#define __set_bit(nr,addr)    set_bit((nr),(addr))
  ./m68k/include/asm/bitops.h:67:#define __set_bit(nr, vaddr)	set_bit(nr, vaddr)
  ./arc/include/asm/bitops.h:293:static inline void __set_bit(unsigned long nr, volatile unsigned long *m)
  ./sh/include/asm/bitops-op32.h:20:static inline void __set_bit(int nr, volatile unsigned long *addr)
  ./hexagon/include/asm/bitops.h:151:static inline void __set_bit(int nr, volatile unsigned long *addr)
  ./s390/include/asm/bitops.h:212:static inline void __set_bit(unsigned long nr, volatile unsigned long *ptr)
  ./x86/include/asm/bitops.h:84:static inline void __set_bit(int nr, volatile unsigned long *addr)
  (others use 'generic')


Thanks.
-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
@ 2013-06-08 10:08 ` Chen Gang
  0 siblings, 0 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-08 10:08 UTC (permalink / raw)
  To: rth, ink, mattst88, dhowells, tony.luck, fenghua.yu, yasutake.koichi
  Cc: linux-alpha, linux-kernel, linux-ia64, linux-am33-list, Linux-Arch

Hello Maintainers:


Several architectures have different __set_bit() API to others, in
standard API, 2nd param of __set_bit() is 'unsigned long *', but:

  in 'min10300', it is 'unsigned char *',
  in 'ia64' and 'alpha', they are 'int' or 'unsigned int'.

If another sub-systems did not notice it, it may lead them to make
mistakes.

It seems related maintainer intended to implement it like that.

So could related maintainers provide the reason for it, so more guys
(e.g. me) can learn about it (at least can avoid related mistakes).


The related information in arch sub-system:

using 'unsigned char *':
  ./mn10300/include/asm/bitops.h:28:#define __set_bit(nr, addr)					\

using 'unsigned int *', implicitly: 
  ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)

using 'int *', implicitly: (need use 'unsigned', at least)
  ./alpha/include/asm/bitops.h:49:__set_bit(unsigned long nr, volatile void * addr)

using 'unsigned long *' implicitly:
  ./frv/include/asm/bitops.h:164:static inline void __set_bit(unsigned long nr, volatile void *addr)
  
standard API:  
  ./h8300/include/asm/bitops.h:74:#define __set_bit(nr,addr)    set_bit((nr),(addr))
  ./m68k/include/asm/bitops.h:67:#define __set_bit(nr, vaddr)	set_bit(nr, vaddr)
  ./arc/include/asm/bitops.h:293:static inline void __set_bit(unsigned long nr, volatile unsigned long *m)
  ./sh/include/asm/bitops-op32.h:20:static inline void __set_bit(int nr, volatile unsigned long *addr)
  ./hexagon/include/asm/bitops.h:151:static inline void __set_bit(int nr, volatile unsigned long *addr)
  ./s390/include/asm/bitops.h:212:static inline void __set_bit(unsigned long nr, volatile unsigned long *ptr)
  ./x86/include/asm/bitops.h:84:static inline void __set_bit(int nr, volatile unsigned long *addr)
  (others use 'generic')


Thanks.
-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
  2013-06-08 10:08 ` Chen Gang
@ 2013-06-10 22:26   ` Tony Luck
  -1 siblings, 0 replies; 10+ messages in thread
From: Tony Luck @ 2013-06-10 22:26 UTC (permalink / raw)
  To: Chen Gang
  Cc: Richard Henderson, ink, Matt Turner, dhowells, Yu, Fenghua,
	yasutake.koichi, linux-alpha, linux-kernel, linux-ia64,
	linux-am33-list, Linux-Arch

On Sat, Jun 8, 2013 at 3:08 AM, Chen Gang <gang.chen@asianux.com> wrote:
> using 'unsigned int *', implicitly:
>   ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)

There is some downside on ia64 to your suggestion.  If "addr" is properly
aligned for an "int", but misaligned for a long ... i.e. addr%8 == 4, then I'll
take an unaligned reference trap if I work with long* where the current code
working with int* does not.

Now perhaps all the callers do guarantee long* alignment?  But I don't know.

Apart from uniformity, there doesn't see to be any upside to changing this.

-Tony Luck

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
@ 2013-06-10 22:26   ` Tony Luck
  0 siblings, 0 replies; 10+ messages in thread
From: Tony Luck @ 2013-06-10 22:26 UTC (permalink / raw)
  To: Chen Gang
  Cc: Richard Henderson, ink, Matt Turner, dhowells, Yu, Fenghua,
	yasutake.koichi, linux-alpha, linux-kernel, linux-ia64,
	linux-am33-list, Linux-Arch

On Sat, Jun 8, 2013 at 3:08 AM, Chen Gang <gang.chen@asianux.com> wrote:
> using 'unsigned int *', implicitly:
>   ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)

There is some downside on ia64 to your suggestion.  If "addr" is properly
aligned for an "int", but misaligned for a long ... i.e. addr%8 = 4, then I'll
take an unaligned reference trap if I work with long* where the current code
working with int* does not.

Now perhaps all the callers do guarantee long* alignment?  But I don't know.

Apart from uniformity, there doesn't see to be any upside to changing this.

-Tony Luck

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
  2013-06-10 22:26   ` Tony Luck
@ 2013-06-11  7:32     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2013-06-11  7:32 UTC (permalink / raw)
  To: Tony Luck
  Cc: Chen Gang, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	dhowells, Yu, Fenghua, Koichi Yasutake, alpha, linux-kernel,
	linux-ia64, linux-am33-list, Linux-Arch

On Tue, Jun 11, 2013 at 12:26 AM, Tony Luck <tony.luck@gmail.com> wrote:
> On Sat, Jun 8, 2013 at 3:08 AM, Chen Gang <gang.chen@asianux.com> wrote:
>> using 'unsigned int *', implicitly:
>>   ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)
>
> There is some downside on ia64 to your suggestion.  If "addr" is properly
> aligned for an "int", but misaligned for a long ... i.e. addr%8 == 4, then I'll
> take an unaligned reference trap if I work with long* where the current code
> working with int* does not.
>
> Now perhaps all the callers do guarantee long* alignment?  But I don't know.
>
> Apart from uniformity, there doesn't see to be any upside to changing this.

The address pointers have been supposed to be "long *" for a very long time.
Probably alpha (the second official Linux platform) did it
differently, and never
standardized to "long *".

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
@ 2013-06-11  7:32     ` Geert Uytterhoeven
  0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2013-06-11  7:32 UTC (permalink / raw)
  To: Tony Luck
  Cc: Chen Gang, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	dhowells, Yu, Fenghua, Koichi Yasutake, alpha, linux-kernel,
	linux-ia64, linux-am33-list, Linux-Arch

On Tue, Jun 11, 2013 at 12:26 AM, Tony Luck <tony.luck@gmail.com> wrote:
> On Sat, Jun 8, 2013 at 3:08 AM, Chen Gang <gang.chen@asianux.com> wrote:
>> using 'unsigned int *', implicitly:
>>   ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)
>
> There is some downside on ia64 to your suggestion.  If "addr" is properly
> aligned for an "int", but misaligned for a long ... i.e. addr%8 = 4, then I'll
> take an unaligned reference trap if I work with long* where the current code
> working with int* does not.
>
> Now perhaps all the callers do guarantee long* alignment?  But I don't know.
>
> Apart from uniformity, there doesn't see to be any upside to changing this.

The address pointers have been supposed to be "long *" for a very long time.
Probably alpha (the second official Linux platform) did it
differently, and never
standardized to "long *".

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
  2013-06-08 10:08 ` Chen Gang
@ 2013-06-13  2:30   ` Chen Gang
  -1 siblings, 0 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-13  2:30 UTC (permalink / raw)
  To: rth, ink, mattst88, dhowells, tony.luck, fenghua.yu, yasutake.koichi
  Cc: linux-alpha, linux-kernel, linux-ia64, linux-am33-list, Linux-Arch

On 06/08/2013 06:08 PM, Chen Gang wrote:
> Several architectures have different __set_bit() API to others, in
> standard API, 2nd param of __set_bit() is 'unsigned long *', but:
> 
>   in 'min10300', it is 'unsigned char *',

Oh, it is my fault, for 'mn10300' it is no issue, it is not 'unsigned
char *' (it is a generic one which can match any type).

Also 'min10300' --> 'mn10300'.



Thanks.
-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
@ 2013-06-13  2:30   ` Chen Gang
  0 siblings, 0 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-13  2:30 UTC (permalink / raw)
  To: rth, ink, mattst88, dhowells, tony.luck, fenghua.yu, yasutake.koichi
  Cc: linux-alpha, linux-kernel, linux-ia64, linux-am33-list, Linux-Arch

On 06/08/2013 06:08 PM, Chen Gang wrote:
> Several architectures have different __set_bit() API to others, in
> standard API, 2nd param of __set_bit() is 'unsigned long *', but:
> 
>   in 'min10300', it is 'unsigned char *',

Oh, it is my fault, for 'mn10300' it is no issue, it is not 'unsigned
char *' (it is a generic one which can match any type).

Also 'min10300' --> 'mn10300'.



Thanks.
-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
  2013-06-11  7:32     ` Geert Uytterhoeven
@ 2013-06-13  2:43       ` Chen Gang
  -1 siblings, 0 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-13  2:43 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Tony Luck, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	dhowells, Yu, Fenghua, Koichi Yasutake, alpha, linux-kernel,
	linux-ia64, linux-am33-list, Linux-Arch

On 06/11/2013 03:32 PM, Geert Uytterhoeven wrote:
> On Tue, Jun 11, 2013 at 12:26 AM, Tony Luck <tony.luck@gmail.com> wrote:
>> > On Sat, Jun 8, 2013 at 3:08 AM, Chen Gang <gang.chen@asianux.com> wrote:
>>> >> using 'unsigned int *', implicitly:
>>> >>   ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)
>> >
>> > There is some downside on ia64 to your suggestion.  If "addr" is properly
>> > aligned for an "int", but misaligned for a long ... i.e. addr%8 == 4, then I'll
>> > take an unaligned reference trap if I work with long* where the current code
>> > working with int* does not.
>> >
>> > Now perhaps all the callers do guarantee long* alignment?  But I don't know.
>> >
>> > Apart from uniformity, there doesn't see to be any upside to changing this.
> The address pointers have been supposed to be "long *" for a very long time.
> Probably alpha (the second official Linux platform) did it
> differently, and never
> standardized to "long *".

Excuse me, I am not quite familiar with the details, but I guess, it is
about functional feature issues, not (or not only) about bug issues.

For the architectures which can fully support 64-bit OS, excluding ia64
and alpha, all of them can support setting 64 bits (from 0 to 63) under
64-bit machine.

I am not quite sure whether any sub-systems have already set higher bit
(> 31) under 64-bit machine, but in the future, it seems they could (at
least our API supposed so).


Thanks.
-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API.
@ 2013-06-13  2:43       ` Chen Gang
  0 siblings, 0 replies; 10+ messages in thread
From: Chen Gang @ 2013-06-13  2:43 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Tony Luck, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	dhowells, Yu, Fenghua, Koichi Yasutake, alpha, linux-kernel,
	linux-ia64, linux-am33-list, Linux-Arch

On 06/11/2013 03:32 PM, Geert Uytterhoeven wrote:
> On Tue, Jun 11, 2013 at 12:26 AM, Tony Luck <tony.luck@gmail.com> wrote:
>> > On Sat, Jun 8, 2013 at 3:08 AM, Chen Gang <gang.chen@asianux.com> wrote:
>>> >> using 'unsigned int *', implicitly:
>>> >>   ./ia64/include/asm/bitops.h:63:__set_bit (int nr, volatile void *addr)
>> >
>> > There is some downside on ia64 to your suggestion.  If "addr" is properly
>> > aligned for an "int", but misaligned for a long ... i.e. addr%8 = 4, then I'll
>> > take an unaligned reference trap if I work with long* where the current code
>> > working with int* does not.
>> >
>> > Now perhaps all the callers do guarantee long* alignment?  But I don't know.
>> >
>> > Apart from uniformity, there doesn't see to be any upside to changing this.
> The address pointers have been supposed to be "long *" for a very long time.
> Probably alpha (the second official Linux platform) did it
> differently, and never
> standardized to "long *".

Excuse me, I am not quite familiar with the details, but I guess, it is
about functional feature issues, not (or not only) about bug issues.

For the architectures which can fully support 64-bit OS, excluding ia64
and alpha, all of them can support setting 64 bits (from 0 to 63) under
64-bit machine.

I am not quite sure whether any sub-systems have already set higher bit
(> 31) under 64-bit machine, but in the future, it seems they could (at
least our API supposed so).


Thanks.
-- 
Chen Gang

Asianux Corporation

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-06-13  2:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-08 10:08 [Suggestion] arch/*/include/asm/bitops.h: about __set_bit() API Chen Gang
2013-06-08 10:08 ` Chen Gang
2013-06-10 22:26 ` Tony Luck
2013-06-10 22:26   ` Tony Luck
2013-06-11  7:32   ` Geert Uytterhoeven
2013-06-11  7:32     ` Geert Uytterhoeven
2013-06-13  2:43     ` Chen Gang
2013-06-13  2:43       ` Chen Gang
2013-06-13  2:30 ` Chen Gang
2013-06-13  2:30   ` Chen Gang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.