05 Jul, 2010

1 commit

  • We should initialize the module dynamic debug datastructures
    only after determining that the module is not loaded yet. This
    fixes a bug that introduced in 2.6.35-rc2, where when a trying
    to load a module twice, we also load it's dynamic printing data
    twice which causes all sorts of nasty issues. Also handle
    the dynamic debug cleanup later on failure.

    Signed-off-by: Yehuda Sadeh
    Signed-off-by: Rusty Russell (removed a #ifdef)
    Signed-off-by: Linus Torvalds

    Yehuda Sadeh
     

05 Jun, 2010

8 commits

  • Problem: it's hard to avoid an init routine stumbling over a
    request_module these days. And it's not clear it's always a bad idea:
    for example, a module like kvm with dynamic dependencies on kvm-intel
    or kvm-amd would be neater if it could simply request_module the right
    one.

    In this particular case, it's libcrc32c:

    libcrc32c_mod_init
    crypto_alloc_shash
    crypto_alloc_tfm
    crypto_find_alg
    crypto_alg_mod_lookup
    crypto_larval_lookup
    request_module

    If another module is waiting inside resolve_symbol() for libcrc32c to
    finish initializing (ie. bne2 depends on libcrc32c) then it does so
    holding the module lock, and our request_module() can't make progress
    until that is released.

    Waiting inside resolve_symbol() without the lock isn't all that hard:
    we just need to pass the -EBUSY up the call chain so we can sleep
    where we don't hold the lock. Error reporting is a bit trickier: we
    need to copy the name of the unfinished module before releasing the
    lock.

    Other notes:
    1) This also fixes a theoretical issue where a weak dependency would allow
    symbol version mismatches to be ignored.
    2) We rename use_module to ref_module to make life easier for the only
    external user (the out-of-tree ksplice patches).

    Signed-off-by: Rusty Russell
    Cc: Linus Torvalds
    Cc: Tim Abbot
    Tested-by: Brandon Philips

    Rusty Russell
     
  • It disabled preempt so it was "safe", but nothing stops another module
    slipping in before this module is added to the global list now we don't
    hold the lock the whole time.

    So we check this just after we check for duplicate modules, and just
    before we put the module in the global list.

    (find_symbol finds symbols in coming and going modules, too).

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • I think Rusty may have made the lock a bit _too_ finegrained there, and
    didn't add it to some places that needed it. It looks, for example, like
    PATCH 1/2 actually drops the lock in places where it's needed
    ("find_module()" is documented to need it, but now load_module() didn't
    hold it at all when it did the find_module()).

    Rather than adding a new "module_loading" list, I think we should be able
    to just use the existing "modules" list, and just fix up the locking a
    bit.

    In fact, maybe we could just move the "look up existing module" a bit
    later - optimistically assuming that the module doesn't exist, and then
    just undoing the work if it turns out that we were wrong, just before
    adding ourselves to the list.

    Signed-off-by: Rusty Russell

    Linus Torvalds
     
  • Kay Sievers reports that we still have some
    contention over module loading which is slowing boot.

    Linus also disliked a previous "drop lock and regrab" patch to fix the
    bne2 "gave up waiting for init of module libcrc32c" message.

    This is more ambitious: we only grab the lock where we need it.

    Signed-off-by: Rusty Russell
    Cc: Brandon Philips
    Cc: Kay Sievers
    Cc: Linus Torvalds

    Rusty Russell
     
  • 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

    Rusty Russell
     
  • This means a little extra work, but is more logical: we don't put
    anything in sysfs until we're about to put the module into the
    global list an parse its parameters.

    This also gives us a logical place to put duplicate module detection
    in the next patch.

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • 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

    Rusty Russell
     
  • 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)

    Linus Torvalds
     

01 Jun, 2010

