• W
    selinux: reduce locking overhead in inode_free_security() · 9629d04a
    Waiman Long 提交于
    The inode_free_security() function just took the superblock's isec_lock
    before checking and trying to remove the inode security struct from the
    linked list. In many cases, the list was empty and so the lock taking
    is wasteful as no useful work is done. On multi-socket systems with
    a large number of CPUs, there can also be a fair amount of spinlock
    contention on the isec_lock if many tasks are exiting at the same time.
    
    This patch changes the code to check the state of the list first before
    taking the lock and attempting to dequeue it. The list_del_init()
    can be called more than once on the same list with no harm as long
    as they are properly serialized. It should not be possible to have
    inode_free_security() called concurrently with list_add(). For better
    safety, however, we use list_empty_careful() here even though it is
    still not completely safe in case that happens.
    Signed-off-by: NWaiman Long <Waiman.Long@hp.com>
    Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
    Signed-off-by: NPaul Moore <pmoore@redhat.com>
    9629d04a
hooks.c 156.4 KB