From patchwork Fri Feb 16 11:15:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13559924 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 EE78AC48260 for ; Fri, 16 Feb 2024 11:16:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 340FF6B00AE; Fri, 16 Feb 2024 06:16:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C9396B00AF; Fri, 16 Feb 2024 06:16:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11C216B00B0; Fri, 16 Feb 2024 06:16:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F071B6B00AE for ; Fri, 16 Feb 2024 06:16:07 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B74381204CB for ; Fri, 16 Feb 2024 11:16:07 +0000 (UTC) X-FDA: 81797412774.05.8A5BFF6 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf05.hostedemail.com (Postfix) with ESMTP id BE028100008 for ; Fri, 16 Feb 2024 11:16:03 +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=1708082166; 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=+40M5M24mjneYowT7SZooV9slN0NYnFm7UxtPX/PJWs=; b=WQ8GeWBCxCl3bXQCJMzi5dfnGC2prcmTSINjtwS8zZV7tygjh+q6X7StEi9j6xmtvtrvkH E1ZS6cWXBI8WAAJkv1HTaBEXkdahyLItmfJTj4R9Fl7Hj2Vr7mPN4e7gutyc27I9dHPM5J E7E0D/kfbTP0B0AqRi1rN22nVHf0/uE= 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=1708082166; a=rsa-sha256; cv=none; b=WRcq83Enb5MMohsI8gMjYSsGvfS/qix44G8WbGnCdea7f8u+pDXTUqjYIK+mVJBoaKXX0E GkoeWe16nRm5CQXwDUDaFaA+Wz1zOYN48LrSsB7qL9tIHs860ybJoEdFhi8OFG3CkegYZc 1JIuLSdMfqqLFG2KOG7n+tfB02WXfuw= X-AuditID: a67dfc5b-d85ff70000001748-14-65cf43f15fe6 From: Byungchul Park To: akpm@linux-foundation.org, ying.huang@intel.com, osalvador@suse.de, baolin.wang@linux.alibaba.com, hannes@cmpxchg.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, stable@vger.kernel.org Subject: [PATCH] mm/vmscan: Fix a bug calling wakeup_kswapd() with a wrong zone index Date: Fri, 16 Feb 2024 20:15:02 +0900 Message-Id: <20240216111502.79759-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpiluLIzCtJLcpLzFFi42LhesuzUPej8/lUgxcLBSzmrF/DZvF/7zFG i9WbfC0u75rDZnFvzX9WizPTiiwWbHzEaHFy1mQWBw6Pw2/eM3ss3vOSyWPTp0nsHidm/Gbx 2PnQ0mPz6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YNxk0mHso510 I6HTz3nvcqFHMw26q07Uuh6/cGuvkdee8CNHHwbfrnwn2nyRqfTvIxnm/7fcncK/zjGpvn8g 8OHE829eT353KSbeLu+r0CmJtLC2lvmfCrVk2VU5eqKn2J8Nm7a7dP8umRiFZMn1Knc3/9Or PVHJtodl9jmfSxuFJ9mZLboTcE+JpTgj0VCLuag4EQCvUs+P/QEAAA== X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: 1eysa3tm5uii9ahgckonsppmikxgdguk X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BE028100008 X-HE-Tag: 1708082163-83516 X-HE-Meta: U2FsdGVkX18UKGJlPUEwu7bKXUYkyH72uDYYtf8rhD7TVLLmoaZFGMm6VHgEvbUO+HM4nAMSZ67EV7S8lzJbty+v398ZMEQMTVfxqSPFZtQzQYhoRwlWoC/TDxxEixCSgJPj8wue/wpd+VceT0I8hph89eGY6kHHdEjFHgg48hsQ6tZUtUpdp0ufRL4M/lmHy7E+SSFi3qj33SLrbkQyO8/5ox36c+1/LpjMgE+yCEmqge1RfAyaDibjI0KZeYvP8+hYqLSgLRjyogsUN/BPWrs/BcAf6PzDdeOXxP2Rrlnr5Jjz/iMN/LT9eMcyLg09Mld6SlZJay42vLb9AHE+0mdStB4IMLYKnzPMlVTmNxO06iFcTpWnBgCCAQ8IFMC2DXvzqF9N3obobn6VBvBoD45YDWQc504V+0VnKJuN3Rx4Sv+KOeBVZgKcL7zgfPCHcIfmHYOkJ8ETfE0OVNqWtZIjYXEcHYq/eVGFkN1Eb3rFi+Rr3AISgC9teBoxGyYhnHO6nE7u9WbIIBMVxqfmdAMJW5QBpvVqz/eqtsV8CNGzxDoqKiAyc5KoiadTfd25IwQx0V684bXFBk4YDgw7whpGKGw/FOF9U3Drs/6fjBIWpuWmsFncgu6oPp3n8mJ5naO/VEBaPKI1pFAuAy9WHapsVY8phOTp0OCBbTn5Ac3Yi0znTzFHIPY05WCI9c0OIDZAniq3zh8mjpF8QXTKzxcm8ekFn5o+HH+8Qt55OtMli3Dq9N6iMshS9Q5MEn6lkeDlyNvrl3T5iDu2avcOZ7+KAZLBwbUcGycDQHEoggtYXPphE9yUZx6wwNYd0lPXp+xhqQ1fEc2iDRPxI4fweD31Q7FFXZwmK/I0YnmlSGoSAt7skxRMYCtS+GmnP4yOC5ffLuQdoNXveBN07YphGAS6ZmlJA6C5b24HM6YiMLe3k3LcsWHSIPf06fLxHVLTBWr+neHTk11aXXZDkzI eoTQKp0w Xz9kEQBAgL3XEP1K/WLTPpYG8s9UTD/US3vim3VbDBKjIGegJ3AFBI2xnjmB3lK+EfOswh+vLJLV+v851foR5xnKDM86VFyCR/nW9FBSnKrGud36tCBzFqCrSsRZFzDugM08QvyWdaSJLGPdbo2+lul/gSw== 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: With numa balancing on, when a numa system is running where a numa node doesn't have its local memory so it has no managed zones, the following oops has been observed. It's because wakeup_kswapd() is called with a wrong zone index, -1. Fixed it by checking the index before calling wakeup_kswapd(). > 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 Cc: stable@vger.kernel.org Fixes: c574bbe917036 ("NUMA balancing: optimize page placement for memory tiering system") --- mm/migrate.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index fbc8586ed735..51ee6865b0f6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2825,6 +2825,14 @@ static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio) if (managed_zone(pgdat->node_zones + z)) break; } + + /* + * If there are no managed zones, it should not proceed + * further. + */ + if (z < 0) + return 0; + wakeup_kswapd(pgdat->node_zones + z, 0, folio_order(folio), ZONE_MOVABLE); return 0;