linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: Minchan Kim <minchan@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-pm@vger.kernel.org,
	Alan Stern <stern@rowland.harvard.edu>,
	Oliver Neukum <oneukum@suse.de>,
	Jiri Kosina <jiri.kosina@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mel Gorman <mel@csn.ul.ie>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Michal Hocko <mhocko@suse.cz>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"Rafael J. Wysocki" <rjw@sisk.pl>, linux-mm <linux-mm@kvack.org>
Subject: Re: [RFC PATCH 1/3] mm: teach mm by current context info to not do I/O during memory allocation
Date: Tue, 16 Oct 2012 21:47:03 +0800	[thread overview]
Message-ID: <CACVXFVMr=JMNHFe1GO=di99eB-6-=_pBkP3QH4x_qtKhdRZMFw@mail.gmail.com> (raw)
In-Reply-To: <20121016130927.GA5603@barrios>

On Tue, Oct 16, 2012 at 9:09 PM, Minchan Kim <minchan@kernel.org> wrote:
>
> Good point. You can check it in __zone_reclaim and change gfp_mask of scan_control
> because it's never hot path.
>
>>
>> So could you make sure it is safe to move the branch into
>> __alloc_pages_slowpath()?  If so, I will add the check into
>> gfp_to_alloc_flags().
>
> How about this?

It is quite smart change, :-)

Considered that other part(sched.h) of the patch need update, I
will merge your change into -v1 for further review with your
Signed-off-by if you have no objection.

>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index d976957..b3607fa 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2614,10 +2614,16 @@ retry_cpuset:
>         page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order,
>                         zonelist, high_zoneidx, alloc_flags,
>                         preferred_zone, migratetype);
> -       if (unlikely(!page))
> +       if (unlikely(!page)) {
> +               /*
> +                * Resume path can deadlock because block device
> +                * isn't active yet.
> +                */

Not only resume path, I/O transfer or its error handling path may deadlock too.

> +               if (unlikely(tsk_memalloc_no_io(current)))
> +                       gfp_mask &= ~GFP_IOFS;
>                 page = __alloc_pages_slowpath(gfp_mask, order,
>                                 zonelist, high_zoneidx, nodemask,
>                                 preferred_zone, migratetype);
> +       }
>
>         trace_mm_page_alloc(page, order, gfp_mask, migratetype);
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index b5e45f4..6c2ccdd 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3290,6 +3290,16 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
>         };
>         unsigned long nr_slab_pages0, nr_slab_pages1;
>
> +       if (unlikely(tsk_memalloc_no_io(current))) {
> +               sc.gfp_mask &= ~GFP_IOFS;
> +               shrink.gfp_mask = sc.gfp_mask;
> +               /*
> +                * We allow to reclaim only clean pages.
> +                * It can affect RECLAIM_SWAP and RECLAIM_WRITE mode
> +                * but this is really rare event and allocator can
>                  * fallback to other zones.
> +                */
> +               sc.may_writepage = 0;
> +               sc.may_swap = 0;
> +       }
> +
>         cond_resched();
>         /*
>          * We need to be able to allocate from the reserves for RECLAIM_SWAP
>

Thanks,
--
Ming Lei

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2012-10-16 13:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1350278059-14904-1-git-send-email-ming.lei@canonical.com>
2012-10-15  5:14 ` Ming Lei
2012-10-15 14:33   ` Alan Stern
2012-10-15 14:41     ` Ming Lei
2012-10-15 15:47   ` Minchan Kim
2012-10-16  1:56     ` Ming Lei
2012-10-16  5:49       ` Minchan Kim
2012-10-16  7:08         ` Ming Lei
2012-10-16 13:09           ` Minchan Kim
2012-10-16 13:47             ` Ming Lei [this message]
2012-10-16 13:53               ` Minchan Kim

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='CACVXFVMr=JMNHFe1GO=di99eB-6-=_pBkP3QH4x_qtKhdRZMFw@mail.gmail.com' \
    --to=ming.lei@canonical.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiri.kosina@suse.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mel@csn.ul.ie \
    --cc=mhocko@suse.cz \
    --cc=minchan@kernel.org \
    --cc=mingo@redhat.com \
    --cc=oneukum@suse.de \
    --cc=peterz@infradead.org \
    --cc=rjw@sisk.pl \
    --cc=stern@rowland.harvard.edu \
    /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