From patchwork Sat Feb 17 07:31:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donet Tom X-Patchwork-Id: 202581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp194951dyc; Fri, 16 Feb 2024 23:33:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWNMFrv4/pDZCJ48XdS8mmLVEHRbgfB3c9ws2NFQdoiJwFQNCCeoOLD85vGhEpF5laGVeOu1mQVvVq007sqFhgquM5j5A== X-Google-Smtp-Source: AGHT+IEMuKOSmPC7mT0Aw/K3CEU1c3u2acQp7rV/MJfDRAehOwIMLcuVScktmW3Ue9OQc+LFDmK6 X-Received: by 2002:a17:906:b785:b0:a3d:6160:fcca with SMTP id dt5-20020a170906b78500b00a3d6160fccamr5344730ejb.69.1708155203114; Fri, 16 Feb 2024 23:33:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708155203; cv=pass; d=google.com; s=arc-20160816; b=PP+sJekULraZa2mBp/JD7/RnHNZmJSUiUgIDgVtx1kovvhdOjVqTpyRnUp7HFoVsTZ FRQ7BAVI1iLcLsm5SwWY90DQWTkkCUB5JjHjcCsRsJIb6NXiFYAH8HjjvKFKEeR/w8yi d7ZcwbB7/0E/lumuI+DrroJ8tdEwINyChesC2jJdMeWGEss+3bCiRcI3WP4e9MYmL4ES I43hOR4AacVZrixL6jDkXZIjGKHcEzE2AwDiDIQzK2M5gcNeUiWDpRLWcoZZMXI6tCv7 9u82NIhyZNBwNn5kpvp4iGn7ev9/FFuYeXZa1SL8/gYLEiizM0M2x/c6zsYeDewGbnpu /muQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=JMT3nuMNp6lUin7O78tqTAkdQ8dhNushNKvFxaKIJGA=; fh=FFcNRKX/cmmdEO/4OCJX4rYOGTYmFqpwDil6Wds3ioM=; b=oqkGvejqya75AehkCIGShB3TUInjx/+W8OI8yivuauW0LFwJ6rqXUCNj7fpiLRZckP WtycjHAGPiyGeCstmxQpUX/xwfjp9bL1EZeKjjrM1VWAxK4+WkWcftU2Mzpxq1npTXHv 7U1vVKcucYteUHkzaprT1SoqoIEnN7aE7m0GRXo70trnuWR+8OWb0VCePYcEEzs1KJaC xY6Slexq5PUPRxt+gtJofww8qEq9PUjp4PXu5aN7nugJKmTJHtrUwLfRV2R2XMd63RXh IgZ131VwkWR72c9nCRT6N5UZnOzV5nCu1vb9V0p1qtUUplCcQrzd/YQ5HAgZ9ZNCO3+9 EluQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=HixjXUQy; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-69718-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69718-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h17-20020a170906261100b00a3d9436a68csi646609ejc.396.2024.02.16.23.33.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 23:33:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69718-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=HixjXUQy; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-69718-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69718-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.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 am.mirrors.kernel.org (Postfix) with ESMTPS id B624D1F222B1 for ; Sat, 17 Feb 2024 07:33:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 513C91D6A7; Sat, 17 Feb 2024 07:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="HixjXUQy" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 25AC71CD2A for ; Sat, 17 Feb 2024 07:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708155162; cv=none; b=Hq4Bb5vQmVrJfiMw+apWoU/FgxY+VhWPhob3ZyVJEjUYlTgN384A7svL3gQM9jBf4dxw1I7EylcDQOvSmriaaEPT8nHuHo1lKPOpZbJfPWLw6srfOXLLJ1ilHpsikvS2AP3lW3C2ipDGVaQ/XzjeH8enCja/VkZRDAkx1YF65Tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708155162; c=relaxed/simple; bh=syzmM7eUW3w//SDCJMEcCcBIvXx2NkPHU3sbMpurQzU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=l9EjVtrs054TPLDoG0WAb8tWBLDf7jKmbvK8SzjvXCkOt2KoAcbcRsw+YSCYUrzeCNSHd/l46rYJwlPsgUYkxnJVBaumpNqiXi3aHS7mKmla43BuNDeoZkgimyIdN3Ljo7cN994YSUXXNuA2Qq5pnAw3sivs67BIYotiPPmg9jc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=HixjXUQy; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41H7AiHE020961; Sat, 17 Feb 2024 07:31:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=JMT3nuMNp6lUin7O78tqTAkdQ8dhNushNKvFxaKIJGA=; b=HixjXUQyKmHu24W/4DHsxhCHLYc/8h9qS3qNDFTbYmNNTm2gYc+dMzVk8q5zHTSdSkVl uSN5Bg/Hui39aiOklBpz/fC+NIchMhpNqMWXimJsGInUlpxwDm7D4b8buwKg8P3luPvT 6o9dO60g8+2Tc+hiKeChPN02e/Ximz3hR1kCJmqLGdOHUGzk4ex1qFt97nIatHyEqh9r 6KnEpPibprbboseZ2E0PKOG6kddssOV2LvOSlkNukyyZQATJN6Uz+Jt/3E3Vh3dlseeh 4R8E5haMZ1gBoqm2SUYNbsvUA23BHFs+JAFQ573JVnVQjIVxS4mIVseyU2PFEZ7MqPdg 1g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3waq8h0s0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:46 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41H7U7ia027144; Sat, 17 Feb 2024 07:31:45 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3waq8h0ryy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:45 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41H623IR004247; Sat, 17 Feb 2024 07:31:44 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3w6kv10tun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:43 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41H7Vdn423986786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 17 Feb 2024 07:31:42 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D65542004E; Sat, 17 Feb 2024 07:31:39 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B043420040; Sat, 17 Feb 2024 07:31:36 +0000 (GMT) Received: from ltczz402-lp1.aus.stglabs.ibm.com (unknown [9.53.171.174]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 17 Feb 2024 07:31:36 +0000 (GMT) From: Donet Tom To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Aneesh Kumar , Huang Ying , Dave Hansen , Mel Gorman , Ben Widawsky , Feng Tang , Michal Hocko , Andrea Arcangeli , Peter Zijlstra , Ingo Molnar , Rik van Riel , Johannes Weiner , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Dan Williams , Hugh Dickins , Kefeng Wang , Suren Baghdasaryan Subject: [PATCH 1/3] mm/mempolicy: Use the already fetched local variable Date: Sat, 17 Feb 2024 01:31:33 -0600 Message-Id: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: DMqtCxbRPBcpizXWL_iXGokDYCRMYDlh X-Proofpoint-ORIG-GUID: ALbNl9CNixSrLoK-j4d-SrAX7YQwG9Md X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-17_04,2024-02-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 priorityscore=1501 suspectscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402170058 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791130550258738314 X-GMAIL-MSGID: 1791130550258738314 Avoid doing a per cpu read and use the local variable thisnid. IMHO this also makes the code more readable. Signed-off-by: Aneesh Kumar K.V (IBM) Signed-off-by: Donet Tom --- mm/mempolicy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 10a590ee1c89..8478574c000c 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2526,7 +2526,7 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, if (node_isset(curnid, pol->nodes)) goto out; z = first_zones_zonelist( - node_zonelist(numa_node_id(), GFP_HIGHUSER), + node_zonelist(thisnid, GFP_HIGHUSER), gfp_zone(GFP_HIGHUSER), &pol->nodes); polnid = zone_to_nid(z->zone); From patchwork Sat Feb 17 07:31:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donet Tom X-Patchwork-Id: 202580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp194896dyc; Fri, 16 Feb 2024 23:33:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWffnip0ignxeYSe+PpsjhCqTca0pyoIuoz7z5XVoie/Hg6OzYwMkB/FD0G4zvcQtlk+MfdWd7xTri6Go+huLLFipT6qg== X-Google-Smtp-Source: AGHT+IF/kXTB6Azywq7eoeRWpHQbpxv+04fHY7e3m403D+wcS3533xFrPAGBMspj67kuYfgiLZDN X-Received: by 2002:a05:622a:1493:b0:42d:e4e8:b802 with SMTP id t19-20020a05622a149300b0042de4e8b802mr3952093qtx.22.1708155193762; Fri, 16 Feb 2024 23:33:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708155193; cv=pass; d=google.com; s=arc-20160816; b=xMcJn/wcjTJ7CpAv7pQ39wFJydRx2r1hzARTDqmA1VyTrLELkCnnqOO75G+c3mrllf y332Q38VqqjP1Dk2ICfBZzxylaxUcNsCGQ/dQqDYAq00g0804bFbyEhDf4bxtNg9xjjo bdHtGA/0blvOW3PFqb4ta0x4TeX0aocrfONvvOnjwJfo9b6IQ217t50NL1BHXm4maLst hT8lnNNfyAG26dvKNtzlTul89B+czwoEtdkn8Jw8d0VrLqBMLsi7NuzhwU8uP9OAmn1S RtJhgRRGlF7P8wnCCsNMo+DTsqfT7Ec5ynMCLIaaVgLqvl5SD+b94lg1Gc5nT8wORIDR 8KKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qNdnXOL/mCGBemUkNo77c+l0ZD3S/yNBwt3aziQTX6E=; fh=FFcNRKX/cmmdEO/4OCJX4rYOGTYmFqpwDil6Wds3ioM=; b=TZZjj/McJkygcS96tDXmidx4R6Nq9xTxwOrEXDmvroQKLTkYSpybsqoeApy+3sAg9x RKuSuTzxSK0F6eUTw43I2ZMCybjTH6E45P5Os9nK1uGU0fPAzdzEhTe9iFIiX2zGZ4Bn VE1TA6Ww3u1yx8eTptL7MbV/KJ7WhRVROz7ZL7YPiRdy9FybFaI1jmzlkNXg682BRX0Z HvB2jTZaG0otzegUruyiNBR66LQad/zx9CTuuvEgoMcguc0ZqB8UVaamLvOCRt/L1alx bZ9eqyRBRs2nk/fUkKmZdCPkY8HP62htt/A3oBX1lYaxBdSIuM+1GQknNkn0ksQNV3lh 6pQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WbfT29f8; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-69717-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69717-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s18-20020ac85cd2000000b0042c7504cd5dsi1786566qta.666.2024.02.16.23.33.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 23:33:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69717-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WbfT29f8; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-69717-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69717-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8A1CA1C20F76 for ; Sat, 17 Feb 2024 07:33:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C53961D53D; Sat, 17 Feb 2024 07:32:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="WbfT29f8" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 72F2D1CD28 for ; Sat, 17 Feb 2024 07:32:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708155161; cv=none; b=nmeqgFBM7yT0vhhKOfoPQZYmROPzjjvKT5XFcxUEsPyEOKBptK34XDmovjTUW7gmhIZhP/1Z5ujuVJnjq20gdGzRunJBwU6nRlHwZMDBO0R4HLa1xts6JvV/sD5bu0THQaWNDv9apUk+33oPLU5RuI7GQu0Jjb8mjLKnPCZ+22o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708155161; c=relaxed/simple; bh=PiQwLTmZ6W5HTM2z6PZFxaEnlW+S6lS3/1uTGO6XgjA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CpwSVUS3Pcupkod00SVvDmd9w8kbymYDvWYIwnvmJRe7gFe1lOJmJNJRPn0khGeOrU+SIxpA+F0c8zq1VkduqzIC9sp4RChtMWzQRh6h3bY/SbhNQ7OkpSj5XSS3IO+5zqk9L2dJBNY97CBtmE2tPW9CwSLmBAU4gohBEG452Xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=WbfT29f8; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41H6gu7b011493; Sat, 17 Feb 2024 07:31:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=qNdnXOL/mCGBemUkNo77c+l0ZD3S/yNBwt3aziQTX6E=; b=WbfT29f8MSInX04uIWKE1R4g4T4wDLqm2Q0+GtfRgUg8RRlhTkOlh/pUMOPmEYnenrCR AKZFo3ViieOyFuey9IE2W8C4mC7joVXQbScMGvMJmCj3HsXfFlyCHBw/kvTaAd4MxTwA uvIqoBWM1tjQghekGbfbiLW7zr53YcsfRPKyi5JRcz4CN4Cm2FynNfNGCIN0DoSwi3MS Epq/DXu3E11Mv2gU7ajZva5PcyzkvqrOtp3Kjj4QaA6wSNOyItBBd/hqsLt+mnkTCJYN rXfNcroAyuUE0GW3Da9WtgypR7CpqVZ5jcYIQad59SlxIWAxQTLjaZe4lLvzyvQXGPYX 0g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3waqs30jmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:48 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41H7UPCA013204; Sat, 17 Feb 2024 07:31:48 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3waqs30jm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:48 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41H55V6k010050; Sat, 17 Feb 2024 07:31:47 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3w6npmg88w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:47 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41H7VhcM18940586 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 17 Feb 2024 07:31:45 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F4832004F; Sat, 17 Feb 2024 07:31:43 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FFD52004B; Sat, 17 Feb 2024 07:31:40 +0000 (GMT) Received: from ltczz402-lp1.aus.stglabs.ibm.com (unknown [9.53.171.174]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 17 Feb 2024 07:31:39 +0000 (GMT) From: Donet Tom To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Aneesh Kumar , Huang Ying , Dave Hansen , Mel Gorman , Ben Widawsky , Feng Tang , Michal Hocko , Andrea Arcangeli , Peter Zijlstra , Ingo Molnar , Rik van Riel , Johannes Weiner , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Dan Williams , Hugh Dickins , Kefeng Wang , Suren Baghdasaryan Subject: [PATCH 2/3] mm/mempolicy: Avoid the fallthrough with MPOLD_BIND in mpol_misplaced. Date: Sat, 17 Feb 2024 01:31:34 -0600 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> References: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: RFIikoKL5ffHBWAyVD9mrafMHgu0IRNd X-Proofpoint-ORIG-GUID: sLIiKqq1v8CAfDTE3aGBn-xbDlUw40Kv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-17_04,2024-02-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402170058 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791130540280480071 X-GMAIL-MSGID: 1791130540280480071 We will update MPOL_PREFERRED_MANY in the follow up patch. This change is required for that. Signed-off-by: Aneesh Kumar K.V (IBM) Signed-off-by: Donet Tom --- mm/mempolicy.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 8478574c000c..73d698e21dae 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2515,7 +2515,15 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, break; goto out; } - fallthrough; + + if (node_isset(curnid, pol->nodes)) + goto out; + z = first_zones_zonelist( + node_zonelist(thisnid, GFP_HIGHUSER), + gfp_zone(GFP_HIGHUSER), + &pol->nodes); + polnid = zone_to_nid(z->zone); + break; case MPOL_PREFERRED_MANY: /* From patchwork Sat Feb 17 07:31:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donet Tom X-Patchwork-Id: 202582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp195577dyc; Fri, 16 Feb 2024 23:35:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUe4u3rI4RzJ9MFiOLtxL2GGz/gwmr1Qe4abiRxTuTlmi4PfMwdCTxeTLO8hz9dZu8eQixdZXZmCXIq4g6uqI+heZ7rkA== X-Google-Smtp-Source: AGHT+IEHPg0Ed4ENJDRF3w591lT4eaM/mD/xFHmLpEjWioynKIu+uKyjCv2hm+BFp8D/KO8DOnnX X-Received: by 2002:a05:622a:190c:b0:42b:e666:5bb1 with SMTP id w12-20020a05622a190c00b0042be6665bb1mr8053281qtc.28.1708155344732; Fri, 16 Feb 2024 23:35:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708155344; cv=pass; d=google.com; s=arc-20160816; b=1FdTcqxd3JGq922eLLMrXuxiNb5H87SLGl0tLEObnL9yYi7dNgxFtaJilBpgspU1ED z/pmJOsHnUIyR9DyTZ4/mGb7tIN2QlRb+DqOmJvQrNOY0Z9MwQoTVJ82fYNb3VpdVRFx e4n1sKNKfeEWEj833MatqB/JjlXyvJabCiMQroJCseJj6M+dmoUwZK3tK3ywzXPhKt+4 HfK7rtvRXK2QEiMhJ80PVb029MV8h69R03LCd2Gd5KWKd/OUDUCRLFzqtqUNqeutv0qX pK1/avPFdO9PjPcUGzYXcdiWBlX/QsqS2/3x0cN2dOtPROzRURxPu4S0a/QW2izI2SSX qsWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UEk1JLmSe642sbxXn82ubc2FynSt0QvkkNE3uRZNLGc=; fh=FFcNRKX/cmmdEO/4OCJX4rYOGTYmFqpwDil6Wds3ioM=; b=rkKnATnAtsSqmlLSM0YR1+4S4a43wbQpBDAkUcoawcK82hjXO/wRg/bOu0LJv71RtN 0WdkQOOAkKDUfa8yAxKtbviFgQpPr9thMFN84Z8AHH3YdUhNJJm6x9NexXLweDiXiXrk C6GhqmLzWAYTgpOEIhqzL0DhIdsjbe7LUJGQ2ZUB54cbmjeO5LNkRpsJApiYGdprClXu BQiS6Ji0c4yVrMb7/8JR/abQzi8lCx6BTsM+aOCr36q0szic8WncFrAH9MCnCd7IXYvD SScFFihYjfIqPyYRS69bmifRkDK6qXAe4pUBxgOAnizBPcRssAq8+L5/wmPl8NAfJVz1 s26w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Un47yEWj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-69719-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69719-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id bb26-20020a05622a1b1a00b0042dc8b61500si1758348qtb.349.2024.02.16.23.35.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 23:35:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69719-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Un47yEWj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-69719-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69719-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 756D31C21033 for ; Sat, 17 Feb 2024 07:35:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36F871CD26; Sat, 17 Feb 2024 07:35:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Un47yEWj" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 A79DA33CA for ; Sat, 17 Feb 2024 07:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708155329; cv=none; b=tMEwR4VUYbKk6lT4otddDAl1jAfunA+XorcilIVThUNEcoZ6yLym9h/abDY405SzXNjubzRdFUjVssWenV/Lb8+f1pDRqGxtG+V0hlCjUm5iKMP8KQUHXR5A0IZnB+0T8+N7byDiwIqjU9S23NsqtU/rL3J0jSiyk/YktL8s7dE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708155329; c=relaxed/simple; bh=BdwHYDKb048UZTl6QADSK7S6tKXeJACzVDM50YdF/Rs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ReXdpFG6LxjfGmP0Eh3Hw6OYtfZGhIMrUQs9p5D7FnMT4rgJkHnlE75upPS79Zzxsx9ZqOW/PJ0Xhu/bBU/8ODAKoPN6D9b6cPUMm/g736H+M9U8sPJ+qL253p42pnZ8V36N0UHitjGDyv7HOJ2KdmRgpi10pHaN1JCgI/eQVsg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Un47yEWj; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41H7RRfW027691; Sat, 17 Feb 2024 07:35:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=UEk1JLmSe642sbxXn82ubc2FynSt0QvkkNE3uRZNLGc=; b=Un47yEWjBJrXA7SRBOmHqumVs/CmT+bDxvgxxOB6VSGHCYsXQwVjcHhkMgpiqs0VOPVg ablU7Tn7MaO5zzux203BbR0YUwQ9bSGeQ90DoV34e106psNEmiZNhi1yHB9o2swwuK+t sRqH14kohmKY1/8WxnHxb4/TnnmJk4tdOAAbN3jZRu398pygs6xRKejGMAwRv/1WvzkM SFMZyAahBPvO9o1SpOODWF+WcztaTs0+9lmz9NbF0Rzlx3VWDxk40ayscvUsCVoIX723 by13UFvrr5eZ+zsbbzzBHgnARjNxlalWZGzPHxs0Jys/Lrz2+h6wc+g/+W1NZaMpleCP wQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wardu821e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:35:02 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41H7Z2XP012248; Sat, 17 Feb 2024 07:35:02 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wardu81ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:35:02 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41H3lSrS016307; Sat, 17 Feb 2024 07:31:50 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3w6myn8j72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 17 Feb 2024 07:31:50 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41H7VkN957475338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 17 Feb 2024 07:31:48 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CEE420063; Sat, 17 Feb 2024 07:31:46 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D9EC20040; Sat, 17 Feb 2024 07:31:43 +0000 (GMT) Received: from ltczz402-lp1.aus.stglabs.ibm.com (unknown [9.53.171.174]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Sat, 17 Feb 2024 07:31:43 +0000 (GMT) From: Donet Tom To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Aneesh Kumar , Huang Ying , Dave Hansen , Mel Gorman , Ben Widawsky , Feng Tang , Michal Hocko , Andrea Arcangeli , Peter Zijlstra , Ingo Molnar , Rik van Riel , Johannes Weiner , Matthew Wilcox , Mike Kravetz , Vlastimil Babka , Dan Williams , Hugh Dickins , Kefeng Wang , Suren Baghdasaryan Subject: [PATCH 3/3] mm/numa_balancing:Allow migrate on protnone reference with MPOL_PREFERRED_MANY policy Date: Sat, 17 Feb 2024 01:31:35 -0600 Message-Id: <8d7737208bd24e754dc7a538a3f7f02de84f1f72.1708097962.git.donettom@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> References: <9c3f7b743477560d1c5b12b8c111a584a2cc92ee.1708097962.git.donettom@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: cIL8LtNuI-z2kC5XRafsucUMhsTTru8H X-Proofpoint-ORIG-GUID: NZM7zSCbHzkgOUkllOLT3YhqdAxSxFIB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-17_04,2024-02-16_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 mlxscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402170058 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791130698865185619 X-GMAIL-MSGID: 1791130698865185619 commit bda420b98505 ("numa balancing: migrate on fault among multiple bound nodes") added support for migrate on protnone reference with MPOL_BIND memory policy. This allowed numa fault migration when the executing node is part of the policy mask for MPOL_BIND. This patch extends migration support to MPOL_PREFERRED_MANY policy. Currently, we cannot specify MPOL_PREFERRED_MANY with the mempolicy flag MPOL_F_NUMA_BALANCING. This causes issues when we want to use NUMA_BALANCING_MEMORY_TIERING. To effectively use the slow memory tier, the kernel should not allocate pages from the slower memory tier via allocation control zonelist fallback. Instead, we should move cold pages from the faster memory node via memory demotion. For a page allocation, kswapd is only woken up after we try to allocate pages from all nodes in the allocation zone list. This implies that, without using memory policies, we will end up allocating hot pages in the slower memory tier. MPOL_PREFERRED_MANY was added by commit b27abaccf8e8 ("mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes") to allow better allocation control when we have memory tiers in the system. With MPOL_PREFERRED_MANY, the user can use a policy node mask consisting only of faster memory nodes. When we fail to allocate pages from the faster memory node, kswapd would be woken up, allowing demotion of cold pages to slower memory nodes. With the current kernel, such usage of memory policies implies we can't do page promotion from a slower memory tier to a faster memory tier using numa fault. This patch fixes this issue. For MPOL_PREFERRED_MANY, if the executing node is in the policy node mask, we allow numa migration to the executing nodes. If the executing node is not in the policy node mask but the folio is already allocated based on policy preference (the folio node is in the policy node mask), we don't allow numa migration. If both the executing node and folio node are outside the policy node mask, we allow numa migration to the executing nodes. Signed-off-by: Aneesh Kumar K.V (IBM) Signed-off-by: Donet Tom --- mm/mempolicy.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 73d698e21dae..8c4c92b10371 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1458,9 +1458,10 @@ static inline int sanitize_mpol_flags(int *mode, unsigned short *flags) if ((*flags & MPOL_F_STATIC_NODES) && (*flags & MPOL_F_RELATIVE_NODES)) return -EINVAL; if (*flags & MPOL_F_NUMA_BALANCING) { - if (*mode != MPOL_BIND) + if (*mode == MPOL_BIND || *mode == MPOL_PREFERRED_MANY) + *flags |= (MPOL_F_MOF | MPOL_F_MORON); + else return -EINVAL; - *flags |= (MPOL_F_MOF | MPOL_F_MORON); } return 0; } @@ -2463,6 +2464,23 @@ static void sp_free(struct sp_node *n) kmem_cache_free(sn_cache, n); } +static inline bool mpol_preferred_should_numa_migrate(int exec_node, int folio_node, + struct mempolicy *pol) +{ + /* if the executing node is in the policy node mask, migrate */ + if (node_isset(exec_node, pol->nodes)) + return true; + + /* If the folio node is in policy node mask, don't migrate */ + if (node_isset(folio_node, pol->nodes)) + return false; + /* + * both the folio node and executing node are outside the policy nodemask, + * migrate as normal numa fault migration. + */ + return true; +} + /** * mpol_misplaced - check whether current folio node is valid in policy * @@ -2526,6 +2544,12 @@ int mpol_misplaced(struct folio *folio, struct vm_area_struct *vma, break; case MPOL_PREFERRED_MANY: + if (pol->flags & MPOL_F_MORON) { + if (!mpol_preferred_should_numa_migrate(thisnid, curnid, pol)) + goto out; + break; + } + /* * use current page if in policy nodemask, * else select nearest allowed node, if any.