2009-07-08 23:33:12

by Roland Dreier

[permalink] [raw]
Subject: lib: Export generic atomic64_t functions

The generic atomic64_t implementation in lib/ did not export the
functions it defined, which means that modules that use atomic64_t
would not link on platforms (such as 32-bit powerpc). For example,
trying to build a kernel with CONFIG_NET_RDS on such a platform would
fail with:

ERROR: "atomic64_read" [net/rds/rds.ko] undefined!
ERROR: "atomic64_set" [net/rds/rds.ko] undefined!

Fix this by exporting the atomic64_t functions to modules. (I export
the entire API even if it's not all currently used by in-tree modules to
avoid having to continue fixing this in dribs and drabs)

Signed-off-by: Roland Dreier <[email protected]>
---
Didn't see this appear anywhere yet, but I apologize if this duplicates
something already queued. I see that the original implementation went
in through benh's tree but I'm not sure what the appropriate way to
merge this is, so I'll send it to both benh and akpm.

lib/atomic64.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/lib/atomic64.c b/lib/atomic64.c
index c5e7255..8bee16e 100644
--- a/lib/atomic64.c
+++ b/lib/atomic64.c
@@ -13,6 +13,7 @@
#include <linux/cache.h>
#include <linux/spinlock.h>
#include <linux/init.h>
+#include <linux/module.h>
#include <asm/atomic.h>

/*
@@ -52,6 +53,7 @@ long long atomic64_read(const atomic64_t *v)
spin_unlock_irqrestore(lock, flags);
return val;
}
+EXPORT_SYMBOL(atomic64_read);

void atomic64_set(atomic64_t *v, long long i)
{
@@ -62,6 +64,7 @@ void atomic64_set(atomic64_t *v, long long i)
v->counter = i;
spin_unlock_irqrestore(lock, flags);
}
+EXPORT_SYMBOL(atomic64_set);

void atomic64_add(long long a, atomic64_t *v)
{
@@ -72,6 +75,7 @@ void atomic64_add(long long a, atomic64_t *v)
v->counter += a;
spin_unlock_irqrestore(lock, flags);
}
+EXPORT_SYMBOL(atomic64_add);

long long atomic64_add_return(long long a, atomic64_t *v)
{
@@ -84,6 +88,7 @@ long long atomic64_add_return(long long a, atomic64_t *v)
spin_unlock_irqrestore(lock, flags);
return val;
}
+EXPORT_SYMBOL(atomic64_add_return);

void atomic64_sub(long long a, atomic64_t *v)
{
@@ -94,6 +99,7 @@ void atomic64_sub(long long a, atomic64_t *v)
v->counter -= a;
spin_unlock_irqrestore(lock, flags);
}
+EXPORT_SYMBOL(atomic64_sub);

long long atomic64_sub_return(long long a, atomic64_t *v)
{
@@ -106,6 +112,7 @@ long long atomic64_sub_return(long long a, atomic64_t *v)
spin_unlock_irqrestore(lock, flags);
return val;
}
+EXPORT_SYMBOL(atomic64_sub_return);

long long atomic64_dec_if_positive(atomic64_t *v)
{
@@ -120,6 +127,7 @@ long long atomic64_dec_if_positive(atomic64_t *v)
spin_unlock_irqrestore(lock, flags);
return val;
}
+EXPORT_SYMBOL(atomic64_dec_if_positive);

long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n)
{
@@ -134,6 +142,7 @@ long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n)
spin_unlock_irqrestore(lock, flags);
return val;
}
+EXPORT_SYMBOL(atomic64_cmpxchg);

long long atomic64_xchg(atomic64_t *v, long long new)
{
@@ -147,6 +156,7 @@ long long atomic64_xchg(atomic64_t *v, long long new)
spin_unlock_irqrestore(lock, flags);
return val;
}
+EXPORT_SYMBOL(atomic64_xchg);

int atomic64_add_unless(atomic64_t *v, long long a, long long u)
{
@@ -162,6 +172,7 @@ int atomic64_add_unless(atomic64_t *v, long long a, long long u)
spin_unlock_irqrestore(lock, flags);
return ret;
}
+EXPORT_SYMBOL(atomic64_add_unless);

static int init_atomic64_lock(void)
{


2009-07-09 01:09:39

by Paul Mackerras

[permalink] [raw]
Subject: Re: lib: Export generic atomic64_t functions

Roland Dreier writes:

> The generic atomic64_t implementation in lib/ did not export the
> functions it defined, which means that modules that use atomic64_t
> would not link on platforms (such as 32-bit powerpc). For example,
> trying to build a kernel with CONFIG_NET_RDS on such a platform would
> fail with:
>
> ERROR: "atomic64_read" [net/rds/rds.ko] undefined!
> ERROR: "atomic64_set" [net/rds/rds.ko] undefined!
>
> Fix this by exporting the atomic64_t functions to modules. (I export
> the entire API even if it's not all currently used by in-tree modules to
> avoid having to continue fixing this in dribs and drabs)
>
> Signed-off-by: Roland Dreier <[email protected]>

Nice, thanks.

Acked-by: Paul Mackerras <[email protected]>

Andrew, I think this should be safe to go in 2.6.31. Could you
include it in your next batch for Linus, or should I send it to him
directly?

Paul.

2009-07-21 23:35:47

by Andrew Morton

[permalink] [raw]
Subject: Re: lib: Export generic atomic64_t functions

On Thu, 9 Jul 2009 11:09:24 +1000
Paul Mackerras <[email protected]> wrote:

> Roland Dreier writes:
>
> > The generic atomic64_t implementation in lib/ did not export the
> > functions it defined, which means that modules that use atomic64_t
> > would not link on platforms (such as 32-bit powerpc). For example,
> > trying to build a kernel with CONFIG_NET_RDS on such a platform would
> > fail with:
> >
> > ERROR: "atomic64_read" [net/rds/rds.ko] undefined!
> > ERROR: "atomic64_set" [net/rds/rds.ko] undefined!
> >
> > Fix this by exporting the atomic64_t functions to modules. (I export
> > the entire API even if it's not all currently used by in-tree modules to
> > avoid having to continue fixing this in dribs and drabs)
> >
> > Signed-off-by: Roland Dreier <[email protected]>
>
> Nice, thanks.
>
> Acked-by: Paul Mackerras <[email protected]>
>
> Andrew, I think this should be safe to go in 2.6.31. Could you
> include it in your next batch for Linus, or should I send it to him
> directly?
>

Am still catching up, sorry. Yup, I put this in my 2.6.31 queue.