From patchwork Mon Mar 25 12:48:58 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: 13602027 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 F08BECD11DB for ; Mon, 25 Mar 2024 12:46:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 114EF6B00A9; Mon, 25 Mar 2024 08:46:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04BE26B00AA; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E07446B00AB; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CCF126B00A9 for ; Mon, 25 Mar 2024 08:46:22 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A1CB1C0404 for ; Mon, 25 Mar 2024 12:46:22 +0000 (UTC) X-FDA: 81935534604.18.95D1A5A Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 46877100017 for ; Mon, 25 Mar 2024 12:46:19 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=at0VDuHS; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711370781; 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=46nx9WN+IELbCOLBNTx6JiC62N+qW0GfiXNmj7LQJ80=; b=D2QBlIAsl9GiGau0RQ/GQQ5YfLnh0ORTqLciWoIeR1ZZuOWvG1kr0z7GBlpc6gEXTrdVoU /AiWNJTk9jearMY0VTk5S4Bqo8TnbPjLo4OYCR6EMWiFFe+tcDe9CHBcbZCgNlSdgiBx1K aHE3ba/Dhyj1GdOvpFLAMA0j0zKXQFY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711370781; a=rsa-sha256; cv=none; b=Ad2i42GYXARAsg6/34EEQeoFby6sLuRKzyOzJA13ouA9HoT6xMpSTAR4FMMAr2Oq3KZSiM ZDlhraC5Hv2HqgIrZeAgYL82VHPbZCRTVcCPvOV1lxZsUwW3/LuwEeUE3tYqHu4gl3WXZ5 tzp8n0lQhcm4VdRmx3H8iq5Zz94NT9U= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=at0VDuHS; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5999DCE179C; Mon, 25 Mar 2024 12:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 457B1C433F1; Mon, 25 Mar 2024 12:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711370776; bh=wVJDweO+3+nZNvpdxD1sOnabgczsKGATc/r/G9PfpiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=at0VDuHS1UFGvZa2neZdLri042ZbLa6A9MUgGRBNE5qGfCI2bODuBIA+VXldGpWmz AzJe9wHMcmIBUbmnO5/pHRIsv/Q/o4PcTWzYXvcIpEEIuGuXBKeuXRMIutXAYCR1I3 /0LHpeFZ6sCQ+Qk8HwfLlumd0YNfJHFmIrE72awqDsW8FNVinqkiaFLuaQswCaZFxq ewFRlvWp135MbtvT4KguhzgPncItoNY2Twe1cufEpby7VJdZTZNedABe6Vo7sqMiCF swfeW+jnM6fzay7hnPM43ksTBiWNp3G9ZwFMuxYPKn2m99dxG82erlMJDDYcuPo63N dtMH7Lhm7e9Nw== From: alexs@kernel.org To: Matthew Wilcox , Andrea Arcangeli , Izik Eidus , david@redhat.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryncsn@gmail.com Cc: "Alex Shi (tencent)" , Hugh Dickins , Chris Wright Subject: [PATCH v3 11/14] mm/ksm: remove get_ksm_page and related info Date: Mon, 25 Mar 2024 20:48:58 +0800 Message-ID: <20240325124904.398913-12-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325124904.398913-1-alexs@kernel.org> References: <20240325124904.398913-1-alexs@kernel.org> MIME-Version: 1.0 X-Stat-Signature: geqbxsn6uod7r3n8sh1eh9jyinccqamd X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 46877100017 X-Rspam-User: X-HE-Tag: 1711370779-585327 X-HE-Meta: U2FsdGVkX18dHfl+4tCm/1VBQzjm47ROvbRGWCenLsf2aQvVDYZ/7pZooIvD03qoV85twgG/IfX8OzBsxu79glRVZipnxxBnU/VPsynzq05OLg1420MBZZfrR7pGHk5rd1ydp/P4Y6JV9QwP43YwgjwutvrigFhnNBJzzb8NoS9/j6J/qVbSkzGttuSdrK2MseCPQ2fowIuSx/JQWldUwwuYlpGPIk2mIhLFBo7scsAhpFDG1XdpSaNNduy9v2qbdMWKs8nIe6oRfOUZC9W6rGI+kJOBWf4ove48nkAKBJlZ9l6hKlxTLd8n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f+ozReYD0b8a/NvQHZQJOke7GpBMv7B9jrNBtJEPbx+vBd7xyWKEZLwnfPjPi4O5MkuckQY+Mk2o0lKZam2Sn2FiVL9pj 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)" Now since all caller are changed to ksm_get_folio, let's sync up the related usages with ksm_get_folio, and remove get_ksm_page. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 34 +++++++++++++--------------------- mm/migrate.c | 2 +- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index e92445f29685..0ad02524e363 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -890,14 +890,14 @@ static void remove_node_from_stable_tree(struct ksm_stable_node *stable_node) free_stable_node(stable_node); } -enum get_ksm_page_flags { +enum ksm_get_folio_flags { GET_KSM_PAGE_NOLOCK, GET_KSM_PAGE_LOCK, GET_KSM_PAGE_TRYLOCK }; /* - * get_ksm_page: checks if the page indicated by the stable node + * ksm_get_folio: checks if the page indicated by the stable node * is still its ksm page, despite having held no reference to it. * In which case we can trust the content of the page, and it * returns the gotten page; but if the page has now been zapped, @@ -916,7 +916,7 @@ enum get_ksm_page_flags { * is on its way to being freed; but it is an anomaly to bear in mind. */ static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node, - enum get_ksm_page_flags flags) + enum ksm_get_folio_flags flags) { struct folio *folio; void *expected_mapping; @@ -990,14 +990,6 @@ static struct folio *ksm_get_folio(struct ksm_stable_node *stable_node, return NULL; } -static struct page *get_ksm_page(struct ksm_stable_node *stable_node, - enum get_ksm_page_flags flags) -{ - struct folio *folio = ksm_get_folio(stable_node, flags); - - return &folio->page; -} - /* * Removing rmap_item from stable or unstable tree. * This function will clean the information from the stable/unstable tree. @@ -1127,7 +1119,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) folio = ksm_get_folio(stable_node, GET_KSM_PAGE_LOCK); if (!folio) { /* - * get_ksm_page did remove_node_from_stable_tree itself. + * ksm_get_folio did remove_node_from_stable_tree itself. */ return 0; } @@ -1140,7 +1132,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) err = -EBUSY; if (!folio_mapped(folio)) { /* - * The stable node did not yet appear stale to get_ksm_page(), + * The stable node did not yet appear stale to ksm_get_folio(), * since that allows for an unmapped ksm folio to be recognized * right up until it is freed; but the node is safe to remove. * This folio might be in an LRU cache waiting to be freed, @@ -1657,7 +1649,7 @@ static struct page *stable_node_dup(struct ksm_stable_node **_stable_node_dup, * We must walk all stable_node_dup to prune the stale * stable nodes during lookup. * - * get_ksm_page can drop the nodes from the + * ksm_get_folio can drop the nodes from the * stable_node->hlist if they point to freed pages * (that's why we do a _safe walk). The "dup" * stable_node parameter itself will be freed from @@ -1764,7 +1756,7 @@ static struct ksm_stable_node *stable_node_dup_any(struct ksm_stable_node *stabl } /* - * Like for get_ksm_page, this function can free the *_stable_node and + * Like for ksm_get_folio, this function can free the *_stable_node and * *_stable_node_dup if the returned tree_page is NULL. * * It can also free and overwrite *_stable_node with the found @@ -1786,7 +1778,7 @@ static void *__stable_node_chain(struct ksm_stable_node **_stable_node_dup, if (!is_stable_node_chain(stable_node)) { if (is_page_sharing_candidate(stable_node)) { *_stable_node_dup = stable_node; - return get_ksm_page(stable_node, GET_KSM_PAGE_NOLOCK); + return ksm_get_folio(stable_node, GET_KSM_PAGE_NOLOCK); } /* * _stable_node_dup set to NULL means the stable_node @@ -1900,7 +1892,7 @@ static void *stable_tree_search(struct page *page) if (!tree_folio) { /* * If we walked over a stale stable_node, - * get_ksm_page() will call rb_erase() and it + * ksm_get_folio() will call rb_erase() and it * may rebalance the tree from under us. So * restart the search from scratch. Returning * NULL would be safe too, but we'd generate @@ -2133,7 +2125,7 @@ static struct ksm_stable_node *stable_tree_insert(struct folio *kfolio) if (!tree_folio) { /* * If we walked over a stale stable_node, - * get_ksm_page() will call rb_erase() and it + * ksm_get_folio() will call rb_erase() and it * may rebalance the tree from under us. So * restart the search from scratch. Returning * NULL would be safe too, but we'd generate @@ -3245,7 +3237,7 @@ void folio_migrate_ksm(struct folio *newfolio, struct folio *folio) /* * newfolio->mapping was set in advance; now we need smp_wmb() * to make sure that the new stable_node->kpfn is visible - * to get_ksm_page() before it can see that folio->mapping + * to ksm_get_folio() before it can see that folio->mapping * has gone stale (or that folio_test_swapcache has been cleared). */ smp_wmb(); @@ -3272,7 +3264,7 @@ static bool stable_node_dup_remove_range(struct ksm_stable_node *stable_node, if (stable_node->kpfn >= start_pfn && stable_node->kpfn < end_pfn) { /* - * Don't get_ksm_page, page has already gone: + * Don't ksm_get_folio, page has already gone: * which is why we keep kpfn instead of page* */ remove_node_from_stable_tree(stable_node); @@ -3360,7 +3352,7 @@ static int ksm_memory_callback(struct notifier_block *self, * Most of the work is done by page migration; but there might * be a few stable_nodes left over, still pointing to struct * pages which have been offlined: prune those from the tree, - * otherwise get_ksm_page() might later try to access a + * otherwise ksm_get_folio() might later try to access a * non-existent struct page. */ ksm_check_stable_tree(mn->start_pfn, diff --git a/mm/migrate.c b/mm/migrate.c index 73a052a382f1..9f0494fd902c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -616,7 +616,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) folio_migrate_ksm(newfolio, folio); /* * Please do not reorder this without considering how mm/ksm.c's - * get_ksm_page() depends upon ksm_migrate_page() and PageSwapCache(). + * ksm_get_folio() depends upon ksm_migrate_page() and PageSwapCache(). */ if (folio_test_swapcache(folio)) folio_clear_swapcache(folio);