[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 12 Dec 2011 12:13:13 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: Ming Lei <tom.leiming@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>, gregkh@...e.de,
akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
ostrikov@...dia.com, adobriyan@...il.com, mingo@...e.hu,
Oliver Neukum <oneukum@...e.de>
Subject: Re: [PATCH 3/3] kref: Remove the memory barriers
Le lundi 12 décembre 2011 à 18:32 +0800, Ming Lei a écrit :
> On Mon, Dec 12, 2011 at 6:12 PM, Peter Zijlstra <peterz@...radead.org> wrote:
>
> > I don't know the driver model, and I don't plan to start learning it
> > now. But if what you said is possible its broken and no memory barriers
> > will fix it.
>
> IMO, you don't need to learn it, and my example is very simple and common
> kref usage in device drivers, :-)
>
> Could we only focus on it and see what is problem? and why won't memory
> barrier fix it?
>
> Anyway, device drivers are the most consumers of kref...
Really, kref is not magical per itself.
Using kref (or any refcounting) doesnt avoid bugs.
In the example you gave, there is a clear bug :
CPU0 CPU1
A:kref_init(&obj->ref)
B:kref_get(&obj->ref)
C:access obj E:access obj
F:kref_put(&ojb->ref)
D:kref_put(obj->ref)
because _nothing_ prevents CPU0 accessing obj right after F:
To solve this problem, you need another way to synchronize accesses.
--
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