2 commits

  • * 'for-35' of git://repo.or.cz/linux-kbuild: (81 commits)
    kbuild: Revert part of e8d400a to resolve a conflict
    kbuild: Fix checking of scm-identifier variable
    gconfig: add support to show hidden options that have prompts
    menuconfig: add support to show hidden options which have prompts
    gconfig: remove show_debug option
    gconfig: remove dbg_print_ptype() and dbg_print_stype()
    kconfig: fix zconfdump()
    kconfig: some small fixes
    add random binaries to .gitignore
    kbuild: Include gen_initramfs_list.sh and the file list in the .d file
    kconfig: recalc symbol value before showing search results
    .gitignore: ignore *.lzo files
    headerdep: perlcritic warning
    scripts/Makefile.lib: Align the output of LZO
    kbuild: Generate modules.builtin in make modules_install
    Revert "kbuild: specify absolute paths for cscope"
    kbuild: Do not unnecessarily regenerate modules.builtin
    headers_install: use local file handles
    headers_check: fix perl warnings
    export_report: fix perl warnings
    ...

    Linus Torvalds
     
  • Rafael sees a sometimes crash at precpu_modfree from kernel/module.c; it
    only occurred with another (since-reverted) patch, but that patch simply
    changed timing to uncover this bug, it was otherwise unrelated.

    The comment about the mod being freed is self-explanatory, but neither
    Tejun nor I read it. This bug was introduced in 259354deaa, after it
    had previously been fixed in 6e2b75740b. How embarrassing.

    Reported-by: "Rafael J. Wysocki"
    Signed-off-by: Rusty Russell
    Embarrassingly-Acked-by: Tejun Heo
    Cc: Masami Hiramatsu
    Tested-by: "Rafael J. Wysocki"
    Signed-off-by: Linus Torvalds

    Rusty Russell
     

26 May, 2010

1 commit

  • This reverts commit 480b02df3aa9f07d1c7df0cd8be7a5ca73893455, since
    Rafael reports that it causes occasional kernel paging request faults in
    load_module().

    Dropping the module lock and re-taking it deep in the call-chain is
    definitely not the right thing to do. That just turns the mutex from a
    lock into a "random non-locking data structure" that doesn't actually
    protect what it's supposed to protect.

    Requested-and-tested-by: Rafael J. Wysocki
    Cc: Rusty Russell
    Cc: Brandon Philips
    Cc: Andrew Morton
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

25 May, 2010

1 commit


22 May, 2010

3 commits

  • * 'modules' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
    module: drop the lock while waiting for module to complete initialization.
    MODULE_DEVICE_TABLE(isapnp, ...) does nothing
    hisax_fcpcipnp: fix broken isapnp device table.
    isapnp: move definitions to mod_devicetable.h so file2alias can reach them.

    Linus Torvalds
     
  • * 'kdb-merge' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb: (25 commits)
    kdb,debug_core: Allow the debug core to receive a panic notification
    MAINTAINERS: update kgdb, kdb, and debug_core info
    debug_core,kdb: Allow the debug core to process a recursive debug entry
    printk,kdb: capture printk() when in kdb shell
    kgdboc,kdb: Allow kdb to work on a non open console port
    kgdb: Add the ability to schedule a breakpoint via a tasklet
    mips,kgdb: kdb low level trap catch and stack trace
    powerpc,kgdb: Introduce low level trap catching
    x86,kgdb: Add low level debug hook
    kgdb: remove post_primary_code references
    kgdb,docs: Update the kgdb docs to include kdb
    kgdboc,keyboard: Keyboard driver for kdb with kgdb
    kgdb: gdb "monitor" -> kdb passthrough
    sparc,sunzilog: Add console polling support for sunzilog serial driver
    sh,sh-sci: Use NO_POLL_CHAR in the SCIF polled console code
    kgdb,8250,pl011: Return immediately from console poll
    kgdb: core changes to support kdb
    kdb: core for kgdb back end (2 of 2)
    kdb: core for kgdb back end (1 of 2)
    kgdb,blackfin: Add in kgdb_arch_set_pc for blackfin
    ...

    Linus Torvalds
     
  • This allows bin_attr->read,write,mmap callbacks to check file specific data
    (such as inode owner) as part of any privilege validation.

    Signed-off-by: Chris Wright
    Signed-off-by: Greg Kroah-Hartman

    Chris Wright
     

