Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp60912rdh; Tue, 6 Feb 2024 19:34:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0MHPSVILktwrUyzVCYLKIEP+i8wTO0K6pt3c0RPlQHLY3srC3+gGGlGV6nww6IxUJEb5q X-Received: by 2002:a05:6a00:994:b0:6e0:3f2d:4c04 with SMTP id u20-20020a056a00099400b006e03f2d4c04mr1924132pfg.23.1707276883816; Tue, 06 Feb 2024 19:34:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707276883; cv=pass; d=google.com; s=arc-20160816; b=LHxf5nd7k1m99igDUeuDmq7juq/942aP8HLq8Esjga6m0fqnAlNVkzifhR4OQSRKi+ oc0+HcC97Dr0C+5RW8ZUZilgNuH3kmZ0egciq+goYtlLz4aVce4Qjngg0O5mDD2WH1Au USLAlgsjzGTkNmsUVt9cyGcnJWZKrByM6shh+7X0om8Vvr7ivpg8RAEDuqGygL+CyVY+ R0ceWX2b/exv22I4pDEMLXLF1cvNT3DguOdONCCWbUGcohYUEJ4eaTqe85bILGAB0pgv ds79h4ouUTWfn8lPnOTNuIsW99rHBGmWZduFxGEyNhF8F22CdJQhBntM2VifH5sR5tp6 UF/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:message-id:date:references:in-reply-to:subject:cc:to :from:dkim-signature; bh=jWgIQvg/35ee5w18f8D9WuoG8Gj68rbyzJdz9/HaPGo=; fh=JiXO6/eU59Frztt+KIEipnPV/km5d6Be/jY7jbJYpQc=; b=0J3AO9wdQaqP/++hItR9hyqH01LAIVyUjutuSF+8FHogwzKps/lM6kY36g3NDPcw1a 4DAvu2VnDeeJj5jQmC5IJfhlHjzXmM1X2wG8c+Z9xx/l4JzCrp78yZNrG6bVmo+0sRev WSI7yUG3bkDmWfiiEvS6JjwX/fqI6bO49JGsSjzss6ZQqXKe9JcC+15L6kcjdPGRnX1E 4xqS4Rbp63XDQTIFGwtFsHQbuk7fT0f1W0AXicpc6QSoQDTsw7LvnZwTaHFfzUHjxXKC X8FkrPWy5Zz/izE0GZGlNUiaNkcaclxaBWkbkowGNjM9o2APEDNbdqj2zYkMkYP6iQWT 9WGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W2j+J1ps; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-55879-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55879-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCU/vdbmZ8d6+biW/USAmWUeBbSe2+LszvfJg5n6NNwmY3mFEuSpu67MlJT8/+EdpY9mzwvqenl7zZOUF3wPnf9VmsRLfcbzsuedhG2gEQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n34-20020a056a000d6200b006e05311e166si488757pfv.172.2024.02.06.19.34.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 19:34:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55879-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W2j+J1ps; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-55879-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55879-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0AD00B282C1 for ; Wed, 7 Feb 2024 03:05:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B130FBEB; Wed, 7 Feb 2024 03:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W2j+J1ps" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1919CF515 for ; Wed, 7 Feb 2024 03:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707275091; cv=none; b=Y8RDzpKSvzd4AaUM+3usaXnN12VcjLVxSkLE4A6MGLcXG4jEYikH05cTRZOjM55S64goUCpWvehhML12EQp1y5/LGvyhUFCfLBMEG4lAVW6XzEbnHw7P6mtA3LeNf7mdDCzGTFC0QR1O1Pinumd0Q8GmtRCDl3Tc9QTXC3W/XF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707275091; c=relaxed/simple; bh=jjyo6oLa4+X/ISknl14tDw/49LaHcu3rQgBObBdx2Kk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=PxXAvObbW6sLp2JVC6UuXkulUGGvZ2rMGy2qRJOf45O9/SKjQX2C3yQ837jCT5fGwSBs5a4RcNiTKxqlzaXOUCALb/o9omojGWtIfVi0W7P0wrY/P/TpNCQwBprIOcXdSyeA0VI22Z7ZPpYqHO7cfPwYqoHPKRi1+W4Iyh67BG4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=W2j+J1ps; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707275089; x=1738811089; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=jjyo6oLa4+X/ISknl14tDw/49LaHcu3rQgBObBdx2Kk=; b=W2j+J1psECxMjz+Ao9GQm/ogi9aUd82lbUS7j/zFfaj+4SOX9YuRMfl0 OAhsGe+GmbVcJD+fIA0UU9IAmJilSo6UuvZGbjwXm8xvfFwyEreotGeDQ u0pPAuqR2AZcx+6ubWZQMHQ9BPUOQHxPeAOsPHAKpC2YyxzMlAvqBiiht G8ZMLQeLCq3yFBFppRzmhd9bnnOtkGkGsUuoKymhHpA7CaK//G7JpO9MZ LtdF5elHV8tECACh6tCNfpsN0o+x29E0zAANSvk1oeLgVtkGkNs7eys3L 1bSHKSjYVkSh4SKFkACtMsiBgH5d2njXkayflH0bbRRgMX9kFJtzmrk0S g==; X-IronPort-AV: E=McAfee;i="6600,9927,10976"; a="1046714" X-IronPort-AV: E=Sophos;i="6.05,248,1701158400"; d="scan'208";a="1046714" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 19:04:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,248,1701158400"; d="scan'208";a="1196327" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 19:04:33 -0800 From: "Huang, Ying" To: Li Zhijian Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org, "Aneesh Kumar K . V" Subject: Re: [PATCH v2] mm/demotion: print demotion targets In-Reply-To: <20240206020151.605516-1-lizhijian@fujitsu.com> (Li Zhijian's message of "Tue, 6 Feb 2024 10:01:51 +0800") References: <20240206020151.605516-1-lizhijian@fujitsu.com> Date: Wed, 07 Feb 2024 11:02:37 +0800 Message-ID: <87cyt9yo1e.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Li Zhijian writes: > Currently, when a demotion occurs, it will prioritize selecting a node > from the preferred targets as the destination node for the demotion. If > the preferred node does not meet the requirements, it will try from all > the lower memory tier nodes until it finds a suitable demotion destination > node or ultimately fails. > > However, the demotion target information isn't exposed to the users, > especially the preferred target information, which relies on more factors. > This makes users hard to understand the exact demotion behavior. > > Rather than having a new sys interface to expose this information, > printing directly to kernel messages, just like the current page > allocation fallback order does. > > A dmesg example with this patch is as follows: > [ 0.704860] Demotion targets for Node 0: null > [ 0.705456] Demotion targets for Node 1: null > // node 2 is onlined > [ 32.259775] Demotion targets for Node 0: perferred: 2, fallback: 2 > [ 32.261290] Demotion targets for Node 1: perferred: 2, fallback: 2 > [ 32.262726] Demotion targets for Node 2: null > // node 3 is onlined > [ 42.448809] Demotion targets for Node 0: perferred: 2, fallback: 2-3 > [ 42.450704] Demotion targets for Node 1: perferred: 2, fallback: 2-3 > [ 42.452556] Demotion targets for Node 2: perferred: 3, fallback: 3 > [ 42.454136] Demotion targets for Node 3: null > // node 4 is onlined > [ 52.676833] Demotion targets for Node 0: perferred: 2, fallback: 2-4 > [ 52.678735] Demotion targets for Node 1: perferred: 2, fallback: 2-4 > [ 52.680493] Demotion targets for Node 2: perferred: 4, fallback: 3-4 > [ 52.682154] Demotion targets for Node 3: null > [ 52.683405] Demotion targets for Node 4: null > // node 5 is onlined > [ 62.931902] Demotion targets for Node 0: perferred: 2, fallback: 2-5 > [ 62.938266] Demotion targets for Node 1: perferred: 5, fallback: 2-5 > [ 62.943515] Demotion targets for Node 2: perferred: 4, fallback: 3-4 > [ 62.947471] Demotion targets for Node 3: null > [ 62.949908] Demotion targets for Node 4: null > [ 62.952137] Demotion targets for Node 5: perferred: 3, fallback: 3-4 > > CC: "Huang, Ying" > CC: Aneesh Kumar K.V > Signed-off-by: Li Zhijian LGTM, Thanks! Reviewed-by: "Huang, Ying" > --- > V2: > Regarding this requirement, we have previously discussed [1]. > The initial proposal involved introducing a new sys interface. > However, due to concerns about potential changes and compatibility > issues with the interface in the future, a consensus was not > reached with the community. Therefore, this time, we are directly > printing out the information. > > [1] https://lore.kernel.org/all/d1d5add8-8f4a-4578-8bf0-2cbe79b09989@fujitsu.com/ > --- > mm/memory-tiers.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/mm/memory-tiers.c b/mm/memory-tiers.c > index 5462d9e3c84c..4d3506a290b7 100644 > --- a/mm/memory-tiers.c > +++ b/mm/memory-tiers.c > @@ -359,6 +359,26 @@ static void disable_all_demotion_targets(void) > synchronize_rcu(); > } > > +static void dump_demotion_targets(void) > +{ > + int node; > + > + for_each_node_state(node, N_MEMORY) { > + struct memory_tier *memtier = __node_get_memory_tier(node); > + nodemask_t preferred = node_demotion[node].preferred; > + > + if (!memtier) > + continue; > + > + if (nodes_empty(preferred)) > + pr_info("Demotion targets for Node %d: null\n", node); > + else > + pr_info("Demotion targets for Node %d: preferred: %*pbl, fallback: %*pbl\n", > + node, nodemask_pr_args(&preferred), > + nodemask_pr_args(&memtier->lower_tier_mask)); > + } > +} > + > /* > * Find an automatic demotion target for all memory > * nodes. Failing here is OK. It might just indicate > @@ -443,7 +463,7 @@ static void establish_demotion_targets(void) > * Now build the lower_tier mask for each node collecting node mask from > * all memory tier below it. This allows us to fallback demotion page > * allocation to a set of nodes that is closer the above selected > - * perferred node. > + * preferred node. > */ > lower_tier = node_states[N_MEMORY]; > list_for_each_entry(memtier, &memory_tiers, list) { > @@ -456,6 +476,8 @@ static void establish_demotion_targets(void) > nodes_andnot(lower_tier, lower_tier, tier_nodes); > memtier->lower_tier_mask = lower_tier; > } > + > + dump_demotion_targets(); > } > > #else