lkml.org 
[lkml]   [2013]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sysfs: use a separate locking class for open files depending on mmap
On Sun, Nov 17, 2013 at 08:45:23PM -0800, Greg Kroah-Hartman wrote:
> On Sun, Nov 17, 2013 at 12:29:37PM +0900, Tejun Heo wrote:
> > On Sat, Nov 16, 2013 at 10:21:19PM -0500, Dave Jones wrote:
> > > On Sun, Nov 17, 2013 at 11:17:36AM +0900, Tejun Heo wrote:
> > >
> > >
> > > > + if (has_mmap)
> > > > + mutex_init(&of->mutex);
> > > > + else
> > > > + mutex_init(&of->mutex);
> > >
> > > ummm...
> >
> > Supposed to look that way. It'll give two separate static lock class
> > keys to of->mutex. Yeah, looks weird. Any better ideas?
>
> Doesn't gcc optimize that away to just one lock class anyway?

Well, it basically becomes

if (has_mmap) {
static struct lock_class_key key;
__mutex_init(blah, &key);
} else {
static struct lock_class_key key;
__mutex_init(blah, &key);
}

So, the compiler isn't allowed to merge the two keys and we actually
use constructs like the above from a few places. Yeah, it is weird
but does work.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2013-11-20 07:41    [W:0.100 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site