Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: slabratetop fails on 5.16 kernel #4316

Closed
jeromemarchand opened this issue Nov 4, 2022 · 1 comment
Closed

tools: slabratetop fails on 5.16 kernel #4316

jeromemarchand opened this issue Nov 4, 2022 · 1 comment

Comments

@jeromemarchand
Copy link
Contributor

Since commit 40f3bf0cb04c ("mm: Convert struct page to struct slab in functions used by other subsystems"), slab_def.h and slub_def.h refers to structures (slab) and functions (slab_address) defined in the internal header mm/slab.h.
It makes slabratetop tool fail with the following error:

$ slabratetop 
In file included from /virtual/main.c:13:
include/linux/slub_def.h:162:26: warning: call to undeclared function 'slab_address'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        void *object = x - (x - slab_address(slab)) % cache->size;
                                ^
include/linux/slub_def.h:162:46: error: invalid operands to binary expression ('void *' and 'unsigned int')
        void *object = x - (x - slab_address(slab)) % cache->size;
                           ~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
include/linux/slub_def.h:164:8: error: incomplete definition of type 'struct slab'
                (slab->objects - 1) * cache->size;
                 ~~~~^
include/linux/kasan.h:13:8: note: forward declaration of 'struct slab'
struct slab;
       ^
In file included from /virtual/main.c:13:
include/linux/slub_def.h:184:31: warning: call to undeclared function 'slab_address'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
        return __obj_to_index(cache, slab_address(slab), obj);
                                     ^
include/linux/slub_def.h:184:31: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'void *' [-Wint-conversion]
        return __obj_to_index(cache, slab_address(slab), obj);
                                     ^~~~~~~~~~~~~~~~~~
include/linux/slub_def.h:173:14: note: passing argument to parameter 'addr' here
                                          void *addr, void *obj)
                                                ^
include/linux/slub_def.h:190:13: error: incomplete definition of type 'struct slab'
        return slab->objects;
               ~~~~^
include/linux/kasan.h:13:8: note: forward declaration of 'struct slab'
struct slab;
       ^
2 warnings and 4 errors generated.
Traceback (most recent call last):
  File "/usr/share/bcc/tools/slabratetop", line 111, in <module>
    b = BPF(text=bpf_text)
        ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/bcc/__init__.py", line 476, in __init__
    raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>
@jeromemarchand
Copy link
Contributor Author

Looks like this has been fixed by commit a3ad36d ("tools/slabratetop: Fix error: incomplete definition of type 'struct slab'")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant