linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return  void
       [not found] <20030415174010$3e7e@gated-at.bofh.it>
@ 2003-04-15 20:04 ` Arnd Bergmann
  2003-04-15 21:27   ` Carl-Daniel Hailfinger
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2003-04-15 20:04 UTC (permalink / raw)
  To: Carl-Daniel Hailfinger, linux-kernel

Carl-Daniel Hailfinger wrote:

> +     mask = 1 << (nr & 0x1f);
> +     cli();
> +     *addr |= mask;
> +     sti();

cli() and sti() are no more. Moreover, the file you are trying to fix is
not even used anywhere. Better submit a patch to remove it completely.

        Arnd <><

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

* Re: [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void
  2003-04-15 20:04 ` [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void Arnd Bergmann
@ 2003-04-15 21:27   ` Carl-Daniel Hailfinger
  2003-04-15 21:34     ` Robert Love
  2003-04-23 18:04     ` Pavel Machek
  0 siblings, 2 replies; 6+ messages in thread
From: Carl-Daniel Hailfinger @ 2003-04-15 21:27 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel

Arnd Bergmann wrote:
> Carl-Daniel Hailfinger wrote:
> 
> 
>>+     mask = 1 << (nr & 0x1f);
>>+     cli();
>>+     *addr |= mask;
>>+     sti();
> 
> 
> cli() and sti() are no more. Moreover, the file you are trying to fix is

What is the preferred way to achieve atomicity in an operation now that
cli() and sti() are gone?

> not even used anywhere. Better submit a patch to remove it completely.

The point of asm-generic is not to use the files, but to give porters a
hint about the functionality. Quoting asm-generic/bitops.h:

/* For the benefit of those who are trying to port Linux to another
 * architecture, here are some C-language equivalents.  You should
 * recode these in the native assembly language, if at all possible.
 * To guarantee atomicity, these routines call cli() and sti() to
 * disable interrupts while they operate.  (You have to provide inline
 * routines to cli() and sti().) */

Or is this comment wrong, too?

Regards,
Carl-Daniel

-- 
http://www.hailfinger.org/


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

* Re: [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void
  2003-04-15 21:27   ` Carl-Daniel Hailfinger
@ 2003-04-15 21:34     ` Robert Love
  2003-04-15 22:46       ` Arnd Bergmann
  2003-04-23 18:04     ` Pavel Machek
  1 sibling, 1 reply; 6+ messages in thread
From: Robert Love @ 2003-04-15 21:34 UTC (permalink / raw)
  To: Carl-Daniel Hailfinger; +Cc: Arnd Bergmann, linux-kernel

On Tue, 2003-04-15 at 17:27, Carl-Daniel Hailfinger wrote:

> What is the preferred way to achieve atomicity in an operation now that
> cli() and sti() are gone?

spin locks.

> The point of asm-generic is not to use the files, but to give porters a
> hint about the functionality. Quoting asm-generic/bitops.h:
> 
> /* For the benefit of those who are trying to port Linux to another
>  * architecture, here are some C-language equivalents.  You should
>  * recode these in the native assembly language, if at all possible.
>  * To guarantee atomicity, these routines call cli() and sti() to
>  * disable interrupts while they operate.  (You have to provide inline
>  * routines to cli() and sti().) */
> 
> Or is this comment wrong, too?

Well, the cli() and sti() part is definitely wrong for 2.5.

It is wrong though to assume that nothing will use these; someone may
copy them directly (and then they do not work) or someone may #include
this file.

I like Arnd's suggestion to just remove these functions and all other
instances of them -- assuming in fact they are never used.

	Robert Love


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

* Re: [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void
  2003-04-15 21:34     ` Robert Love
@ 2003-04-15 22:46       ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2003-04-15 22:46 UTC (permalink / raw)
  To: Robert Love, Carl-Daniel Hailfinger; +Cc: linux-kernel

On Tuesday 15 April 2003 23:34, Robert Love wrote:
> > The point of asm-generic is not to use the files, but to give porters a
> > hint about the functionality. Quoting asm-generic/bitops.h:
> >
> > /* For the benefit of those who are trying to port Linux to another
> >  * architecture, here are some C-language equivalents.  You should
> >  * recode these in the native assembly language, if at all possible.
> >  * To guarantee atomicity, these routines call cli() and sti() to
> >  * disable interrupts while they operate.  (You have to provide inline
> >  * routines to cli() and sti().) */
> >
> > Or is this comment wrong, too?
>
> Well, the cli() and sti() part is definitely wrong for 2.5.
>
> It is wrong though to assume that nothing will use these; someone may
> copy them directly (and then they do not work) or someone may #include
> this file.

AFAICS, the meaning of the asm-generic directory has completely changed
during the 2.4/2.5 timeframe. They are now meant to be included from 
other header files, with the exception of unaligned.h and bitops.h.

These two files are now worthless for the purpose they were meant for. When
someone wants to start a new architecture, the maintained architectures
are the place to look at. For example, the parisc and ia64 implementations 
of bitops.h are both generic enough to be used for a new architecture 
and they actually are SMP safe and complete, while the asm-generic 
variant has been broken since linux-2.0!

> I like Arnd's suggestion to just remove these functions and all other
> instances of them -- assuming in fact they are never used.

I actually meant removing the asm-generic/bitops.h file, not the functions.

	Arnd <><

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

* Re: [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void
  2003-04-15 21:27   ` Carl-Daniel Hailfinger
  2003-04-15 21:34     ` Robert Love
@ 2003-04-23 18:04     ` Pavel Machek
  1 sibling, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2003-04-23 18:04 UTC (permalink / raw)
  To: Carl-Daniel Hailfinger; +Cc: Arnd Bergmann, linux-kernel

Hi!

> > 
> > 
> >>+     mask = 1 << (nr & 0x1f);
> >>+     cli();
> >>+     *addr |= mask;
> >>+     sti();
> > 
> > 
> > cli() and sti() are no more. Moreover, the file you are trying to fix is

No. That file is still usefull.

> What is the preferred way to achieve atomicity in an operation now that
> cli() and sti() are gone?

spin_lock_irqsave(&bitops_lock).

> > not even used anywhere. Better submit a patch to remove it completely.
> 
> The point of asm-generic is not to use the files, but to give porters a
> hint about the functionality. Quoting asm-generic/bitops.h:
> 
> /* For the benefit of those who are trying to port Linux to another
>  * architecture, here are some C-language equivalents.  You should
>  * recode these in the native assembly language, if at all possible.
>  * To guarantee atomicity, these routines call cli() and sti() to
>  * disable interrupts while they operate.  (You have to provide inline
>  * routines to cli() and sti().) */
> 
> Or is this comment wrong, too?
-- 
				Pavel
Written on sharp zaurus, because my Velo1 broke. If you have Velo you don't need...


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

* [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void
@ 2003-04-15 17:36 Carl-Daniel Hailfinger
  0 siblings, 0 replies; 6+ messages in thread
From: Carl-Daniel Hailfinger @ 2003-04-15 17:36 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Linux Kernel Mailing List

Linus,

{set,clear}_bit for all arches no longer return int, but void.
This patch renames the old generic implementations to
test_and_{set,clear}_bit and adds new-style {set,clear}_bit.

Regards,
Carl-Daniel

===== include/asm-generic/bitops.h 1.2 vs edited =====
--- 1.2/include/asm-generic/bitops.h	Fri May  3 02:08:35 2002
+++ edited/include/asm-generic/bitops.h	Thu Apr 10 09:12:41 2003
@@ -16,7 +16,31 @@
  * C language equivalents written by Theodore Ts'o, 9/26/92
  */

+extern __inline__ void set_bit(int nr,long * addr)
+{
+	int	mask;
+
+	addr += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	cli();
+	*addr |= mask;
+	sti();
+	return;
+}
+
+extern __inline__ void clear_bit(int nr, long * addr)
+{
+	int	mask;
+
+	addr += nr >> 5;
+	mask = 1 << (nr & 0x1f);
+	cli();
+	*addr &= ~mask;
+	sti();
+	return;
+}
+
-extern __inline__ int set_bit(int nr,long * addr)
+extern __inline__ int test_and_set_bit(int nr,long * addr)
 {
 	int	mask, retval;

@@ -29,7 +53,7 @@
 	return retval;
 }

-extern __inline__ int clear_bit(int nr, long * addr)
+extern __inline__ int test_and_clear_bit(int nr, long * addr)
 {
 	int	mask, retval;


-- 
Linux scales to much more than 64 CPUs!
See include/linux/smp.h:64
#define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */


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

end of thread, other threads:[~2003-04-27 22:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20030415174010$3e7e@gated-at.bofh.it>
2003-04-15 20:04 ` [PATCH] [2.5] include/asm-generic/bitops.h {set,clear}_bit return void Arnd Bergmann
2003-04-15 21:27   ` Carl-Daniel Hailfinger
2003-04-15 21:34     ` Robert Love
2003-04-15 22:46       ` Arnd Bergmann
2003-04-23 18:04     ` Pavel Machek
2003-04-15 17:36 Carl-Daniel Hailfinger

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).