cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cgroup: Fix compilation issue due to cgroup_mutex not being  exported
@ 2025-04-18  2:42 gaoxu
  2025-04-18  7:47 ` Kamalesh Babulal
  0 siblings, 1 reply; 3+ messages in thread
From: gaoxu @ 2025-04-18  2:42 UTC (permalink / raw)
  To: Tejun Heo, Johannes Weiner, "Michal Koutný"
  Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kamalesh Babulal, surenb@google.com, yipengxiang

When adding folio_memcg function call in the zram module for
Android 16-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.

Signed-off-by: gao xu <gaoxu2@honor.com>
---
v1 -> v2: update the notes of the description above DEFINE_MUTEX(cgroup_mutex)
per Kamalesh's suggestion.
---
 kernel/cgroup/cgroup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 447ac857e..c1bc51058 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -84,13 +84,13 @@
  * css_set_lock protects task->cgroups pointer, the list of css_set
  * objects, and the chain of tasks off each css_set.
  *
- * These locks are exported if CONFIG_PROVE_RCU so that accessors in
- * cgroup.h can use them for lockdep annotations.
+ * These locks are exported if CONFIG_PROVE_RCU or CONFIG_LOCKDEP so that
+ * accessors in cgroup.h can use them for lockdep annotations.
  */
 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
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] cgroup: Fix compilation issue due to cgroup_mutex not being exported
  2025-04-18  2:42 [PATCH v2] cgroup: Fix compilation issue due to cgroup_mutex not being exported gaoxu
@ 2025-04-18  7:47 ` Kamalesh Babulal
  2025-04-20  0:49   ` 回复: " gaoxu
  0 siblings, 1 reply; 3+ messages in thread
From: Kamalesh Babulal @ 2025-04-18  7:47 UTC (permalink / raw)
  To: gaoxu, Tejun Heo, Johannes Weiner, Michal Koutný
  Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	surenb@google.com, yipengxiang

Hi,

On 4/18/25 8:12 AM, gaoxu wrote:

[...]
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 447ac857e..c1bc51058 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -84,13 +84,13 @@
>   * css_set_lock protects task->cgroups pointer, the list of css_set
>   * objects, and the chain of tasks off each css_set.
>   *
> - * These locks are exported if CONFIG_PROVE_RCU so that accessors in
> - * cgroup.h can use them for lockdep annotations.
> + * These locks are exported if CONFIG_PROVE_RCU or CONFIG_LOCKDEP so that
> + * accessors in cgroup.h can use them for lockdep annotations.
>   */

Tejun has already merged the initial version of the patch without
the updated description. You may want to send the description change
as a separate patch, rebased on top of the cgroup/for-next branch.

I've rephrased the description to clarify that lockdep annotations
can occur even without CONFIG_PROVE_RCU. Feel free to use this
version or modify it further:
"Export locks for lockdep annotations. Use CONFIG_PROVE_RCU for
accessors in cgroup.h, and CONFIG_LOCKDEP for accessors that do not
require CONFIG_PROVE_RCU."

-- 
Cheers,
Kamalesh


^ permalink raw reply	[flat|nested] 3+ messages in thread

* 回复: [PATCH v2] cgroup: Fix compilation issue due to cgroup_mutex not being exported
  2025-04-18  7:47 ` Kamalesh Babulal
@ 2025-04-20  0:49   ` gaoxu
  0 siblings, 0 replies; 3+ messages in thread
From: gaoxu @ 2025-04-20  0:49 UTC (permalink / raw)
  To: Kamalesh Babulal, Tejun Heo, Johannes Weiner, Michal Koutný
  Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	surenb@google.com, yipengxiang

> 
> Hi,
> 
> On 4/18/25 8:12 AM, gaoxu wrote:
> 
> [...]
> > diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index
> > 447ac857e..c1bc51058 100644
> > --- a/kernel/cgroup/cgroup.c
> > +++ b/kernel/cgroup/cgroup.c
> > @@ -84,13 +84,13 @@
> >   * css_set_lock protects task->cgroups pointer, the list of css_set
> >   * objects, and the chain of tasks off each css_set.
> >   *
> > - * These locks are exported if CONFIG_PROVE_RCU so that accessors in
> > - * cgroup.h can use them for lockdep annotations.
> > + * These locks are exported if CONFIG_PROVE_RCU or CONFIG_LOCKDEP so
> > + that
> > + * accessors in cgroup.h can use them for lockdep annotations.
> >   */
> 
> Tejun has already merged the initial version of the patch without the updated
> description. You may want to send the description change as a separate patch,
> rebased on top of the cgroup/for-next branch.
> 
> I've rephrased the description to clarify that lockdep annotations can occur even
> without CONFIG_PROVE_RCU. Feel free to use this version or modify it further:
> "Export locks for lockdep annotations. Use CONFIG_PROVE_RCU for accessors in
> cgroup.h, and CONFIG_LOCKDEP for accessors that do not require
> CONFIG_PROVE_RCU."
Received, thanks!
> 
> --
> Cheers,
> Kamalesh


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-20  0:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-18  2:42 [PATCH v2] cgroup: Fix compilation issue due to cgroup_mutex not being exported gaoxu
2025-04-18  7:47 ` Kamalesh Babulal
2025-04-20  0:49   ` 回复: " gaoxu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).