forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libbpf-tools: Fix renaming of the state field of task_struct
Kernel commit 2f064a59a1 ("sched: Change task_struct::state") changes the name of task_struct::state to task_struct::__state, which breaks several libbpf tools. Fix them by utilizing the libbpf CO-RE support. Signed-off-by: Hengqi Chen <[email protected]>
- Loading branch information
1 parent
fb09f59
commit 8b350fd
Showing
5 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ | ||
/* Copyright (c) 2021 Hengqi Chen */ | ||
|
||
#ifndef __CORE_FIXES_BPF_H | ||
#define __CORE_FIXES_BPF_H | ||
|
||
#include <vmlinux.h> | ||
#include <bpf/bpf_core_read.h> | ||
|
||
/** | ||
* commit 2f064a59a1 ("sched: Change task_struct::state") changes | ||
* the name of task_struct::state to task_struct::__state | ||
* see: | ||
* https://github.com/torvalds/linux/commit/2f064a59a1 | ||
*/ | ||
struct task_struct___x { | ||
unsigned int __state; | ||
}; | ||
|
||
static __s64 get_task_state(void *task) | ||
{ | ||
struct task_struct___x *t = task; | ||
|
||
if (bpf_core_field_exists(t->__state)) | ||
return t->__state; | ||
return ((struct task_struct *)task)->state; | ||
} | ||
|
||
#endif /* __CORE_FIXES_BPF_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters