Skip to contentSkip to conversation

migrate: Wrap CONFIG_DEVICE_PRIVATE dependent function declarations with ifdef

PATCH RESEND In review SeongJae Park 2 participants 2 messages Feb 9, 2022 – Feb 11, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 migrate: Wrap CONFIG_DEVICE_PRIVATE dependent function declarations with ifdef

'migrate_vma_{setup,pages,finalize}()' functions are defined under CONFIG_DEVICE_PRIVATE, but their declarations are not. This commit wraps the declaration under the config to minimize confusion.

---
 include/linux/migrate.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/migrate.h +5 -0
index 66a34eae8cb6..f8fa7db83e23 100644
@@ -162,9 +162,14 @@ struct migrate_vma {
 	unsigned long		flags;
 };
 
+#ifdef CONFIG_DEVICE_PRIVATE
+
 int migrate_vma_setup(struct migrate_vma *args);
 void migrate_vma_pages(struct migrate_vma *migrate);
 void migrate_vma_finalize(struct migrate_vma *migrate);
+
+#endif /* CONFIG_DEVICE_PRIVATE */
+
 int next_demotion_node(int node);
 
 #else /* CONFIG_MIGRATION disabled: */
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 10 lines · On Wed, 9 Feb 2022 09:47:53 +0000 SeongJae Park <[email protected]> wrote:

'migrate_vma_{setup,pages,finalize}()' functions are defined under CONFIG_DEVICE_PRIVATE, but their declarations are not. This commit wraps the declaration under the config to minimize confusion.

...

include/linux/migrate.h +0 -0
@@ -162,9 +162,14 @@ struct migrate_vma {
 	unsigned long		flags;

include/linux/migrate.h struct migrate_vma { · line 172

Quoted 10 lines
include/linux/migrate.h +5 -0
 };
 
+#ifdef CONFIG_DEVICE_PRIVATE
+
 int migrate_vma_setup(struct migrate_vma *args);
 void migrate_vma_pages(struct migrate_vma *migrate);
 void migrate_vma_finalize(struct migrate_vma *migrate);
+
+#endif /* CONFIG_DEVICE_PRIVATE */
+

We often don't do this. The advantage is that errors are revealed at compile time rather than at link time. But the downside is quite a lot of maintenance overhead and messier-looking header files.

And that maintenance overhead is significant, partly because we can get this wrong but the kernel will still happily compile and boot! So the only way to maintain these things is by inspection.