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.2 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 C5236C433F5 for ; Thu, 16 Sep 2021 08:11:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4884B6105A for ; Thu, 16 Sep 2021 08:11:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4884B6105A 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 30785900002; Thu, 16 Sep 2021 04:11:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 290B46B0072; Thu, 16 Sep 2021 04:11:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15844900002; Thu, 16 Sep 2021 04:11:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id 02E686B0071 for ; Thu, 16 Sep 2021 04:11:22 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AC3DA1F36A for ; Thu, 16 Sep 2021 08:11:21 +0000 (UTC) X-FDA: 78592716762.27.9D2ED5C Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf22.hostedemail.com (Postfix) with ESMTP id E02521902 for ; Thu, 16 Sep 2021 08:11:20 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6200,9189,10108"; a="202010879" X-IronPort-AV: E=Sophos;i="5.85,297,1624345200"; d="scan'208";a="202010879" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2021 01:11:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,297,1624345200"; d="scan'208";a="698775843" Received: from shbuild999.sh.intel.com (HELO localhost) ([10.239.146.151]) by fmsmga006.fm.intel.com with ESMTP; 16 Sep 2021 01:11:12 -0700 Date: Thu, 16 Sep 2021 16:11:12 +0800 From: Feng Tang To: Michal Hocko Cc: David Rientjes , Andrew Morton , 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: <20210916081112.GA41645@shbuild999.sh.intel.com> References: <1631590828-25565-1-git-send-email-feng.tang@intel.com> <3bd87d8a-d09e-ac7-1d1d-25ad1b9d5ed9@google.com> <20210915053247.GG56674@shbuild999.sh.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) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf22.hostedemail.com: domain of feng.tang@intel.com has no SPF policy when checking 192.55.52.136) smtp.mailfrom=feng.tang@intel.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E02521902 X-Stat-Signature: s4eh3eonj66degedipsxs1iqrbftm5d9 X-HE-Tag: 1631779880-422704 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 15, 2021 at 01:30:27PM +0200, Michal Hocko wrote: > On Wed 15-09-21 13:32:47, Feng Tang wrote: > > On Tue, Sep 14, 2021 at 05:30:03PM -0700, David Rientjes wrote: > [...] > > > I'm wondering about a single node nodemask, for example, where all > > > ZONE_NORMAL memory is hot-removed. > > While this is theoretically possible it is highly unlikely to happen. > Non movable memory just takes one kernel allocation to prevent any > hotremove operation to finish. I have to say I was not aware of the > hotplug callback. It all seems rather suspicious. I will have a look. > > Anyway something worth having covered "just in case". Thanks for > pointing it out. > > > Thanks for the reminding! Yes, memory hot remove can change the > > cpuset's effective nodemask, we may need to add similar check inside > > cpuset_hotplug_update_tasks() which is called by cpuset_hotplug_workfn(), > > something like below? > > > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > > index 7fa633e..d5f6776 100644 > > --- a/kernel/cgroup/cpuset.c > > +++ b/kernel/cgroup/cpuset.c > > @@ -3186,6 +3186,14 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) > > cpus_updated = !cpumask_equal(&new_cpus, cs->effective_cpus); > > mems_updated = !nodes_equal(new_mems, cs->effective_mems); > > > > + if (mems_updated && !cpusets_insane_config() && > > + movable_only_nodes(new_mems)) { > > + static_branch_enable(&cpusets_insane_config_key); > > + pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl) after memory hotplug." > > + "Cpuset allocations might fail even with a lot of memory available.\n", > > + nodemask_pr_args(new_mems); > > + } > > Please create a helper rather than two copies of the same. Thanks! Sure. Some draft add-on patch below. Thanks, Feng diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 7fa633e..3bb9f4ea 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -391,6 +391,18 @@ static inline bool is_in_v2_mode(void) (cpuset_cgrp_subsys.root->flags & CGRP_ROOT_CPUSET_V2_MODE); } +static inline void check_insane_mems_config(nodemask_t *nodes) +{ + if (!cpusets_insane_config() && + movable_only_nodes(nodes)) { + static_branch_enable(&cpusets_insane_config_key); + pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl)! " + "Cpuset allocations might fail even with a lot of memory available.\n", + nodemask_pr_args(nodes)); + } +} + /* * Return in pmask the portion of a task's cpusets's cpus_allowed that * are online and are capable of running the task. If none are found, @@ -1875,13 +1887,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs, if (retval < 0) goto done; - if (!cpusets_insane_config() && - movable_only_nodes(&trialcs->mems_allowed)) { - static_branch_enable(&cpusets_insane_config_key); - pr_info("Unsupported (movable nodes only) cpuset configuration detected (nmask=%*pbl)! " - "Cpuset allocations might fail even with a lot of memory available.\n", - nodemask_pr_args(&trialcs->mems_allowed)); - } + check_insane_mems_config(&trialcs->mems_allowed); spin_lock_irq(&callback_lock); cs->mems_allowed = trialcs->mems_allowed; @@ -3186,6 +3192,9 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp) cpus_updated = !cpumask_equal(&new_cpus, cs->effective_cpus); mems_updated = !nodes_equal(new_mems, cs->effective_mems); + if (mems_updated) + check_insane_mems_config(&new_mems); + if (is_in_v2_mode()) hotplug_update_tasks(cs, &new_cpus, &new_mems, cpus_updated, mems_updated);