From patchwork Fri Jul 12 02:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13731250 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 C389FC3DA49 for ; Fri, 12 Jul 2024 02:45:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E1636B0088; Thu, 11 Jul 2024 22:45:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 290296B008A; Thu, 11 Jul 2024 22:45:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 158866B0099; Thu, 11 Jul 2024 22:45:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E8F986B0088 for ; Thu, 11 Jul 2024 22:45:09 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 96C84140822 for ; Fri, 12 Jul 2024 02:45:09 +0000 (UTC) X-FDA: 82329558738.12.A6BAF53 Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) by imf17.hostedemail.com (Postfix) with ESMTP id 7148740007 for ; Fri, 12 Jul 2024 02:45:06 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=cGX5LLRU; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=gaD08SoQ; spf=pass (imf17.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.154 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720752262; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=mZXQybFJfj4oW2kR9aus3Dkh3XdyBd8HLQGRekYCKZM=; b=v6ZRjdjW4P1WBhKSzTosJhxQSXrosENvF1Z0putV52DogtVpMn6QSV5lhbzAudWZK7dDsa R5y1z36I+3CGU9/XB3iPdo61+fXoNiQRUBy170g6fhkPgernMIzuxzJn3wJt5tJOnxGNbJ ozyq0L5CxZqpBvqzj8rzG2JDuoNWP9o= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=sent.com header.s=fm2 header.b=cGX5LLRU; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=gaD08SoQ; spf=pass (imf17.hostedemail.com: domain of zi.yan@sent.com designates 103.168.172.154 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720752262; a=rsa-sha256; cv=none; b=cQhC4KQtkkAdJaYaVeO9EzQUx/W/2OPteNS05osinnnDq+VX83Vp0Jgs2+uNFwabp99iua eZ+AYvEuEaHZ7ulv9SwTizYsvx4hxQF/QnvVeX6VL5pqZQl6Bxx6YC5UE+zTyzCGdiEr2b AKe32KUeNlGZd67MnoA9rmCmJGe8QuA= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id B165E114158A; Thu, 11 Jul 2024 22:45:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 11 Jul 2024 22:45:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:reply-to:subject :subject:to:to; s=fm2; t=1720752305; x=1720838705; bh=mZXQybFJfj 4oW2kR9aus3Dkh3XdyBd8HLQGRekYCKZM=; b=cGX5LLRUb2PZAgUTusLHvdsUrO Y7A9YYWE/CdjEyqHuxSt7AijHCdpZuewiLmMjgwdAn7JNea275wrOAdxsLnq5mfN zZBKNNu70qAfm8hKF/0dGaJEoVJvvH0TSA6MRwARfVQfSV5A1/EXREhTdsFN//BT qdGSUzZ8mlQpyyiJ4tu2ULABC0TPw8mdsXO77Z8wmQ+pRivZ5HC5mSPY4DpWkhax bQ0iwHl9r6rVy3bzAA4qKvaKU6oOtRgUOs0g6VYMyglrevbszveorYHJ1zD3IKIX Xt+PzJJlEmnaNh2L6ZiU8x3sAv7TrLufeBmX4Pu+Tsm2o+9tEGYMncDXsfFw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:reply-to:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1720752305; x=1720838705; bh=mZXQybFJfj4oW 2kR9aus3Dkh3XdyBd8HLQGRekYCKZM=; b=gaD08SoQKUgO0Ncqp6huEs3QqY0dv jX22KgUAGW8lh0zyK+hQOyw9rN9C4KY8/xc1ZF8x4rFN0YCOO629hKJ/SMSs0yiK CLcbq0nvoweWPC3rMmboPn8TIOydYMKo/ayTaKPmD0gv1JlEb/JY+8PfdtqFmu6Y MsXzkdo3z8f2/0LFZ92idNfwt4h5gHtLxpqVqc+VOAg0ZL4TsVOAS6ofzTnSKCP6 1OY9lh+9qoimewFkHD4x9MehYMUKt3vCpyLckCOpGlbeyJCk/ctG8UKf9sYJ9bVx pLEUf6Dn1l2JWQEJmQSCuBlEFPbj4yXu15i04pXN+TjLsCNH6/atQS1zw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrfeehgdeigecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkfforhgggfestdekredtredttdenucfhrhhomhepkghiucgjrghn uceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepffejueeife ejudejudfgiedtfeeltdfgueffhfdulefgtdekteekfeejheekhedtnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnsehsvghnth drtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Jul 2024 22:45:03 -0400 (EDT) From: Zi Yan To: David Hildenbrand , "Huang, Ying" , linux-mm@kvack.org Cc: Zi Yan , Andrew Morton , Baolin Wang , linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/3] Fix and refactor do_{huge_pmd_}numa_page() Date: Thu, 11 Jul 2024 22:44:52 -0400 Message-ID: <20240712024455.163543-1-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7148740007 X-Stat-Signature: yfg5xdqkdnmhyyse4ue3qeuowwtuozmt X-Rspam-User: X-HE-Tag: 1720752306-851884 X-HE-Meta: U2FsdGVkX1/qyIWAHuF86HN4A99mpfOhZWrT6vSv4Lh4g8wyC826iLwKTaVuGniar4jESd2NPK3Se2wvslBYFBL1xMMf/PapDojyis/01BLuaf2gBPfbzY4ZPAcKBW1xZV/NJ8YRii5F/cu0bVzCfOUFRBJNzGauKWEvLA8J9GuCpA3FcLc2i14oMlPaPNl0/O468BtVoXWnYs7W+0cA2yfNAFKgL08kxDDEbRKwj3U8R1SVv5BWVUNlD5HaG3lRj3UXyPEmfqGft2aDE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0GI1kBhKt5w7cVya0TD2IlkwDgfES3e6nUtorfE71iH0Z9DlntVU8oL7eYzb1Zzm2LRFcbWXmFtXkxTbDvSDes69xQllF0SAI7HwXCJA= 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: List-Subscribe: List-Unsubscribe: From: Zi Yan First patch adds the missing sysctl_numa_balancing_mode check. Second patch introduces folio_has_cpupid() to replace open coded folio last_cpupid check. Third patch consolidates code in do_numa_page() and do_huge_pmd_numa_page() by moving more common code into numa_migrate_prep() (renamed to numa_migrate_check() in the patch). The RFC is mainly for third patch. It changes the original code behavior: 1. do_huge_pmd_numa_page() did not check shared folios to set TNF_SHARED. 2. do_huge_pmd_numa_page() did not check and skip zone device folios. Zi Yan (3): memory tiering: read last_cpupid correctly in do_huge_pmd_numa_page() memory tiering: introduce folio_has_cpupid() check mm/migrate: move common code to numa_migrate_check (was numa_migrate_prep) include/linux/memory-tiers.h | 8 ++++ kernel/sched/fair.c | 3 +- mm/huge_memory.c | 31 +++++--------- mm/internal.h | 5 ++- mm/memory-tiers.c | 17 ++++++++ mm/memory.c | 82 +++++++++++++++++------------------- mm/mprotect.c | 3 +- 7 files changed, 80 insertions(+), 69 deletions(-)