From patchwork Wed Mar 20 07:40:46 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: 13597424 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 22E01C54E58 for ; Wed, 20 Mar 2024 07:38:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 917558E0001; Wed, 20 Mar 2024 03:38:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C8646B00A5; Wed, 20 Mar 2024 03:38:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 768158E0001; Wed, 20 Mar 2024 03:38:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 678416B00A4 for ; Wed, 20 Mar 2024 03:38:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3C9B21402C7 for ; Wed, 20 Mar 2024 07:38:14 +0000 (UTC) X-FDA: 81916614108.18.6F64422 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf09.hostedemail.com (Postfix) with ESMTP id 120D8140018 for ; Wed, 20 Mar 2024 07:38:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NAz1Jtn5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 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=1710920292; 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=Gy8pt/xqRJMf3r7GZ9kkqZx4ekh1Lp8oaLaZ7e4CbS0=; b=OQHaMeGJ/+OxhEf5NGJQoan45o5YxASB+KMXPcP2iRb43HPYbv2AFegj6wZ5oZWUo4CTSz gssk3VE5FURBHkEShatJTa59VpbXUcNCixsEAdDr+RS/C8kb8QiLpul04P4K4rwgA6+fZ3 ApNRPB/FVKpHeAXBY2kHWVmKe4eKKik= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NAz1Jtn5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of alexs@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=alexs@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710920292; a=rsa-sha256; cv=none; b=ih0yG3S7LPbsIVpZQs0o5EIV5AzVcBapfUwceB6hp5/zR/Udl/1SV0z9Wk9wHHsJocFmFS 8oeEXtHHt/R0+N2Wx/EB0ZKjTf1CoFjath8xDR2mf+uoPNbAt/WrRSnKFnBfLtDQvuT6yy uY/3fEUDPOnYqCiM5YBEbKDyFcV2wsw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 746FFCE1093; Wed, 20 Mar 2024 07:38:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3178CC433F1; Wed, 20 Mar 2024 07:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710920288; bh=4/ipLVxA+I+/npLz6EvsQqobqTxElBqybjRD2uQTgUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NAz1Jtn5Tv7xWex39egXoEsKh+6Jyz4na6sqHGHE5Gn7vpfr/BD5NGADxf131MnF8 nS679xCkTyyQY1M8WtgJdNq8mqaUixp8HZrftKU44Ld/m7tOJd5wILQYaeRALdGZav wS5kjN/WFPEojTEskJziqJTsLeXlW+eoz/PRYZVDNqgGvpd/i/xAsOTqtjaZ9HN5Wl e9MSXRQFkU1funeUToZImXIzxFfPPfX05lRAjuCpOe/pKbeh3Vldew9uu+mJRTZuYg XcIxbGSEnfSyVXgguUKGdo2qx73PFtZy6OF36ZSemWtHs+H/mFl9yoO47rNR5HxZDP teWlc/3bOCa/g== From: alexs@kernel.org To: Izik Eidus , Matthew Wilcox , Andrea Arcangeli , Hugh Dickins , Chris Wright , kasong@tencent.com, Andrew Morton , linux-mm@kvack.org (open list:MEMORY MANAGEMENT), linux-kernel@vger.kernel.org (open list) Cc: linux-kernel@vger.kernel.org, "Alex Shi (tencent)" Subject: [PATCH 10/11] mm/ksm: rename get_ksm_page to get_ksm_folio and return type Date: Wed, 20 Mar 2024 15:40:46 +0800 Message-ID: <20240320074049.4130552-11-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240320074049.4130552-1-alexs@kernel.org> References: <20240320074049.4130552-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 120D8140018 X-Stat-Signature: 5k6ug4wnirdy8jba7kb3cghsu7demaj4 X-Rspam-User: X-HE-Tag: 1710920291-636578 X-HE-Meta: U2FsdGVkX196u3ue+nKLQRvWXG9etpRrqUMxj74hr6/NcFtnAc/KYx6KLnoR4dEdIeADnJzI1hqvfSzmW92YpIUXsuVHUrvk8ca22YXXDqg2HMy/+ZwLQB37Y6dtH5q0D5ZZyxs5CxHrBoM6IDus+m5kANBqGufH075jXihUmlyKAaXJHyAVt2kA6T0+TKo1fViWL6zkWXmorGndIG2hKyh2oVFjpCeLQZvQL+pnMHW9UUNtwy/pP5J9HvcN9N6Qbx9efhUn1rXuR2iqs1w1eYNU3CUCk0nhw/U3G0QOabr+PeNHi+G5Kgsexpx1Hn4irFh4NXyLUmPdEvuBbQ3N7azO5n+mvUKVKGz/9q7SpLr1wRjw6/x1Jnx+lx0+hCB87LBbSkey8WgUhVKzn4mAJa3LqEMetT+Tfgadv61AX/J/zaaExR8+t559ElOftu7eb1LopU7oiOQXj+u7yvLkL3FkubQ7Y/L3qmF5NGmroL63tTmxIJUc+DPjlyjuLKCg7rTN/qICf66uPe3NnZja2Q+5yCqB3D1mZEcw/3wBRexy7BhDXDNtHLdxZRucobtkiwC0eq3yD4AKXWVI9XJfvbibX29NvA5GbeewVewIihz8xGn5GrYP7j2p6iDyRYk67WxXAFV2boAKyAvuMWAtdIgSIpaYSqAkTzkHEZ/k21vhrxsLnsgnVoFV/oFWvsqi5QVMeZg+af2WBZXcKBSnrrcTvobm1rI2st0xhgUDXoWN0ae8KPgHq74EGOOCAiKGqY3hDOkfZUx2gTHyCAEUiYH6crLx30CNLPrR9fi7Vj/uetb+RqzYOpBHxzV+D8QSumQ32jRwmMdncMIbF1yXtnWD/acrjMSF3iwX9J3a0PGO/c8IiYQjZx5V2ZODy6WXDfMFbBXrwVlGUSrNCOX4HiNV9rR43WLsv5ecHDAQS1+yrnMGu+m9xOfz82GKLdFALPyw+L1i/9DorosXO8H QUcnioCZ 8b3e4 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 folio, return to folio and rename it as get_ksm_folio. Signed-off-by: Alex Shi (tencent) Cc: Izik Eidus Cc: Matthew Wilcox Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Chris Wright --- mm/ksm.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/mm/ksm.c b/mm/ksm.c index 75401b3bae5c..806ad4d2693b 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 get_ksm_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 + * get_ksm_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, @@ -915,8 +915,8 @@ enum get_ksm_page_flags { * a page to put something that might look like our key in page->mapping. * is on its way to being freed; but it is an anomaly to bear in mind. */ -static void *get_ksm_page(struct ksm_stable_node *stable_node, - enum get_ksm_page_flags flags) +static struct folio *get_ksm_folio(struct ksm_stable_node *stable_node, + enum get_ksm_folio_flags flags) { struct folio *folio; void *expected_mapping; @@ -1001,7 +1001,7 @@ static void remove_rmap_item_from_tree(struct ksm_rmap_item *rmap_item) struct folio *folio; stable_node = rmap_item->head; - folio = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); + folio = get_ksm_folio(stable_node, GET_KSM_PAGE_LOCK); if (!folio) goto out; @@ -1110,10 +1110,10 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) struct folio *folio; int err; - folio = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK); + folio = get_ksm_folio(stable_node, GET_KSM_PAGE_LOCK); if (!folio) { /* - * get_ksm_page did remove_node_from_stable_tree itself. + * get_ksm_folio did remove_node_from_stable_tree itself. */ return 0; } @@ -1126,7 +1126,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 get_ksm_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, @@ -1641,13 +1641,13 @@ static void *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 + * get_ksm_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 * under us if it returns NULL. */ - folio = get_ksm_page(dup, GET_KSM_PAGE_NOLOCK); + folio = get_ksm_folio(dup, GET_KSM_PAGE_NOLOCK); if (!folio) continue; nr += 1; @@ -1748,7 +1748,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 get_ksm_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 @@ -1770,7 +1770,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 get_ksm_folio(stable_node, GET_KSM_PAGE_NOLOCK); } /* * _stable_node_dup set to NULL means the stable_node @@ -1877,14 +1877,14 @@ static void *stable_tree_search(struct page *page) * write protected at all times. Any will work * fine to continue the walk. */ - tree_folio = get_ksm_page(stable_node_any, - GET_KSM_PAGE_NOLOCK); + tree_folio = get_ksm_folio(stable_node_any, + GET_KSM_PAGE_NOLOCK); } VM_BUG_ON(!stable_node_dup ^ !!stable_node_any); if (!tree_folio) { /* * If we walked over a stale stable_node, - * get_ksm_page() will call rb_erase() and it + * get_ksm_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 @@ -1938,8 +1938,8 @@ static void *stable_tree_search(struct page *page) * It would be more elegant to return stable_node * than kpage, but that involves more changes. */ - tree_folio = get_ksm_page(stable_node_dup, - GET_KSM_PAGE_TRYLOCK); + tree_folio = get_ksm_folio(stable_node_dup, + GET_KSM_PAGE_TRYLOCK); if (PTR_ERR(tree_folio) == -EBUSY) return ERR_PTR(-EBUSY); @@ -2110,14 +2110,14 @@ static struct ksm_stable_node *stable_tree_insert(struct folio *kfolio) * write protected at all times. Any will work * fine to continue the walk. */ - tree_folio = get_ksm_page(stable_node_any, - GET_KSM_PAGE_NOLOCK); + tree_folio = get_ksm_folio(stable_node_any, + GET_KSM_PAGE_NOLOCK); } VM_BUG_ON(!stable_node_dup ^ !!stable_node_any); if (!tree_folio) { /* * If we walked over a stale stable_node, - * get_ksm_page() will call rb_erase() and it + * get_ksm_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 @@ -2601,8 +2601,8 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page) list_for_each_entry_safe(stable_node, next, &migrate_nodes, list) { - folio = get_ksm_page(stable_node, - GET_KSM_PAGE_NOLOCK); + folio = get_ksm_folio(stable_node, + GET_KSM_PAGE_NOLOCK); if (folio) folio_put(folio); cond_resched(); @@ -3229,7 +3229,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 get_ksm_folio() before it can see that folio->mapping * has gone stale (or that folio_test_swapcache has been cleared). */ smp_wmb(); @@ -3256,7 +3256,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 get_ksm_folio, page has already gone: * which is why we keep kpfn instead of page* */ remove_node_from_stable_tree(stable_node); @@ -3344,7 +3344,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 get_ksm_folio() might later try to access a * non-existent struct page. */ ksm_check_stable_tree(mn->start_pfn,