linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
To: Hillf Danton <hdanton@sina.com>
Cc: Mike Christie <mchristi@redhat.com>,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	axboe@kernel.dk, James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com, linux-kernel@vger.kernel.org,
	linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
	Linux-MM <linux-mm@kvack.org>
Subject: Re: [RFC PATCH] Add proc interface to set PF_MEMALLOC flags
Date: Wed, 11 Sep 2019 23:20:38 +0900	[thread overview]
Message-ID: <6cff2ae9-4436-8df7-55a7-59e2e80b1054@i-love.sakura.ne.jp> (raw)
In-Reply-To: <20190911135237.11248-1-hdanton@sina.com>

On 2019/09/11 22:52, Hillf Danton wrote:
> 
> On Wed, 11 Sep 2019 19:07:34 +0900
>>
>> But I guess that there is a problem.
> 
> Not a new one. (see commit 7dea19f9ee63)
> 
>> Setting PF_MEMALLOC_NOIO causes
>> current_gfp_context() to mask __GFP_IO | __GFP_FS, but the OOM killer cannot
>> be invoked when __GFP_FS is masked. As a result, any userspace thread which
>> has PF_MEMALLOC_NOIO cannot invoke the OOM killer.
> 
> Correct.
> 
>> If the userspace thread
>> which uses PF_MEMALLOC_NOIO is involved in memory reclaiming activities,
>> the memory reclaiming activities won't be able to make forward progress when
>> the userspace thread triggered e.g. a page fault. Can the "userspace components
>> that can run in the IO path" survive without any memory allocation?
> 
> Good question.
> 
> It can be solved without oom killer involved because user should be
> aware of the risk of PF_MEMALLOC_NOIO if they ask for the convenience.
> OTOH we are able to control any abuse of it as you worry, knowing that
> the combination of __GFP_FS and oom killer can not get more than 50 users
> works done, and we have to pay as much attention as we can to the decisions
> they make. In case of PF_MEMALLOC_NOIO, we simply fail the allocation
> rather than killing a random victim.

According to commit c288983dddf71421 ("mm/page_alloc.c: make sure OOM victim can
try allocations with no watermarks once"), memory allocation failure from a page
fault results in invocation of the OOM killer via pagefault_out_of_memory() which
after all kills a random victim.

> 
> 
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -3854,6 +3854,8 @@ __alloc_pages_may_oom(gfp_t gfp_mask, un
>  	 * out_of_memory). Once filesystems are ready to handle allocation
>  	 * failures more gracefully we should just bail out here.
>  	 */
> +	if (current->flags & PF_MEMALLOC_NOIO)
> +		goto out;
>  
>  	/* The OOM killer may not free memory on a specific node */
>  	if (gfp_mask & __GFP_THISNODE)
> 
> 

  parent reply	other threads:[~2019-09-11 14:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190911031348.9648-1-hdanton@sina.com>
2019-09-11 10:07 ` [RFC PATCH] Add proc interface to set PF_MEMALLOC flags Tetsuo Handa
2019-09-11 15:44   ` Mike Christie
     [not found] ` <20190911135237.11248-1-hdanton@sina.com>
2019-09-11 14:20   ` Tetsuo Handa [this message]
2019-09-09 16:28 Mike Christie
2019-09-09 18:26 ` Mike Christie
2019-09-10  8:35   ` Damien Le Moal
2019-09-11  8:43     ` Martin Raiber
     [not found]     ` <0102016d1f7af966-334f093b-2a62-4baa-9678-8d90d5fba6d9-000000@eu-west-1.amazonses.com>
2019-09-11 16:56       ` Mike Christie
2019-09-11 19:21         ` Martin Raiber
2019-09-12 16:22           ` Mike Christie
2019-09-12 16:27             ` Mike Christie
2019-09-10 22:12   ` Tetsuo Handa
2019-09-10 23:28     ` Kirill A. Shutemov
2019-09-11 15:23     ` Mike Christie
2019-09-10 10:00 ` Kirill A. Shutemov
2019-09-10 12:05   ` Damien Le Moal
2019-09-10 12:41     ` Kirill A. Shutemov
2019-09-10 13:37       ` Damien Le Moal
2019-09-10 16:06   ` Mike Christie
2019-09-11  8:23 ` Bart Van Assche

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=6cff2ae9-4436-8df7-55a7-59e2e80b1054@i-love.sakura.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=axboe@kernel.dk \
    --cc=hdanton@sina.com \
    --cc=kirill@shutemov.name \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mchristi@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).