lkml.org 
[lkml]   [2008]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC][PATCH 7/7] lockdep: spin_lock_nest_lock()
    On Mon, Aug 04, 2008 at 12:31:22PM -0700, Linus Torvalds wrote:
    >
    >
    > On Mon, 4 Aug 2008, Jeremy Fitzhardinge wrote:
    > >
    > > OK. I don't actually need to do this, but I was asking for completeness. But
    > > to clarify, you only need to do the reverse unlock if you do it after
    > > unlocking the outer lock? If you're still holding the outer lock, you can
    > > unlock in any order?
    >
    > Release order should always be totally irrelevant, whether you hold outer
    > locks or not. Only the order of _getting_ locks matter.

    Technically, you are 100% correct.

    >
    > And yes, if there is an outer lock, even the order of getting locks is
    > irrelevant, as long as anybody who gets more than one inner lock always
    > holds the outer one.

    But I need to disagree on a programming practice style. Unlocking locks
    in a non nested order is just bad programming practice. Unless there is
    a good reason to do so, one should never release locks in a non reverse
    order they were taken.

    This can be a source of bugs, where people might notice an outer lock
    being released and think the inner locks were too.

    Lately the kernel has been going through a lot of clean ups that have
    been making the kernel a much more maintainable beast. I feel we should
    enforce the rule of unlocking order (again, unless there is a good
    reason not to). Not for a technical reason, but just for a more
    maintainable one.

    -- Steve



    \
     
     \ /
      Last update: 2008-10-08 17:29    [W:2.395 / U:0.052 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site