Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp210828lqg; Wed, 10 Apr 2024 23:29:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWU2eKkC+A3EB/SuuSAv6I3WNO/uo0xqWoanDhO8E8XEZAhmqSeRWqHDUIZ8N9CdFqKdGMPLssKfmY8Y8sHcNNT3xbXq3d9PPAv0XFbaA== X-Google-Smtp-Source: AGHT+IE6qkE45TtaZSe9/bgDgzNc1ypVCTZmKSs2Dhsc6adEY51jJixQ18PkQmZuIb/1/Cj12B1P X-Received: by 2002:a17:902:f644:b0:1e5:5be8:15af with SMTP id m4-20020a170902f64400b001e55be815afmr494838plg.17.1712816989567; Wed, 10 Apr 2024 23:29:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712816989; cv=pass; d=google.com; s=arc-20160816; b=WsxYMH8KwpD5rI5bRiFRscjQ575ex0aCkrWjNlLEKI6rMzuqAafamZEEXa++BRX0mN 4LotxArNW0CZvYwldtN3w0ZSdo+IfXvREDwehmu0sDn8ZbJyC1Fk3p41zaKbI4myOfL5 zUqNcZlAugpgg4brX7HAGEfsdLpv26Ous6eiyl+zM2JkIwbmYcwMiwXhW86Dv1D+3eAB rPqB5LE5tNVoQHa/3NRgLUAYtZ75IkFQ3YasK4kJ9eEA790Ke8tCzAinbTMrTgW95tZ9 Mpibu/esFvIme/foxuUkCG5TqBtrYCFChvuO2zg2s+zZz9v1JW7IzfjCZKdDJH5fVnnS lncA== 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=MFcG4Yr2Hq5moJirQsn9mRkvbvfjJMIc5VQrDCoHTkM=; fh=WEMOZDYzhROtJ53Nx6fHy9wYEqwkxnRo6fKhqlB4aEM=; b=pSFHRiv7OorYcuyvpzEb+ey8y9RZnyxexjZ0QnG3qi0D0g1d8280NfDXGM29vgNgfD rAHbC3N8J3NXFLCGlafpHF/b13mMCPh+NnRbUeSDh4gcM3WAs7oGAcerl+QS559AQY/i 6my+TLajXHHLr0FX798nNLq6+zMNKUz5DGzCslcXyqKDfW5TzBIkaTrYeWpv+UfSJbPN wyQmZ+JwIiE/8dWr4YTcsQuSS/sZAjVdxlYp1R6B7zoMveTAWoVuelZeKq7AxNA8vgwM 9rgtMRK74yzSkgzle27NQ94LdEkjQ6dIH5kSwR19KAlUfOfC6v7PDs9oieRTKZ7VLEi0 ycXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p8rhinow; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139833-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. [147.75.48.161]) by mx.google.com with ESMTPS id q16-20020a170902789000b001e4621295c7si685545pll.344.2024.04.10.23.29.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 23:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p8rhinow; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139833-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139833-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 145A5B21BEC for ; Thu, 11 Apr 2024 06:16:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12AC513E024; Thu, 11 Apr 2024 06:14:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p8rhinow" 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 377AD13DDD8 for ; Thu, 11 Apr 2024 06:14:42 +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=1712816082; cv=none; b=RwnqeM+SmQigE5XiOGMA+j2VEvBIyesMZ0i03QJySllWRKKvF5nUNxQxiDeCyA/tn5InQ6Jxlh9oJVI1NQYUjIuT/GTdq2vuEhl3wmHGoIG/iqh22v4MKkr5/uDZQRjLTedtFB5RNzQiopTADvk+l+zH6atydCHo3/vGP/jHdoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712816082; c=relaxed/simple; bh=2BbBT91rO5EKEsTUfQ1HnSSvv2jhr/Cd5b48tiAufmA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GB1oygyXhkWwvG80KiDCShrOJXAg/P+tcwU8Tg8Npl9hQ5luZTxld97ab35L/CGApvyDfuyNa+Jk7eMkXhuxIW3RNlQj0eNCoEQCAorvLfSuhcTVeeWmPD8rvjrAVL/tp2nKja3I9nwK0dIQKesM7daAM05bCyinuByzKSjyd3k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p8rhinow; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3C97C433C7; Thu, 11 Apr 2024 06:14:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712816082; bh=2BbBT91rO5EKEsTUfQ1HnSSvv2jhr/Cd5b48tiAufmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8rhinowpXykMIv8xrZeYQ4/sM/rBmUtzroByI24TOcabbu/AkuHzwOo+wLvLyBpS ei0r0IEsaUt6MiLYL78P4HxgT4D0qn7aVE0oPYB+vS8d+2JgmWR7RC6mVVCbCYkxJS d96sO+9dyG3l6GtE7RAf2pH1a4qCulOXq6jesyBIpnKlqbyvXaujgi2UkUOtJ9tsME 3vjChWTYULjRrUtk/iQvsOXiOwgV8vZobvEoLodOJdwvRydog0NJLVNYYyq2vcvoi2 U4GARspuxshWeFuJK3WhJGdkBjbfZ05BoReePvWFmPG2XqxozAr9Nz/Z39EAWC3ew+ x5SoVAJSv6oPA== From: alexs@kernel.org To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, zik.eidus@ravellosystems.com, willy@infradead.org, aarcange@redhat.com, hughd@google.com, chrisw@sous-sol.org, david@redhat.com Cc: "Alex Shi (tencent)" , Izik Eidus Subject: [PATCH v5 10/10] mm/ksm: replace set_page_stable_node by folio_set_stable_node Date: Thu, 11 Apr 2024 14:17:11 +0800 Message-ID: <20240411061713.1847574-11-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411061713.1847574-1-alexs@kernel.org> References: <20240411061713.1847574-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(). Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright Signed-off-by: Alex Shi (tencent) 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 662fdaaf3ea3..486c9974f8e2 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