Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1857964lqe; Tue, 9 Apr 2024 02:30:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVigVDyLKSi314yQu9maC/j/iwLip4AehSTzAhxr5FfEP4cGMGtAIApfqiaD15aw9A4HV99or7HpO+cj6ggmKEJ+kBSYyfdLIJHUVaV5g== X-Google-Smtp-Source: AGHT+IHkWNcSiUG/8TTNMASFKIXLYMb0hFm1jAjeOGauPQWeUBR8uHpdUHhvY0kunGJqUZ/Yv2Uo X-Received: by 2002:a05:6870:15c4:b0:22e:a70f:158 with SMTP id k4-20020a05687015c400b0022ea70f0158mr13083862oad.7.1712655008430; Tue, 09 Apr 2024 02:30:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712655008; cv=pass; d=google.com; s=arc-20160816; b=OIiLWNJLIhNqIwU52AKKR3qWLGy68tlkHl0N8Wq/uedSaRqG/ZmOsFeAO6UTGsT9k5 g224VsPD02/z/zA3XtB54HWMOb1xZ3BRLMLRwDZz2bJTsgCKo1sOH4iqQjQejWyfn7WM MSNecqloRamrTgiFkuyXNsTSjlM34eVsOTNVcl27PW7LI8H/noYs/vIPqSoVQ3R73lKb vVvdOY/AcTxzlHawtWlzFtiWbj/LTYbKg9qbvJJtAwwH2CTqyPCZyXUu/Mh7fL2TyO/u +J31oLmURESWPT+vFUJNG0JhhYKnAmuHkmBnsulUsudmz99jF7kZTEned2QdFS77EJL9 wBRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=768Emqci/FTw1ok7jT9pkAzjbRBjqS5i3RDOq4D3A08=; fh=L4VNAxQbQYrcrdeHT1sPO3RlS0TogNvaAEf/71clfA0=; b=J1+eyWcxaFQxHz7IVUkYtrol2UKhlP0Z43UzDPAGt7iw4v6/xRRTdXwnzk2Yk6NlE3 CkT4SzesSODWbfgNQ8JQMcw2s8KFp8DAbSqAAVtkBDoJWhlrVLdTPalByuEhurU3hEMV XyiE/a3vjBBH59smIyYW5UKHd24neIGGnPFWw4cAbfOHxFZIDC89pEvVZELxzAyIayvp 0cCyUtoJWSoT5Hfdw/2pHUSghizXfDsd2gGzJ4BWrI6QovmktUoVsyym2Syq++3GEZek Uu+MyXCa5/aKlGsmqvsdVKbfrANrOngaBKAdKnRYLrSfiM1Fnkclhd4oNe3C+GWdXCCL mJ6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WssjhCxI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-136562-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136562-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o14-20020a63fb0e000000b005dc4b7ae767si8034360pgh.459.2024.04.09.02.30.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:30:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136562-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WssjhCxI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-136562-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136562-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 81716B2355A for ; Tue, 9 Apr 2024 09:27:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3433E126F2A; Tue, 9 Apr 2024 09:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WssjhCxI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 603C085631 for ; Tue, 9 Apr 2024 09:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712654739; cv=none; b=M5gdWb25NR3BoFyn3OpD+gLYxaal3amaT6SdFKQDZoq5SzYGb5H9oBzNDNISqt6NfdwUywFIdDrQ6M8sp1uV8O+VOo0JgzDQA2K0/0X6qk8HCtfV17GkDZSHPDjRBhx7XALroBpd3rqEyBKnBGd1wA6VHCD3ebszeBJOhObNp+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712654739; c=relaxed/simple; bh=MGM8cnYOc2xUfzqiaHDKMMd1O2BaUHSekMXG68vTT9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MSaajEa6hajevLHAjOtlhvzMjB6hexh5VQmA1mJSCJh2WxCWZfgB4BBnzehPFzYJUGZUFFPtwjNBNURmoQ1GfJBSW37n7ULjZ1G/nmoM+cE485l7vBFq1sAFd3MhAKdlHbB9wLwl94cZIzYs04QgQb4O8nZhS0m1+K02aJvwDT8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WssjhCxI; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 -- 2.43.0