From patchwork Fri Feb 16 07:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13559655 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 82303C48260 for ; Fri, 16 Feb 2024 07:34:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C88F68D0006; Fri, 16 Feb 2024 02:34:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C118B8D0001; Fri, 16 Feb 2024 02:34:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A64508D0006; Fri, 16 Feb 2024 02:34:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 945268D0001 for ; Fri, 16 Feb 2024 02:34:00 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5BA0880263 for ; Fri, 16 Feb 2024 07:34:00 +0000 (UTC) X-FDA: 81796853040.28.E928AAD Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf05.hostedemail.com (Postfix) with ESMTP id E03B910000C for ; Fri, 16 Feb 2024 07:33:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708068838; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=/XxCxwROeOCDPArzBgS9MgtOe3w+AY3a5KRgXner2eY=; b=RKvSv/smHV6vXGhqMeGa9jMGzp2B72+k/vtLC17vSJC4FPRXUCcj38sMEUSlDZqOHjLTeJ g8SNxYY7aS6rjWSKUXONunGKvq2gaKsQE/WEonGHPmBeAx0JcSUWWAfdn0eXa5upoiIfht 0VDif9WElfXN9M0mJTArq+TJcH4JxPc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708068838; a=rsa-sha256; cv=none; b=YyICoIVfol1uXUZSL09rRgR0MuE3mZayjEB6u5SnOBKl8FpvHvMD4O9XyNPEBBbkobsVUn 9/dY14WT985kjDxRDHR0tG3KPhWbClss+AH42zOnpPTkGCBwQ8TTyG56mZc2vLbstJr11T wgdBnZAYuUrpvvK1JyPMilWTFwxS/Yw= X-AuditID: a67dfc5b-d6dff70000001748-0a-65cf0fde2f2c From: Byungchul Park To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, akpm@linux-foundation.org Subject: [PATCH v2] sched/numa, mm: do not promote folios to nodes not set N_MEMORY Date: Fri, 16 Feb 2024 16:33:40 +0900 Message-Id: <20240216073340.55404-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLLMWRmVeSWpSXmKPExsXC9ZZnke49/vOpBs9fSlrMWb+GzeLS46ts FtNfNrJYPJ2wldnibv9UFovLu+awWdxb85/VYvK7Z4wWlw4sYLI43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vMwKveT83E2M wLBaVvtn4g7GL5fdDzEKcDAq8fAe+HM2VYg1say4MvcQowQHs5II76TeM6lCvCmJlVWpRfnx RaU5qcWHGKU5WJTEeb3CUxOEBNITS1KzU1MLUotgskwcnFINjNUZnqo/itbvuv1Aeo511C6O i4pX9E2vfo7ekHNjo72qaMARVe4Da5zLNtbPPP7jdMHFTSc9J8hMuNbMs++iudYr3vlf9FYt +7IvRmQGZ9HKKoMG46mWLu47D1eV/D1dfNS0MGX/tTm5Fc3bp3RxBK4XfPV55TY73aDbOyaK TDUu6n9QXLFSRleJpTgj0VCLuag4EQAptKZcJwIAAA== X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: E03B910000C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ammycaahieuc7dc9qypk3jk1ticfei7u X-HE-Tag: 1708068834-924866 X-HE-Meta: U2FsdGVkX19iyQ3ZghZugelWANMnVAQerYlopywMLEs7ZXxwWb6nafjmDKREyHWIANs43+MUlhggpqhnnLy4O0ODagTz4M6vBtxlIumVZ0XxYRAaucCED+kqdw1FWYbzCXxT9nCqQyNIgflc/kxYqM6w1U02fFUBRrGYcL0yzxyUP0PQyTQNxg2Jt2Yemf7jRNUsJhKWRBuuxLnVoiuTYSuyCC3Svo0f9uzrhHpPfqAshWDvPPcAkPV/RFWQDl9PMBGteNtPJQHwwHOdYYpTNwYBI2764Ot0SwNDcGm9h/JepheyXi0qq/PBB4socv5F7Jkf6P3QZevHywescrYaKjeRbBAtThM9dmaEgkQnwSvrufYm0wH+YfLlpgqgYILBZE1k5psuSkHAMhiA5qSwbrYo5ZKpseid8TyNdusy39//wv5UMMpbUikzQoXra3qgO2Q9p07XuSVxaCKuTgJ7DU+lNbSivs0VNQ4Cns7T6EP84J4vCiun6kksQYISsnicCqcaJAhvzeLZtkfLV5BcPldF/xYLtvLH4ZLKtskHtEQjmUGoIfD4j7WcoKstnfDGZeKqb1MAicXLjAUW1J60GA8U67fZkApfnE+9kkhYH0IoYmJlk+vK8XtC5NPMgJzvg60p8KvIW4WQjeCsER5MvgOsrq1UEFygF7n7Sz+ibBDSmYFu2lZsouOHzDPxAn4QuTWhslMLsAYnYmLVixRdSmhcC+a7aul+9Sb5IrRRDovzrU839obeeUMAmqDiswXQZzeSoG2aSKGyBHhtNE2T8UBmUpD8fxx7PsML4ye9qEcA0leJi6aMTdc76D4Hf/fUHdAshHt7pojlXTsW2nV825wBZxsZOE7vclMLHnQ5gT2/7FrJ43+fSfaxN1njT4C7mSUPV/ZOeJbL4vYVJT8vY451CFQdO4nMqrlhk4Xn5tDDXWErBM58oSfe9EqzwPwKmpJNn/F9ey6OOy30z+B th3Fup9O NzGKw5xR2bqeO8kRHS9uYJBCHi1SLphVBUgp9OJcLhgGej0U+N0vEtXlZ5QP7rg5dioR6aoRg70mPnst2olODRle+si2E17Ny/QhW 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: Changes from v1: 1. Trim the verbose oops in the commit message. (feedbacked by Phil Auld) 2. Rewrite a comment in code. (feedbacked by Phil Auld) --->8--- From 6830b59db267a31b78f6f09af12ae0e3132b4bca Mon Sep 17 00:00:00 2001 From: Byungchul Park Date: Fri, 16 Feb 2024 16:26:23 +0900 Subject: [PATCH v2] sched/numa, mm: do not promote folios to nodes not set N_MEMORY While running qemu with a configuration where some CPUs don't have their local memory and with a kernel numa balancing on, the following oops has been observed. It's because of null pointers of ->zone_pgdat of zones of those nodes that are not initialized properly at booting time. So should avoid nodes not set N_MEMORY from getting promoted. > BUG: unable to handle page fault for address: 00000000000033f3 > #PF: supervisor read access in kernel mode > #PF: error_code(0x0000) - not-present page > PGD 0 P4D 0 > Oops: 0000 [#1] PREEMPT SMP NOPTI > CPU: 2 PID: 895 Comm: masim Not tainted 6.6.0-dirty #255 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS > rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 > RIP: 0010:wakeup_kswapd (./linux/mm/vmscan.c:7812) > Code: (omitted) > RSP: 0000:ffffc90004257d58 EFLAGS: 00010286 > RAX: ffffffffffffffff RBX: ffff88883fff0480 RCX: 0000000000000003 > RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88883fff0480 > RBP: ffffffffffffffff R08: ff0003ffffffffff R09: ffffffffffffffff > R10: ffff888106c95540 R11: 0000000055555554 R12: 0000000000000003 > R13: 0000000000000000 R14: 0000000000000000 R15: ffff88883fff0940 > FS: 00007fc4b8124740(0000) GS:ffff888827c00000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 00000000000033f3 CR3: 000000026cc08004 CR4: 0000000000770ee0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > PKRU: 55555554 > Call Trace: > > ? __die > ? page_fault_oops > ? __pte_offset_map_lock > ? exc_page_fault > ? asm_exc_page_fault > ? wakeup_kswapd > migrate_misplaced_page > __handle_mm_fault > handle_mm_fault > do_user_addr_fault > exc_page_fault > asm_exc_page_fault > RIP: 0033:0x55b897ba0808 > Code: (omitted) > RSP: 002b:00007ffeefa821a0 EFLAGS: 00010287 > RAX: 000055b89983acd0 RBX: 00007ffeefa823f8 RCX: 000055b89983acd0 > RDX: 00007fc2f8122010 RSI: 0000000000020000 RDI: 000055b89983acd0 > RBP: 00007ffeefa821a0 R08: 0000000000000037 R09: 0000000000000075 > R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000 > R13: 00007ffeefa82410 R14: 000055b897ba5dd8 R15: 00007fc4b8340000 > Signed-off-by: Byungchul Park Reported-by: Hyeongtak Ji --- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d7a3c63a2171..859ef78ef72b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1828,6 +1828,15 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, int dst_nid = cpu_to_node(dst_cpu); int last_cpupid, this_cpupid; + /* + * A node of dst_nid might not have its local memory. Promoting + * a folio to the node is meaningless. What's even worse, oops + * can be observed by the null pointer of ->zone_pgdat in + * various points of the code during migration. + */ + if (!node_state(dst_nid, N_MEMORY)) + return false; + /* * The pages in slow memory node should be migrated according * to hot/cold instead of private/shared.