Re: Shared futexes (was [PATCH] FUTEX : new PRIVATE futexes)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2007-04-06 at 23:15 +1000, Nick Piggin wrote:
> Hugh Dickins wrote:
> > On Fri, 6 Apr 2007, Peter Zijlstra wrote:
> > 
> >>some thoughts on shared futexes;
> >>
> >>Could we get rid of the mmap_sem on the shared futexes in the following
> >>manner:
> 
> I'd imagine shared futexes would be much less common than private for
> threaded programs... I'd say we should reevaluate things once we have
> private futexes, and malloc/free stop hammering mmap_sem so hard...

Indeed, private futexes are by far the most common.

> >> - get a page using pfn_to_page (skipping VM_PFNMAP)
> >> - get the futex key from page->mapping->host and page->index
> >>   and offset from addr % PAGE_SIZE.
> >>
> >>or given a key:
> >>
> >> - lookup the page from key.shared.inode->i_mapping by key.shared.pgoff
> >>   possibly loading the page using mapping->a_ops->readpage().
> 
> For shared futexes, wouldn't i_mapping be worse, because you'd be
> ping-ponging the tree_lock between processes, rather than have each
> use their own mmap_sem?

Your lockless pagecache work would solve most of that, no?

> That also only helps for the wakeup case too, doesn't it? You have
> to use the vmas to find out which inode to use to do the wait, I think?
> (unless you introduce a new shared futex API).

one could do something like this:

 struct address_space *mapping = page_mapping(page);
 if (!mapping || mapping == &swapper_space)
   do_private_futex();
 else
   do_shared_futex(mapping->host, page->index, addr % PAGE_SIZE);


But alas, it seems I overlooked that the mmap_sem also protects the page
tables as pointed out by Hugh, so this is all in fain it seems.

A well.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux