Skip to contentSkip to conversation

rust: helpers: move list_lru and task_work helpers out of binder.c

PATCH Superseded Xiaobo Liu 3 participants 4 messages Jun 23

Subsystems (3)
lore
Share & tools
lore

Xiaobo Liu

author
#0 lore raw

PATCH 1/1 rust: helpers: move list_lru and task_work helpers out of binder.c

The helpers in binder.c wrap generic list_lru and task_work inline functions and have nothing to do with binder. Move them to mm.c and task_work.c respectively, where they belong by subsystem.

---
 rust/helpers/binder.c    | 27 ---------------------------
 rust/helpers/helpers.c   |  2 +-
 rust/helpers/mm.c        | 14 ++++++++++++++
 rust/helpers/task_work.c |  9 +++++++++
 4 files changed, 24 insertions(+), 28 deletions(-)
 delete mode 100644 rust/helpers/binder.c
 create mode 100644 rust/helpers/task_work.c
rust/helpers/binder.c deleted +0 -27
deleted file mode 100644
index a2327f1b3..000000000
@@ -1,27 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-/*
- * Copyright (C) 2025 Google LLC.
- */
-
-#include <linux/list_lru.h>
-#include <linux/task_work.h>
-
-__rust_helper unsigned long rust_helper_list_lru_count(struct list_lru *lru)
-{
-	return list_lru_count(lru);
-}
-
-__rust_helper unsigned long rust_helper_list_lru_walk(struct list_lru *lru,
-						      list_lru_walk_cb isolate,
-						      void *cb_arg,
-						      unsigned long nr_to_walk)
-{
-	return list_lru_walk(lru, isolate, cb_arg, nr_to_walk);
-}
-
-__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
-					      task_work_func_t func)
-{
-	init_task_work(twork, func);
-}
rust/helpers/helpers.c +1 -1
index 998e31052..fe0883b33 100644
@@ -43,7 +43,6 @@
 #include "atomic_ext.c"
 #include "auxiliary.c"
 #include "barrier.c"
-#include "binder.c"
 #include "bitmap.c"
 #include "bitops.c"
 #include "blk.c"
@@ -93,6 +92,7 @@
 #include "string.c"
 #include "sync.c"
 #include "task.c"
+#include "task_work.c"
 #include "time.c"
 #include "uaccess.c"
 #include "usb.c"
rust/helpers/mm.c +14 -0
index b5540997b..941984feb 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <linux/list_lru.h>
 #include <linux/mm.h>
 #include <linux/sched/mm.h>
 
@@ -8,6 +9,19 @@ __rust_helper void rust_helper_mmgrab(struct mm_struct *mm)
 	mmgrab(mm);
 }
 
+__rust_helper unsigned long rust_helper_list_lru_count(struct list_lru *lru)
+{
+	return list_lru_count(lru);
+}
+
+__rust_helper unsigned long rust_helper_list_lru_walk(struct list_lru *lru,
+						      list_lru_walk_cb isolate,
+						      void *cb_arg,
+						      unsigned long nr_to_walk)
+{
+	return list_lru_walk(lru, isolate, cb_arg, nr_to_walk);
+}
+
 __rust_helper void rust_helper_mmdrop(struct mm_struct *mm)
 {
 	mmdrop(mm);
rust/helpers/task_work.c new file +9 -0
new file mode 100644
index 000000000..5bdb752cb
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/task_work.h>
+
+__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
+					      task_work_func_t func)
+{
+	init_task_work(twork, func);
+}
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Xiaobo Liu

The helpers in binder.c wrap generic list_lru and task_work inline functions and have nothing to do with binder. Move them to mm.c and task_work.c respectively, where they belong by subsystem.

In general, please Cc the relevant maintainers/reviewers/subsystems as well as the LKML -- scripts/get_maintainer.pl can help there; otherwise, you can check MAINTAINERS manually too.

Doing so here for you to give you an idea of how it could look like -- I hope it helps.

Quoted 1 line

+#include <linux/list_lru.h>

Since you are creating a new file for task_work, what about one for list_lru too?

(And we should likely add the new files to the respective MAINTAINERS entries.)

Thanks!

Cheers,
Miguel

author
#2 lore raw

PATCH v2 1/1 rust: helpers: move list_lru and task_work helpers out of binder.c

The helpers in binder.c wrap generic list_lru and task_work inline functions and have nothing to do with binder. Move each of them to a file named after its own C header:

- list_lru helpers move to list_lru.c,
- init_task_work moves to task_work.c.

Add the new list_lru.c to the SHRINKER entry in MAINTAINERS, which already covers include/linux/list_lru.h.

---
 MAINTAINERS                           |  1 +
 rust/helpers/helpers.c                |  3 ++-
 rust/helpers/{binder.c => list_lru.c} |  7 -------
 rust/helpers/task_work.c              | 13 +++++++++++++
 4 files changed, 16 insertions(+), 8 deletions(-)
 rename rust/helpers/{binder.c => list_lru.c} (72%)
 create mode 100644 rust/helpers/task_work.c
MAINTAINERS +1 -0
index ba45953bb..428992431 100644
@@ -24590,6 +24590,7 @@ S:	Maintained
 F:	Documentation/admin-guide/mm/shrinker_debugfs.rst
 F:	include/linux/list_lru.h
 F:	include/linux/shrinker.h
