lkml.org 
[lkml]   [2005]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH] rmmod notifier chain
    On Thu, Sep 08, 2005 at 05:03:58PM +0200, Jan Beulich wrote:

    > (Note: Patch also attached because the inline version is certain to get
    > line wrapped.)
    >
    > Debugging and maintenance support code occasionally needs to know not
    > only of module insertions, but also modulke removals. This adds a
    > notifier
    > chain for this purpose.

    It's possible to do this a bit differently, if I'm guessing right at
    what NLKD does. The following is from the KGDB patches (trimmed of some
    other, unrelated to the notify part code):

    diff -puN include/linux/module.h~module include/linux/module.h
    --- linux-2.6.13/include/linux/module.h~module 2005-09-01 12:00:49.000000000 -0700
    +++ linux-2.6.13-trini/include/linux/module.h 2005-09-01 12:00:49.000000000 -0700
    @@ -210,6 +210,7 @@ enum module_state
    MODULE_STATE_LIVE,
    MODULE_STATE_COMING,
    MODULE_STATE_GOING,
    + MODULE_STATE_GONE,
    };

    /* Similar stuff for section attributes. */
    diff -puN kernel/module.c~module kernel/module.c
    --- linux-2.6.13/kernel/module.c~module 2005-09-01 12:00:49.000000000 -0700
    +++ linux-2.6.13-trini/kernel/module.c 2005-09-01 12:00:49.000000000 -0700
    @@ -623,6 +623,12 @@ sys_delete_module(const char __user *nam
    if (ret != 0)
    goto out;

    + down(&notify_mutex);
    + notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
    + mod);
    + up(&notify_mutex);
    +
    +
    /* Never wait if forced. */
    if (!forced && module_refcount(mod) != 0)
    wait_for_zero_refcount(mod);
    @@ -635,6 +641,11 @@ sys_delete_module(const char __user *nam
    }
    free_module(mod);

    + down(&notify_mutex);
    + notifier_call_chain(&module_notify_list, MODULE_STATE_GONE,
    + NULL);
    + up(&notify_mutex);
    +
    out:
    up(&module_mutex);
    return ret;
    @@ -1909,6 +1961,10 @@ sys_init_module(void __user *umod,
    /* Init routine failed: abort. Try to protect us from
    buggy refcounters. */
    mod->state = MODULE_STATE_GOING;
    + down(&notify_mutex);
    + notifier_call_chain(&module_notify_list, MODULE_STATE_GOING,
    + mod);
    + up(&notify_mutex);
    synchronize_sched();
    if (mod->unsafe)
    printk(KERN_ERR "%s: module is now stuck!\n",
    _
    --
    Tom Rini
    http://gate.crashing.org/~trini/
    -
    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-09-08 17:35    [W:0.024 / U:30.560 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site