Commit b40c6eabfcd40 ("ftrace: Simplify the calculation of page number for ftrace_page->records") simplified the calculation of the number of pages needed for each page group without having any empty pages, but it can be simplified even further. Link: https://lore.kernel.org/lkml/CAHk-=wjt9b7kxQ2J=aDNKbR1QBMB3Hiqb_hYcZbKsxGRSEb+gQ@mail.gmail.com/
Unified · Split
| @@ -3156,15 +3156,9 @@ static int ftrace_allocate_records(struct ftrace_page *pg, int count) · 3155 unmodified lines | ||
| 3156 | 3156 | if (WARN_ON(!count)) |
| 3157 | 3157 | return -EINVAL; |
| 3158 | 3158 | |
| 3159 | + /* We want to fill as much as possible, with no empty pages */ | |
| 3159 | 3160 | pages = DIV_ROUND_UP(count, ENTRIES_PER_PAGE); |
| 3160 | − order = get_count_order(pages); | |
| 3161 | − | |
| 3162 | − /* | |
| 3163 | − * We want to fill as much as possible. No more than a page | |
| 3164 | − * may be empty. | |
| 3165 | − */ | |
| 3166 | − if (!is_power_of_2(pages)) | |
| 3167 | − order--; | |
| 3161 | + order = fls(pages) - 1; | |
| 3168 | 3162 | |
| 3169 | 3163 | again: |
| 3170 | 3164 | pg->records = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order); |