21 May, 2010

1 commit

  • This patch contains the hooks and instrumentation into kernel which
    live outside the kernel/debug directory, which the kdb core
    will call to run commands like lsmod, dmesg, bt etc...

    CC: linux-arch@vger.kernel.org
    Signed-off-by: Jason Wessel
    Signed-off-by: Martin Hicks

    Jason Wessel
     

19 May, 2010

1 commit

  • This fixes "gave up waiting for init of module libcrc32c." which
    happened at boot time due to multiple parallel module loads.

    The problem was a deadlock: we wait for a module to finish
    initializing, but we keep the module_lock mutex so it can't complete.
    In particular, this could reasonably happen if a module does a
    request_module() in its initialization routine.

    So we change use_module() to return an errno rather than a bool, and if
    it's -EBUSY we drop the lock and wait in the caller, then reaquire the
    lock.

    Reported-by: Brandon Philips
    Signed-off-by: Rusty Russell
    Tested-by: Brandon Philips

    Rusty Russell
     

18 May, 2010

1 commit

  • …/git/tip/linux-2.6-tip

    * 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (49 commits)
    stop_machine: Move local variable closer to the usage site in cpu_stop_cpu_callback()
    sched, wait: Use wrapper functions
    sched: Remove a stale comment
    ondemand: Make the iowait-is-busy time a sysfs tunable
    ondemand: Solve a big performance issue by counting IOWAIT time as busy
    sched: Intoduce get_cpu_iowait_time_us()
    sched: Eliminate the ts->idle_lastupdate field
    sched: Fold updating of the last_update_time_info into update_ts_time_stats()
    sched: Update the idle statistics in get_cpu_idle_time_us()
    sched: Introduce a function to update the idle statistics
    sched: Add a comment to get_cpu_idle_time_us()
    cpu_stop: add dummy implementation for UP
    sched: Remove rq argument to the tracepoints
    rcu: need barrier() in UP synchronize_sched_expedited()
    sched: correctly place paranioa memory barriers in synchronize_sched_expedited()
    sched: kill paranoia check in synchronize_sched_expedited()
    sched: replace migration_thread with cpu_stop
    stop_machine: reimplement using cpu_stop
    cpu_stop: implement stop_cpu[s]()
    sched: Fix select_idle_sibling() logic in select_task_rq_fair()
    ...

    Linus Torvalds
     

07 May, 2010

1 commit

  • Reimplement stop_machine using cpu_stop. As cpu stoppers are
    guaranteed to be available for all online cpus,
    stop_machine_create/destroy() are no longer necessary and removed.

    With resource management and synchronization handled by cpu_stop, the
    new implementation is much simpler. Asking the cpu_stop to execute
    the stop_cpu() state machine on all online cpus with cpu hotplug
    disabled is enough.

    stop_machine itself doesn't need to manage any global resources
    anymore, so all per-instance information is rolled into struct
    stop_machine_data and the mutex and all static data variables are
    removed.

    The previous implementation created and destroyed RT workqueues as
    necessary which made stop_machine() calls highly expensive on very
    large machines. According to Dimitri Sivanich, preventing the dynamic
    creation/destruction makes booting faster more than twice on very
    large machines. cpu_stop resources are preallocated for all online
    cpus and should have the same effect.

    Signed-off-by: Tejun Heo
    Acked-by: Rusty Russell
    Acked-by: Peter Zijlstra
    Cc: Oleg Nesterov
    Cc: Dimitri Sivanich

    Tejun Heo
     

08 Apr, 2010

