Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2643752imu; Mon, 17 Dec 2018 05:36:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/UYyVQRIhmJeYRa5BGdLkf7H0FEEaZmNRN/xUIB9Q3r2uGZHeot04249Dke38AZCPLsyoWb X-Received: by 2002:a62:8c11:: with SMTP id m17mr12844881pfd.224.1545053782164; Mon, 17 Dec 2018 05:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545053782; cv=none; d=google.com; s=arc-20160816; b=zR1N4cmdjEsUx3pqy75+hfS3pwnLr+z/+AAjhcA9EeJDBYAW/xeqAAXqrEwbwNtqWP E1jwBUNKElwKqIVEPwavEq2K9VpV717W91ks0B+HvEK7IqNsxsJTyjGKybbkngmOO3dA aYqnFEIOXMbeqEfakw8+x6VZP//ebZCGk39oW/Z7w7+OWyDu/D4WBYgVxUWOdGzW/WOQ uip24PC7RrbL1HcnYWALi0wlnECddIITP71O5oIzM1hJpXLbs1tw84elm4Gq/mvvl7LJ mUWCo3I7Jd5ifFllAUCK3/B1vQUBgGH3ppctmuKbMt0YEH6bddoRoi0UKpHbHS5qG2H9 yyMQ== 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=cKwrKdbVsLBbEjG3Z+/G2ai/YaYEk/WwdMavvrd5pFQ=; b=F/PzyWv8yFKGuy75CgUfkEZjJ/ZggcGT2h6pYFt5VD45HcF/zo/fQLdbTawsktFKpJ kfnHjaVEBVB1lPymUTVtXuF0uDocDiO5F74EDHbzCYBkRPdgdC6ypX5yn6j9jKrscjBS HtW1mY3sPU6Z0CU0fZ2FWYU1j6FCxymX9nrFyElw0UQLT1dIQSAu62vurnLTKS/T2V+f I142rAiw3wtIZo0G28ri2NCZ81LAfFgCjBxfoHQ6jzzZ2Xit28RTbtuBlNUvRAeuBkBm 7MalZqEu6VKdw+qMoj+WTBshQRADfqZLUV0GiXFMWpkv3qAE3ouaVZidqLtgsCEqHn87 hCbQ== 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 f13si11887522pln.368.2018.12.17.05.36.06; Mon, 17 Dec 2018 05:36:22 -0800 (PST) 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 S1727119AbeLQKwN (ORCPT + 99 others); Mon, 17 Dec 2018 05:52:13 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:65353 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbeLQKwN (ORCPT ); Mon, 17 Dec 2018 05:52:13 -0500 Received: from fsav303.sakura.ne.jp (fsav303.sakura.ne.jp [153.120.85.134]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id wBHApWsQ055613; Mon, 17 Dec 2018 19:51:32 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav303.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav303.sakura.ne.jp); Mon, 17 Dec 2018 19:51:32 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav303.sakura.ne.jp) Received: from [192.168.1.8] (softbank126126163036.bbtec.net [126.126.163.36]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id wBHApSOk055586 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NO); Mon, 17 Dec 2018 19:51:32 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: Re: [PATCH] squashfs: enable __GFP_FS in ->readpage to prevent hang in mem alloc To: Michal Hocko , Matthew Wilcox Cc: Hou Tao , phillip@squashfs.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20181204020840.49576-1-houtao1@huawei.com> <20181215143824.GJ10600@bombadil.infradead.org> <69457a5a-79c9-4950-37ae-eff7fa4f949a@huawei.com> <20181217035157.GK10600@bombadil.infradead.org> <20181217093337.GC30879@dhcp22.suse.cz> From: Tetsuo Handa Message-ID: <00ff5d2d-a50f-4730-db8a-cea3d7a3eef7@I-love.SAKURA.ne.jp> Date: Mon, 17 Dec 2018 19:51:27 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <20181217093337.GC30879@dhcp22.suse.cz> 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 2018/12/17 18:33, Michal Hocko wrote: > On Sun 16-12-18 19:51:57, Matthew Wilcox wrote: > [...] >> Ah, yes, that makes perfect sense. Thank you for the explanation. >> >> I wonder if the correct fix, however, is not to move the check for >> GFP_NOFS in out_of_memory() down to below the check whether to kill >> the current task. That would solve your problem, and I don't _think_ >> it would cause any new ones. Michal, you touched this code last, what >> do you think? > > What do you mean exactly? Whether we kill a current task or something > else doesn't change much on the fact that NOFS is a reclaim restricted > context and we might kill too early. If the fs can do GFP_FS then it is > obviously a better thing to do because FS metadata can be reclaimed as > well and therefore there is potentially less memory pressure on > application data. > I interpreted "to move the check for GFP_NOFS in out_of_memory() down to below the check whether to kill the current task" as @@ -1077,15 +1077,6 @@ bool out_of_memory(struct oom_control *oc) } /* - * The OOM killer does not compensate for IO-less reclaim. - * pagefault_out_of_memory lost its gfp context so we have to - * make sure exclude 0 mask - all other users should have at least - * ___GFP_DIRECT_RECLAIM to get here. - */ - if (oc->gfp_mask && !(oc->gfp_mask & __GFP_FS)) - return true; - - /* * Check if there were limitations on the allocation (only relevant for * NUMA and memcg) that may require different handling. */ @@ -1104,6 +1095,19 @@ bool out_of_memory(struct oom_control *oc) } select_bad_process(oc); + + /* + * The OOM killer does not compensate for IO-less reclaim. + * pagefault_out_of_memory lost its gfp context so we have to + * make sure exclude 0 mask - all other users should have at least + * ___GFP_DIRECT_RECLAIM to get here. + */ + if ((oc->gfp_mask && !(oc->gfp_mask & __GFP_FS)) && oc->chosen && + oc->chosen != (void *)-1UL && oc->chosen != current) { + put_task_struct(oc->chosen); + return true; + } + /* Found nothing?!?! */ if (!oc->chosen) { dump_header(oc, NULL); which is prefixed by "the correct fix is not". Behaving like sysctl_oom_kill_allocating_task == 1 if __GFP_FS is not used will not be the correct fix. But ... Hou Tao wrote: > There is no need to disable __GFP_FS in ->readpage: > * It's a read-only fs, so there will be no dirty/writeback page and > there will be no deadlock against the caller's locked page is read-only filesystem sufficient for safe to use __GFP_FS? Isn't "whether it is safe to use __GFP_FS" depends on "whether fs locks are held or not" rather than "whether fs has dirty/writeback page or not" ?