From patchwork Thu Aug 22 02:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Ge X-Patchwork-Id: 13772562 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 1B9E8C52D7C for ; Thu, 22 Aug 2024 02:58:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D43A6B01F1; Wed, 21 Aug 2024 22:58:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 982C36B01FA; Wed, 21 Aug 2024 22:58:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8235C6B01F9; Wed, 21 Aug 2024 22:58:32 -0400 (EDT) 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 63E8F6B01F1 for ; Wed, 21 Aug 2024 22:58:32 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 04502120407 for ; Thu, 22 Aug 2024 02:58:31 +0000 (UTC) X-FDA: 82478373264.11.56E6B7A Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf17.hostedemail.com (Postfix) with ESMTP id 48DBA4000E for ; Thu, 22 Aug 2024 02:58:29 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wmUxSb65; spf=pass (imf17.hostedemail.com: domain of hao.ge@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=hao.ge@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724295430; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=CMqT1JRpZMqfnZqYRqGpe67qSPBBah1BIw750OMqQxY=; b=PQiIwHykwaAlzKz3DlnBI7lAQ/UHJrmyiTuX7MfIsmWn03MfkvohBCil0B957ZML3A0jcF HCmktTjGadHC98m1i1MsSwiNQHW0zP1oIrN8+nZ7auzo3Ph5E/CLQC1WfG4lokg+iDZ87R t9GSqNdDuApqwylX7rDlFthbfwZ4b2Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724295430; a=rsa-sha256; cv=none; b=llOWXcviQx4FBnGJ8e20KfHqf/HkVGTykeLY+3cChcp4YEv5k9Ikn78CAIWxTI8qXa/6yk KTuzbkix7FQuTnvYu5+fNxgufl7I0ei1m8lsdH8Um/KUOoDhUiebyUKMWamCoANkPCNNo5 8qJOnwIqi7CFO6Mct8+M/xRhHV0VgxE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wmUxSb65; spf=pass (imf17.hostedemail.com: domain of hao.ge@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=hao.ge@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724295506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=CMqT1JRpZMqfnZqYRqGpe67qSPBBah1BIw750OMqQxY=; b=wmUxSb65WfKkxS3qaa7KcSIjJyGM42rwra/8+84lFDeqYbYuGGOX8ZgCODB8hFGuVBG26z v8vP5ymj8FQpXKEZP2mkqJSeYoq22EZPulM88J3Ktpq+18q+MXxpBMzvIR4jkyPbCpGill 8lr88KkoaANKPYNXrgg7v6mKLNuaqYw= From: Hao Ge To: linmiaohe@huawei.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, surenb@google.com, pasha.tatashin@soleen.com, david@redhat.com, kent.overstreet@linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, hao.ge@linux.dev, Hao Ge , stable@vger.kernel.org Subject: [PATCH] codetag: debug: mark codetags for pages which transitioned from being poison to unpoison as empty Date: Thu, 22 Aug 2024 10:58:00 +0800 Message-Id: <20240822025800.13380-1-hao.ge@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 48DBA4000E X-Stat-Signature: 4rarpmudrju3tr7o6rjny36ytxc1erim X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724295509-895327 X-HE-Meta: U2FsdGVkX1/yDcWNa7qTnVsc2GMpaQ6MrJP2le9kYuHMRf2/baVmllYixf8K/o2pZzbyLFdS5MTW2WG7Lbdmc79Zq27CUOmYckcxDYs+H8/7lElJ111HlRHtWZtCRk9kKb5b4INRSwq/5uTH6p2ofcfcrJlRm+8n1Z16CvIpRL3eoDkvZCooXeMBaw+HAMybOd7GWbXi+nxKhxAblpqFYhqpm1Nz9KLXWK+bNMGPTipqxCup7gzuuMKaJa0b6A+r8Dq6qQmlGpUb92H8bop9XsJnuj++TV9KelcgBbmy/xzigQZWGCZYN+rv/NQ1oAnLgBgcIzeXWNSRbjsyLX2U4LCwIU+Gy1EnbSJ7pGaEJk6+JygICZ1soApMkakOrUcTmuCMd7sgVtnaTzrWJCjYv9BDNzb+Qgiywq63Ok6q0WBbwFhjO+6zxBCCIP5smXCCCQfXR8T8u2I2crcaYe7HA19X+LXDaEkTK6nn1xI1fB0Ktacdqb2z7431QmvRPgVEX+MZgHM5xAenYtgoFto3dZWitbd3r8axxIAi2FT4Ybylk2MQS0L4wQQw0ZRObegDEtGi3pkPENlJpK5fE9HfsuPNIBwy6Jtz74WLCk3DY8BQ21gatkwCOPephAx2CwdfqaeL/dBFM6YoK64ersa6WauKtdRRuJJdqbAYXlK4cgvXludUhZnv71itz+Wk2I1anZEvFdG//1R8PjL+iZXVBRWDHf9Tj1pMx8QBY9nTadRX8vXJKHzofe7VRjONeOVNbqjNq4ZdCtqyFjG0I8zcLQ1t6BOdJuhBQ1tUeLb6I9Z+D4GjT23NSd7+K+apXPyhfGeVrMd2UYxY/1ORiY+jWTRwnOfSKY1Ij+Pq8Qnbo52uu3lzvHnUfLJgSN6DVqfAetEWjObFBAaxGJXh6mMv9El8LngMJc0LEa+3hmYfI5LVkDeN51Btq/CT0G1w4PkpxA5hESxQo/o70vE5USH 8QpsIlXm BP3GVc8Ym4H8Ril6QpkKUmNBTYtrOUWSO5AlhGnJYJ4LFvE7gYQc8cTPBWGT8Bq4Ho4lr68SkYGFu/xc9UVt808/GuhfyxVI+Km7YnL9bB4G5fuFG4cuAmsKuYH2bxYzBmLpNAh7vhewHrNhFd5JYM8ZQ31mfPzYJkCw6tDo137JxSXk8U6fEqzsgPEaGwiGME8w3MLJ7Yu58lDaSgCTxfC3CsOPHE39nvtloDokz5BNic8k4MHfCk/r4eqIuToXbhFAJNsL/c97nuUo= 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: Hao Ge The PG_hwpoison page will be caught and isolated on the entrance to the free buddy page pool. so,when we clear this flag and return it to the buddy system,mark codetags for pages as empty. It was detected by [1] and the following WARN occurred: [ 113.930443][ T3282] ------------[ cut here ]------------ [ 113.931105][ T3282] alloc_tag was not set [ 113.931576][ T3282] WARNING: CPU: 2 PID: 3282 at ./include/linux/alloc_tag.h:130 pgalloc_tag_sub.part.66+0x154/0x164 [ 113.932866][ T3282] Modules linked in: hwpoison_inject fuse ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 xt_conntrack ebtable_nat ebtable_broute ip6table_nat ip6table_man4 [ 113.941638][ T3282] CPU: 2 UID: 0 PID: 3282 Comm: madvise11 Kdump: loaded Tainted: G W 6.11.0-rc4-dirty #18 [ 113.943003][ T3282] Tainted: [W]=WARN [ 113.943453][ T3282] Hardware name: QEMU KVM Virtual Machine, BIOS unknown 2/2/2022 [ 113.944378][ T3282] pstate: 40400005 (nZcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 113.945319][ T3282] pc : pgalloc_tag_sub.part.66+0x154/0x164 [ 113.946016][ T3282] lr : pgalloc_tag_sub.part.66+0x154/0x164 [ 113.946706][ T3282] sp : ffff800087093a10 [ 113.947197][ T3282] x29: ffff800087093a10 x28: ffff0000d7a9d400 x27: ffff80008249f0a0 [ 113.948165][ T3282] x26: 0000000000000000 x25: ffff80008249f2b0 x24: 0000000000000000 [ 113.949134][ T3282] x23: 0000000000000001 x22: 0000000000000001 x21: 0000000000000000 [ 113.950597][ T3282] x20: ffff0000c08fcad8 x19: ffff80008251e000 x18: ffffffffffffffff [ 113.952207][ T3282] x17: 0000000000000000 x16: 0000000000000000 x15: ffff800081746210 [ 113.953161][ T3282] x14: 0000000000000000 x13: 205d323832335420 x12: 5b5d353031313339 [ 113.954120][ T3282] x11: ffff800087093500 x10: 000000000000005d x9 : 00000000ffffffd0 [ 113.955078][ T3282] x8 : 7f7f7f7f7f7f7f7f x7 : ffff80008236ba90 x6 : c0000000ffff7fff [ 113.956036][ T3282] x5 : ffff000b34bf4dc8 x4 : ffff8000820aba90 x3 : 0000000000000001 [ 113.956994][ T3282] x2 : ffff800ab320f000 x1 : 841d1e35ac932e00 x0 : 0000000000000000 [ 113.957962][ T3282] Call trace: [ 113.958350][ T3282] pgalloc_tag_sub.part.66+0x154/0x164 [ 113.959000][ T3282] pgalloc_tag_sub+0x14/0x1c [ 113.959539][ T3282] free_unref_page+0xf4/0x4b8 [ 113.960096][ T3282] __folio_put+0xd4/0x120 [ 113.960614][ T3282] folio_put+0x24/0x50 [ 113.961103][ T3282] unpoison_memory+0x4f0/0x5b0 [ 113.961678][ T3282] hwpoison_unpoison+0x30/0x48 [hwpoison_inject] [ 113.962436][ T3282] simple_attr_write_xsigned.isra.34+0xec/0x1cc [ 113.963183][ T3282] simple_attr_write+0x38/0x48 [ 113.963750][ T3282] debugfs_attr_write+0x54/0x80 [ 113.964330][ T3282] full_proxy_write+0x68/0x98 [ 113.964880][ T3282] vfs_write+0xdc/0x4d0 [ 113.965372][ T3282] ksys_write+0x78/0x100 [ 113.965875][ T3282] __arm64_sys_write+0x24/0x30 [ 113.966440][ T3282] invoke_syscall+0x7c/0x104 [ 113.966984][ T3282] el0_svc_common.constprop.1+0x88/0x104 [ 113.967652][ T3282] do_el0_svc+0x2c/0x38 [ 113.968893][ T3282] el0_svc+0x3c/0x1b8 [ 113.969379][ T3282] el0t_64_sync_handler+0x98/0xbc [ 113.969980][ T3282] el0t_64_sync+0x19c/0x1a0 [ 113.970511][ T3282] ---[ end trace 0000000000000000 ]--- Link [1]: https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise11.c Fixes: a8fc28dad6d5 ("alloc_tag: introduce clear_page_tag_ref() helper function") Cc: stable@vger.kernel.org # v6.10 Signed-off-by: Hao Ge --- mm/memory-failure.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 7066fc84f351..570388c41532 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2623,6 +2623,12 @@ int unpoison_memory(unsigned long pfn) folio_put(folio); if (TestClearPageHWPoison(p)) { + /* the PG_hwpoison page will be caught and isolated + * on the entrance to the free buddy page pool. + * so,when we clear this flag and return it to the buddy system, + * clear it's codetag + */ + clear_page_tag_ref(p); folio_put(folio); ret = 0; }