History

ftrace: Simplify the calculation of page number for ftrace_page->records

Based on the following two reasones, we could simplify the calculation: - If the number after roundup count is not power of 2, we would definitely have more than 1 empty page with a higher order. - get_count_order() just return current order, so one lower order could meet the requirement. The calculation could be simplified by lower one order level when pages are not power of 2. Link: https://lkml.kernel.org/r/20200831031104.23322-5-richard.weiyang@linux.alibaba.com

Wei Yang committed 6 years ago

Commit b40c6ea1 parent 02dae281 file · +4 −3Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/ftrace.c+4−3
@@ -3129,18 +3129,19 @@ static int ftrace_update_code(struct module *mod, struct ftrace_page *new_pgs) · 3128 unmodified lines
31293129 static int ftrace_allocate_records(struct ftrace_page *pg, int count)
31303130 {
31313131 int order;
3132− int cnt;
3132+ int pages, cnt;
31333133
31343134 if (WARN_ON(!count))
31353135 return -EINVAL;
31363136
3137− order = get_count_order(DIV_ROUND_UP(count, ENTRIES_PER_PAGE));
3137+ pages = DIV_ROUND_UP(count, ENTRIES_PER_PAGE);
3138+ order = get_count_order(pages);
31383139
31393140 /*
31403141 * We want to fill as much as possible. No more than a page
31413142 * may be empty.
31423143 */
3143− while ((PAGE_SIZE << order) / ENTRY_SIZE >= count + ENTRIES_PER_PAGE)
3144+ if (!is_power_of_2(pages))
31443145 order--;
31453146
31463147 again:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t