ftrace: Optimize the allocation for mcount entries
authorWang Wensheng <wangwensheng4@huawei.com>
Wed, 9 Nov 2022 09:44:33 +0000 (09:44 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:24:42 +0000 (09:24 +0100)
commit bcea02b096333dc74af987cb9685a4dbdd820840 upstream.

If we can't allocate this size, try something smaller with half of the
size. Its order should be decreased by one instead of divided by two.

Link: https://lkml.kernel.org/r/20221109094434.84046-3-wangwensheng4@huawei.com
Cc: <mhiramat@kernel.org>
Cc: <mark.rutland@arm.com>
Cc: stable@vger.kernel.org
Fixes: a79008755497d ("ftrace: Allocate the mcount record pages as groups")
Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/ftrace.c

index 21b804f4f3253ff996f892a3dd86dede90ad1e47..5b49c0058040f9a63af08415f7cd70bf9376b8e0 100644 (file)
@@ -3174,7 +3174,7 @@ static int ftrace_allocate_records(struct ftrace_page *pg, int count)
                /* if we can't allocate this size, try something smaller */
                if (!order)
                        return -ENOMEM;
-               order >>= 1;
+               order--;
                goto again;
        }