Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1239382pxb; Thu, 23 Sep 2021 23:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywYURcBYf88zPncQHJaBSvSPRjc/6a0iu5hlGyhG+1+yrby03ci84EluDRf/m1m5RHdShg X-Received: by 2002:a5d:9051:: with SMTP id v17mr7494925ioq.134.1632464015229; Thu, 23 Sep 2021 23:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632464015; cv=none; d=google.com; s=arc-20160816; b=SxXQTQH6DpxmCnl4210Wx79yElSupmNNSRcimm2Vx4GOZBwPHXOcR34nlmsEFTrCBj LsX3S6n6e6I/+5la1gz/ESkTe6poJte5YREUbpdrrE0AF0eimc2P6vuKeWW6REwVo3vc lTLeh241Fq1VF50ZtLOda7+08xMoT4Bi+VIdo9tlu8cFHpXFMGhX9CHEQyabF4IN7XL7 gbpXdmV1BzxZYT54lQWhy3PMmTkYjNW1OJapJs7pEq6+56bl0cKCaGDptIEybeQvB/1t 63Z5BI+xWSRx2r1K0fBwE8UlVgH8ctzq5ueRkIsWxnMV4IJHWnkaI7cWmzCRkAypM4qz gyOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=H00UXpUi0ZB6kRhTUnSR9R+eaw12/V15nHryQn2b4T8=; b=FMx2sy8V2TVtneLSicrU/QDgyYB78mSZoWpdm1uA9xwJJFIt07h/VBZ3jYsgxJo6t7 BM79fGm3LiwfBXbyHQdsRjsHL+/7I0LGQ8oFU0TttNxuYsK3Y5+eJMx09GfjEfL9GGWj X4JPvQVI1AtxdU09zfKhcQzwUMAzhtu3w08XvwASCuUR/EvuJR6l+AmNY2ULQWt45plb ot9OSNQocNOpvZ4Mo88q2vK3K6tscBWwT8saJ0tIMVz75fIlI96iK3AMYd6Nz+DWM1En dwYAhbczLSusPSe8jyIiPh7GSh73Yz4/r0+NVYmR9P5oJUqWbyKgGRSyq1rOREIKShNF JIvg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si8791894jae.78.2021.09.23.23.13.20; Thu, 23 Sep 2021 23:13:35 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbhIXGMi (ORCPT + 99 others); Fri, 24 Sep 2021 02:12:38 -0400 Received: from mga18.intel.com ([134.134.136.126]:6019 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244146AbhIXGMi (ORCPT ); Fri, 24 Sep 2021 02:12:38 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10116"; a="211085588" X-IronPort-AV: E=Sophos;i="5.85,319,1624345200"; d="scan'208";a="211085588" 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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