1 commit

  • Conflicts:
    include/linux/module.h
    kernel/module.c

    Semantic conflict:
    include/trace/events/module.h

    Merge reason: Resolve the conflict with upstream commit 5fbfb18 ("Fix up
    possibly racy module refcounting")

    Signed-off-by: Ingo Molnar

    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

    Nick Piggin
     

01 Apr, 2010

2 commits

  • If modules are configured in the build but unloading of modules is not,
    then the refcnt is not defined. Place the get/put module tracepoints
    under CONFIG_MODULE_UNLOAD since it references this field in the module
    structure.

    As a side-effect, this patch also reduces the code when MODULE_UNLOAD
    is not set, because these unused tracepoints are not created.

    Signed-off-by: Steven Rostedt

    Steven Rostedt
     
  • 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

    Li Zefan
     

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

    Tejun Heo
     
  • 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

    Tejun Heo
     

08 Mar, 2010

1 commit


03 Mar, 2010

1 commit


02 Feb, 2010

1 commit


06 Jan, 2010

1 commit

  • Commit 35dead4 "modules: don't export section names of empty sections
    via sysfs" changed the set of sections that have attributes, but did
    not change the iteration over these attributes in add_notes_attrs().
    This can lead to add_notes_attrs() creating attributes with the wrong
    names or with null name pointers.

    Introduce a sect_empty() function and use it in both add_sect_attrs()
    and add_notes_attrs().

    Reported-by: Martin Michlmayr
    Signed-off-by: Ben Hutchings
    Tested-by: Martin Michlmayr
    Cc: stable@kernel.org
    Signed-off-by: Rusty Russell
    Signed-off-by: Linus Torvalds

    Ben Hutchings
     

05 Jan, 2010

1 commit

  • 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

    Christoph Lameter
     

18 Dec, 2009

1 commit

  • * 'kmemleak' of git://linux-arm.org/linux-2.6:
    kmemleak: fix kconfig for crc32 build error
    kmemleak: Reduce the false positives by checking for modified objects
    kmemleak: Show the age of an unreferenced object
    kmemleak: Release the object lock before calling put_object()
    kmemleak: Scan the _ftrace_events section in modules
    kmemleak: Simplify the kmemleak_scan_area() function prototype
    kmemleak: Do not use off-slab management with SLAB_NOLEAKTRACE

    Linus Torvalds
     

15 Dec, 2009

2 commits

  • powerpc applies relocations to the kcrctab. They're absolute symbols,
    but it's not completely unreasonable: other archs may too, but the
    relocation is often 0.

    http://lists.ozlabs.org/pipermail/linuxppc-dev/2009-November/077972.html

    Inspired-by: Neil Horman
    Signed-off-by: Rusty Russell
    Tested-by: Neil Horman
    Acked-by: Paul Mackerras

    Rusty Russell
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu: (34 commits)
    m68k: rename global variable vmalloc_end to m68k_vmalloc_end
    percpu: add missing per_cpu_ptr_to_phys() definition for UP
    percpu: Fix kdump failure if booted with percpu_alloc=page
    percpu: make misc percpu symbols unique
    percpu: make percpu symbols in ia64 unique
    percpu: make percpu symbols in powerpc unique
    percpu: make percpu symbols in x86 unique
    percpu: make percpu symbols in xen unique
    percpu: make percpu symbols in cpufreq unique
    percpu: make percpu symbols in oprofile unique
    percpu: make percpu symbols in tracer unique
    percpu: make percpu symbols under kernel/ and mm/ unique
    percpu: remove some sparse warnings
    percpu: make alloc_percpu() handle array types
    vmalloc: fix use of non-existent percpu variable in put_cpu_var()
    this_cpu: Use this_cpu_xx in trace_functions_graph.c
    this_cpu: Use this_cpu_xx for ftrace
    this_cpu: Use this_cpu_xx in nmi handling
    this_cpu: Use this_cpu operations in RCU
    this_cpu: Use this_cpu ops for VM statistics
    ...

    Fix up trivial (famous last words) global per-cpu naming conflicts in
    arch/x86/kvm/svm.c
    mm/slab.c

    Linus Torvalds
     

03 Dec, 2009

1 commit

  • On the parisc architecture we face for each and every loaded kernel module
    this kernel "badness warning":
    sysfs: cannot create duplicate filename '/module/ac97_bus/sections/.text'
    Badness at fs/sysfs/dir.c:487

    Reason for that is, that on parisc all kernel modules do have multiple
    .text sections due to the usage of the -ffunction-sections compiler flag
    which is needed to reach all jump targets on this platform.

    An objdump on such a kernel module gives:
    Sections:
    Idx Name Size VMA LMA File off Algn
    0 .note.gnu.build-id 00000024 00000000 00000000 00000034 2**2
    CONTENTS, ALLOC, LOAD, READONLY, DATA
    1 .text 00000000 00000000 00000000 00000058 2**0
    CONTENTS, ALLOC, LOAD, READONLY, CODE
    2 .text.ac97_bus_match 0000001c 00000000 00000000 00000058 2**2
    CONTENTS, ALLOC, LOAD, READONLY, CODE
    3 .text 00000000 00000000 00000000 000000d4 2**0
    CONTENTS, ALLOC, LOAD, READONLY, CODE
    ...
    Since the .text sections are empty (size of 0 bytes) and won't be
    loaded by the kernel module loader anyway, I don't see a reason
    why such sections need to be listed under
    /sys/module//sections/ either.

    The attached patch does solve this issue by not exporting section
    names which are empty.

    This fixes bugzilla http://bugzilla.kernel.org/show_bug.cgi?id=14703

    Signed-off-by: Helge Deller
    CC: rusty@rustcorp.com.au
    CC: akpm@linux-foundation.org
    CC: James.Bottomley@HansenPartnership.com
    CC: roland@redhat.com
    CC: dave@hiauly1.hia.nrc.ca
    Signed-off-by: Linus Torvalds

    Helge Deller
     

29 Oct, 2009

1 commit


28 Oct, 2009

1 commit


02 Oct, 2009

2 commits

  • With ia64 converted, there's no arch left which still uses legacy
    percpu allocator. Kill it.

    Signed-off-by: Tejun Heo
    Delightedly-acked-by: Rusty Russell
    Cc: Ingo Molnar
    Cc: Christoph Lameter

    Tejun Heo
     
  • Starting from commit 4a4962263f07d14660849ec134ee42b63e95ea9a "reduce
    symbol table for loaded modules (v2)", the kernel/module.c build is broken
    with CONFIG_KALLSYMS disabled.

    CC kernel/module.o
    kernel/module.c:1995: warning: type defaults to 'int' in declaration of 'Elf_Hdr'
    kernel/module.c:1995: error: expected ';', ',' or ')' before '*' token
    kernel/module.c: In function 'load_module':
    kernel/module.c:2203: error: 'strmap' undeclared (first use in this function)
    kernel/module.c:2203: error: (Each undeclared identifier is reported only once
    kernel/module.c:2203: error: for each function it appears in.)
    kernel/module.c:2239: error: 'symoffs' undeclared (first use in this function)
    kernel/module.c:2239: error: implicit declaration of function 'layout_symtab'
    kernel/module.c:2240: error: 'stroffs' undeclared (first use in this function)
    make[1]: *** [kernel/module.o] Error 1
    make: *** [kernel/module.o] Error 2

    There are three different issues:

    - layout_symtab() takes a const Elf_Ehdr

    - layout_symtab() needs to return a value

    - symoffs/stroffs/strmap are referenced by the load_module() code
    despite being ifdefed out, which seems unnecessary given the noop
    behaviour of layout_symtab()/add_kallsyms() in the case of
    CONFIG_KALLSYMS=n.

    Signed-off-by: Paul Mundt
    Acked-by: Jan Beulich
    Acked-by: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Mundt
     

27 Sep, 2009

1 commit

  • …nel/git/tip/linux-2.6-tip

    * 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    modules, tracing: Remove stale struct marker signature from module_layout()
    tracing/workqueue: Use %pf in workqueue trace events
    tracing: Fix a comment and a trivial format issue in tracepoint.h
    tracing: Fix failure path in ftrace_regex_open()
    tracing: Fix failure path in ftrace_graph_write()
    tracing: Check the return value of trace_get_user()
    tracing: Fix off-by-one in trace_get_user()

    Linus Torvalds