Skip to content

Commit ecda15c

Browse files
Rtoaxdkruces
authored andcommitted
tools/readahead: Add filemap_alloc_folio_noprof() support
In kernel commit b951aaff5035 ("mm: enable page allocation tagging") [1], add _noprof suffix to filemap_alloc_folio. Link: torvalds/linux@b951aaf [1] Signed-off-by: Rong Tao <[email protected]>
1 parent e9747a9 commit ecda15c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tools/readahead.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@
149149
bpf_text_kfunc_cache_alloc_ret_folio = """
150150
KRETFUNC_PROBE(filemap_alloc_folio, gfp_t gfp, unsigned int order,
151151
struct folio *retval)
152+
"""
153+
# In kernel commit b951aaff5035 ("mm: enable page allocation tagging"), add
154+
# _noprof suffix to filemap_alloc_folio.
155+
bpf_text_kfunc_cache_alloc_ret_folio_noprof = """
156+
KRETFUNC_PROBE(filemap_alloc_folio_noprof, gfp_t gfp, unsigned int order,
157+
struct folio *retval)
158+
"""
159+
bpf_text_kfunc_cache_alloc_ret_folio_func_body = """
152160
{
153161
u64 ts;
154162
u32 zero = 0; // static key for accessing pages[0]
@@ -179,7 +187,14 @@
179187
if BPF.get_kprobe_functions(b"__page_cache_alloc"):
180188
bpf_text += bpf_text_kfunc_cache_alloc_ret_page
181189
else:
182-
bpf_text += bpf_text_kfunc_cache_alloc_ret_folio
190+
if BPF.get_kprobe_functions(b"filemap_alloc_folio"):
191+
bpf_text += bpf_text_kfunc_cache_alloc_ret_folio
192+
elif BPF.get_kprobe_functions(b"filemap_alloc_folio_noprof"):
193+
bpf_text += bpf_text_kfunc_cache_alloc_ret_folio_noprof
194+
else:
195+
print("ERROR: No cache alloc function found. Exiting.")
196+
exit()
197+
bpf_text += bpf_text_kfunc_cache_alloc_ret_folio_func_body
183198
b = BPF(text=bpf_text)
184199
else:
185200
bpf_text += bpf_text_kprobe
@@ -196,8 +211,15 @@
196211
cache_func = "__page_cache_alloc"
197212
bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'PT_REGS_RC(ctx)')
198213
else:
199-
cache_func = "filemap_alloc_folio"
214+
if BPF.get_kprobe_functions(b"filemap_alloc_folio"):
215+
cache_func = "filemap_alloc_folio"
216+
elif BPF.get_kprobe_functions(b"filemap_alloc_folio_noprof"):
217+
cache_func = "filemap_alloc_folio_noprof"
218+
else:
219+
print("ERROR: No cache alloc function found. Exiting.")
220+
exit()
200221
bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'folio_page((struct folio *)PT_REGS_RC(ctx), 0)')
222+
201223
b = BPF(text=bpf_text)
202224
b.attach_kprobe(event=ra_event, fn_name="entry__do_page_cache_readahead")
203225
b.attach_kretprobe(event=ra_event, fn_name="exit__do_page_cache_readahead")

0 commit comments

Comments
 (0)