Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Commit

Permalink
scx: Add more user_exit_info macros for exit code
Browse files Browse the repository at this point in the history
Now that we have bits reserved for system exit code reasons and actions,
as well as bits available for user by user space, let's add some
ease-of-use macro to user_exit_info.h. A subsequent patch will add
selftests that use these macros.

Signed-off-by: David Vernet <[email protected]>
  • Loading branch information
Byte-Lab committed Apr 10, 2024
1 parent 0a1bffb commit 64b818f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tools/sched_ext/include/scx/user_exit_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ struct user_exit_info {
__sync_val_compare_and_swap(&(__skel)->data->__uei_name.kind, -1, -1); \
})

#define UEI_KIND(__skel, __uei_name) ((__skel)->data->__uei_name.kind)

#define ECODE_USER_MASK ((1LLU << 32) - 1)
#define ECODE_SYS_ACT_MASK (((1LLU << 48) - 1) ^ ECODE_USER_MASK)
#define ECODE_SYS_RSN_MASK (~0LLU ^ (ECODE_SYS_ACT_MASK | ECODE_USER_MASK))

#define UEI_ECODE(__skel, __uei_name) (__skel)->data->__uei_name.exit_code
#define UEI_ECODE_SYS_ACT(__skel, __uei_name) (UEI_ECODE(__skel, __uei_name) & ECODE_SYS_ACT_MASK)
#define UEI_ECODE_SYS_RSN(__skel, __uei_name) (UEI_ECODE(__skel, __uei_name) & ECODE_SYS_RSN_MASK)
#define UEI_ECODE_USER(__skel, __uei_name) (UEI_ECODE(__skel, __uei_name) & ECODE_USER_MASK)

#define UEI_REPORT(__skel, __uei_name) ({ \
struct user_exit_info *__uei = &(__skel)->data->__uei_name; \
char *__uei_dump = (__skel)->data_##__uei_name##_dump->__uei_name##_dump; \
Expand All @@ -79,5 +90,14 @@ struct user_exit_info {
fputs("\n", stderr); \
})

#define UEI_RESET(__skel, __uei_name) ({ \
struct user_exit_info *__uei = &(__skel)->data->__uei_name; \
char *__uei_dump = (__skel)->data_##__uei_name##_dump->__uei_name##_dump; \
size_t __uei_dump_len = (__skel)->rodata->__uei_name##_dump_len; \
\
memset(__uei, 0, sizeof(struct user_exit_info)); \
memset(__uei_dump, 0, __uei_dump_len); \
})

#endif /* __bpf__ */
#endif /* __USER_EXIT_INFO_H */

0 comments on commit 64b818f

Please sign in to comment.