Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3300113ybz; Mon, 27 Apr 2020 13:34:54 -0700 (PDT) X-Google-Smtp-Source: APiQypJkhyBn+zD0iSUoocOyED/FNB2vQR59RBjm1+yGaaXdRczzYF9QCITIjzqUXXAm3Txf7Ag2 X-Received: by 2002:a17:906:1a06:: with SMTP id i6mr20910962ejf.90.1588019694173; Mon, 27 Apr 2020 13:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588019694; cv=none; d=google.com; s=arc-20160816; b=Vs67biYSGCiTxttTWpsImnzd7No1LfMaA8zmWLgE4tXDbyWxeQGZThmgxSOFgE5Sq5 U/wMF0/VgRvcxckstdYyzC5IjCrmuqMlv/oM13N+CVev/asyGBigfXFwGEnyIQ9YzMyW 8qsgqvvZo5twsiQ2bFYCDSmpg/oS3PjjAgd5tHoX74qLS93OAcD01wdegoc4yIO1ERDl oAZzcWtrcT/pFIzMGSzzFI2/xMJ70Dv76QncnPZmDLnOjPPftxdJY32DV2KMP74IFZzJ 62VcqAa1K9Lt+IpVbyGwe2jMO24MpGDm26YR+Oe6fK3mY0XoqM9AtxyEye911cTjuotw nb+w== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=UIHdvjRPGtrwgLXQnLGKRMzuG4STEaebyjcpP467BUA=; b=QvedzZpeQwfXDY4EoxyzZvnp3IkdqMMv6EhFlkTf2vrF/Z3M8pcU917ahU89RKPeIO 0OBN5vSOrh11CtMx2ZeeqVeQY5L5yJzJ/ifJSp5wPxBh7dsg6VvyWOHPi86aC/IiKuz5 d0guhBgl8ir6tqQRfis0Wht7ETp8Exgp8DnssZjNLW8WB68fTWGK+rFQDdhKpuwEtJM3 UMg+5tCiHUYnnWS9kmLcEF2/n2yf2vndjd6O24d3cNakbH6Os485HyNJCqEVsBbxElGc prS9CYq8VDq/PLeUSvbQ0agXJpOqkkMVpnD8S7BMuK5+FuMKsJxizDWXHdCaqy+AgMw0 sckQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WqOkTOeE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e15si379109ejj.374.2020.04.27.13.34.30; Mon, 27 Apr 2020 13:34:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WqOkTOeE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbgD0Uax (ORCPT + 99 others); Mon, 27 Apr 2020 16:30:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:44470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgD0Uaw (ORCPT ); Mon, 27 Apr 2020 16:30:52 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 04AD7206D4; Mon, 27 Apr 2020 20:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588019452; bh=3OaU0s347QfqeFqIzMECGLi3g6NTgnY6bjs+lqsqumo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WqOkTOeEGwBaKAM+DhtEkIARd8K6PGThTZPLzxxNPuk0yjqwzqWZ/yv2BR3ViUPTQ G9Z5skn6CjwjQesmvO+yI62J2raArApqb0KUyhxrZPBZhp8Q5p3/UmRQTZZxD7iSFH sTaegxf/bjyaKpzRobuOVZ1rqVDWIGjnViFb8NwQ= Date: Mon, 27 Apr 2020 13:30:51 -0700 From: Andrew Morton To: David Rientjes Cc: Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [patch] mm, oom: stop reclaiming if GFP_ATOMIC will start failing soon Message-Id: <20200427133051.b71f961c1bc53a8e72c4f003@linux-foundation.org> In-Reply-To: References: <20200425172706.26b5011293e8dc77b1dccaf3@linux-foundation.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 26 Apr 2020 20:12:58 -0700 (PDT) David Rientjes wrote: > > > blockable allocations and then queue a worker to asynchronously oom kill > > > if it finds watermarks to be sufficiently low as well. > > > > > > > Well, what's really going on here? > > > > Is networking potentially consuming an unbounded amount of memory? If > > so, then killing a process will just cause networking to consume more > > memory then hit against the same thing. So presumably the answer is > > "no, the watermarks are inappropriately set for this workload". > > > > So would it not be sensible to dynamically adjust the watermarks in > > response to this condition? Maintain a larger pool of memory for these > > allocations? Or possibly push back on networking and tell it to reduce > > its queue sizes? So that stuff doesn't keep on getting oom-killed? > > > > No - that would actually make the problem worse. > > Today, per-zone min watermarks dictate when user allocations will loop or > oom kill. should_reclaim_retry() currently loops if reclaim has succeeded > in the past few tries and we should be able to allocate if we are able to > reclaim the amount of memory that we think we can. > > The issue is that this supposes that looping to reclaim more will result > in more free memory. That doesn't always happen if there are concurrent > memory allocators. > > GFP_ATOMIC allocators can access below these per-zone watermarks. So the > issue is that per-zone free pages stays between ALLOC_HIGH watermarks > (the watermark that GFP_ATOMIC allocators can allocate to) and min > watermarks. We never reclaim enough memory to get back to min watermarks > because reclaim cannot keep up with the amount of GFP_ATOMIC allocations. But there should be an upper bound upon the total amount of in-flight GFP_ATOMIC memory at any point in time? These aren't like pagecache which will take more if we give it more. Setting the various thresholds appropriately should ensure that blockable allocations don't get their memory stolen by GPP_ATOMIC allocations? I took a look at doing a quick-fix for the direct-reclaimers-get-their-stuff-stolen issue about a million years ago. I don't recall where it ended up. It's pretty trivial for the direct reclaimer to free pages into current->reclaimed_pages and to take a look in there on the allocation path, etc. But it's only practical for order-0 pages.