[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100329184740.5d99edef@notabene.brown>
Date: Mon, 29 Mar 2010 18:47:40 +1100
From: Neil Brown <neilb@...e.de>
To: Neil Brown <neilb@...e.de>
Cc: ebiederm@...ssion.com (Eric W. Biederman),
Greg Kroah-Hartman <gregkh@...e.de>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] sysfs: simplify handling for s_active refcount
On Mon, 29 Mar 2010 15:43:25 +1100
Neil Brown <neilb@...e.de> wrote:
> However if we do consider memory ordering guarantees we can describe a clear
> limit to the possibly delay between SYSFS_FLAG_REMOVED being set, and being
> seen. The atomic_inc_not_zero serves as a memory barrier in exactly the same
> way that the current code requires atomic_dec_return. So while
>
> if (likely(sd)
> && (sd->s_flags & SYSFS_FLAG_REMOVED) == 0
> && atomic_inc_not_zero(&sd->s_active)) {
>
> could possibly gain a reference even 'after' SYS_FLAG_REMOVED as been set,
> a second call to this on the same processor will see SYSFS_FLAG_REMOVED.
> So at the absolute most, we could see NCPUS active references gained and
> dropped after SYSFS_FLAG_REMOVED was set - a clear limit which is all we need.
It just occurred to me that this 'proof' isn't quite complete in itself. I
need to also show that there is a suitable memory barrier after
SYSFS_FLAG_REMOVED is set. There is as it is always set under sysfs_mutex,
so the mutex_unlock provides a barrier.
So after sysfs_mutex is unlocked, it is conceivable that each CPU could grant
one active reference against the sysfs_dirent before SYSFS_FLAG_REMOVED was
globally visible.
> I'm still not sure we even need to argue in terms of memory barriers to be
> sure the code is correct, but it seems they are sufficient to give a simple
> proof.
NeilBrown
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists