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

doc: bpf_get_current_task helper #1547

Merged
merged 1 commit into from
Jan 30, 2018

Conversation

pchaigno
Copy link
Contributor

Add an entry for bpf_get_current_task in the reference guide.

Copy link
Collaborator

@goldshtn goldshtn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to specify what you can get from the task_struct. Also, wasn’t there some issue with field randomization in recent kernel versions?

@yonghong-song
Copy link
Collaborator

wasn’t there some issue with field randomization in recent kernel versions?

4.13 has issues and you will need to put the below before your header files:

#define randomized_struct_fields_start  struct {
#define randomized_struct_fields_end    };

Other kernel versions should be okay.

@pchaigno
Copy link
Contributor Author

It would be nice to specify what you can get from the task_struct.

@goldshtn I've added a sentence with a few examples. If you have other more relevant examples, please tell me!

4.13 has issues and you will need to put the below before your header files:

Since the randomized_struct_fields_xxx directives are already defined in linux/compiler.h, which itself is included by linux/sched.h, do we really need to make a note about it? It looks like a very specific corner case (?)

@yonghong-song
Copy link
Collaborator

At linux:include/linux directory, for 4.13,

-bash-4.2$ egrep -r randomized_struct_fields_start                                                                                   
compiler-gcc.h:#define randomized_struct_fields_start   struct {
compiler.h:#ifndef randomized_struct_fields_start
compiler.h:# define randomized_struct_fields_start
sched.h:        randomized_struct_fields_start
-bash-4.2$

4.15

-bash-4.2$ egrep -r randomized_struct_fields_start
compiler-clang.h:#define randomized_struct_fields_start struct {
compiler-gcc.h:#define randomized_struct_fields_start   struct {
sched.h:        randomized_struct_fields_start
compiler_types.h:#ifndef randomized_struct_fields_start
compiler_types.h:# define randomized_struct_fields_start
-bash-4.2$ 

for clang, randomized_struct_fields_start is not defined in 4.13, it is defined in 4.14 stable and 4.15. So people use task_struct with 4.13 in their bpf programs may have issues. It would be good to make a note of this, so we can refer to it when people have issues.

@pchaigno
Copy link
Contributor Author

I see. I though it was only necessary when the kernel headers and the kernel used differed because I couldn't reproduce with any bcc tool under 4.13. I'll add a note.

@pchaigno
Copy link
Contributor Author

Done.

Copy link
Collaborator

@yonghong-song yonghong-song left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@yonghong-song yonghong-song merged commit df55284 into iovisor:master Jan 30, 2018
@pchaigno pchaigno deleted the doc-bpf-get-current-task branch January 30, 2018 17:16
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

Successfully merging this pull request may close these issues.

None yet

3 participants