Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a620a55 authored by Wu Zhangjin's avatar Wu Zhangjin Committed by Ralf Baechle
Browse files

MIPS, Tracing: Speed up function graph tracer



This simply moves the "ip-=4" statement down to the end of the do { ...
} while (...); loop, which reduces one unneeded subtration and the
subsequent memory loading and comparison.

Signed-off-by: default avatarWu Zhangjin <wuzhangjin@gmail.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2006/


Signed-off-by: default avatarRalf Baechle <ralf@duck.linux-mips.net>
parent 52bd080d
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -200,19 +200,17 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
	int faulted;
	int faulted;


	/*
	/*
	 * For module, move the ip from calling site of mcount to the
	 * For module, move the ip from calling site of mcount after the
	 * instruction "lui v1, hi_16bit_of_mcount"(offset is 20), but for
	 * instruction "lui v1, hi_16bit_of_mcount"(offset is 24), but for
	 * kernel, move to the instruction "move ra, at"(offset is 12)
	 * kernel, move after the instruction "move ra, at"(offset is 16)
	 */
	 */
	ip = self_addr - (in_module(self_addr) ? 20 : 12);
	ip = self_addr - (in_module(self_addr) ? 24 : 16);


	/*
	/*
	 * search the text until finding the non-store instruction or "s{d,w}
	 * search the text until finding the non-store instruction or "s{d,w}
	 * ra, offset(sp)" instruction
	 * ra, offset(sp)" instruction
	 */
	 */
	do {
	do {
		ip -= 4;

		/* get the code at "ip": code = *(unsigned int *)ip; */
		/* get the code at "ip": code = *(unsigned int *)ip; */
		safe_load_code(code, ip, faulted);
		safe_load_code(code, ip, faulted);


@@ -226,7 +224,9 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
		if ((code & S_R_SP) != S_R_SP)
		if ((code & S_R_SP) != S_R_SP)
			return parent_addr;
			return parent_addr;


	} while (((code & S_RA_SP) != S_RA_SP));
		/* Move to the next instruction */
		ip -= 4;
	} while ((code & S_RA_SP) != S_RA_SP);


	sp = fp + (code & OFFSET_MASK);
	sp = fp + (code & OFFSET_MASK);