From patchwork Tue Apr 9 09:28:24 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: 13622067 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 C704CCD1284 for ; Tue, 9 Apr 2024 09:25:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54FFA6B00A1; Tue, 9 Apr 2024 05:25:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D9AF6B00A2; Tue, 9 Apr 2024 05:25:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32B066B00A3; Tue, 9 Apr 2024 05:25:42 -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 0D1816B00A1 for ; Tue, 9 Apr 2024 05:25:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BE3271402E5 for ; Tue, 9 Apr 2024 09:25:41 +0000 (UTC) X-FDA: 81989460882.26.D7AEF74 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 200582001F for ; Tue, 9 Apr 2024 09:25:39 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WssjhCxI; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.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=1712654740; 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:in-reply-to:references:references:dkim-signature; bh=768Emqci/FTw1ok7jT9pkAzjbRBjqS5i3RDOq4D3A08=; b=bXAifRb5Z1Bwac3hk/lFxDSF6z0dQn2JS8gUdJYOFUko3cqResVMHYRgDaVODBJKJNserr 6bWdzNXUAET8rFZkk7e7DXB1U91DlfDKXuBKbby2fxXgdoJSXl9zsoI/LjJm1zpwrRwKpl TVlyM7k1q0rWsAGFB+z/9GNKZYcJGa4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WssjhCxI; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.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=1712654740; a=rsa-sha256; cv=none; b=hQXtkNMTtWUCl92IPCsoxZoJPL1/2WJ5a7QcahSbPi0IjPgqZSv86UGINJ8xB5gqxOENpu VYgpXare1e3MApRyZe+2Z7MgRaG0oHVnhrpBzleEPUNd8o5qOcWj3YL1YFhSk7bVKHqeTN CS/T9hrPpZauzMkrJL+ra61HBPAlLPg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5881461639; Tue, 9 Apr 2024 09:25:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9AEBC43390; Tue, 9 Apr 2024 09:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712654739; bh=MGM8cnYOc2xUfzqiaHDKMMd1O2BaUHSekMXG68vTT9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WssjhCxIFV/yIm+DWR08ghSxRH0lwhxnaD1vS2T9rvquOXkj3qGcbCZmtRVCMugbx IpWPk8pGp412gnIoQ31Hh+Nj/nr0kRrJQXzBuprxRcKWtx46uGS3zwlAVGzzAnLZOa 52pTuciC59Q7qvfrK/iyC4ieJiOEUd4NAdFCWYHbq3mk8cYivLFFarlmlmJQ3ANn4L vJKWBxpUoAfA+1TuCAgUsamwLOWgCzpz3n7rfQU0g534XfH/f/OuaqzHk9rvsWc4Go 6wBLSxMwmhQEKLpYL8rYKa8MXVHlvfAV/2jf/n0c8537CHdVO8iTIdYeth+9BA3DNQ yLoovR8/YKs9Q== From: alexs@kernel.org To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Alex Shi (tencent)" , Izik Eidus , Matthew Wilcox , Andrea Arcangeli , Hugh Dickins , Chris Wright , David Hildenbrand Subject: [PATCH v4 9/9] mm/ksm: replace set_page_stable_node by folio_set_stable_node Date: Tue, 9 Apr 2024 17:28:24 +0800 Message-ID: <20240409092826.1733637-10-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240409092826.1733637-1-alexs@kernel.org> References: <20240409092826.1733637-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 200582001F X-Stat-Signature: pp17tquqnhwgnfpbzmcrjbd8sxyyz1jz X-HE-Tag: 1712654739-423739 X-HE-Meta: U2FsdGVkX1+jFsGgdr1Hn2rmC+05UxdbHzHpVdx1gmrq+kKivznvjTEMDVTm573kASyi+5owQaf8LIZb28R6kuzpD91j7a1AqmSl3409lB23ydXSAGLy96TKCiJxeR9cTWy2ZQBLTtgb0X1Acu0da79baAiEWHSjaOlFgvaCWMfrJdZloRBjD1VWfE+KG+/eJAin/r/yyhrFYZavR8VdNNHCayyGTh8O5gyIkaafCuIvtsjKzfpBKhhCPrLxfXy2A5/jYrVEnrXvaBMEEU3CoYU6ztE9RbSNzRnKGUAqrd8kQ7adu5PjcYycM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ZQqW14vRn5lQ9UAnixZFieeVOexWOGYj4SgRHruouQ38ZVI7nOZHfMIwZnAZu1TkxQk8dgpjiCVe3sP7VQBK4E/UJp 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 (tencent)" Only single page could be reached where we set stable node after write protect, so use folio converted func to replace page's. And remove the unused func set_page_stable_node(). Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Reviewed-by: David Hildenbrand --- mm/ksm.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index a705ed16aa1b..0d703c3da9d8 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1094,17 +1094,11 @@ static inline struct ksm_stable_node *page_stable_node(struct page *page) return folio_stable_node(page_folio(page)); } -static inline void set_page_stable_node(struct page *page, - struct ksm_stable_node *stable_node) -{ - VM_BUG_ON_PAGE(PageAnon(page) && PageAnonExclusive(page), page); - page->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); -} - static inline void folio_set_stable_node(struct folio *folio, struct ksm_stable_node *stable_node) { - set_page_stable_node(&folio->page, stable_node); + VM_WARN_ON_FOLIO(folio_test_anon(folio) && PageAnonExclusive(&folio->page), folio); + folio->mapping = (void *)((unsigned long)stable_node | PAGE_MAPPING_KSM); } #ifdef CONFIG_SYSFS @@ -1519,7 +1513,7 @@ static int try_to_merge_one_page(struct vm_area_struct *vma, * PageAnon+anon_vma to PageKsm+NULL stable_node: * stable_tree_insert() will update stable_node. */ - set_page_stable_node(page, NULL); + folio_set_stable_node(page_folio(page), NULL); mark_page_accessed(page); /* * Page reclaim just frees a clean page with no dirty