From: Ridong Chen <ridong.chen@linux.dev>
To: Baoquan He <baoquan.he@linux.dev>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Dave Chinner <david@fromorbit.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Muchun Song <muchun.song@linux.dev>,
Qi Zheng <qi.zheng@linux.dev>, Kairui Song <kasong@tencent.com>,
Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-mm@kvack.org,
"open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)"
<cgroups@vger.kernel.org>,
"open list:BPF [MISC]:Keyword:(?:b|_)bpf(?:b|_)"
<bpf@vger.kernel.org>, Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH v5 2/6] mm/vmscan: move vmscan tracepoints to a local header
Date: Mon, 2 Nov 2026 18:46:00 +0800 [thread overview]
Message-ID: <2f272a9b-ea83-4157-8968-0081990cb709@linux.dev> (raw)
In-Reply-To: <aufpQS0XL-CD9YW_@bogon>
On 11/2/2026 9:37 AM, Baoquan He wrote:
> On 10/31/26 at 05:00pm, Ridong Chen wrote:
>> From: Ridong Chen <chenridong@xiaomi.com>
>>
>> Move include/trace/events/vmscan.h to mm/trace_vmscan.h so that the
>> tracepoints can be extended to reference vmscan-internal structures such
>> as struct scan_control, which is not visible outside mm/. This mirrors
>> what several other subsystems already do with their trace headers (e.g.
>> fs/fuse/fuse_trace.h, fs/gfs2/trace_gfs2.h, fs/lockd/trace.h). As they
>> do, set TRACE_INCLUDE_PATH to "." and add mm/ to the include path of
>> vmscan.o, the only user that defines CREATE_TRACE_POINTS.
>>
>> No functional change.
>>
>> Signed-off-by: Ridong Chen <chenridong@xiaomi.com>
>> Reviewed-by: Barry Song <baohua@kernel.org>
>> ---
>> MAINTAINERS | 2 ++
>> mm/Makefile | 1 +
>> mm/shrinker.c | 2 +-
>> include/trace/events/vmscan.h => mm/trace_vmscan.h | 4 ++++
>> mm/vmscan.c | 2 +-
>> 5 files changed, 9 insertions(+), 2 deletions(-)
>> rename include/trace/events/vmscan.h => mm/trace_vmscan.h (99%)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index aaf2825ac945..2ad01107fa05 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -17653,6 +17653,7 @@ F: Documentation/admin-guide/mm/multigen_lru.rst
>> F: Documentation/mm/multigen_lru.rst
>> F: include/linux/mm_inline.h
>> F: include/linux/mmzone.h
>> +F: mm/trace_vmscan.h
>> F: mm/vmscan.c
>> F: mm/workingset.c
>>
>> @@ -17802,6 +17803,7 @@ R: Shakeel Butt <shakeel.butt@linux.dev>
>> R: Lorenzo Stoakes <ljs@kernel.org>
>> L: linux-mm@kvack.org
>> S: Maintained
>> +F: mm/trace_vmscan.h
>> F: mm/vmscan.c
>> F: mm/workingset.c
>>
>> diff --git a/mm/Makefile b/mm/Makefile
>> index 2a3ec53d62ee..277b97f7f8d7 100644
>> --- a/mm/Makefile
>> +++ b/mm/Makefile
>> @@ -32,6 +32,7 @@ KCOV_INSTRUMENT_vmstat.o := n
>> KCOV_INSTRUMENT_failslab.o := n
>>
>> CFLAGS_init-mm.o += -Wno-override-init
>> +CFLAGS_vmscan.o += -I$(src)
>
> One nit:
>
> Does it really need the above line? It affects mm/shrinker.c too, did your
> shrinker.o building fail?
>
> Seems it's redundant because kbuild adds -I$(src) -I$(obj) for every object
> in the directory since commit cdd750bfb1f7 ("kbuild: remove 'addtree' and
> 'flags' magic for header search paths"). Please correct me if I am
> wrong.
>
Hi Baoquan,
Thanks for the review.
The line is needed for vmscan.o, and mm/shrinker.c is fine without it,
because the two files include trace_vmscan.h in different ways.
mm/shrinker.c only does a plain #include "trace_vmscan.h". The lookup
starts from mm/, where the header lives, so no -I is needed.
mm/vmscan.c defines CREATE_TRACE_POINTS before including the header.
In that case <trace/define_trace.h>, included at the end of
trace_vmscan.h, includes the header again to generate the tracepoint
definitions:
#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) /* -> "./trace_vmscan.h" */
This #include is in include/trace/define_trace.h, so the lookup starts
from include/trace/ and only finds the header through -I. Without the
flag, vmscan.o fails to build:
./include/trace/define_trace.h:118:42: fatal error: ./trace_vmscan.h: No such
file or directory
As for cdd750bfb1f7, it doesn't add -I$(src) for every build. kbuild
only adds -I$(src) -I$(obj) automatically when building with O=
(see "ifdef building_out_of_srctree" in scripts/Makefile.lib). So
with O= the line is indeed redundant and vmscan.o builds fine without
it, but a plain in-tree "make" fails with the error above. The
explicit flag keeps both working.
To be honest, I had the same worry at first: I thought every .c file
that includes the header would need a Makefile change. That's why v3
used a relative TRACE_INCLUDE_PATH (../../mm) instead. Steven corrected
me and pointed out that the proper way is TRACE_INCLUDE_PATH "." plus
-I$(src) for the one object that defines CREATE_TRACE_POINTS [1]. That
turned out to need only this one line. Thanks again to Steven for
that.
[1] https://lore.kernel.org/all/20261014124914.21c21559@gandalf.local.home/
> Other than the nit, this patch looks good to me,
>
> Reviewed-by: Baoquan He <baoquan.he@linux.dev>
>
> Thanks.
>>
>> mmu-y := nommu.o
>> mmu-$(CONFIG_MMU) := highmem.o memory.o mincore.o \
>> diff --git a/mm/shrinker.c b/mm/shrinker.c
>> index 4fb424e721bc..4fbdade6d2f6 100644
>> --- a/mm/shrinker.c
>> +++ b/mm/shrinker.c
>> @@ -3,7 +3,7 @@
>> #include <linux/rwsem.h>
>> #include <linux/shrinker.h>
>> #include <linux/rculist.h>
>> -#include <trace/events/vmscan.h>
>> +#include "trace_vmscan.h"
>>
>> #include "internal.h"
>>
>> diff --git a/include/trace/events/vmscan.h b/mm/trace_vmscan.h
>> similarity index 99%
>> rename from include/trace/events/vmscan.h
>> rename to mm/trace_vmscan.h
>> index 8a872990b4be..ad90f0e9bf2e 100644
>> --- a/include/trace/events/vmscan.h
>> +++ b/mm/trace_vmscan.h
>> @@ -648,4 +648,8 @@ TRACE_EVENT(mm_vmscan_kswapd_clear_hopeless,
>> #endif /* _TRACE_VMSCAN_H */
>>
>> /* This part must be outside protection */
>> +#undef TRACE_INCLUDE_FILE
>> +#undef TRACE_INCLUDE_PATH
>> +#define TRACE_INCLUDE_PATH .
>> +#define TRACE_INCLUDE_FILE trace_vmscan
>> #include <trace/define_trace.h>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index 9959ca158ce8..79d2d614afd0 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -71,7 +71,7 @@
>> #include "swap.h"
>>
>> #define CREATE_TRACE_POINTS
>> -#include <trace/events/vmscan.h>
>> +#include "trace_vmscan.h"
>>
>> struct scan_control {
>> /* How many pages shrink_list() should reclaim */
>> --
>> 2.43.0
>>
--
Best regards
Ridong
next prev parent reply other threads:[~2026-11-02 10:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 9:00 [PATCH v5 0/6] mm/vmscan: move tracepoints to mm/ and add MGLRU tracepoints Ridong Chen
2026-10-31 9:00 ` [PATCH v5 1/6] mm/memcontrol: drop unused vmscan tracepoint include Ridong Chen
2026-11-01 3:20 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 2/6] mm/vmscan: move vmscan tracepoints to a local header Ridong Chen
2026-10-31 9:27 ` Muchun Song
2026-11-02 1:37 ` Baoquan He
2026-11-02 10:46 ` Ridong Chen [this message]
2026-10-31 9:00 ` [PATCH v5 3/6] mm/vmscan: move struct scan_control to a dedicated header Ridong Chen
2026-10-31 9:29 ` Muchun Song
2026-11-02 1:38 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 4/6] mm/vmscan: pass scan_control to the vmscan tracepoints Ridong Chen
2026-10-31 10:12 ` Muchun Song
2026-11-02 1:40 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 5/6] mm/mglru: add tracepoint for scan_folios() Ridong Chen
2026-10-31 21:02 ` Barry Song
2026-11-02 1:44 ` Baoquan He
2026-10-31 9:00 ` [PATCH v5 6/6] mm/mglru: add tracepoint for inc_max_seq() Ridong Chen
2026-10-31 21:21 ` Barry Song
2026-11-02 2:13 ` Baoquan He
2026-11-02 11:22 ` Ridong Chen
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=2f272a9b-ea83-4157-8968-0081990cb709@linux.dev \
--to=ridong.chen@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=bpf@vger.kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@xiaomi.com \
--cc=david@fromorbit.com \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=ljs@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=qi.zheng@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shakeel.butt@linux.dev \
--cc=weixugc@google.com \
--cc=yuanchu@google.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
all inboxes | Powered by JetHome®