Skip to content

Commit f76d1c4

Browse files
hongaoomhiramat
authored andcommitted
kprobes: retry blocked optprobe in do_free_cleaned_kprobes
Once the aggrprobe is fully reverted in do_free_cleaned_kprobes(), retry optimize_kprobe() on that sibling so it can return to OPTIMIZED. Also remove the stale comment in __disarm_kprobe(). Link: https://lore.kernel.org/all/349359900266B25F+20260115023804.3951960-2-hongao@uniontech.com/ Signed-off-by: hongao <hongao@uniontech.com> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
1 parent 0f61b18 commit f76d1c4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

kernel/kprobes.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ static LIST_HEAD(freeing_list);
516516

517517
static void kprobe_optimizer(struct work_struct *work);
518518
static DECLARE_DELAYED_WORK(optimizing_work, kprobe_optimizer);
519+
static void optimize_kprobe(struct kprobe *p);
519520
#define OPTIMIZE_DELAY 5
520521

521522
/*
@@ -593,6 +594,17 @@ static void do_free_cleaned_kprobes(void)
593594
*/
594595
continue;
595596
}
597+
598+
/*
599+
* The aggregator was holding back another probe while it sat on the
600+
* unoptimizing/freeing lists. Now that the aggregator has been fully
601+
* reverted we can safely retry the optimization of that sibling.
602+
*/
603+
604+
struct kprobe *_p = get_optimized_kprobe(op->kp.addr);
605+
if (unlikely(_p))
606+
optimize_kprobe(_p);
607+
596608
free_aggr_kprobe(&op->kp);
597609
}
598610
}
@@ -1002,12 +1014,6 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt)
10021014
if (unlikely(_p) && reopt)
10031015
optimize_kprobe(_p);
10041016
}
1005-
/*
1006-
* TODO: Since unoptimization and real disarming will be done by
1007-
* the worker thread, we can not check whether another probe are
1008-
* unoptimized because of this probe here. It should be re-optimized
1009-
* by the worker thread.
1010-
*/
10111017
}
10121018

10131019
#else /* !CONFIG_OPTPROBES */

0 commit comments

Comments
 (0)