All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: Question on atomic_inc/dec
@ 2003-10-14 21:17 Perez-Gonzalez, Inaky
  2003-10-14 21:34 ` sankar
  2003-10-14 21:44 ` Tim Hockin
  0 siblings, 2 replies; 9+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-14 21:17 UTC (permalink / raw)
  To: sankar, linux-kernel

> From: sankar
> 
> Hi,
> I have a question concerning the macro atomic_inc on REDHAT 9.0. I had used
> atomic_inc on REDHAT 7.2 earlier. I installed redhat 9.0 and tried to run my
> old code on this. I got the error saying atomic_inc not declared.
> 
> I tried to search the header file in which this is defined but with failure.

Seems you were using a kernel definition of a function (this 
normally happens only because it was out there by mistake,
or because you had __KERNEL__ #defined).

It will be in include/asm/atomic.h; however, it is not wise to
use directly the kernel stuff unless you are coding kernel stuff.

You can always strip them, of course :)

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)

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

* Re: Question on atomic_inc/dec
  2003-10-14 21:17 Question on atomic_inc/dec Perez-Gonzalez, Inaky
@ 2003-10-14 21:34 ` sankar
  2003-10-14 21:44 ` Tim Hockin
  1 sibling, 0 replies; 9+ messages in thread
From: sankar @ 2003-10-14 21:34 UTC (permalink / raw)
  To: Perez-Gonzalez, Inaky, linux-kernel

Thx for the reply...
The definition for atomic_inc() used to be there in asm/atomic.h on redhat
versions 7.2..
But on redhat ver 9.0 asm/atomic.h does not have the definition for
atomic_inc().
Is it moved to anyother file on redhat 9.0??

Pls reply...
----- Original Message -----
From: "Perez-Gonzalez, Inaky" <inaky.perez-gonzalez@intel.com>
To: "sankar" <san_madhav@hotmail.com>; <linux-kernel@vger.kernel.org>
Sent: Tuesday, October 14, 2003 2:17 PM
Subject: RE: Question on atomic_inc/dec


> From: sankar
>
> Hi,
> I have a question concerning the macro atomic_inc on REDHAT 9.0. I had
used
> atomic_inc on REDHAT 7.2 earlier. I installed redhat 9.0 and tried to run
my
> old code on this. I got the error saying atomic_inc not declared.
>
> I tried to search the header file in which this is defined but with
failure.

Seems you were using a kernel definition of a function (this
normally happens only because it was out there by mistake,
or because you had __KERNEL__ #defined).

It will be in include/asm/atomic.h; however, it is not wise to
use directly the kernel stuff unless you are coding kernel stuff.

You can always strip them, of course :)

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)

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

* Re: Question on atomic_inc/dec
  2003-10-14 21:17 Question on atomic_inc/dec Perez-Gonzalez, Inaky
  2003-10-14 21:34 ` sankar
@ 2003-10-14 21:44 ` Tim Hockin
  2003-10-14 22:35   ` David S. Miller
  2003-10-15  7:57   ` Arjan van de Ven
  1 sibling, 2 replies; 9+ messages in thread
From: Tim Hockin @ 2003-10-14 21:44 UTC (permalink / raw)
  To: Perez-Gonzalez, Inaky; +Cc: sankar, linux-kernel

On Tue, Oct 14, 2003 at 02:17:49PM -0700, Perez-Gonzalez, Inaky wrote:
> It will be in include/asm/atomic.h; however, it is not wise to
> use directly the kernel stuff unless you are coding kernel stuff.

Is there any reason NOT to use the atomic ops in user-space?  I mean, are
they privileged on some architectures, or ...?  It seems like some
user-space apps might really benefit from simple atomic ops.  Or at least,
kernel-coders writing in userspace could sure use simple atomic ops :)

Tim

-- 
Notice that as computers are becoming easier and easier to use,
suddenly there's a big market for "Dummies" books.  Cause and effect,
or merely an ironic juxtaposition of unrelated facts?


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

* Re: Question on atomic_inc/dec
  2003-10-14 21:44 ` Tim Hockin
@ 2003-10-14 22:35   ` David S. Miller
  2003-10-15  7:57   ` Arjan van de Ven
  1 sibling, 0 replies; 9+ messages in thread
From: David S. Miller @ 2003-10-14 22:35 UTC (permalink / raw)
  To: Tim Hockin; +Cc: inaky.perez-gonzalez, san_madhav, linux-kernel

On Tue, 14 Oct 2003 14:44:37 -0700
Tim Hockin <thockin@hockin.org> wrote:

> Is there any reason NOT to use the atomic ops in user-space?  I mean, are
> they privileged on some architectures, or ...?

Yes, they are.  Some use interrupt disabling and a spinlock inside
the kernel to implement the atomicity.

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

* Re: Question on atomic_inc/dec
  2003-10-14 21:44 ` Tim Hockin
  2003-10-14 22:35   ` David S. Miller
@ 2003-10-15  7:57   ` Arjan van de Ven
  1 sibling, 0 replies; 9+ messages in thread
From: Arjan van de Ven @ 2003-10-15  7:57 UTC (permalink / raw)
  To: Tim Hockin; +Cc: Perez-Gonzalez, Inaky, sankar, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]

On Tue, 2003-10-14 at 23:44, Tim Hockin wrote:
> On Tue, Oct 14, 2003 at 02:17:49PM -0700, Perez-Gonzalez, Inaky wrote:
> > It will be in include/asm/atomic.h; however, it is not wise to
> > use directly the kernel stuff unless you are coding kernel stuff.
> 
> Is there any reason NOT to use the atomic ops in user-space? 

also the /usr/include/asm/atomic.h versions never were actually atomic!
Those being actually atomic depends on CONFIG_SMP defined, which for
userspace... well you get the picture.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* RE: Question on atomic_inc/dec
@ 2003-10-15 17:38 Perez-Gonzalez, Inaky
  0 siblings, 0 replies; 9+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-15 17:38 UTC (permalink / raw)
  To: sankar, Tim Hockin; +Cc: linux-kernel

> From: sankar [mailto:san_madhav@hotmail.com]

>  any solution to the original problem???
> (atomic_inc() defintion not there in redhat 9.0 asm/atomic.h)

Create an atomic.h header file in your source tree with the code
below, but bear in mind that porting to other arches might be painful:

struct atomic
{
  volatile int i;
}

  /* Simple atomic increment. */

static inline
void atomic_inc (struct atomic *a)
{
    asm volatile (
      "lock; incl %0"
      : "=m" (a->i)
      : "m" (a->i));
}

  /* Simple atomic decrement. */

static inline
void atomic_dec (struct atomic *a)
{
    asm volatile (
      "lock; decl %0"
      : "=m" (a->i)
      : "m" (a->i));
}

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)


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

* Re: Question on atomic_inc/dec
  2003-10-14 22:29 Perez-Gonzalez, Inaky
@ 2003-10-15 17:28 ` sankar
  0 siblings, 0 replies; 9+ messages in thread
From: sankar @ 2003-10-15 17:28 UTC (permalink / raw)
  To: Perez-Gonzalez, Inaky, Tim Hockin; +Cc: linux-kernel

Hi,
 any solution to the original problem???
(atomic_inc() defintion not there in redhat 9.0 asm/atomic.h)
----- Original Message -----
From: "Perez-Gonzalez, Inaky" <inaky.perez-gonzalez@intel.com>
To: "Tim Hockin" <thockin@hockin.org>
Cc: "sankar" <san_madhav@hotmail.com>; <linux-kernel@vger.kernel.org>
Sent: Tuesday, October 14, 2003 3:29 PM
Subject: RE: Question on atomic_inc/dec


> From: Tim Hockin [mailto:thockin@hockin.org]
>
> On Tue, Oct 14, 2003 at 02:17:49PM -0700, Perez-Gonzalez, Inaky wrote:
> > It will be in include/asm/atomic.h; however, it is not wise to
> > use directly the kernel stuff unless you are coding kernel stuff.
>
> Is there any reason NOT to use the atomic ops in user-space?  I mean, are
> they privileged on some architectures, or ...?  It seems like some
> user-space apps might really benefit from simple atomic ops.  Or at least,
> kernel-coders writing in userspace could sure use simple atomic ops :)

Well, you are right; functionally speaking, there are no concerns,
however, there are problems.

Not all architectures have really simple atomic operations like
for example, ia32 or PPC. For example, Sparc has to do this ugly
spinlock thinguie and that's why you can only count on 24 bits
out of the whole atomic data type; another example is ARM,
you just disables irqs and preemption, I guess, and operates), there
is no way they will work in user space

When you have implementations like this, where ia32 is one of the
lucky exceptions because you can do it with a couple of asm opcodes,
it is really impossible to offer something that can float up to
user space.

PS: hey, how's Mike doing? Say hi from me, pls

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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

* RE: Question on atomic_inc/dec
@ 2003-10-14 22:29 Perez-Gonzalez, Inaky
  2003-10-15 17:28 ` sankar
  0 siblings, 1 reply; 9+ messages in thread
From: Perez-Gonzalez, Inaky @ 2003-10-14 22:29 UTC (permalink / raw)
  To: Tim Hockin; +Cc: sankar, linux-kernel

> From: Tim Hockin [mailto:thockin@hockin.org]
> 
> On Tue, Oct 14, 2003 at 02:17:49PM -0700, Perez-Gonzalez, Inaky wrote:
> > It will be in include/asm/atomic.h; however, it is not wise to
> > use directly the kernel stuff unless you are coding kernel stuff.
> 
> Is there any reason NOT to use the atomic ops in user-space?  I mean, are
> they privileged on some architectures, or ...?  It seems like some
> user-space apps might really benefit from simple atomic ops.  Or at least,
> kernel-coders writing in userspace could sure use simple atomic ops :)

Well, you are right; functionally speaking, there are no concerns,
however, there are problems.

Not all architectures have really simple atomic operations like
for example, ia32 or PPC. For example, Sparc has to do this ugly 
spinlock thinguie and that's why you can only count on 24 bits 
out of the whole atomic data type; another example is ARM,
you just disables irqs and preemption, I guess, and operates), there
is no way they will work in user space

When you have implementations like this, where ia32 is one of the 
lucky exceptions because you can do it with a couple of asm opcodes,
it is really impossible to offer something that can float up to
user space.

PS: hey, how's Mike doing? Say hi from me, pls

Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own (and my fault)

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

* Question on atomic_inc/dec
@ 2003-10-14 18:38 sankar
  0 siblings, 0 replies; 9+ messages in thread
From: sankar @ 2003-10-14 18:38 UTC (permalink / raw)
  To: linux-kernel

Hi,
I have a question concerning the macro atomic_inc on REDHAT 9.0. I had used
atomic_inc on REDHAT 7.2 earlier. I installed redhat 9.0 and tried to run my
old code on this. I got the error saying atomic_inc not declared.

I tried to search the header file in which this is defined but with failure.

If any of u guys know about this problem pls help me ...

thx in advance
Sankarshana M

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

end of thread, other threads:[~2003-10-15 17:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-14 21:17 Question on atomic_inc/dec Perez-Gonzalez, Inaky
2003-10-14 21:34 ` sankar
2003-10-14 21:44 ` Tim Hockin
2003-10-14 22:35   ` David S. Miller
2003-10-15  7:57   ` Arjan van de Ven
  -- strict thread matches above, loose matches on Subject: below --
2003-10-15 17:38 Perez-Gonzalez, Inaky
2003-10-14 22:29 Perez-Gonzalez, Inaky
2003-10-15 17:28 ` sankar
2003-10-14 18:38 sankar

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.