diff options
Diffstat (limited to 'include/linux/module.h')
| -rw-r--r-- | include/linux/module.h | 76 |
1 files changed, 49 insertions, 27 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 7760c6d344a..bbd77fa05b1 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -21,8 +21,7 @@ | |||
| 21 | #include <linux/percpu.h> | 21 | #include <linux/percpu.h> |
| 22 | #include <asm/module.h> | 22 | #include <asm/module.h> |
| 23 | 23 | ||
| 24 | /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */ | 24 | #include <trace/events/module.h> |
| 25 | #define MODULE_SIG_STRING "~Module signature appended~\n" | ||
| 26 | 25 | ||
| 27 | /* Not Yet Implemented */ | 26 | /* Not Yet Implemented */ |
| 28 | #define MODULE_SUPPORTED_DEVICE(name) | 27 | #define MODULE_SUPPORTED_DEVICE(name) |
| @@ -136,6 +135,11 @@ extern const struct gtype##_id __mod_##gtype##_table \ | |||
| 136 | /* What your module does. */ | 135 | /* What your module does. */ |
| 137 | #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) | 136 | #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description) |
| 138 | 137 | ||
| 138 | /* One for each parameter, describing how to use it. Some files do | ||
| 139 | multiple of these per line, so can't just use MODULE_INFO. */ | ||
| 140 | #define MODULE_PARM_DESC(_parm, desc) \ | ||
| 141 | __MODULE_INFO(parm, _parm, #_parm ":" desc) | ||
| 142 | |||
| 139 | #define MODULE_DEVICE_TABLE(type,name) \ | 143 | #define MODULE_DEVICE_TABLE(type,name) \ |
| 140 | MODULE_GENERIC_TABLE(type##_device,name) | 144 | MODULE_GENERIC_TABLE(type##_device,name) |
| 141 | 145 | ||
| @@ -206,20 +210,6 @@ enum module_state | |||
| 206 | MODULE_STATE_GOING, | 210 | MODULE_STATE_GOING, |
| 207 | }; | 211 | }; |
| 208 | 212 | ||
| 209 | /** | ||
| 210 | * struct module_ref - per cpu module reference counts | ||
| 211 | * @incs: number of module get on this cpu | ||
| 212 | * @decs: number of module put on this cpu | ||
| 213 | * | ||
| 214 | * We force an alignment on 8 or 16 bytes, so that alloc_percpu() | ||
| 215 | * put @incs/@decs in same cache line, with no extra memory cost, | ||
| 216 | * since alloc_percpu() is fine grained. | ||
| 217 | */ | ||
| 218 | struct module_ref { | ||
| 219 | unsigned long incs; | ||
| 220 | unsigned long decs; | ||
| 221 | } __attribute((aligned(2 * sizeof(unsigned long)))); | ||
| 222 | |||
| 223 | struct module | 213 | struct module |
| 224 | { | 214 | { |
| 225 | enum module_state state; | 215 | enum module_state state; |
| @@ -263,11 +253,6 @@ struct module | |||
| 263 | const unsigned long *unused_gpl_crcs; | 253 | const unsigned long *unused_gpl_crcs; |
| 264 | #endif | 254 | #endif |
| 265 | 255 | ||
| 266 | #ifdef CONFIG_MODULE_SIG | ||
| 267 | /* Signature was verified. */ | ||
| 268 | bool sig_ok; | ||
| 269 | #endif | ||
| 270 | |||
| 271 | /* symbols that will be GPL-only in the near future. */ | 256 | /* symbols that will be GPL-only in the near future. */ |
| 272 | const struct kernel_symbol *gpl_future_syms; | 257 | const struct kernel_symbol *gpl_future_syms; |
| 273 | const unsigned long *gpl_future_crcs; | 258 | const unsigned long *gpl_future_crcs; |
| @@ -367,7 +352,10 @@ struct module | |||
| 367 | /* Destruction function. */ | 352 | /* Destruction function. */ |
| 368 | void (*exit)(void); | 353 | void (*exit)(void); |
| 369 | 354 | ||
| 370 | struct module_ref __percpu *refptr; | 355 | struct module_ref { |
| 356 | unsigned int incs; | ||
| 357 | unsigned int decs; | ||
| 358 | } __percpu *refptr; | ||
| 371 | #endif | 359 | #endif |
| 372 | 360 | ||
| 373 | #ifdef CONFIG_CONSTRUCTORS | 361 | #ifdef CONFIG_CONSTRUCTORS |
| @@ -451,18 +439,40 @@ extern void __module_put_and_exit(struct module *mod, long code) | |||
| 451 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); | 439 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); |
| 452 | 440 | ||
| 453 | #ifdef CONFIG_MODULE_UNLOAD | 441 | #ifdef CONFIG_MODULE_UNLOAD |
| 454 | unsigned long module_refcount(struct module *mod); | 442 | unsigned int module_refcount(struct module *mod); |
| 455 | void __symbol_put(const char *symbol); | 443 | void __symbol_put(const char *symbol); |
| 456 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) | 444 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) |
| 457 | void symbol_put_addr(void *addr); | 445 | void symbol_put_addr(void *addr); |
| 458 | 446 | ||
| 459 | /* Sometimes we know we already have a refcount, and it's easier not | 447 | /* Sometimes we know we already have a refcount, and it's easier not |
| 460 | to handle the error case (which only happens with rmmod --wait). */ | 448 | to handle the error case (which only happens with rmmod --wait). */ |
| 461 | extern void __module_get(struct module *module); | 449 | static inline void __module_get(struct module *module) |
| 450 | { | ||
| 451 | if (module) { | ||
| 452 | preempt_disable(); | ||
| 453 | __this_cpu_inc(module->refptr->incs); | ||
| 454 | trace_module_get(module, _THIS_IP_); | ||
| 455 | preempt_enable(); | ||
| 456 | } | ||
| 457 | } | ||
| 458 | |||
| 459 | static inline int try_module_get(struct module *module) | ||
| 460 | { | ||
| 461 | int ret = 1; | ||
| 462 | 462 | ||
| 463 | /* This is the Right Way to get a module: if it fails, it's being removed, | 463 | if (module) { |
| 464 | * so pretend it's not there. */ | 464 | preempt_disable(); |
| 465 | extern bool try_module_get(struct module *module); | 465 | |
| 466 | if (likely(module_is_live(module))) { | ||
| 467 | __this_cpu_inc(module->refptr->incs); | ||
| 468 | trace_module_get(module, _THIS_IP_); | ||
| 469 | } else | ||
| 470 | ret = 0; | ||
| 471 | |||
| 472 | preempt_enable(); | ||
| 473 | } | ||
| 474 | return ret; | ||
| 475 | } | ||
| 466 | 476 | ||
| 467 | extern void module_put(struct module *module); | 477 | extern void module_put(struct module *module); |
| 468 | 478 | ||
| @@ -509,6 +519,9 @@ int unregister_module_notifier(struct notifier_block * nb); | |||
| 509 | 519 | ||
| 510 | extern void print_modules(void); | 520 | extern void print_modules(void); |
| 511 | 521 | ||
| 522 | extern void module_update_tracepoints(void); | ||
| 523 | extern int module_get_iter_tracepoints(struct tracepoint_iter *iter); | ||
| 524 | |||
| 512 | #else /* !CONFIG_MODULES... */ | 525 | #else /* !CONFIG_MODULES... */ |
| 513 | 526 | ||
| 514 | /* Given an address, look for it in the exception tables. */ | 527 | /* Given an address, look for it in the exception tables. */ |
| @@ -619,6 +632,15 @@ static inline int unregister_module_notifier(struct notifier_block * nb) | |||
| 619 | static inline void print_modules(void) | 632 | static inline void print_modules(void) |
| 620 | { | 633 | { |
| 621 | } | 634 | } |
| 635 | |||
| 636 | static inline void module_update_tracepoints(void) | ||
| 637 | { | ||
| 638 | } | ||
| 639 | |||
| 640 | static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter) | ||
| 641 | { | ||
| 642 | return 0; | ||
| 643 | } | ||
| 622 | #endif /* CONFIG_MODULES */ | 644 | #endif /* CONFIG_MODULES */ |
| 623 | 645 | ||
| 624 | #ifdef CONFIG_SYSFS | 646 | #ifdef CONFIG_SYSFS |
