From patchwork Mon Mar 18 12:14:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13595320 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 A5E3DC54E5D for ; Mon, 18 Mar 2024 12:11:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2B426B0082; Mon, 18 Mar 2024 08:11:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDB176B0083; Mon, 18 Mar 2024 08:11:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC9E46B0085; Mon, 18 Mar 2024 08:11:25 -0400 (EDT) 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 CCAA66B0082 for ; Mon, 18 Mar 2024 08:11:25 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3B473160EF1 for ; Mon, 18 Mar 2024 12:11:25 +0000 (UTC) X-FDA: 81910044930.21.CEE6E72 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id A7AA74001A for ; Mon, 18 Mar 2024 12:11:22 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qhNCPdXY; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710763882; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=VkBT1r5BPU5F/3B05HCHkD5OlONUkYMHyin3Hc3dSgw=; b=hKUiFXcdudDpxC2fhgXmCw2TOQ8oKsg6lzidWvVuJEQ6rihi9kbhWEAxzKnnLQ2jZD7APu ttCaAtPypYdMIdJ/5AF2KVPDYKxxTYC5r1QvDQaFdZTlopVBmlLui5JHuMKCW2lz5z42fk 0DqJJF6+q/6BkWx9B8wcPQTAvzi7T+0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qhNCPdXY; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf27.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710763882; a=rsa-sha256; cv=none; b=AjUdClyR+neByYYK6eVCLFLFNTOg0vi2I5+6X1DPX0qsrsuFSMKttgLUmpvIxqPKdJdl0N k1zMCow/iJSGPLWQn5ouUGqhOGfFzjbfumO60EvOyH5VPw94FUS35O9D//FKTVkExQ1j9s ZVMFnVDeJQ3k1qlOmC8+S+5vFSnPXcc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 8E5AB60C17; Mon, 18 Mar 2024 12:11:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A178C433F1; Mon, 18 Mar 2024 12:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710763881; bh=JGYfbRVIlHuHoI0NmXjtxepKc6ayun3xXlgDn4j46pw=; h=From:To:Subject:Date:From; b=qhNCPdXYMkprcVdjnMn62xTr1ev9QT80OeSwydB8rxi2JOdRpMbLfbVXABSBeqO/B QNn+lahk2HRco7Ry/mGwVwYXVhIJLQ2+vxjol3pMpexnomkDo1Az+EEj2IG3ZF4el1 sZqhtbj56qd+zBEiKBb6DkBfjX3ta6qqWlM7LLsTPx7SdIjd+BVi+MgVNksfGWnS1h SefuNpistEXlrQ3w9/+za8sLv4iS7nnwfoG6Fm89v+IoF1VemtGdNlml6j6rWgq2pY SmDsBHVyqF8tWaY6pj1lYDpJBHglTnCVyTnLA7bG2/QzrvSBqnzl4olfVuaIO022CA ZlvQG2kuW3KxA== From: alexs@kernel.org To: kasong@tencent.com, Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 01/12] mm/ksm: catch tail page abnormal in page_stable_node Date: Mon, 18 Mar 2024 20:14:30 +0800 Message-ID: <20240318121443.3991104-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: A7AA74001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 4b4u57m5kuoqbxeyti17b9s8bykb79g4 X-HE-Tag: 1710763882-204122 X-HE-Meta: U2FsdGVkX1/ax/OJzmQrCPVF2SVdbitj5pyk1xi+ag1GE3pzy1qySCetR4o26/F+zPAmSgxEgY6eGlh+PRcq94/KDcpMCbTVrMo232ulcbzzBIfGh9uURapv4WEGjzt56aroxUWex9dEHnsEEnWbOKUK+mhny0myu6I63MPeNz9FI77kjgrWSTYqrcNYc0aTjb/2Pyvxu5ArdIlYyxmpgts9MVBS0dFnPtvkO0+AAcl0dGwfy1JREKKHePp3bRqkZsgNlj/BGp7wKafZhx69sI1wtbfo6YqeihGRQhrmltVah2VpyMCe8oV4+FyTqW1BdjE/2nv2jqnHFamdp+YY1Q4dHH71iHHUu60o3ZNs77ZId6JyargWqcoTJi04rr5McY2gFcwvnyAtkrjZ7MGc08F1M3tME/2iEodNSLRVQgiQRh/XG+iOLhRuWI0Qj1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sSpK/jvGZoYK1uoGl8TRdtMCpuUCwicPAX8TY62naErGVJMonHrK9eo8JlBSXlVyVJQLb7lqgho6wKg== 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: Alex Shi commit 19138349ed59 ("mm/migrate: Add folio_migrate_flags()") change the meaning of func page_stable_node() to check the compound head for tail 'page' instead of tail page self. But seems both semantics are same at results, the func always return NULL for tail page. So adding a bug monitor here in case of abnormal. Signed-off-by: Alex Shi Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright To: linux-kernel@vger.kernel.org To: linux-mm@kvack.org To: Andrew Morton --- mm/ksm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/ksm.c b/mm/ksm.c index 8c001819cf10..3ff469961927 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1091,7 +1091,12 @@ static inline struct ksm_stable_node *folio_stable_node(struct folio *folio) static inline struct ksm_stable_node *page_stable_node(struct page *page) { - return folio_stable_node(page_folio(page)); + struct ksm_stable_node *node; + + node = folio_stable_node(page_folio(page)); + VM_BUG_ON_PAGE(PageTail(page) && node, page); + + return node; } static inline void set_page_stable_node(struct page *page,