Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp963506ybe; Wed, 11 Sep 2019 07:23:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6IoOdLMcKDy1CM9aT/jKLPspizIcaqdtkPh18i+0gRDDhmkip7BZ1M6GHytIlcw4lrVl9 X-Received: by 2002:a17:906:fae1:: with SMTP id lu33mr1259961ejb.131.1568211801690; Wed, 11 Sep 2019 07:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568211801; cv=none; d=google.com; s=arc-20160816; b=lLSZ6VuN4cUQWmcrFLp1wkM4mVNPV5QlYEL1HiXfChYa08HuVQdX9Wk/ZkTmYqevFA XMx3fdav8ZChblx5sqVv9EmA6pO966qfwTUnl7LgOkWKxrLE8/Ljb2pKY3IdSRscYO2H nCgd13it6drLaMiesf1EB93Pwf5rrSxJ8bxNVw3TGNKhCaUekme9zz2f2wwwfkXmet+N Ypo+GOHh+oZqTFb/K7Yme3NU2Smh3QsObefjybQWaJ5XyHG9TC/ELRoeR8+8WcpyvfjT defKPydJ9z8sRk9QG86SWzr/LkSSk3qx1hVnnW7BHqmm3iG4Evc8PKNZ8x5SABazera9 aM3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=nO7sRMlqKRR2KiPUISnibbE331+c5GYSt4Ls5njnxDQ=; b=zcspwUyY9bD7b/33NlegTQUYMTlizA68BAj+UtY0FdYV3uzKiQ5GZKbawlhkmwLbQq Ij6QQuiwF5wozANa4oIEVfPmo1XUDu3ClULCS9Ki+xX+kanqDmCvNeEheCT63X84NnGH wprhPMWeNtg2KfyxHCJuOQ5MVyYt8dm1bYxC0e5VKy1LHjG/XLYEnJWrxjnU8K/mpjf9 GC/Ba7QKzoJIYcQlb3fp/p1/wFAPZz3oIGPIg54CSHk7S5nqhDUF6ewL2hH/EX9ganf2 VaLPHg2uDT2d3GT77lJnlpqql+ptBKuGbetzVTfGAe6DrVd3e2GTu5dTPDl7gBlvOusN 5bIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34si2010012edk.26.2019.09.11.07.22.57; Wed, 11 Sep 2019 07:23:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728076AbfIKOVQ (ORCPT + 99 others); Wed, 11 Sep 2019 10:21:16 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:63115 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbfIKOVQ (ORCPT ); Wed, 11 Sep 2019 10:21:16 -0400 Received: from fsav403.sakura.ne.jp (fsav403.sakura.ne.jp [133.242.250.102]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id x8BEKgld005032; Wed, 11 Sep 2019 23:20:42 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav403.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp); Wed, 11 Sep 2019 23:20:42 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav403.sakura.ne.jp) Received: from [192.168.1.8] (softbank126227201116.bbtec.net [126.227.201.116]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id x8BEKg1D005028 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NO); Wed, 11 Sep 2019 23:20:42 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [RFC PATCH] Add proc interface to set PF_MEMALLOC flags To: Hillf Danton Cc: Mike Christie , "Kirill A. Shutemov" , 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 References: <20190911031348.9648-1-hdanton@sina.com> <20190911135237.11248-1-hdanton@sina.com> From: Tetsuo Handa Message-ID: <6cff2ae9-4436-8df7-55a7-59e2e80b1054@i-love.sakura.ne.jp> Date: Wed, 11 Sep 2019 23:20:38 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20190911135237.11248-1-hdanton@sina.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) > >