diff options
Diffstat (limited to 'include/linux/module.h')
-rw-r--r-- | include/linux/module.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 4f7ea12463d3..145a75528cc1 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -219,11 +219,6 @@ void *__symbol_get_gpl(const char *symbol); | |||
219 | 219 | ||
220 | #endif | 220 | #endif |
221 | 221 | ||
222 | struct module_ref | ||
223 | { | ||
224 | local_t count; | ||
225 | } ____cacheline_aligned; | ||
226 | |||
227 | enum module_state | 222 | enum module_state |
228 | { | 223 | { |
229 | MODULE_STATE_LIVE, | 224 | MODULE_STATE_LIVE, |
@@ -344,8 +339,11 @@ struct module | |||
344 | /* Destruction function. */ | 339 | /* Destruction function. */ |
345 | void (*exit)(void); | 340 | void (*exit)(void); |
346 | 341 | ||
347 | /* Reference counts */ | 342 | #ifdef CONFIG_SMP |
348 | struct module_ref ref[NR_CPUS]; | 343 | char *refptr; |
344 | #else | ||
345 | local_t ref; | ||
346 | #endif | ||
349 | #endif | 347 | #endif |
350 | }; | 348 | }; |
351 | #ifndef MODULE_ARCH_INIT | 349 | #ifndef MODULE_ARCH_INIT |
@@ -395,13 +393,21 @@ void __symbol_put(const char *symbol); | |||
395 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) | 393 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) |
396 | void symbol_put_addr(void *addr); | 394 | void symbol_put_addr(void *addr); |
397 | 395 | ||
396 | static inline local_t *__module_ref_addr(struct module *mod, int cpu) | ||
397 | { | ||
398 | #ifdef CONFIG_SMP | ||
399 | return (local_t *) (mod->refptr + per_cpu_offset(cpu)); | ||
400 | #else | ||
401 | return &mod->ref; | ||
402 | #endif | ||
403 | } | ||
404 | |||
398 | /* Sometimes we know we already have a refcount, and it's easier not | 405 | /* Sometimes we know we already have a refcount, and it's easier not |
399 | to handle the error case (which only happens with rmmod --wait). */ | 406 | to handle the error case (which only happens with rmmod --wait). */ |
400 | static inline void __module_get(struct module *module) | 407 | static inline void __module_get(struct module *module) |
401 | { | 408 | { |
402 | if (module) { | 409 | if (module) { |
403 | BUG_ON(module_refcount(module) == 0); | 410 | local_inc(__module_ref_addr(module, get_cpu())); |
404 | local_inc(&module->ref[get_cpu()].count); | ||
405 | put_cpu(); | 411 | put_cpu(); |
406 | } | 412 | } |
407 | } | 413 | } |
@@ -413,7 +419,7 @@ static inline int try_module_get(struct module *module) | |||
413 | if (module) { | 419 | if (module) { |
414 | unsigned int cpu = get_cpu(); | 420 | unsigned int cpu = get_cpu(); |
415 | if (likely(module_is_live(module))) | 421 | if (likely(module_is_live(module))) |
416 | local_inc(&module->ref[cpu].count); | 422 | local_inc(__module_ref_addr(module, cpu)); |
417 | else | 423 | else |
418 | ret = 0; | 424 | ret = 0; |
419 | put_cpu(); | 425 | put_cpu(); |