Skip to content

Commit

Permalink
tetragon: Make do_action static
Browse files Browse the repository at this point in the history
bpf_generic_kprobe_v61.o.csv:

Program                        Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
-----------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_fmodret_override              18         18       +0 (+0.00%)           2           2      +0 (+0.00%)
generic_kprobe_actions             86858      27758  -59100 (-68.04%)        2724        1013  -1711 (-62.81%)
generic_kprobe_event                 404        404       +0 (+0.00%)          29          29      +0 (+0.00%)
generic_kprobe_filter_arg         181622     181622       +0 (+0.00%)        6252        6252      +0 (+0.00%)
generic_kprobe_output                409        409       +0 (+0.00%)          31          31      +0 (+0.00%)
generic_kprobe_override               20         20       +0 (+0.00%)           2           2      +0 (+0.00%)
generic_kprobe_process_event       28117      28117       +0 (+0.00%)         870         870      +0 (+0.00%)
generic_kprobe_process_filter     178641     178641       +0 (+0.00%)        7346        7346      +0 (+0.00%)
generic_kprobe_setup_event         30362      30362       +0 (+0.00%)        1022        1022      +0 (+0.00%)

bpf_generic_retkprobe_v61.o.csv:

Program                       Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
----------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_retkprobe_actions         76370      26393  -49977 (-65.44%)        2380         970  -1410 (-59.24%)
generic_retkprobe_event           30157      30157       +0 (+0.00%)        2148        2148      +0 (+0.00%)
generic_retkprobe_filter_arg     181597     181597       +0 (+0.00%)        6252        6252      +0 (+0.00%)
generic_retkprobe_output             41         41       +0 (+0.00%)           3           3      +0 (+0.00%)

bpf_generic_tracepoint_v61.o.csv:

Program                           Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
--------------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_tracepoint_actions            90074      27431  -62643 (-69.55%)        2743         999  -1744 (-63.58%)
generic_tracepoint_arg               181622     181622       +0 (+0.00%)        6252        6252      +0 (+0.00%)
generic_tracepoint_event               1776       1776       +0 (+0.00%)          86          86      +0 (+0.00%)
generic_tracepoint_filter            178641     178641       +0 (+0.00%)        7346        7346      +0 (+0.00%)
generic_tracepoint_output               409        409       +0 (+0.00%)          31          31      +0 (+0.00%)
generic_tracepoint_process_event       5544       5544       +0 (+0.00%)         390         390      +0 (+0.00%)

bpf_generic_uprobe_v61.o.csv:

Program                        Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
-----------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_uprobe_actions             76370      26393  -49977 (-65.44%)        2380         970  -1410 (-59.24%)
generic_uprobe_event                 281        281       +0 (+0.00%)          17          17      +0 (+0.00%)
generic_uprobe_filter_arg         181622     181622       +0 (+0.00%)        6252        6252      +0 (+0.00%)
generic_uprobe_output                409        409       +0 (+0.00%)          31          31      +0 (+0.00%)
generic_uprobe_process_event        5544       5544       +0 (+0.00%)         390         390      +0 (+0.00%)
generic_uprobe_process_filter     178641     178641       +0 (+0.00%)        7346        7346      +0 (+0.00%)
generic_uprobe_setup_event          5419       5419       +0 (+0.00%)         382         382      +0 (+0.00%)

bpf_multi_kprobe_v61.o.csv:

Program                        Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
-----------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_fmodret_override              18         18       +0 (+0.00%)           2           2      +0 (+0.00%)
generic_kprobe_actions             86858      27758  -59100 (-68.04%)        2724        1013  -1711 (-62.81%)
generic_kprobe_event                 419        419       +0 (+0.00%)          30          30      +0 (+0.00%)
generic_kprobe_filter_arg         181622     181622       +0 (+0.00%)        6252        6252      +0 (+0.00%)
generic_kprobe_output                409        409       +0 (+0.00%)          31          31      +0 (+0.00%)
generic_kprobe_override               20         20       +0 (+0.00%)           2           2      +0 (+0.00%)
generic_kprobe_process_event       28117      28117       +0 (+0.00%)         870         870      +0 (+0.00%)
generic_kprobe_process_filter     178641     178641       +0 (+0.00%)        7346        7346      +0 (+0.00%)
generic_kprobe_setup_event         30362      30362       +0 (+0.00%)        1022        1022      +0 (+0.00%)

bpf_multi_retkprobe_v61.o.csv:

Program                       Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
----------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_retkprobe_actions         76370      26393  -49977 (-65.44%)        2380         970  -1410 (-59.24%)
generic_retkprobe_event           28135      28135       +0 (+0.00%)        1923        1923      +0 (+0.00%)
generic_retkprobe_filter_arg     181597     181597       +0 (+0.00%)        6252        6252      +0 (+0.00%)
generic_retkprobe_output             41         41       +0 (+0.00%)           3           3      +0 (+0.00%)

bpf_multi_uprobe_v61.o.csv:

Program                        Insns (A)  Insns (B)  Insns     (DIFF)  States (A)  States (B)  States   (DIFF)
-----------------------------  ---------  ---------  ----------------  ----------  ----------  ---------------
generic_uprobe_actions             76370      26393  -49977 (-65.44%)        2380         970  -1410 (-59.24%)
generic_uprobe_event                 284        284       +0 (+0.00%)          17          17      +0 (+0.00%)
generic_uprobe_filter_arg         169723     169723       +0 (+0.00%)        5358        5358      +0 (+0.00%)
generic_uprobe_output                409        409       +0 (+0.00%)          31          31      +0 (+0.00%)
generic_uprobe_process_event        5544       5544       +0 (+0.00%)         390         390      +0 (+0.00%)
generic_uprobe_process_filter     178641     178641       +0 (+0.00%)        7346        7346      +0 (+0.00%)
generic_uprobe_setup_event          5419       5419       +0 (+0.00%)         382         382      +0 (+0.00%)

bpf_fork.o.csv:

Program                 Insns (A)  Insns (B)  Insns (DIFF)  States (A)  States (B)  States (DIFF)
----------------------  ---------  ---------  ------------  ----------  ----------  -------------
event_wake_up_new_task       1536       1536   +0 (+0.00%)          82          82    +0 (+0.00%)

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed May 22, 2024
1 parent 5bd6953 commit 04f6692
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions bpf/process/types/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,9 @@ rate_limit(__u64 ratelimit_interval, __u64 ratelimit_scope, struct msg_generic_k
asm volatile("%[arg_size] &= 0x3f;\n" // ensure this mask is greater than KEY_BYTES_PER_ARG
: [arg_size] "+r"(arg_size)
:);
asm volatile("%[index] &= 0xff;\n"
: [index] "+r"(index)
:);
probe_read(&dst[index], arg_size, &e->args[key_index]);
index += arg_size;
}
Expand Down Expand Up @@ -2114,19 +2117,26 @@ FUNC_INLINE void do_action_notify_enforcer(int error, int signal)
#define do_action_notify_enforcer(error, signal)
#endif

FUNC_INLINE __u32
do_action(void *ctx, __u32 i, struct msg_generic_kprobe *e,
struct selector_action *actions, struct bpf_map_def *override_tasks, bool *post)
FUNC_LOCAL __u32
do_action(void *ctx, __u32 i, struct selector_action *actions,
struct generic_maps *maps, bool *post)
{
struct bpf_map_def *override_tasks = maps->override;
int signal __maybe_unused = FGS_SIGKILL;
int action = actions->act[i];
struct msg_generic_kprobe *e;
__s32 error, *error_p;
int fdi, namei;
int newfdi, oldfdi;
int socki;
int err = 0;
int zero = 0;
__u64 id;

e = map_lookup_elem(maps->heap, &zero);
if (!e)
return 0;

switch (action) {
case ACTION_NOPOST:
*post = false;
Expand Down Expand Up @@ -2229,8 +2239,7 @@ has_action(struct selector_action *actions, __u32 idx)

/* Currently supporting 2 actions for selector. */
FUNC_INLINE bool
do_actions(void *ctx, struct msg_generic_kprobe *e, struct selector_action *actions,
struct bpf_map_def *override_tasks)
do_actions(void *ctx, struct selector_action *actions, struct generic_maps *maps)
{
bool post = true;
__u32 l, i = 0;
Expand All @@ -2241,7 +2250,7 @@ do_actions(void *ctx, struct msg_generic_kprobe *e, struct selector_action *acti
for (l = 0; l < MAX_ACTIONS; l++) {
if (!has_action(actions, i))
break;
i = do_action(ctx, i, e, actions, override_tasks, &post);
i = do_action(ctx, i, actions, maps, &post);
}

return post;
Expand Down Expand Up @@ -2314,7 +2323,7 @@ generic_actions(void *ctx, struct generic_maps *maps)
:);
actions = (struct selector_action *)&f[actoff];

postit = do_actions(ctx, e, actions, maps->override);
postit = do_actions(ctx, actions, maps);
if (postit)
tail_call(ctx, maps->calls, TAIL_CALL_SEND);
return 0;
Expand Down

0 comments on commit 04f6692

Please sign in to comment.