+F:	rust/helpers/list_lru.c
 F:	mm/list_lru.c
 F:	mm/shrinker.c
 F:	mm/shrinker_debug.c
rust/helpers/helpers.c +2 -1
index 998e31052..ea34101b9 100644
@@ -43,7 +43,6 @@
 #include "atomic_ext.c"
 #include "auxiliary.c"
 #include "barrier.c"
-#include "binder.c"
 #include "bitmap.c"
 #include "bitops.c"
 #include "blk.c"
@@ -69,6 +68,7 @@
 #include "jump_label.c"
 #include "kunit.c"
 #include "list.c"
+#include "list_lru.c"
 #include "maple_tree.c"
 #include "mm.c"
 #include "mutex.c"
@@ -93,6 +93,7 @@
 #include "string.c"
 #include "sync.c"
 #include "task.c"
+#include "task_work.c"
 #include "time.c"
 #include "uaccess.c"
 #include "usb.c"
rust/helpers/list_lru.c renamed from rust/helpers/binder.c +0 -7
similarity index 72%
rename from rust/helpers/binder.c
rename to rust/helpers/list_lru.c
index a2327f1b3..3b88d1a96 100644
@@ -5,7 +5,6 @@
  */
 
 #include <linux/list_lru.h>
-#include <linux/task_work.h>
 
 __rust_helper unsigned long rust_helper_list_lru_count(struct list_lru *lru)
 {
@@ -19,9 +18,3 @@ __rust_helper unsigned long rust_helper_list_lru_walk(struct list_lru *lru,
 {
 	return list_lru_walk(lru, isolate, cb_arg, nr_to_walk);
 }
-
-__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
-					      task_work_func_t func)
-{
-	init_task_work(twork, func);
-}
rust/helpers/task_work.c new file +13 -0
new file mode 100644
index 000000000..cb961cd22
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2025 Google LLC.
+ */
+
+#include <linux/task_work.h>
+
+__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
+					      task_work_func_t func)
+{
+	init_task_work(twork, func);
+}
Signature · 1 line
2.34.1
#3 lore raw
Quoted 108 lines · Xiaobo Liu

The helpers in binder.c wrap generic list_lru and task_work inline functions and have nothing to do with binder. Move each of them to a file named after its own C header:

- list_lru helpers move to list_lru.c,
- init_task_work moves to task_work.c.

Add the new list_lru.c to the SHRINKER entry in MAINTAINERS, which already covers include/linux/list_lru.h.

---
 MAINTAINERS                           |  1 +
 rust/helpers/helpers.c                |  3 ++-
 rust/helpers/{binder.c => list_lru.c} |  7 -------
 rust/helpers/task_work.c              | 13 +++++++++++++
 4 files changed, 16 insertions(+), 8 deletions(-)
 rename rust/helpers/{binder.c => list_lru.c} (72%)
 create mode 100644 rust/helpers/task_work.c
MAINTAINERS +1 -0
index ba45953bb..428992431 100644
@@ -24590,6 +24590,7 @@ S:	Maintained
 F:	Documentation/admin-guide/mm/shrinker_debugfs.rst
 F:	include/linux/list_lru.h
 F:	include/linux/shrinker.h
+F:	rust/helpers/list_lru.c
 F:	mm/list_lru.c
 F:	mm/shrinker.c
 F:	mm/shrinker_debug.c
rust/helpers/helpers.c +2 -1
index 998e31052..ea34101b9 100644
@@ -43,7 +43,6 @@
 #include "atomic_ext.c"
 #include "auxiliary.c"
 #include "barrier.c"
-#include "binder.c"
 #include "bitmap.c"
 #include "bitops.c"
 #include "blk.c"
@@ -69,6 +68,7 @@
 #include "jump_label.c"
 #include "kunit.c"
 #include "list.c"
+#include "list_lru.c"
 #include "maple_tree.c"
 #include "mm.c"
 #include "mutex.c"
@@ -93,6 +93,7 @@
 #include "string.c"
 #include "sync.c"
 #include "task.c"
+#include "task_work.c"
 #include "time.c"
 #include "uaccess.c"
 #include "usb.c"
rust/helpers/list_lru.c renamed from rust/helpers/binder.c +0 -7
similarity index 72%
rename from rust/helpers/binder.c
rename to rust/helpers/list_lru.c
index a2327f1b3..3b88d1a96 100644
@@ -5,7 +5,6 @@
  */
 
 #include <linux/list_lru.h>
-#include <linux/task_work.h>
 
 __rust_helper unsigned long rust_helper_list_lru_count(struct list_lru *lru)
 {
@@ -19,9 +18,3 @@ __rust_helper unsigned long rust_helper_list_lru_walk(struct list_lru *lru,
 {
 	return list_lru_walk(lru, isolate, cb_arg, nr_to_walk);
 }
-
-__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
-					      task_work_func_t func)
-{
-	init_task_work(twork, func);
-}
rust/helpers/task_work.c new file +13 -0
new file mode 100644
index 000000000..cb961cd22
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright (C) 2025 Google LLC.
+ */
+
+#include <linux/task_work.h>
+
+__rust_helper void rust_helper_init_task_work(struct callback_head *twork,
+					      task_work_func_t func)
+{
+	init_task_work(twork, func);
+}
Signature · 1 line
2.34.1

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot