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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 630F9D58067 for ; Mon, 25 Nov 2024 11:33:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAEE36B0085; Mon, 25 Nov 2024 06:33:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E5DC66B0088; Mon, 25 Nov 2024 06:33:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D255E6B0089; Mon, 25 Nov 2024 06:33:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B4EA86B0085 for ; Mon, 25 Nov 2024 06:33:56 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3A3CD1207FD for ; Mon, 25 Nov 2024 11:33:56 +0000 (UTC) X-FDA: 82824408030.02.495C555 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by imf09.hostedemail.com (Postfix) with ESMTP id 19405140018 for ; Mon, 25 Nov 2024 11:33:51 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=cqG2ryKZ; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf09.hostedemail.com: domain of mhocko@suse.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732534431; a=rsa-sha256; cv=none; b=R5PDp44VlNfacq3g/oFdz9xN+woqdFABxhjfO3wbyke+IdoONQCru4suf1w62QH+8InCAY TSlxFX0og8rB8gJ6RrHD6q/bSf1xeONeTdX3Kh8IhOVlrDMOK3Y25nM2etqFdrwen/NF71 36tuXpdntm9vOwrzMeyByyOqUxP6/w8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=cqG2ryKZ; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf09.hostedemail.com: domain of mhocko@suse.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732534431; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mTM76Mdzqwb1GuClwHSoU2f/CrBS4pEthO5eWu6Q3V0=; b=Ji9f646mjx2hfV9zfR/zq2zTHrUAA4EvRz7xYyCKHP98DRRhCQjNg22rcjvXvKJbwABifW mTE49QLiwXb8Ots9qJtCSMpcT7Lk3xHgxYPEG086dsm+3HbGYDPLJ7kebjFqF1HM1tNZzX Fk3Ki6LplpGmszEOo3m3E9Ms39NrO0Q= Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso55133785e9.0 for ; Mon, 25 Nov 2024 03:33:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1732534433; x=1733139233; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mTM76Mdzqwb1GuClwHSoU2f/CrBS4pEthO5eWu6Q3V0=; b=cqG2ryKZ7yTayMwwziEH0rfOb/48G4/FZNUHxlU6RL9cb+H8Lo2DrUtQlIzK65XRB+ 95dz4ssOCmEBtHPomp/wYdjL24d9iaQHTJNIiK8O2sV0dln1fDUrUfzcJo+vi5n9p7TG NOIgEDRYwrl+UMQXxxn/uXUKDylhiTHtUNxgeE/dM8L/nl9B2XYcZZFLajk9woHWtwAP THtKdCmaJszCbGi6sKsNzpd2b/OKBpJNUkvFFZGxcvXJR2SuHdsaJSZ51y8XMOt9PBn5 JE/b76wuaEdP/y8o5pga4tbCMm4lsG9BGNnbKPGN/QhS4esXunmtVHau9EXndLrJomgM /DqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732534433; x=1733139233; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mTM76Mdzqwb1GuClwHSoU2f/CrBS4pEthO5eWu6Q3V0=; b=L9/y6IM6T7vSvNZ5/LCsJc+22NoiLCuE+3hXKeXmvdFrlpmb1t2Y8QNOt+BMPGIGcb gJXaWWYCt81sD4M0QU3yHz+Y3rwUwpBuPENImyLpCzEbbecosMfDXe/ShjmsAXYfTrT3 0mcJQzlA3h10ce7flOaiFxBO6dkzg3G5a+lBK12ric3DLlioCkeFODV6oVIP5yoU9f19 JA7AJasLiMJhW+b/jTIEA5sGYhgBFN4AnivDv9UbQHOuJ8e+gGoBku97Lolquzay80tQ RQCudVHFrqI0jgiNKyZ+lMjy5tApH9QpRznR858PO/FNrCR1tDyczyhI5LTqTybd22RH hecw== X-Gm-Message-State: AOJu0YxGUEJaNEqNFvtixAgZQLqp87mldqRQ2fYwLJWOVzZcBM7HNzpL Se4mx32z4e6n1ybOA2Sc9PBeQJ+gTapU+mA5SG+rvbHIXDRp3CTqQhehtO81mHNMh0246mb04go E X-Gm-Gg: ASbGnct6SwlDBZewjPS2lbd8VaNxG6bnnrw39AgQGPmgtO/6Pmb331dDhiD6BXBqfu8 TkxhgBsH9GpfHgdaJXSdLQIIcwB91I97BlVKg9lcWwyDO/FlDqAXqMZORYDGYvBhfl4gp+w5Axg k/+SXE+lZupl0c1rlcJ8rjlELWybCBphFjgAdNVyJlMHZhZkVgIvRljyvdUGsGRj+UBbyQQ1UXb 9tNFq842I5/jaDnIKqRjtUZiAWbIxSeWDCSy6TF X-Google-Smtp-Source: AGHT+IFYVyoFFMSqiR1Kn1O5xE8JxWbX8XxZKjBgzdjMtFSUnEr6pflHMkezvxbC5V+qeE5ilJxAfA== X-Received: by 2002:a05:600c:3ac3:b0:431:4b88:d407 with SMTP id 5b1f17b1804b1-433ce410255mr123612545e9.5.1732534432768; Mon, 25 Nov 2024 03:33:52 -0800 (PST) Received: from localhost ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432f643e65bsm174028585e9.0.2024.11.25.03.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 03:33:52 -0800 (PST) Date: Mon, 25 Nov 2024 12:33:52 +0100 From: Michal Hocko To: Junjie Fu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com Subject: Re: [PATCH] mm/mempolicy: Fix decision-making issues for memory migration during NUMA balancing Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: ieq8h411pucn6qnzh1dowq1e6fsh6tat X-Rspamd-Queue-Id: 19405140018 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1732534431-612901 X-HE-Meta: U2FsdGVkX1/jY1Cf3IEbrHspAXzGNWqSN69Ihg2U/4lFkvpMQAq7smQrhBr7grN4Q+WTsoxL72AHj1klY10sBrnXworIyuVf7tNTWPO1WQ+Cr6g6KpsY4LtxVG0DSuCXgxxhwnZWwGKQ3b5ObkU304bz9G9kEjBU8Tv6CQ/pJ/P05118pQLm0JCiHm7rYCcGf+GmPbYFBysLum9EmchJjLM8Vf+mFSZE5j4krkXQKxufXc4idEM/94/4+NCHI1xvF9q+B38hm/FwqmzVT1WTQ9DZmHNhf3NxcOvUuqvbLCCqEDxDKpBIZgwvE/AhNSUnmHc+2cN/8CFHYKYDIJdJzeaNSID5jkAYEVFWDy67Kt+3MEWdauWWKL076Mpena07NZL8p7e1OjHD+atGSR2/OuWtG/6lr/Uol7pIIhhyIXrAuJhT/n29w2FFAxzTFqqWXQKeQeL6COXCbC7Cy4fJ645T7nuDkEy9amiEJfE/x7EUaQO5fcoX1CzwNaiu/dr9PAqizIv1zschDnIHsifPuUlor9t6MWDEILpgrofWvhNHA5OA0gNKoVWawgw0v6s2XZBpTNHSf0RjHEnmyGorxiNxHG0GAbLZDgfXWsHmcNVL0oziThkf4SWwJauzxla8YkxZWd8hNk4NByJUOdqru26aQd3lJIWJUwZ6dlgegpEbWb9y8SN91AygYrVxxDPD4Fapd3SX/TBe+xgPDrSTS/I5ZC5AD9zYxA7OVHm8h5ikWSIEiY9z2AUCaGglInOGgCYRyQcuRXvElJsZMJh/aOChy6sdmulEHVEeZOaX8DaN9SGCTIw6faLJUVonxfFn6gtNpMl/9rTHVJ9L6s9SgwCV4g6V4Rtyh5Z/rMnbXaNVVkbj939rRT3rJq41/4D/vFToUwGrddOUyB+GIErxRiYqM8r6bbnV/ORxhbKXH5W+xNu00XzTGr0hWyVlDaWoiL9lUe7t4Eyicc7NEE0 nhUDi+/Y QL9netoX/w47NLn/Y6nA2o0DjsRvvXYNrjoibxAng8+IPNLfSMAeeFhC+/Z7wxs3H3waip1iAKYVnYxJvq+jkJwA2Y+K+o/2UCqFoP6uzPNxxV/CZCXz7fYg7jGgslsbx95+73sfgesR0+xxPHW5tUbrtUgmngf47PYe0DCl+dduqAxbDtIEVfsG5eO69qRkpWYwdIUm6emaKqdszvp3SjWzrAwl++IgszVtBR2f98+UCHZlKrukF2+WUswjvRy8tceRV6joRUHFxib/tsMgRv7GO2DiVP9c2A997IZBhg6jOLpJ2WMAX+w5lFQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000076, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sun 24-11-24 03:09:35, Junjie Fu wrote: > When handling a page fault caused by NUMA balancing (do_numa_page), it is > necessary to decide whether to migrate the current page to another node or > keep it on its current node. For pages with the MPOL_PREFERRED memory > policy, it is sufficient to check whether the first node set in the > nodemask is the same as the node where the page is currently located. If > this is the case, the page should remain in its current state. Otherwise, > migration to another node should be attempted. > > Because the definition of MPOL_PREFERRED is as follows: "This mode sets the > preferred node for allocation. The kernel will try to allocate pages from > this node first and fall back to nearby nodes if the preferred node is low > on free memory. If the nodemask specifies more than one node ID, the first > node in the mask will be selected as the preferred node." > > Thus, if the node where the current page resides is not the first node in > the nodemask, it is not the PREFERRED node, and memory migration can be > attempted. > > However, in the original code, the check only verifies whether the current > node exists in the nodemask (which may or may not be the first node in the > mask). This could lead to a scenario where, if the current node is not the > first node in the nodemask, the code incorrectly decides not to attempt > migration to other nodes. > > This behavior is clearly incorrect. If the target node for migration and > the page's current NUMA node are both within the nodemask but neither is > the first node, they should be treated with the same priority, and > migration attempts should proceed. The code is clearly confusing but is there any actual problem to be solved? IIRC although we do keep nodemask for MPOL_PREFERRED policy we do not allow to set more than a single node to be set there. Have a look at mpol_new_preferred -- Michal Hocko SUSE Labs