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_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 5549FC433FE for ; Fri, 24 Sep 2021 06:11:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E0C0461214 for ; Fri, 24 Sep 2021 06:11:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E0C0461214 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 3A7C36B006C; Fri, 24 Sep 2021 02:11:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 356796B0071; Fri, 24 Sep 2021 02:11:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26CF1900002; Fri, 24 Sep 2021 02:11:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 1C7016B006C for ; Fri, 24 Sep 2021 02:11:08 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D58851808F54E for ; Fri, 24 Sep 2021 06:11:07 +0000 (UTC) X-FDA: 78621444174.34.0692C42 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf01.hostedemail.com (Postfix) with ESMTP id DB0D950606B9 for ; Fri, 24 Sep 2021 06:11:06 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10116"; a="211085589" X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="211085589" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2021 23:10:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="534865769" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.151]) by fmsmga004.fm.intel.com with ESMTP; 23 Sep 2021 23:10:54 -0700 Date: Fri, 24 Sep 2021 14:10:54 +0800 From: Feng Tang To: Michal Hocko Cc: Andrew Morton , David Rientjes , Tejun Heo , Zefan Li , Johannes Weiner , Mel Gorman , Vlastimil Babka , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] mm/page_alloc: detect allocation forbidden by cpuset and bail out early Message-ID: <20210924061054.GA72911@shbuild999.sh.intel.com> References: <1631590828-25565-1-git-send-email-feng.tang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: DB0D950606B9 X-Stat-Signature: 9ypdkknk8q8c7memjmuoouzwq5gi5cyx Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf01.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=feng.tang@intel.com X-HE-Tag: 1632463866-237084 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: Hi Michal, On Tue, Sep 14, 2021 at 10:50:42AM +0200, Michal Hocko wrote: > On Tue 14-09-21 11:40:28, Feng Tang wrote: [SPIN] > > The OOM killer cannot help to resolve the situation as there is no > > usable memory for the request in the cpuset scope. The only reasonable > > measure to take is to fail the allocation right away and have the caller > > to deal with it. > > > > So add a check for cases like this in the slowpath of allocation, and > > bail out early returning NULL for the allocation. > > > > As page allocation is one of the hottest path in kernel, this check > > will hurt all users with sane cpuset configuration, add a static branch > > check and detect the abnormal config in cpuset memory binding setup so > > that the extra check in page allocation is not paid by everyone. > > > > [thanks to Micho Hocko and David Rientjes for suggesting not handle > > it inside OOM code, adding cpuset check, refining comments] > > > > Suggested-by: Michal Hocko > > Signed-off-by: Feng Tang > > Acked-by: Michal Hocko Thank you! > Minor nit below > [...] > > +/* Whether the 'nodes' are all movable nodes */ > > +static inline bool movable_only_nodes(nodemask_t *nodes) > > +{ > > + struct zonelist *zonelist; > > + struct zoneref *z; > > + > > + if (nodes_empty(*nodes)) > > + return false; > > + > > + zonelist = > > + &NODE_DATA(first_node(*nodes))->node_zonelists[ZONELIST_FALLBACK]; > > + z = first_zones_zonelist(zonelist, ZONE_NORMAL, nodes); > > + return (!z->zone) ? true : false; > > This would read easier to me > /* > * We can chose arbitrary node from the nodemask to get a > * zonelist as they are interlinked. We just need to find > * at least one zone that can satisfy kernel allocations. > */ > node = NODE_DATA(first_node(*nodes)); > zonelist = node_zonelist(node, GFP_KERNEL); > z = first_zones_zonelist(zonelist, ZONE_NORMAL, nodes); When working on the v4 patch, I see some compile warning that 'node_zonelist()' and 'GFP_KERNEL' are either implicit or undeclared, as they are from "gfp.h". So we may need to move this function to gfp.h or keep the current code with slight modification? nid = first_node(*nodes); zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK]; z = first_zones_zonelist(zonelist, ZONE_NORMAL, nodes); return (!z->zone) ? true : false; Thanks, Feng