mm/zsmalloc: move get_zspage_lockless into #ifdef

Message ID 20240228094036.2267912-1-arnd@kernel.org
State New
Headers
Series mm/zsmalloc: move get_zspage_lockless into #ifdef |

Commit Message

Arnd Bergmann Feb. 28, 2024, 9:40 a.m. UTC
  From: Arnd Bergmann <arnd@arndb.de>

It's only used from inside of an #ifdef section, causing a warning otherwise:

mm/zsmalloc.c:735:23: error: unused function 'get_zspage_lockless' [-Werror,-Wunused-function]
  735 | static struct zspage *get_zspage_lockless(struct page *page)
      |                       ^~~~~~~~~~~~~~~~~~~

Move it down into that block to avoid adding another #ifdef.

Fixes: 2258bdebb55e ("mm/zsmalloc: don't hold locks of all pages when free_zspage()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/zsmalloc.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
  

Comments

Chengming Zhou Feb. 28, 2024, 9:45 a.m. UTC | #1
On 2024/2/28 17:40, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> It's only used from inside of an #ifdef section, causing a warning otherwise:
> 
> mm/zsmalloc.c:735:23: error: unused function 'get_zspage_lockless' [-Werror,-Wunused-function]
>   735 | static struct zspage *get_zspage_lockless(struct page *page)
>       |                       ^~~~~~~~~~~~~~~~~~~
> 
> Move it down into that block to avoid adding another #ifdef.
> 
> Fixes: 2258bdebb55e ("mm/zsmalloc: don't hold locks of all pages when free_zspage()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Hello Arnd,

Thanks for your fix! But this series has problem and should be removed by Andrew later[1][2].

[1] https://lore.kernel.org/all/20240228043534.GG11972@google.com/
[2] https://lore.kernel.org/all/20240228035403.GE11972@google.com/

Thanks!
  

Patch

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 1a044690b389..11422305d819 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -731,14 +731,6 @@  static struct zspage *get_zspage(struct page *page)
 	return zspage;
 }
 
-/* Only used in zs_page_migrate() to get zspage locklessly. */
-static struct zspage *get_zspage_lockless(struct page *page)
-{
-	struct zspage __rcu **private = (struct zspage __rcu **)&page->private;
-
-	return rcu_dereference(*private);
-}
-
 static struct page *get_next_page(struct page *page)
 {
 	struct zspage *zspage = get_zspage(page);
@@ -1651,6 +1643,13 @@  static void migrate_write_unlock(struct zspage *zspage)
 }
 
 #ifdef CONFIG_COMPACTION
+/* Only used in zs_page_migrate() to get zspage locklessly. */
+static struct zspage *get_zspage_lockless(struct page *page)
+{
+	struct zspage __rcu **private = (struct zspage __rcu **)&page->private;
+
+	return rcu_dereference(*private);
+}
 
 static const struct movable_operations zsmalloc_mops;