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 77B7DD58D61 for ; Mon, 25 Nov 2024 16:06:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEDC16B008C; Mon, 25 Nov 2024 11:06:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9D206B0092; Mon, 25 Nov 2024 11:06:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C657B6B0093; Mon, 25 Nov 2024 11:06:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AC73F6B008C for ; Mon, 25 Nov 2024 11:06:32 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3E54B1A0A26 for ; Mon, 25 Nov 2024 16:06:32 +0000 (UTC) X-FDA: 82825094898.12.4B1A24F Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by imf07.hostedemail.com (Postfix) with ESMTP id B694440018 for ; Mon, 25 Nov 2024 16:06:26 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b="p/9IYkIz"; spf=pass (imf07.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.179 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732550786; 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=9a9VnHGIm3FCJ1sQpVPUgDLqqd8uoWG359o3vCNQ3GQ=; b=wJl8TCHZ8EZdCHPPrDIfKm03uA0w0Q2isG3GeCgHTp4n56/fMLsbOhlCATQRiMaDAIQqkx NmyXxbdLa1OpIIgj4ZERj3cLAFbCNJeLmy+DhdAhowTd1E8VfQnMq+C6SADL+hBc2NiWRR JSGN8bY7VdmNrzB/urDOHJG3XJaYlt8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gourry.net header.s=google header.b="p/9IYkIz"; spf=pass (imf07.hostedemail.com: domain of gourry@gourry.net designates 209.85.222.179 as permitted sender) smtp.mailfrom=gourry@gourry.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732550786; a=rsa-sha256; cv=none; b=pJjM+Epv29BbYQ2AcIps5ybBxmbV0poLPdKlOTf7CHoUtR55WPh8SC8NUvgS3q/EqVjEE0 oR8JkiGvyjUCajX0xabP+5Y+IWDj3TQhl7fCwZktUWKBPSSWIdkOV1KpR+EpVbrQ82ss0U KXvnxvu4zd9omV2CnpvWXoZsV+0GmHE= Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7b673cb2708so7243785a.2 for ; Mon, 25 Nov 2024 08:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1732550789; x=1733155589; 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=9a9VnHGIm3FCJ1sQpVPUgDLqqd8uoWG359o3vCNQ3GQ=; b=p/9IYkIzoMuFvWUS3TKwvlEMxlGDKyRzNzuUpSJGxy7w7tIu/x1g97IOsqjrYVsZMg 2qLUObiO5PD5DJSphhoyYu/tgEYOC+44xlkIHS0Kzv0HOnp2hc+GrhI9rvA6DJCFWtHB T44t1ijM5G6kk2rnkh2T77YX60TT+rob6FvGLO8KEer+57G4Q9XZ8hL3WNK4R7qI9EP4 DTZoWsAT+IBJjMyxfpFKHjzWnBv3MOT62MIJbSWtYs20JIuuGWE5l1vPSjKzBNzeii6j Utb/6aDkKfOTWAwjfXwiHSBLW08/+ayAIxBTJqr8vCaH1q87UhAdsQJUFBdLd0U8/KPD GLyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732550789; x=1733155589; 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=9a9VnHGIm3FCJ1sQpVPUgDLqqd8uoWG359o3vCNQ3GQ=; b=vAnN6oTT90sq7iOgjsZvsCczY3yyO76CEOrneMSIZBH1am4stUxfhVpq9wQtp1mpir p3PPlhS+OLu6TwzmbpwwAMjBRsJT+3Yjk/Ms0JYYOIVqMUtAcgTNNEYQ7yRu7Bk0fIhh atcPNtsQuBrWGrGLQ/v2aYIL9T0NZyYq4S0itBsjSPr7vSOdU6o44u1Gzh9Drr+aHxUK XxCw90iMRsp2ihlINLxZVY+bMPKKm1Wkp37dLBE/bPiZQXBKV9Ynxc2ozbqtyCgChxmU r4M1EUy91vW2KpLghPo4k94hSjY9n7CAMTVEKb3fdX12ZPxQXNaToPrB/VDiWS9xryZp FUGg== X-Forwarded-Encrypted: i=1; AJvYcCVXBrGrYEyyWWkJ0hCX0yH2q8m+BAn0irpEWyY2ly4TeJdEDuppnz5Nb6toxmEkSzUpebUYcHvE9g==@kvack.org X-Gm-Message-State: AOJu0YwP1RaazuDmk+O95aKio+voaZ0Yu/zDM8OC8pjg74RfEpkQqVSq FyHQyuAQDtq/i/Tj+GXVpDeL4N7MaPsGpBoTSRhMsHuDLydlnYaBGEvMAcjycmE= X-Gm-Gg: ASbGncu7JnECu8tPMEJpiePa+47oeWnvBAf1aOojYnN90F/VypbvKbzPrdD0C06C3ZP vNPAn0A+ZZYjwdxGBpzcduZYzMCL7ql/18BTUg04Rb8+ebFjxmWHoTYdbS9z9AXrvJPS49wxytU snMC8UZkCXTk7leFH/HpFXDRcmOcd+KAegEJcAsnroewPDCwoBBeFpeOklp6Cs0votzr21v99R3 S++bTEjaQstBlCpS6Xo8PQF+8JyVV+Qh3wLT0yo+pj/PeHBoNGnDJDav6/jbsGY7PY3s9EdCu54 bWqipXvAfNpo7mAKlBqSARYSuYXpBIa765Q= X-Google-Smtp-Source: AGHT+IE55aCWNNffPxQR1LsNEJ7M4lMOwJhPMcg1RI0t056r0i9TCZeKRVeIgZ80psxU71anDh3zyg== X-Received: by 2002:a05:620a:880c:b0:7b6:6e7c:8efa with SMTP id af79cd13be357-7b66e7c926amr409889385a.53.1732550789224; Mon, 25 Nov 2024 08:06:29 -0800 (PST) Received: from PC2K9PVX.TheFacebook.com (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d451b23ed7sm43858756d6.75.2024.11.25.08.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 08:06:28 -0800 (PST) Date: Mon, 25 Nov 2024 11:06:14 -0500 From: Gregory Price To: Michal Hocko Cc: Junjie Fu , 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B694440018 X-Stat-Signature: 6wnedptkaq57uzuoq78u36paaaeehtky X-Rspam-User: X-HE-Tag: 1732550786-557341 X-HE-Meta: U2FsdGVkX19u5MXTt48QMi2ZqOophkkboVSI1ceXXF9/LjYACSG3lsg2plwuZfad7EdKEHMkccLyc0gqQuR80pSF7zzsodchMnB9Petlpe38sdvfaAHCwlSH5/NlzTSsFLUiaXSajr1ro9TTkVQT8E8BEJ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htLLiwOGSwm+5rOObcIq8UDMBZIqvlysd/OjECkhOAo7NSgL/fXN+Hk2L6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.015584, 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 Mon, Nov 25, 2024 at 12:33:52PM +0100, Michal Hocko wrote: > 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 > concur here - the proposed patch doesn't actually change any behavior (or it shouldn, at least). Is there a migration error being observed that this patch fixes, or is this just an `observational fix`? ~Gregory