From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36467C4320E for ; Wed, 1 Sep 2021 13:42:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC26D60F92 for ; Wed, 1 Sep 2021 13:42:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BC26D60F92 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 05A096B006C; Wed, 1 Sep 2021 09:42:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 008D38D0002; Wed, 1 Sep 2021 09:42:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DECA78D0001; Wed, 1 Sep 2021 09:42:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0167.hostedemail.com [216.40.44.167]) by kanga.kvack.org (Postfix) with ESMTP id D24736B006C for ; Wed, 1 Sep 2021 09:42:11 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 820F0274D3 for ; Wed, 1 Sep 2021 13:42:11 +0000 (UTC) X-FDA: 78539118462.11.410BFBC Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf04.hostedemail.com (Postfix) with ESMTP id F271250000AE for ; Wed, 1 Sep 2021 13:42:09 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10093"; a="205977497" X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="205977497" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2021 06:42:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,369,1620716400"; d="scan'208";a="498900664" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.151]) by fmsmga008.fm.intel.com with ESMTP; 01 Sep 2021 06:42:00 -0700 Date: Wed, 1 Sep 2021 21:42:00 +0800 From: Feng Tang To: David Rientjes , Michal Hocko Cc: "linux-mm@kvack.org" , Andrew Morton , Christian Brauner , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH] mm/oom: detect and kill task which has allocation forbidden by cpuset limit Message-ID: <20210901134200.GA50993@shbuild999.sh.intel.com> References: <1630399085-70431-1-git-send-email-feng.tang@intel.com> <52d80e9-cf27-9a59-94fd-d27a1e2dac6f@google.com> <20210901024402.GB46357@shbuild999.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210901024402.GB46357@shbuild999.sh.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Rspamd-Queue-Id: F271250000AE Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf04.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.20) smtp.mailfrom=feng.tang@intel.com X-Rspamd-Server: rspam01 X-Stat-Signature: f3hbfaytoyhno7csnc5bym7rask7wz1x X-HE-Tag: 1630503729-421132 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 01, 2021 at 10:44:02AM +0800, Tang, Feng wrote: [SNIP] > > So I'd agree in this case that it would be better to simply fail the > > allocation. > > I agree with yours and Michal's comments, putting it in the OOM code > is a little late and wastes cpu cycles. > > > Feng, would you move this check to __alloc_pages_may_oom() like the other > > special cases and simply fail rather than call into the oom killer? > > Will explore more in this direction, thanks! I tried below patch, which can solve the blindly killing issue, that the docker processes will see page allocation errors, and eventually quit running. Thanks, Feng --- diff --git a/mm/page_alloc.c b/mm/page_alloc.c index eeb3a9cb36bb..d1ae77be45a2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4271,10 +4271,18 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, .gfp_mask = gfp_mask, .order = order, }; - struct page *page; + struct page *page = NULL; + struct zoneref *z; *did_some_progress = 0; + if (cpusets_enabled() && (gfp_mask & __GFP_HARDWALL)) { + z = first_zones_zonelist(ac->zonelist, + gfp_zone(gfp_mask), &cpuset_current_mems_allowed); + if (!z->zone) + goto out; + } + /* * Acquire the oom lock. If that fails, somebody else is * making progress for us.