From: Rusty Russell <rusty@rustcorp.com.au>
To: Jamie Lokier <jamie@shareable.org>
Cc: Hugh Dickins <hugh@veritas.com>, Andrew Morton <akpm@osdl.org>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>
Subject: Re: [PATCH] Alternate futex non-page-pinning and COW fix
Date: Thu, 04 Sep 2003 11:35:27 +1000 [thread overview]
Message-ID: <20030904014229.404F12C0CB@lists.samba.org> (raw)
In-Reply-To: Your message of "Wed, 03 Sep 2003 08:36:28 +0100." <20030903073628.GA19920@mail.jlokier.co.uk>
In message <20030903073628.GA19920@mail.jlokier.co.uk> you write:
> Hi Rusty,
>
> You will be please to know I have written a complete patch :)
Hi Jamie,
Very pleased! Remember, Open Source is all about having other
people do your work for you 8)
> > Assume that we do:
> > 1) Look up vma.
> > 2) If vma->vm_flags & VM_SHARED, index by page->mapping & page->index.
> > 3) Otherwise, index by vma->vm_mm & uaddr.
>
> Like that, but 2) uses vma->vm_file->f_dentry->d_inode.
>
> That way, there is no need to walk the page table at all unless it's a
> non-linear mapping (which my patch does handle).
OK.
> > 2) If VM_SHARED, and page->mapping is NULL, what to do? AFAICT, this
> > can happen in the case of anonymous shared mappings, say mmap
> > /dev/zero MAP_SHARED and fork()? Treating it as !VM_SHARED (and
> > hence matching in mm & uaddr) won't work, since the mm's will be
> > different (and with mremap, the uaddrs may be different).
>
> No, that doesn't happen. An anoymous shared mapping calls
> shmem_zero_setup(), which creates an anonymous tmpfs file to back the
> mapping. It then looks the same as IPC shm or any other tmpfs file.
>
> So it works :)
Ah, I didn't look down that far in do_mmap_pgoff. Right: that makes
things much simpler.
> > 3) Since we need the offset in the file anyway for the VM_SHARED, it
> > makes more sense to use get_user_pages() to get the vma and page in
> > one call, rather than find_extend_vma().
>
> You need the offset, but you don't need the page. For a linear
> mapping, the offset is a very simple calculation - no page table lock
> and no page table walk. As a silly bonus it doesn't touch the page.
>
> For non-linear mappings, I try follow_page() and then
> get_user_pages(), as usual, to get page->index. Technically you don't
> need to swap the page in, but there's no point using complicated code
> for that unimportant case.
>
> I added a flag VM_NONLINEAR to distinguish them.
OK, I would have done it the naive way, but Ingo would probably have
just written what you did (he did the follow_page optimization) 8)
The rest is just nitpicking...
> + /* Page keys and offset within the page. */
> + unsigned long keys[2];
> int offset;
I prefer a union here. It's a little more verbose, but I think it's
clearer:
struct anon_key
{
struct mm_struct *mm;
unsigned long uaddr;
};
struct filebacked_key
{
struct inode *inode;
unsigned long page_index;
};
union hash_key
{
struct anon_key anon;
struct filebacked_key filebacked;
unsigned long keys[2];
};
> +#ifdef FIXADDR_USER_START
> + if (addr >= FIXADDR_USER_START && addr < FIXADDR_USER_END) {
> + keys[0] = 1; /* Different from any pointer value. */
> + keys[1] = addr - FIXADDR_USER_START;
> + return 0;
> + }
> +#endif
I think this is a bit extreme: this would allow futexes in the
VSYSCALL region, right? I admire your thoroughness, but perhaps this
should wait until someone comes up with a reason to do it?
The rest looks ok, I'll do a differential once the rest settles down...
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2003-09-04 1:43 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-26 3:12 [PATCH 2/2] Futex non-page-pinning fix Rusty Russell
2003-08-26 4:06 ` Andrew Morton
2003-08-26 5:30 ` Ingo Molnar
2003-08-26 5:50 ` Andrew Morton
2003-08-26 5:58 ` Ingo Molnar
2003-08-26 6:14 ` Andrew Morton
2003-08-26 6:36 ` Ingo Molnar
2003-08-26 7:02 ` Andrew Morton
2003-08-26 7:56 ` Arjan van de Ven
2003-08-26 8:08 ` Muli Ben-Yehuda
2003-08-26 8:11 ` Arjan van de Ven
2003-08-26 8:25 ` Andrew Morton
2003-08-26 9:02 ` Muli Ben-Yehuda
2003-08-26 10:38 ` William Lee Irwin III
2003-08-26 10:44 ` Andrew Morton
2003-08-26 10:45 ` William Lee Irwin III
2003-08-26 17:29 ` Andrew Morton
2003-08-26 19:35 ` William Lee Irwin III
2003-08-27 5:17 ` Rusty Russell
2003-08-27 6:20 ` Andrew Morton
2003-08-28 0:47 ` Rusty Russell
2003-08-28 8:21 ` Andrew Morton
2003-08-29 3:46 ` Rusty Russell
2003-08-29 4:17 ` Andrew Morton
2003-08-30 7:49 ` Rusty Russell
2003-09-01 0:35 ` Jamie Lokier
2003-09-01 4:11 ` Rusty Russell
2003-09-01 20:57 ` Hugh Dickins
2003-09-02 3:12 ` Rusty Russell
2003-09-02 6:51 ` Jamie Lokier
2003-09-02 16:14 ` Hugh Dickins
2003-09-02 19:54 ` Jamie Lokier
2003-09-02 20:15 ` Andrew Morton
2003-09-02 21:20 ` Jamie Lokier
2003-09-03 2:40 ` Rusty Russell
2003-09-03 7:36 ` [PATCH] Alternate futex non-page-pinning and COW fix Jamie Lokier
2003-09-03 11:19 ` Hugh Dickins
2003-09-03 14:38 ` Jamie Lokier
2003-09-03 17:39 ` Jamie Lokier
2003-09-03 17:55 ` Linus Torvalds
2003-09-03 18:06 ` Hugh Dickins
2003-09-03 18:19 ` Linus Torvalds
2003-09-03 18:43 ` Hugh Dickins
2003-09-03 19:05 ` Linus Torvalds
2003-09-03 19:40 ` Hugh Dickins
2003-09-03 20:04 ` Linus Torvalds
2003-09-04 2:43 ` Rusty Russell
2003-09-04 8:28 ` Linus Torvalds
2003-09-04 12:20 ` Hugh Dickins
2003-09-04 15:40 ` Linus Torvalds
2003-09-04 16:55 ` Hugh Dickins
2003-09-04 18:38 ` Jamie Lokier
2003-09-04 18:46 ` Linus Torvalds
2003-09-04 20:04 ` Jamie Lokier
2003-09-04 21:49 ` Linus Torvalds
2003-09-04 22:10 ` Jamie Lokier
2003-09-04 17:16 ` Jamie Lokier
2003-09-04 17:38 ` Linus Torvalds
2003-09-04 18:42 ` Linus Torvalds
2003-09-04 18:42 ` Linus Torvalds
2003-09-05 3:55 ` Rusty Russell
2003-09-05 17:55 ` Jamie Lokier
2003-09-04 17:26 ` Jamie Lokier
2003-09-04 1:30 ` Rusty Russell
2003-09-04 21:00 ` Jamie Lokier
2003-09-05 5:19 ` Rusty Russell
2003-09-05 20:54 ` Jamie Lokier
2003-09-07 6:45 ` Rusty Russell
2003-09-07 13:20 ` Jamie Lokier
2003-09-08 1:49 ` Rusty Russell
2003-09-08 9:44 ` Jamie Lokier
2003-09-03 14:40 ` [PATCH 2] Little fixes to previous futex patch Jamie Lokier
2003-09-04 16:45 ` Hugh Dickins
2003-09-04 17:59 ` Jamie Lokier
2003-09-04 18:35 ` Hugh Dickins
2003-09-04 20:11 ` Jamie Lokier
2003-09-04 21:36 ` Hugh Dickins
2003-09-04 21:58 ` Jamie Lokier
2003-09-07 7:23 ` Ingo Molnar
2003-09-07 12:27 ` Hugh Dickins
2003-09-07 15:03 ` Jamie Lokier
2003-09-08 1:56 ` Rusty Russell
2003-09-07 13:00 ` Jamie Lokier
2003-09-08 3:32 ` Ingo Molnar
2003-09-08 9:33 ` Jamie Lokier
2003-09-08 9:57 ` Ingo Molnar
2003-09-05 4:56 ` Rusty Russell
2003-09-03 15:34 ` [PATCH] Alternate futex non-page-pinning and COW fix Andrew Morton
2003-09-03 17:16 ` Jamie Lokier
2003-09-04 1:35 ` Rusty Russell [this message]
2003-09-04 17:35 ` Jamie Lokier
2003-09-03 0:14 ` [PATCH 2/2] Futex non-page-pinning fix Rusty Russell
2003-09-03 1:16 ` Andrew Morton
2003-09-03 1:54 ` Dave Hansen
2003-09-03 2:54 ` Andrew Morton
2003-09-02 3:23 ` Hugh Dickins
2003-09-02 23:58 ` Rusty Russell
2003-08-27 8:37 ` Hugh Dickins
2003-08-27 8:56 ` William Lee Irwin III
2003-08-27 10:38 ` Andrew Morton
2003-08-27 10:57 ` Hugh Dickins
2003-08-28 8:03 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030904014229.404F12C0CB@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=akpm@osdl.org \
--cc=hugh@veritas.com \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox