public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eugene Teo <eugeneteo@kernel.sg>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Eugene Teo <eugeneteo@kernel.sg>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	torvalds@linux-foundation.org, corbet@lwn.net
Subject: Re: [PATCH 2/2 resend] mm: various cleanups in get_user_pages()
Date: Wed, 13 Feb 2008 10:40:20 +0800	[thread overview]
Message-ID: <20080213024020.GA4002@kernel.sg> (raw)
In-Reply-To: <200802131213.04902.nickpiggin@yahoo.com.au>

Hi Nick,

Thanks for the review.

<quote sender="Nick Piggin">
> On Wednesday 13 February 2008 00:10, Eugene Teo wrote:
[...]
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 54f951b..c7e0610 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -1003,7 +1003,9 @@ int get_user_pages(struct task_struct *tsk, struct
> > mm_struct *mm, unsigned int foll_flags;
> >
> >  		vma = find_extend_vma(mm, start);
> > -		if (!vma && in_gate_area(tsk, start)) {
> > +		if (!vma)
> > +			goto finish_or_fault;
> > +		if (in_gate_area(tsk, start)) {
> >  			unsigned long pg = start & PAGE_MASK;
> >  			struct vm_area_struct *gate_vma = get_gate_vma(tsk);
> >  			pgd_t *pgd;
> 
> Doesn't this break the logic?
> 
> If you don't have a vma, but you are in the gate area, then you
> should use the gate vma. With your patch, gate area will fault.

Yes, you are right. I also relooked at the patch, and actually vma is
validated after if (... in_gate_area(tsk, start)) { ... }, so my patch
is not correct.

> > @@ -1011,7 +1013,7 @@ int get_user_pages(struct task_struct *tsk, struct
> > mm_struct *mm, pmd_t *pmd;
> >  			pte_t *pte;
> >  			if (write) /* user gate pages are read-only */
> > -				return i ? : -EFAULT;
> > +				goto finish_or_fault;
> 
> I don't know if this is exactly a cleanup or not... I guess gcc
> probably isn't smart enough to fold them all together, so it should
> use a little less code in the unlikely branches. Does it?

Agree.

Eugene

      reply	other threads:[~2008-02-13  2:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-12 11:29 [PATCH 2/2] mm: various cleanups in get_user_pages() Eugene Teo
2008-02-12 11:40 ` [PATCH 2/2 resend] " Eugene Teo
2008-02-12 13:10   ` Eugene Teo
2008-02-13  1:13     ` Nick Piggin
2008-02-13  2:40       ` Eugene Teo [this message]

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=20080213024020.GA4002@kernel.sg \
    --to=eugeneteo@kernel.sg \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=torvalds@linux-foundation.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