From: Ingo Molnar <mingo@elte.hu>
To: Darren Hart <dvhltc@us.ibm.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Nick Piggin <npiggin@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hugh@veritas.com>
Cc: "lkml, " <linux-kernel@vger.kernel.org>,
Rusty Russell <rusty@au1.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: futex.c and fault handling
Date: Fri, 19 Dec 2008 23:37:20 +0100 [thread overview]
Message-ID: <20081219223720.GD13409@elte.hu> (raw)
In-Reply-To: <494C1DE5.4040901@us.ibm.com>
(extended the Cc: list with MM experts.)
* Darren Hart <dvhltc@us.ibm.com> wrote:
> I've been working in linux-tip core/futexes lately and have a need to be
> able to properly handle faults for r/w access to a uaddr. I was
> planning on modeling this on the fault handling in futex_lock_pi which
> used both get_user() and futex_handle_fault() to get the pages.
> However, that used to be based on whether or not we held the mmap_sem.
> Now that we're using fast_gup throughout futex.c, and the mmap_sem
> locking has been pushed in tighter in get_futex_key(), I'm not sure if
> the fault handling is still correct - the comments are certainly
> incorrect since we no longer hold the mmap_sem when we hit
> uaddr_faulted: inside futex_lock_pi (and a few other places have similar
> comment vs. code dicrepancies):
>
> uaddr_faulted:
> /*
> * We have to r/w *(int __user *)uaddr, and we have to modify it
> * atomically. Therefore, if we continue to fault after get_user()
> * below, we need to handle the fault ourselves, while still holding
> * the mmap_sem. This can occur if the uaddr is under contention as
> * we have to drop the mmap_sem in order to call get_user().
> */
> queue_unlock(&q, hb);
>
> if (attempt++) {
> ret = futex_handle_fault((unsigned long)uaddr, attempt);
> if (ret)
> goto out_put_key;
> goto retry_unlocked;
> }
>
> ---> previous versions dropped the mmap_sem here in preparation for get_user()
>
> ret = get_user(uval, uaddr);
> if (!ret)
> goto retry;
>
>
> So is the code still correct without the holding of mmap_sem? I suppose
> get_user() is still the more efficient path, and perhaps even more so
> now that we don't have to release mmap_sem and reacquire it later in
> order to call it. If so, then I guess all that is needed is a comments
> patch, which I'd be happy to write up.
>
> Thanks,
>
> --
> Darren Hart
> IBM Linux Technology Center
> Real-Time Linux Team
next prev parent reply other threads:[~2008-12-19 22:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-19 22:19 futex.c and fault handling Darren Hart
2008-12-19 22:37 ` Ingo Molnar [this message]
2008-12-22 4:32 ` Nick Piggin
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=20081219223720.GD13409@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=dvhltc@us.ibm.com \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@suse.de \
--cc=rusty@au1.ibm.com \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.