linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Harry Yoo <harry.yoo@oracle.com>
To: Thomas Ballasi <tballasi@linux.microsoft.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org,
	rostedt@goodmis.org
Subject: build error on CONFIG_MEMCG=n "error: invalid use of undefined type 'struct mem_cgroup'"
Date: Wed, 7 Jan 2026 10:56:46 +0900	[thread overview]
Message-ID: <aV29Xj2wo786xVn1@hyeyoo> (raw)
In-Reply-To: <20260105160423.23708-2-tballasi@linux.microsoft.com>

On Mon, Jan 05, 2026 at 08:04:22AM -0800, Thomas Ballasi wrote:
> Memory reclaim events are currently difficult to attribute to
> specific cgroups, making debugging memory pressure issues
> challenging.  This patch adds memory cgroup ID (memcg_id) to key
> vmscan tracepoints to enable better correlation and analysis.
> 
> For operations not associated with a specific cgroup, the field
> is defaulted to 0.
> 
> Signed-off-by: Thomas Ballasi <tballasi@linux.microsoft.com>
> ---
>  include/trace/events/vmscan.h | 79 ++++++++++++++++++++---------------
>  mm/shrinker.c                 |  2 +-
>  mm/vmscan.c                   | 17 ++++----
>  3 files changed, 56 insertions(+), 42 deletions(-)
> 
> diff --git a/include/trace/events/vmscan.h b/include/trace/events/vmscan.h
> index 490958fa10dee..93a9a9ba9405d 100644
> --- a/include/trace/events/vmscan.h
> +++ b/include/trace/events/vmscan.h
> @@ -208,31 +215,34 @@ TRACE_EVENT(mm_shrink_slab_start,
>  	TP_fast_assign(
>  		__entry->shr = shr;
>  		__entry->shrink = shr->scan_objects;
> -		__entry->nid = sc->nid;
>  		__entry->nr_objects_to_shrink = nr_objects_to_shrink;
>  		__entry->gfp_flags = (__force unsigned long)sc->gfp_mask;
>  		__entry->cache_items = cache_items;
>  		__entry->delta = delta;
>  		__entry->total_scan = total_scan;
>  		__entry->priority = priority;
> +		__entry->nid = sc->nid;
> +		__entry->memcg_id = sc->memcg ? cgroup_id(sc->memcg->css.cgroup) : 0;

Hi Thomas, this is breaking CONFIG_MEMCG=n builds.

In file included from ./include/trace/define_trace.h:132,
                 from ./include/trace/events/vmscan.h:569,
                 from mm/vmscan.c:73:
./include/trace/events/vmscan.h: In function ‘do_trace_event_raw_event_mm_shrink_slab_start’:
./include/trace/events/vmscan.h:248:68: error: invalid use of undefined type ‘struct mem_cgroup’
  248 |                 __entry->memcg_id = sc->memcg ? cgroup_id(sc->memcg->css.cgroup) : 0;
      |                                                                    ^~
./include/trace/trace_events.h:427:11: note: in definition of macro ‘__DECLARE_EVENT_CLASS’
  427 |         { assign; }                                                     \
      |           ^~~~~~
./include/trace/trace_events.h:435:23: note: in expansion of macro ‘PARAMS’
  435 |                       PARAMS(assign), PARAMS(print))                    \
      |                       ^~~~~~
./include/trace/trace_events.h:40:9: note: in expansion of macro ‘DECLARE_EVENT_CLASS’
   40 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
./include/trace/trace_events.h:44:30: note: in expansion of macro ‘PARAMS’
   44 |                              PARAMS(assign),                   \
      |                              ^~~~~~
./include/trace/events/vmscan.h:214:1: note: in expansion of macro ‘TRACE_EVENT’
  214 | TRACE_EVENT(mm_shrink_slab_start,
      | ^~~~~~~~~~~
./include/trace/events/vmscan.h:237:9: note: in expansion of macro ‘TP_fast_assign’
  237 |         TP_fast_assign(
      |         ^~~~~~~~~~~~~~
./include/trace/events/vmscan.h: In function ‘do_trace_event_raw_event_mm_shrink_slab_end’:
./include/trace/events/vmscan.h:293:56: error: invalid use of undefined type ‘struct mem_cgroup’
  293 |                 __entry->memcg_id = cgroup_id(sc->memcg->css.cgroup);
      |                                                        ^~
./include/trace/trace_events.h:427:11: note: in definition of macro ‘__DECLARE_EVENT_CLASS’
  427 |         { assign; }                                                     \
      |           ^~~~~~
./include/trace/trace_events.h:435:23: note: in expansion of macro ‘PARAMS’
  435 |                       PARAMS(assign), PARAMS(print))                    \
      |                       ^~~~~~
./include/trace/trace_events.h:40:9: note: in expansion of macro ‘DECLARE_EVENT_CLASS’
   40 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
./include/trace/trace_events.h:44:30: note: in expansion of macro ‘PARAMS’
   44 |                              PARAMS(assign),                   \
      |                              ^~~~~~
./include/trace/events/vmscan.h:266:1: note: in expansion of macro ‘TRACE_EVENT’
  266 | TRACE_EVENT(mm_shrink_slab_end,
      | ^~~~~~~~~~~
./include/trace/events/vmscan.h:285:9: note: in expansion of macro ‘TP_fast_assign’
  285 |         TP_fast_assign(
      |         ^~~~~~~~~~~~~~
In file included from ./include/trace/define_trace.h:133:
./include/trace/events/vmscan.h: In function ‘do_perf_trace_mm_shrink_slab_start’:
./include/trace/events/vmscan.h:248:68: error: invalid use of undefined type ‘struct mem_cgroup’
  248 |                 __entry->memcg_id = sc->memcg ? cgroup_id(sc->memcg->css.cgroup) : 0;
      |                                                                    ^~
./include/trace/perf.h:51:11: note: in definition of macro ‘__DECLARE_EVENT_CLASS’
   51 |         { assign; }                                                     \
      |           ^~~~~~
./include/trace/perf.h:67:23: note: in expansion of macro ‘PARAMS’
   67 |                       PARAMS(assign), PARAMS(print))                    \
      |                       ^~~~~~
./include/trace/trace_events.h:40:9: note: in expansion of macro ‘DECLARE_EVENT_CLASS’
   40 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
./include/trace/trace_events.h:44:30: note: in expansion of macro ‘PARAMS’
   44 |                              PARAMS(assign),                   \
      |                              ^~~~~~
./include/trace/events/vmscan.h:214:1: note: in expansion of macro ‘TRACE_EVENT’
  214 | TRACE_EVENT(mm_shrink_slab_start,
      | ^~~~~~~~~~~
./include/trace/events/vmscan.h:237:9: note: in expansion of macro ‘TP_fast_assign’
  237 |         TP_fast_assign(
      |         ^~~~~~~~~~~~~~
./include/trace/events/vmscan.h: In function ‘do_perf_trace_mm_shrink_slab_end’:
./include/trace/events/vmscan.h:293:56: error: invalid use of undefined type ‘struct mem_cgroup’
  293 |                 __entry->memcg_id = cgroup_id(sc->memcg->css.cgroup);
      |                                                        ^~
./include/trace/perf.h:51:11: note: in definition of macro ‘__DECLARE_EVENT_CLASS’
   51 |         { assign; }                                                     \
      |           ^~~~~~
./include/trace/perf.h:67:23: note: in expansion of macro ‘PARAMS’
   67 |                       PARAMS(assign), PARAMS(print))                    \
      |                       ^~~~~~
./include/trace/trace_events.h:40:9: note: in expansion of macro ‘DECLARE_EVENT_CLASS’
   40 |         DECLARE_EVENT_CLASS(name,                              \
      |         ^~~~~~~~~~~~~~~~~~~
./include/trace/trace_events.h:44:30: note: in expansion of macro ‘PARAMS’
   44 |                              PARAMS(assign),                   \
      |                              ^~~~~~
./include/trace/events/vmscan.h:266:1: note: in expansion of macro ‘TRACE_EVENT’
  266 | TRACE_EVENT(mm_shrink_slab_end,
      | ^~~~~~~~~~~
./include/trace/events/vmscan.h:285:9: note: in expansion of macro ‘TP_fast_assign’
  285 |         TP_fast_assign(
      |         ^~~~~~~~~~~~~~
  CC      arch/x86/mm/extable.o
make[3]: *** [scripts/Makefile.build:287: mm/vmscan.o] Error 1
make[2]: *** [scripts/Makefile.build:556: mm] Error 2
make[2]: *** Waiting for unfinished jobs....

-- 
Cheers,
Harry / Hyeonggon

>  	),
>  
> -	TP_printk("%pS %p: nid: %d objects to shrink %ld gfp_flags %s cache items %ld delta %lld total_scan %ld priority %d",
> +	TP_printk("%pS %p: nid: %d memcg_id: %u objects to shrink %ld gfp_flags %s cache items %ld delta %lld total_scan %ld priority %d",
>  		__entry->shrink,
>  		__entry->shr,
>  		__entry->nid,
> +		__entry->memcg_id,
>  		__entry->nr_objects_to_shrink,
>  		show_gfp_flags(__entry->gfp_flags),
>  		__entry->cache_items,
> @@ -242,36 +252,39 @@ TRACE_EVENT(mm_shrink_slab_start,
>  );
>  
>  TRACE_EVENT(mm_shrink_slab_end,
> -	TP_PROTO(struct shrinker *shr, int nid, int shrinker_retval,
> +	TP_PROTO(struct shrinker *shr, struct shrink_control *sc, int shrinker_retval,
>  		long unused_scan_cnt, long new_scan_cnt, long total_scan),
>  
> -	TP_ARGS(shr, nid, shrinker_retval, unused_scan_cnt, new_scan_cnt,
> +	TP_ARGS(shr, sc, shrinker_retval, unused_scan_cnt, new_scan_cnt,
>  		total_scan),
>  
>  	TP_STRUCT__entry(
>  		__field(struct shrinker *, shr)
> -		__field(int, nid)
>  		__field(void *, shrink)
>  		__field(long, unused_scan)
>  		__field(long, new_scan)
> -		__field(int, retval)
>  		__field(long, total_scan)
> +		__field(int, nid)
> +		__field(int, retval)
> +		__field(unsigned short, memcg_id)
>  	),
>  
>  	TP_fast_assign(
>  		__entry->shr = shr;
> -		__entry->nid = nid;
>  		__entry->shrink = shr->scan_objects;
>  		__entry->unused_scan = unused_scan_cnt;
>  		__entry->new_scan = new_scan_cnt;
> -		__entry->retval = shrinker_retval;
>  		__entry->total_scan = total_scan;
> +		__entry->nid = sc->nid;
> +		__entry->retval = shrinker_retval;
> +		__entry->memcg_id = cgroup_id(sc->memcg->css.cgroup);
>  	),
>  
> -	TP_printk("%pS %p: nid: %d unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
> +	TP_printk("%pS %p: nid: %d memcg_id: %u unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
>  		__entry->shrink,
>  		__entry->shr,
>  		__entry->nid,
> +		__entry->memcg_id,
>  		__entry->unused_scan,
>  		__entry->new_scan,
>  		__entry->total_scan,
> @@ -504,9 +517,9 @@ TRACE_EVENT(mm_vmscan_node_reclaim_begin,
>  
>  DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_node_reclaim_end,
>  
> -	TP_PROTO(unsigned long nr_reclaimed),
> +	TP_PROTO(unsigned long nr_reclaimed, unsigned short memcg_id),
>  
> -	TP_ARGS(nr_reclaimed)
> +	TP_ARGS(nr_reclaimed, memcg_id)
>  );
>  
>  TRACE_EVENT(mm_vmscan_throttled,


  parent reply	other threads:[~2026-01-07  1:57 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08 18:14 [PATCH 0/2] mm: vmscan: add PID and cgroup ID to vmscan tracepoints Thomas Ballasi
2025-12-08 18:14 ` [PATCH 1/2] mm: vmscan: add cgroup IDs " Thomas Ballasi
2025-12-08 18:14 ` [PATCH 2/2] mm: vmscan: add PIDs " Thomas Ballasi
2025-12-10  3:09   ` Steven Rostedt
2025-12-16 14:02 ` [PATCH v2 0/2] mm: vmscan: add PID and cgroup ID " Thomas Ballasi
2025-12-16 14:02   ` [PATCH v2 1/2] mm: vmscan: add cgroup IDs " Thomas Ballasi
2025-12-16 18:50     ` Shakeel Butt
2025-12-17 22:21     ` Steven Rostedt
2025-12-16 14:02   ` [PATCH v2 2/2] mm: vmscan: add PIDs " Thomas Ballasi
2025-12-16 18:03     ` Steven Rostedt
2025-12-29 10:54       ` Thomas Ballasi
2025-12-29 18:29         ` Steven Rostedt
2025-12-29 21:36           ` Steven Rostedt
2026-01-05 16:04   ` [PATCH v3 0/2] mm: vmscan: add PID and cgroup ID " Thomas Ballasi
2026-01-05 16:04     ` [PATCH v3 1/2] mm: vmscan: add cgroup IDs " Thomas Ballasi
2026-01-05 22:46       ` Shakeel Butt
2026-01-07 18:14         ` Shakeel Butt
2026-01-07 18:32           ` Andrew Morton
2026-01-07 20:35             ` Shakeel Butt
2026-01-07  1:56       ` Harry Yoo [this message]
2026-01-07  2:17         ` build error on CONFIG_MEMCG=n "error: invalid use of undefined type 'struct mem_cgroup'" Andrew Morton
2026-01-05 16:04     ` [PATCH v3 2/2] mm: vmscan: add PIDs to vmscan tracepoints Thomas Ballasi
2026-01-06  2:06     ` [PATCH v3 0/2] mm: vmscan: add PID and cgroup ID " Andrew Morton
2026-01-06  2:21       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aV29Xj2wo786xVn1@hyeyoo \
    --to=harry.yoo@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tballasi@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox