08 Oct, 2010
1 commit
-
Conflicts:
arch/x86/kernel/module.cMerge reason: Resolve the conflict, pick up fixes.
Signed-off-by: Ingo Molnar
06 Oct, 2010
1 commit
-
With all the recent module loading cleanups, we've minimized the code
that sits under module_mutex, fixing various deadlocks and making it
possible to do most of the module loading in parallel.However, that whole conversion totally missed the rather obscure code
that adds a new module to the list for BUG() handling. That code was
doubly obscure because (a) the code itself lives in lib/bugs.c (for
dubious reasons) and (b) it gets called from the architecture-specific
"module_finalize()" rather than from generic code.Calling it from arch-specific code makes no sense what-so-ever to begin
with, and is now actively wrong since that code isn't protected by the
module loading lock any more.So this commit moves the "module_bug_{finalize,cleanup}()" calls away
from the arch-specific code, and into the generic code - and in the
process protects it with the module_mutex so that the list operations
are now safe.Future fixups:
- move the module list handling code into kernel/module.c where it
belongs.
- get rid of 'module_bug_list' and just use the regular list of modules
(called 'modules' - imagine that) that we already create and maintain
for other reasons.Reported-and-tested-by: Thomas Gleixner
Cc: Rusty Russell
Cc: Adrian Bunk
Cc: Andrew Morton
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds
23 Sep, 2010
1 commit
-
base patch to implement 'jump labeling'. Based on a new 'asm goto' inline
assembly gcc mechanism, we can now branch to labels from an 'asm goto'
statment. This allows us to create a 'no-op' fastpath, which can subsequently
be patched with a jump to the slowpath code. This is useful for code which
might be rarely used, but which we'd like to be able to call, if needed.
Tracepoints are the current usecase that these are being implemented for.Acked-by: David S. Miller
Signed-off-by: Jason Baron
LKML-Reference:[ cleaned up some formating ]
Signed-off-by: Steven Rostedt
05 Jun, 2010
3 commits
-
These were placed in the header in ef665c1a06 to get the various
SYSFS/MODULE config combintations to compile.That may have been necessary then, but it's not now. These functions
are all local to module.c.Signed-off-by: Rusty Russell
Cc: Randy Dunlap -
Linus changed the structure, and luckily this didn't compile any more.
Reported-by: Stephen Rothwell
Signed-off-by: Rusty Russell
Cc: Jason Wessel
Cc: Martin Hicks -
When adding a module that depends on another one, we used to create a
one-way list of "modules_which_use_me", so that module unloading could
see who needs a module.It's actually quite simple to make that list go both ways: so that we
not only can see "who uses me", but also see a list of modules that are
"used by me".In fact, we always wanted that list in "module_unload_free()": when we
unload a module, we want to also release all the other modules that are
used by that module. But because we didn't have that list, we used to
first iterate over all modules, and then iterate over each "used by me"
list of that module.By making the list two-way, we simplify module_unload_free(), and it
allows for some trivial fixes later too.Signed-off-by: Linus Torvalds
Signed-off-by: Rusty Russell (cleaned & rebased)
08 Apr, 2010
1 commit
-
Conflicts:
include/linux/module.h
kernel/module.cSemantic conflict:
include/trace/events/module.hMerge reason: Resolve the conflict with upstream commit 5fbfb18 ("Fix up
possibly racy module refcounting")Signed-off-by: Ingo Molnar
06 Apr, 2010
1 commit
-
Module refcounting is implemented with a per-cpu counter for speed.
However there is a race when tallying the counter where a reference may
be taken by one CPU and released by another. Reference count summation
may then see the decrement without having seen the previous increment,
leading to lower than expected count. A module which never has its
actual reference drop below 1 may return a reference count of 0 due to
this race.Module removal generally runs under stop_machine, which prevents this
race causing bugs due to removal of in-use modules. However there are
other real bugs in module.c code and driver code (module_refcount is
exported) where the callers do not run under stop_machine.Fix this by maintaining running per-cpu counters for the number of
module refcount increments and the number of refcount decrements. The
increments are tallied after the decrements, so any decrement seen will
always have its corresponding increment counted. The final refcount is
the difference of the total increments and decrements, preventing a
low-refcount from being returned.Signed-off-by: Nick Piggin
Acked-by: Rusty Russell
Signed-off-by: Linus Torvalds
01 Apr, 2010
1 commit
-
Remove the @refcnt argument, because it has side-effects, and arguments with
side-effects are not skipped by the jump over disabled instrumentation and are
executed even when the tracepoint is disabled.This was also causing a GPF as found by Randy Dunlap:
Subject: 2.6.33 GP fault only when built with tracing
LKML-Reference:Note, the current 2.6.34-rc has a fix for the actual cause of the GPF,
but this fixes one of its triggers.Tested-by: Randy Dunlap
Acked-by: Mathieu Desnoyers
Signed-off-by: Li Zefan
LKML-Reference:
Signed-off-by: Steven Rostedt
31 Mar, 2010
1 commit
-
Fix build for CONFIG_MODULES not enabled by providing a stub
for is_module_percpu_address().kernel/lockdep.c:605: error: implicit declaration of function 'is_module_percpu_address'
Signed-off-by: Randy Dunlap
Signed-off-by: Tejun Heo
29 Mar, 2010
2 commits
-
lockdep has custom code to check whether a pointer belongs to static
percpu area which is somewhat broken. Implement proper
is_kernel/module_percpu_address() and replace the custom code.On UP, percpu variables are regular static variables and can't be
distinguished from them. Always return %false on UP.Signed-off-by: Tejun Heo
Acked-by: Peter Zijlstra
Cc: Rusty Russell
Cc: Ingo Molnar -
Better encapsulate module static percpu area handling so that code
outsidef of CONFIG_SMP ifdef doesn't deal with mod->percpu directly
and add mod->percpu_size and record percpu_size in it. Both percpu
fields are compiled out on UP. While at it, mark mod->percpu w/
__percpu.This is to prepare for is_module_percpu_address().
Signed-off-by: Tejun Heo
Acked-by: Rusty Russell
13 Mar, 2010
1 commit
-
Extern declarations in sysctl.c should be moved to their own header file,
and then include them in relavant .c files.Move modprobe_path extern declaration to linux/kmod.h
Move modules_disabled extern declaration to linux/module.hSigned-off-by: Dave Young
Cc: Rusty Russell
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
17 Feb, 2010
1 commit
-
Add __percpu sparse annotations to core subsystems.
These annotations are to make sparse consider percpu variables to be
in a different address space and warn if accessed without going
through percpu accessors. This patch doesn't affect normal builds.Signed-off-by: Tejun Heo
Reviewed-by: Christoph Lameter
Acked-by: Paul E. McKenney
Cc: Jens Axboe
Cc: linux-mm@kvack.org
Cc: Rusty Russell
Cc: Dipankar Sarma
Cc: Peter Zijlstra
Cc: Andrew Morton
Cc: Eric Biederman
05 Jan, 2010
2 commits
-
ringbuffer*.c are the last users of local.h.
Remove the include from modules.h and add it to ringbuffer files.
Signed-off-by: Christoph Lameter
Signed-off-by: Tejun Heo -
Use cpu ops to deal with the per cpu data instead of a local_t. Reduces memory
requirements, cache footprint and decreases cycle counts.The this_cpu_xx operations are also used for !SMP mode. Otherwise we could
not drop the use of __module_ref_addr() which would make per cpu data handling
complicated. this_cpu_xx operations have their own fallback for !SMP.V8-V9:
- Leave include asm/module.h since ringbuffer.c depends on it. Nothing else
does though. Another patch will deal with that.
- Remove spurious free.Signed-off-by: Christoph Lameter
Acked-by: Rusty Russell
Signed-off-by: Tejun Heo
15 Dec, 2009
1 commit
-
The next commit will require the use of MODULE_SYMBOL_PREFIX in
.tmp_exports-asm.S. Currently it is mixed in with C structure
definitions in "asm/module.h". Move the definition of this arch option
into Kconfig, so it can be easily accessed by any code.This also lets modpost.c use the same definition. Previously modpost
relied on a hardcoded list of architectures in mk_elfconfig.c.A build test for blackfin, one of the two MODULE_SYMBOL_PREFIX archs,
showed the generated code was unchanged. vmlinux was identical save
for build ids, and an apparently randomized suffix on a single "__key"
symbol in the kallsyms data).Signed-off-by: Alan Jenkins
Acked-by: Mike Frysinger (blackfin)
CC: Sam Ravnborg
Signed-off-by: Rusty Russell
24 Sep, 2009
3 commits
-
For the longest time now we've been using multiple MODULE_AUTHOR()
statements when a module has more than one author, but the comment here
disagrees.Signed-off-by: Johannes Berg
Cc: Jiri Kosina
Cc: Luciano Coelho
Signed-off-by: Andrew Morton
Signed-off-by: Rusty Russell -
Also remove all parts of the string table (referenced by the symbol
table) that are not needed for kallsyms use (i.e. which were only
referenced by symbols discarded by the previous patch, or not
referenced at all for whatever reason).Signed-off-by: Jan Beulich
Signed-off-by: Rusty Russell -
Discard all symbols not interesting for kallsyms use: absolute,
section, and in the common case (!KALLSYMS_ALL) data ones.Signed-off-by: Jan Beulich
Signed-off-by: Rusty Russell
19 Sep, 2009
1 commit
-
Now that the last users of markers have migrated to the event
tracer we can kill off the (now orphan) support code.Signed-off-by: Christoph Hellwig
Acked-by: Mathieu Desnoyers
Cc: Steven Rostedt
Cc: Frederic Weisbecker
LKML-Reference:
Signed-off-by: Ingo Molnar
17 Aug, 2009
1 commit
-
Add trace points to trace module_load, module_free, module_get,
module_put and module_request, and use trace_event facility to
get the trace output.Here's the sample output:
TASK-PID CPU# TIMESTAMP FUNCTION
| | | | |
-42 [000] 1.758380: module_request: fb0 wait=1 call_site=fb_open
...
-60 [000] 3.269403: module_load: scsi_wait_scan
-60 [000] 3.269432: module_put: scsi_wait_scan call_site=sys_init_module refcnt=0
-61 [001] 3.273168: module_free: scsi_wait_scan
...
-1021 [000] 13.836081: module_load: sunrpc
-1021 [000] 13.840589: module_put: sunrpc call_site=sys_init_module refcnt=-1
-1027 [000] 13.848098: module_get: sunrpc call_site=try_module_get refcnt=0
-1027 [000] 13.848308: module_get: sunrpc call_site=get_filesystem refcnt=1
-1027 [000] 13.848692: module_put: sunrpc call_site=put_filesystem refcnt=0
...
modprobe-2587 [001] 1088.437213: module_load: trace_events_sample F
modprobe-2587 [001] 1088.437786: module_put: trace_events_sample call_site=sys_init_module refcnt=0Note:
- the taints flag can be 'F', 'C' and/or 'P' if mod->taints != 0
- the module refcnt is percpu, so it can be negative in a
specific cpuSigned-off-by: Li Zefan
Acked-by: Rusty Russell
Cc: Steven Rostedt
Cc: Frederic Weisbecker
Cc: Rusty Russell
LKML-Reference:
Signed-off-by: Ingo Molnar
19 Jun, 2009
1 commit
-
Call constructors (gcc-generated initcall-like functions) during kernel
start and module load. Constructors are e.g. used for gcov data
initialization.Disable constructor support for usermode Linux to prevent conflicts with
host glibc.Signed-off-by: Peter Oberparleiter
Acked-by: Rusty Russell
Acked-by: WANG Cong
Cc: Sam Ravnborg
Cc: Jeff Dike
Cc: Andi Kleen
Cc: Huang Ying
Cc: Li Wei
Cc: Michael Ellerman
Cc: Ingo Molnar
Cc: Heiko Carstens
Cc: Martin Schwidefsky
Cc: Al Viro
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
17 Jun, 2009
1 commit
-
They're in linux/bug.h at present, which causes include order tangles. In
particular, linux/bug.h cannot be used by linux/atomic.h because,
according to Nikanth:linux/bug.h pulls in linux/module.h => linux/spinlock.h => asm/spinlock.h
(which uses atomic_inc) => asm/atomic.h.bug.h is a pretty low-level thing and module.h is a higher-level thing,
IMO.Cc: Nikanth Karthikesan
Cc: Rusty Russell
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
12 Jun, 2009
1 commit
-
It's theoretically possible that there are exception table entries
which point into the (freed) init text of modules. These could cause
future problems if other modules get loaded into that memory and cause
an exception as we'd see the wrong fixup. The only case I know of is
kvm-intel.ko (when CONFIG_CC_OPTIMIZE_FOR_SIZE=n).Amerigo fixed this long-standing FIXME in the x86 version, but this
patch is more general.This implements trim_init_extable(); most archs are simple since they
use the standard lib/extable.c sort code. Alpha and IA64 use relative
addresses in their fixups, so thier trimming is a slight variation.Sparc32 is unique; it doesn't seem to define ARCH_HAS_SORT_EXTABLE,
yet it defines its own sort_extable() which overrides the one in lib.
It doesn't sort, so we have to mark deleted entries instead of
actually trimming them.Inspired-by: Amerigo Wang
Signed-off-by: Rusty Russell
Cc: linux-alpha@vger.kernel.org
Cc: sparclinux@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
17 Apr, 2009
1 commit
-
The hooks in the module code for the function tracer must be called
before any of that module code runs. The function tracer hooks
modify the module (replacing calls to mcount to nops). If the code
is executed while the change occurs, then the CPU can take a GPF.To handle the above with a bit of paranoia, I originally implemented
the hooks as calls directly from the module code.After examining the notifier calls, it looks as though the start up
notify is called before any of the module's code is executed. This makes
the use of the notify safe with ftrace.Only the startup notify is required to be "safe". The shutdown simply
removes the entries from the ftrace function list, and does not modify
any code.This change has another benefit. It removes a issue with a reverse dependency
in the mutexes of ftrace_lock and module_mutex.[ Impact: fix lock dependency bug, cleanup ]
Cc: Rusty Russell
Signed-off-by: Steven Rostedt
15 Apr, 2009
1 commit
-
Impact: allow modules to add TRACE_EVENTS on load
This patch adds the final hooks to allow modules to use the TRACE_EVENT
macro. A notifier and a data structure are used to link the TRACE_EVENTs
defined in the module to connect them with the ftrace event tracing system.It also adds the necessary automated clean ups to the trace events when a
module is removed.Cc: Rusty Russell
Signed-off-by: Steven Rostedt
06 Apr, 2009
1 commit
-
* 'tracing-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (413 commits)
tracing, net: fix net tree and tracing tree merge interaction
tracing, powerpc: fix powerpc tree and tracing tree interaction
ring-buffer: do not remove reader page from list on ring buffer free
function-graph: allow unregistering twice
trace: make argument 'mem' of trace_seq_putmem() const
tracing: add missing 'extern' keywords to trace_output.h
tracing: provide trace_seq_reserve()
blktrace: print out BLK_TN_MESSAGE properly
blktrace: extract duplidate code
blktrace: fix memory leak when freeing struct blk_io_trace
blktrace: fix blk_probes_ref chaos
blktrace: make classic output more classic
blktrace: fix off-by-one bug
blktrace: fix the original blktrace
blktrace: fix a race when creating blk_tree_root in debugfs
blktrace: fix timestamp in binary output
tracing, Text Edit Lock: cleanup
tracing: filter fix for TRACE_EVENT_FORMAT events
ftrace: Using FTRACE_WARN_ON() to check "freed record" in ftrace_release()
x86: kretprobe-booster interrupt emulation code fix
...Fix up trivial conflicts in
arch/parisc/include/asm/ftrace.h
include/linux/memory.h
kernel/extable.c
kernel/module.c
31 Mar, 2009
5 commits
-
Impact: Expose some module.c symbols
Ksplice uses several functions from module.c in order to resolve
symbols and implement dependency handling. Calling these functions
requires holding module_mutex, so it is exported.(This is just the module part of a bigger add-exports patch from Tim).
Cc: Anders Kaseorg
Cc: Jeff Arnold
Signed-off-by: Tim Abbott
Signed-off-by: Rusty Russell -
Impact: New API
kallsyms_lookup_name only returns the first match that it finds. Ksplice
needs information about all symbols with a given name in order to correctly
resolve local symbols.kallsyms_on_each_symbol provides a generic mechanism for iterating over the
kallsyms table.Cc: Jeff Arnold
Cc: Tim Abbott
Signed-off-by: Anders Kaseorg
Signed-off-by: Rusty Russell -
Impact: Replace and remove risky (non-EXPORTed) API
module_text_address() returns a pointer to the module, which given locking
improvements in module.c, is useless except to test for NULL:1) If the module can't go away, use __module_text_address.
2) Otherwise, just use is_module_text_address().Cc: linux-mtd@lists.infradead.org
Signed-off-by: Rusty Russell -
Impact: New API, cleanup
ksplice wants to know the bounds of a module, not just the module text.
It makes sense to have __module_address. We then implement
is_module_address and __module_text_address in terms of this (and
change is_module_text_address() to bool while we're at it).Also, add proper kerneldoc for them all.
Cc: Anders Kaseorg
Cc: Jeff Arnold
Cc: Tim Abbott
Signed-off-by: Rusty Russell -
Impact: fix crash on reading from /sys/module/.../ieee80211_default_rc_algo
The module_param type "charp" simply sets a char * pointer in the
module to the parameter in the commandline string: this is why we keep
the (mangled) module command line around. But when set via sysfs (as
about 11 charp parameters can be) this memory is freed on the way
out of the write(). Future reads hit random mem.So we kstrdup instead: we have to check we're not in early commandline
parsing, and we have to note when we've used it so we can reliably
kfree the parameter when it's next overwritten, and also on module
unload.(Thanks to Randy Dunlap for CONFIG_SYSFS=n fixes)
Reported-by: Sitsofe Wheeler
Diagnosed-by: Frederic Weisbecker
Tested-by: Frederic Weisbecker
Tested-by: Christof Schmitt
Signed-off-by: Rusty Russell
07 Mar, 2009
2 commits
-
Impact: faster and lighter tracing
Now that we have trace_bprintk() which is faster and consume lesser
memory than trace_printk() and has the same purpose, we can now drop
the old implementation in favour of the binary one from trace_bprintk(),
which means we move all the implementation of trace_bprintk() to
trace_printk(), so the Api doesn't change except that we must now use
trace_seq_bprintk() to print the TRACE_PRINT entries.Some changes result of this:
- Previously, trace_bprintk depended of a single tracer and couldn't
work without. This tracer has been dropped and the whole implementation
of trace_printk() (like the module formats management) is now integrated
in the tracing core (comes with CONFIG_TRACING), though we keep the file
trace_printk (previously trace_bprintk.c) where we can find the module
management. Thus we don't overflow trace.c- changes some parts to use trace_seq_bprintk() to print TRACE_PRINT entries.
- change a bit trace_printk/trace_vprintk macros to support non-builtin formats
constants, and fix 'const' qualifiers warnings. But this is all transparent for
developers.- etc...
V2:
- Rebase against last changes
- Fix mispell on the changelogV3:
- Rebase against last changes (moving trace_printk() to kernel.h)
Signed-off-by: Frederic Weisbecker
Acked-by: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar -
Impact: add a generic printk() for tracing, like trace_printk()
trace_bprintk() uses the infrastructure to record events on ring_buffer.
[ fweisbec@gmail.com: ported to latest -tip, made it work if
!CONFIG_MODULES, never free the format strings from modules
because we can't keep track of them and conditionnaly create
the ftrace format strings section (reported by Steven Rostedt) ]Signed-off-by: Lai Jiangshan
Signed-off-by: Frederic Weisbecker
Acked-by: Steven Rostedt
LKML-Reference:
Signed-off-by: Ingo Molnar
08 Feb, 2009
1 commit
-
Impact: fix spurious BUG_ON() triggered under load
module_refcount() isn't reliable outside stop_machine(), as demonstrated
by Karsten Keil , networking can trigger it under load
(an inc on one cpu and dec on another while module_refcount() is tallying
can give false results, for example).Almost noone should be using __module_get, but that's another issue.
Cc: Karsten Keil
Signed-off-by: Rusty Russell
Signed-off-by: Linus Torvalds
03 Feb, 2009
1 commit
-
Current refcounting for modules (done if CONFIG_MODULE_UNLOAD=y) is
using a lot of memory.Each 'struct module' contains an [NR_CPUS] array of full cache lines.
This patch uses existing infrastructure (percpu_modalloc() &
percpu_modfree()) to allocate percpu space for the refcount storage.Instead of wasting NR_CPUS*128 bytes (on i386), we now use
nr_cpu_ids*sizeof(local_t) bytes.On a typical distro, where NR_CPUS=8, shiping 2000 modules, we reduce
size of module files by about 2 Mbytes. (1Kb per module)Instead of having all refcounters in the same memory node - with TLB misses
because of vmalloc() - this new implementation permits to have better
NUMA properties, since each CPU will use storage on its preferred node,
thanks to percpu storage.Signed-off-by: Eric Dumazet
Signed-off-by: Rusty Russell
Signed-off-by: Linus Torvalds
07 Jan, 2009
2 commits
-
This series of patches allows kprobes to probe module's __init and __exit
functions. This means, you can probe driver initialization and
terminating.Currently, kprobes can't probe __init function because these functions are
freed after module initialization. And it also can't probe module __exit
functions because kprobe increments reference count of target module and
user can't unload it. this means __exit functions never be called unless
removing probes from the module.To solve both cases, this series of patches introduces GONE flag and sets
it when the target code is freed(for this purpose, kprobes hooks
MODULE_STATE_* events). This also removes refcount incrementing for
allowing user to unload target module. Users can check which probes are
GONE by debugfs interface. For taking timing of freeing module's .init
text, these also include a patch which adds module's notifier of
MODULE_STATE_LIVE event.This patch:
Add within_module_core() and within_module_init() for checking whether an
address is in the module .init.text section or .text section, and replace
within() local inline functions in kernel/module.c with them.kprobes uses these functions to check where the kprobe is inserted.
Signed-off-by: Masami Hiramatsu
Cc: Ananth N Mavinakayanahalli
Cc: Anil S Keshavamurthy
Acked-by: Rusty Russell
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Signed-off-by: Alexey Dobriyan
Cc: Gabor Gombas
Cc: Jan Beulich
Cc: Andi Kleen
Cc: Ingo Molnar ,
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
22 Oct, 2008
1 commit
-
Instead of insisting each new module_param sysfs entry is unique,
handle the case where it already exists (for builtin modules).The current code assumes that all identical prefixes are together in
the section: true for normal uses, but not necessarily so if someone
overrides MODULE_PARAM_PREFIX. More importantly, it's not true with
the new "core_param()" code which uses "kernel" as a prefix.This simplifies the caller for the builtin case, at a slight loss of
efficiency (we do the lookup every time to see if the directory
exists).Signed-off-by: Rusty Russell
Cc: Greg Kroah-Hartman