Skip to contentSkip to conversation

cgroup: Fix compilation issue due to cgroup_mutex not being exported

PATCH Applied gaoxu 4 participants 5 messages Apr 17, 2025 – Apr 18, 2025 cgroup

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

gaoxu

author
#0 lore raw

PATCH 1/1 cgroup: Fix compilation issue due to cgroup_mutex not being exported

When adding folio_memcg function call in the zram module for Android16-6.12, the following error occurs during compilation:
ERROR: modpost: "cgroup_mutex" [../soc-repo/zram.ko] undefined!

This error is caused by the indirect call to lockdep_is_held(&cgroup_mutex) within folio_memcg. The export setting for cgroup_mutex is controlled by the CONFIG_PROVE_RCU macro. If CONFIG_LOCKDEP is enabled while CONFIG_PROVE_RCU is not, this compilation error will occur.

To resolve this issue, add a parallel macro CONFIG_LOCKDEP control to ensure cgroup_mutex is properly exported when needed.

---
 kernel/cgroup/cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cgroup.c +1 -1
index 447ac857e..9e60ff629 100644
@@ -90,7 +90,7 @@
 DEFINE_MUTEX(cgroup_mutex);
 DEFINE_SPINLOCK(css_set_lock);
 
-#ifdef CONFIG_PROVE_RCU
+#if (defined CONFIG_PROVE_RCU || defined CONFIG_LOCKDEP)
 EXPORT_SYMBOL_GPL(cgroup_mutex);
 EXPORT_SYMBOL_GPL(css_set_lock);
 #endif
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#1 lore raw

Thanks, Gao.

kernel/cgroup/cgroup.c line 93

Quoted 8 lines · gaoxu
kernel/cgroup/cgroup.c +1 -1
@@ -90,7 +90,7 @@
 DEFINE_MUTEX(cgroup_mutex);
 DEFINE_SPINLOCK(css_set_lock);
 
-#ifdef CONFIG_PROVE_RCU
+#if (defined CONFIG_PROVE_RCU || defined CONFIG_LOCKDEP)

#if defined(CONFIG_PROVE_RCU) || defined(CONFIG_LOCKDEP)

seems more conventional wrt existing code.
But in principle

#2 lore raw
In reply to gaoxu

On 4/17/25 1:00 PM, gaoxu wrote:
[...]

kernel/cgroup/cgroup.c line 96

Quoted 13 lines
kernel/cgroup/cgroup.c +1 -1
index 447ac857e..9e60ff629 100644
@@ -90,7 +90,7 @@
 DEFINE_MUTEX(cgroup_mutex);
 DEFINE_SPINLOCK(css_set_lock);
 
-#ifdef CONFIG_PROVE_RCU
+#if (defined CONFIG_PROVE_RCU || defined CONFIG_LOCKDEP)
 EXPORT_SYMBOL_GPL(cgroup_mutex);
 EXPORT_SYMBOL_GPL(css_set_lock);
 #endif

It can be triggered when CONFIG_LOCK_STAT=y is enabled, which selects CONFIG_LOCKDEP=y and sets CONFIG_PROVE_RCU=n. The patch looks good to me.

You may also want to update the description above DEFINE_MUTEX(cgroup_mutex); to reflect the modifications introduced by this patch.

Signature · 2 lines
Cheers,
Kamalesh
author
#3 lore raw
Quoted 23 lines · gaoxu

[...]

kernel/cgroup/cgroup.c line 96

Quoted 13 lines
kernel/cgroup/cgroup.c index renamed from kernel/cgroup/cgroup.c +0 -0

447ac857e..9e60ff629 100644

kernel/cgroup/cgroup.c +1 -1
@@ -90,7 +90,7 @@
 DEFINE_MUTEX(cgroup_mutex);
 DEFINE_SPINLOCK(css_set_lock);
 
-#ifdef CONFIG_PROVE_RCU
+#if (defined CONFIG_PROVE_RCU || defined CONFIG_LOCKDEP)
 EXPORT_SYMBOL_GPL(cgroup_mutex);
 EXPORT_SYMBOL_GPL(css_set_lock);
 #endif

It can be triggered when CONFIG_LOCK_STAT=y is enabled, which selects CONFIG_LOCKDEP=y and sets CONFIG_PROVE_RCU=n. The patch looks good to me.

Quoted 3 lines

You may also want to update the description above DEFINE_MUTEX(cgroup_mutex); to reflect the modifications introduced by this patch.

Received, thanks!

Quoted 4 lines

--
Cheers,
Kamalesh

maintainer Applied
#4 lore raw
In reply to gaoxu
Quoted 9 lines · gaoxu

When adding folio_memcg function call in the zram module for Android16-6.12, the following error occurs during compilation:
ERROR: modpost: "cgroup_mutex" [../soc-repo/zram.ko] undefined!

This error is caused by the indirect call to lockdep_is_held(&cgroup_mutex) within folio_memcg. The export setting for cgroup_mutex is controlled by the CONFIG_PROVE_RCU macro. If CONFIG_LOCKDEP is enabled while CONFIG_PROVE_RCU is not, this compilation error will occur.

Quoted 4 lines

To resolve this issue, add a parallel macro CONFIG_LOCKDEP control to ensure cgroup_mutex is properly exported when needed.

Applied to cgroup/for-6.15-fixes.

Thanks.

Signature · 1 line
tejun