ENTRIES_PER_PAGE_GROUP() returns the number of dyn_ftrace entries in a page
group, identified by its order.

No functional change.

Signed-off-by: Guenter Roeck <[email protected]>
---
v4: New patch, optional. Squash, drop, or apply as separate patch.

 kernel/trace/ftrace.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index aa758efc3731..df4ce244202e 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1148,6 +1148,7 @@ struct ftrace_page {
 };
 
 #define ENTRY_SIZE sizeof(struct dyn_ftrace)
+#define ENTRIES_PER_PAGE_GROUP(order) ((PAGE_SIZE << (order)) / ENTRY_SIZE)
 
 static struct ftrace_page      *ftrace_pages_start;
 static struct ftrace_page      *ftrace_pages;
@@ -3862,7 +3863,7 @@ static int ftrace_allocate_records(struct ftrace_page 
*pg, int count,
        *num_pages += 1 << order;
        ftrace_number_of_groups++;
 
-       cnt = (PAGE_SIZE << order) / ENTRY_SIZE;
+       cnt = ENTRIES_PER_PAGE_GROUP(order);
        pg->order = order;
 
        if (cnt > count)
@@ -7309,7 +7310,7 @@ static int ftrace_process_locs(struct module *mod,
                long skip;
 
                /* Count the number of entries unused and compare it to 
skipped. */
-               pg_remaining = (PAGE_SIZE << pg->order) / ENTRY_SIZE - 
pg->index;
+               pg_remaining = ENTRIES_PER_PAGE_GROUP(pg->order) - pg->index;
 
                if (!WARN(skipped < pg_remaining, "Extra allocated pages for 
ftrace")) {
 
@@ -7317,7 +7318,7 @@ static int ftrace_process_locs(struct module *mod,
 
                        for (pg = pg_unuse; pg && skip > 0; pg = pg->next) {
                                remaining += 1 << pg->order;
-                               skip -= (PAGE_SIZE << pg->order) / ENTRY_SIZE;
+                               skip -= ENTRIES_PER_PAGE_GROUP(pg->order);
                        }
 
                        pages -= remaining;
-- 
2.45.2


Reply via email to