[lkml]   [2007]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subject[PATCHSET #master] sysfs: make sysfs disconnect immediately on deletion, take 2
    Hello, all.

    This is the second take of sysfs-immediate-disconnct patchset.

    In the last take, rwsem was added to s_elem.dir to protect kobj only.
    This wasn't enough because attr and bin_attr need to hold onto not
    only the kobject of their parents but also the module backing
    themselves and ops too, so the first set still needed separate and
    duplicate attribute file orphaning mechanism.

    In this take, the rwsem is generalized to become active reference
    count. Now each sysfs_dirent has two reference counts - s_count and
    s_active. s_count is a regular reference count which guarantees that
    the containing sysfs_dirent is accessible. As long as s_count
    reference is held, all sysfs internal fields in sysfs_dirent are
    accessible including s_parent and s_name.

    The newly added s_active is active reference count. This is acquired
    by invoking sysfs_get_active() and it's the caller's responsibility to
    ensure sysfs_dirent itself is accessible (should be holding s_count
    one way or the other). Dereferencing sysfs_dirent to access objects
    out of sysfs proper requires active reference. This includes access
    to the associated kobjects, attributes and ops.

    Because attr/bin_attr ops access both the node itself and its parent
    for kobject, they need to hold active references to both.
    sysfs_get/put_active_two() helpers are provided to help grabbing both
    references. Parent's is acquired first and released last.

    Basically, s_count provides the reference counted objects to the upper
    layer while s_active guards low level access such that low level
    objects can just go away when they want to, and the same mechanism is
    applied to all types of sysfs nodes. I think it's conceptually
    cleaner and thus easier to understand this way.

    With all the patches applied, the same test used in the last take ran
    9+hrs without any problem.

    Change from the last take are...

    * Patch 3 now doesn't move sysfs_get_kobject() as the it's replaced by
    active references later.

    * Patch 12 updated such that sdir->rwsem is generalized into active
    reference count.

    Please read the original lifetime rules discussion[1] and description
    of the last take[2] for more info.




    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2007-04-09 06:23    [W:0.028 / U:7.160 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site