mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 07:34:12 +08:00
02106f883c
Since kprobe breakpoing handler is using bsearch(), probing on this routine can cause recursive breakpoint problem. int3 ->do_int3() ->ftrace_int3_handler() ->ftrace_location() ->ftrace_location_range() ->bsearch() -> int3 Prohibit probing on bsearch(). Signed-off-by: Andrea Righi <righi.andrea@gmail.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/154998813406.31052.8791425358974650922.stgit@devbox Signed-off-by: Ingo Molnar <mingo@kernel.org>
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
/*
|
|
* A generic implementation of binary search for the Linux kernel
|
|
*
|
|
* Copyright (C) 2008-2009 Ksplice, Inc.
|
|
* Author: Tim Abbott <tabbott@ksplice.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; version 2.
|
|
*/
|
|
|
|
#include <linux/export.h>
|
|
#include <linux/bsearch.h>
|
|
#include <linux/kprobes.h>
|
|
|
|
/*
|
|
* bsearch - binary search an array of elements
|
|
* @key: pointer to item being searched for
|
|
* @base: pointer to first element to search
|
|
* @num: number of elements
|
|
* @size: size of each element
|
|
* @cmp: pointer to comparison function
|
|
*
|
|
* This function does a binary search on the given array. The
|
|
* contents of the array should already be in ascending sorted order
|
|
* under the provided comparison function.
|
|
*
|
|
* Note that the key need not have the same type as the elements in
|
|
* the array, e.g. key could be a string and the comparison function
|
|
* could compare the string with the struct's name field. However, if
|
|
* the key and elements in the array are of the same type, you can use
|
|
* the same comparison function for both sort() and bsearch().
|
|
*/
|
|
void *bsearch(const void *key, const void *base, size_t num, size_t size,
|
|
int (*cmp)(const void *key, const void *elt))
|
|
{
|
|
const char *pivot;
|
|
int result;
|
|
|
|
while (num > 0) {
|
|
pivot = base + (num >> 1) * size;
|
|
result = cmp(key, pivot);
|
|
|
|
if (result == 0)
|
|
return (void *)pivot;
|
|
|
|
if (result > 0) {
|
|
base = pivot + size;
|
|
num--;
|
|
}
|
|
num >>= 1;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL(bsearch);
|
|
NOKPROBE_SYMBOL(bsearch);
|