lkml.org 
[lkml]   [2003]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH/RFC] New module refcounting for net_proto_family
Date
In message <5.1.0.14.2.20030224112723.05a5e640@mail1.qualcomm.com> you write:
> appropriate name for that function. But I can live with __try_module_get() :)
> I'll make new patch for net/socket.c as soon as yours goes in.

Linus, please apply. This is the "module_dup" which Viro wanted, by
another name.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Name: __try_module_get
Author: Rusty Russell
Status: Compile tested on 2.5.63

D: Introduces __try_module_get for places where we know we already hold
D: a reference and ignoring the fact that the module is being "rmmod --wait"ed
D: is simpler.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .22009-linux-2.5.63/include/linux/module.h .22009-linux-2.5.63.updated/include/linux/module.h
--- .22009-linux-2.5.63/include/linux/module.h 2003-02-25 10:11:08.000000000 +1100
+++ .22009-linux-2.5.63.updated/include/linux/module.h 2003-02-25 16:00:53.000000000 +1100
@@ -292,6 +292,16 @@ void symbol_put_addr(void *addr);
#define local_dec(x) atomic_dec(x)
#endif

+/* Sometimes we know we already have a refcount, and it's easier not
+ to handle the error case (which only happens with rmmod --wait). */
+static inline void __try_module_get(struct module *module)
+{
+ if (module) {
+ local_inc(&module->ref[get_cpu()].count);
+ put_cpu();
+ }
+}
+
static inline int try_module_get(struct module *module)
{
int ret = 1;
@@ -327,6 +337,9 @@ static inline int try_module_get(struct
static inline void module_put(struct module *module)
{
}
+static inline void __try_module_get(struct module *module)
+{
+}
#define symbol_put(x) do { } while(0)
#define symbol_put_addr(p) do { } while(0)

@@ -381,6 +394,10 @@ static inline int module_text_address(un
#define symbol_put(x) do { } while(0)
#define symbol_put_addr(x) do { } while(0)

+static inline void __try_module_get(struct module *module)
+{
+}
+
static inline int try_module_get(struct module *module)
{
return 1;
-
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/
\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.052 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site