|
149 | 149 | bpf_text_kfunc_cache_alloc_ret_folio = """ |
150 | 150 | KRETFUNC_PROBE(filemap_alloc_folio, gfp_t gfp, unsigned int order, |
151 | 151 | 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 = """ |
152 | 160 | { |
153 | 161 | u64 ts; |
154 | 162 | u32 zero = 0; // static key for accessing pages[0] |
|
179 | 187 | if BPF.get_kprobe_functions(b"__page_cache_alloc"): |
180 | 188 | bpf_text += bpf_text_kfunc_cache_alloc_ret_page |
181 | 189 | 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 |
183 | 198 | b = BPF(text=bpf_text) |
184 | 199 | else: |
185 | 200 | bpf_text += bpf_text_kprobe |
|
196 | 211 | cache_func = "__page_cache_alloc" |
197 | 212 | bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'PT_REGS_RC(ctx)') |
198 | 213 | 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() |
200 | 221 | bpf_text = bpf_text.replace('GET_RETVAL_PAGE', 'folio_page((struct folio *)PT_REGS_RC(ctx), 0)') |
| 222 | + |
201 | 223 | b = BPF(text=bpf_text) |
202 | 224 | b.attach_kprobe(event=ra_event, fn_name="entry__do_page_cache_readahead") |
203 | 225 | b.attach_kretprobe(event=ra_event, fn_name="exit__do_page_cache_readahead") |
|
0 commit comments