Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp878759pxb; Wed, 1 Sep 2021 11:56:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/oJImkDUNUs6S+uRken4bYBMsn3IO7Sl1cf5oTlNWhaiZT8NRM6vdYE7wjy0ux0Aznsza X-Received: by 2002:a05:6e02:964:: with SMTP id q4mr653786ilt.229.1630522611004; Wed, 01 Sep 2021 11:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630522610; cv=none; d=google.com; s=arc-20160816; b=YPK1qwL+4+iMS/6ru2D+/NFLFxIPyWiOMUCeZ19kCPE3Yv2CcsfwE0VtBMD/f/04Io 4x9ByTCEU3gGvY1d3Xwf/1GHIpHLxKwzALmbKcl+uKvo5N8PoD5wpFhmprWGCKhcYIFY Xxp2DT+jxR/oSewXI4fHH9V9SmnxZKuDK0Bb28Rp2sA1GH8kcNYG7JRYU+D0e3Toa+lm +gVriFAtOFzGIm7BuhoVNtBqSfU8254ipthFxQU4GNut0gUMDB1pBYF6UKiaAYGX8HIW EmpAK9IvThFLZ70ZAgGYlZv3VHE7FGiXh0lZ0DfUjWRyoMTRf5F6LuX/yvOHOguA86/l dLQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=A5CQMxYr8Knsq3vFDrRQ8ixBT4QrOt3iGkhDaaK15bg=; b=B21pzxAn6fjnavNgZLGjKx063YaHOAPdac+P0wUE37Nfxhga70fbzx7b9c7nSsiFPl 2GgWYdFIif3yOjPptMovTtaJCPTAT93FDkuOcrufKdaCk0Nf3SgbFcCo4aVWqF6T6sf8 t3tZN6wCAadJ3Iy3zMKL2Uk1lw6TxO1Wy/S5ml6fWJxfT8Hg/yM0AS0XsSripEpORMK/ hqNrzrFlt0mgY6AMXMlSiKWee8q1UFrSmO0PIqIvcf6iVsN+jwaydEqDRTJ6l/rjA6ip pEHdT49oh5gRIa4do4/KiJT86krog45PMZcIKZWVkug8EYG8ihgCB7yobjUaYKmLD7zu AR7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=b8OJW+yw; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si221804jaa.119.2021.09.01.11.56.39; Wed, 01 Sep 2021 11:56:50 -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=@suse.com header.s=susede1 header.b=b8OJW+yw; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244850AbhIAOGl (ORCPT + 99 others); Wed, 1 Sep 2021 10:06:41 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:51822 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244136AbhIAOGl (ORCPT ); Wed, 1 Sep 2021 10:06:41 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 801B52246F; Wed, 1 Sep 2021 14:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1630505143; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=A5CQMxYr8Knsq3vFDrRQ8ixBT4QrOt3iGkhDaaK15bg=; b=b8OJW+ywPOul9Qh4Eymlc7uE3F2l3lui6G2CvNsm63X50+tvXuOAnQRE8mKJPEkSNI1xIu 8FNCJj49fRnCBmnpiboHxw9PKpONP+vnzIEbWGF2s1l1Bj28Kk5NnH4UfP7t5XIh2RbTWb hkT5hsTcTpxH/sWO7hKaOYEmH5YuCuk= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 28B7DA3B9C; Wed, 1 Sep 2021 14:05:43 +0000 (UTC) Date: Wed, 1 Sep 2021 16:05:40 +0200 From: Michal Hocko To: Feng Tang Cc: David Rientjes , "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: References: <1630399085-70431-1-git-send-email-feng.tang@intel.com> <52d80e9-cf27-9a59-94fd-d27a1e2dac6f@google.com> <20210901024402.GB46357@shbuild999.sh.intel.com> <20210901134200.GA50993@shbuild999.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210901134200.GA50993@shbuild999.sh.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 01-09-21 21:42:00, Feng Tang wrote: [...] > 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; > + } > + This looks better than the previous attempt. It would be still better to solve this at the page allocator layer. The slowpath is already doing this for the nodemask. E.g. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index eeb3a9cb36bb..a3193134540d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4929,6 +4929,17 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, if (!ac->preferred_zoneref->zone) goto nopage; + /* + * Check for insane configurations where the cpuset doesn't contain any suitable + * zone to satisfy the request - e.g. kernel allocations from MOVABLE nodes only + */ + if (cpusets_enabled() && (gfp_mask & __GFP_HARDWALL)) { + struct zoneref *z = first_zones_zonelist(ac->zonelist, ac->highest_zoneidx, + &cpuset_current_mems_allowed); + if (!z->zone) + goto nopage; + } + if (alloc_flags & ALLOC_KSWAPD) wake_all_kswapds(order, gfp_mask, ac); if this is seen as an additional overhead for an insane configuration then we can add insane_cpusets_enabled() which would be a static branch enabled when somebody actually tries to configure movable only cpusets or potentially other dubious usage. -- Michal Hocko SUSE Labs