Commit a9e0c589 authored by Guenter Roeck's avatar Guenter Roeck Committed by Steven Rostedt (Google)
Browse files

ftrace: Introduce and use ENTRIES_PER_PAGE_GROUP macro

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

No functional change.

Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20260113152243.3557219-2-linux@roeck-us.net


Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 2d8b7f9b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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;