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

Commit 0f2b4ea6 authored by Joel Fernandes (Google)'s avatar Joel Fernandes (Google) Committed by Joel Fernandes
Browse files

FROMLIST: vsprintf: Inline call to ptr_to_hashval

There is concern that ptr_to_hashval not being inlined can cause performance
issues (unlike before where it was a static branch) with trace_printk being a
hot path for it. Just create an inline version called __ptr_to_hashval(), and
have the actual ptr_to_hashval() call it.

Link: http://lore.kernel.org/r/20191113153816.14b95acd@gandalf.local.home


Link: lore.kernel.org/r/20191114164622.GC233237@google.com
Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Change-Id: Ie7133b9f32a8185e244db2634b028b316a3d7ea1
Signed-off-by: default avatarJoel Fernandes <joel@joelfernandes.org>
Signed-off-by: default avatarJoel Fernandes <joelaf@google.com>
parent 23727eb1
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1708,7 +1708,7 @@ static int __init initialize_ptr_random(void)
}
early_initcall(initialize_ptr_random);

int ptr_to_hashval(const void *ptr, unsigned long *hashval_out)
static inline int __ptr_to_hashval(const void *ptr, unsigned long *hashval_out)
{
	unsigned long hashval;

@@ -1729,6 +1729,11 @@ int ptr_to_hashval(const void *ptr, unsigned long *hashval_out)
	return 0;
}

int ptr_to_hashval(const void *ptr, unsigned long *hashval_out)
{
	return __ptr_to_hashval(ptr, hashval_out);
}

/* Maps a pointer to a 32 bit unique identifier. */
static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
{
@@ -1742,7 +1747,7 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
		return pointer_string(buf, end, (const void *)hashval, spec);
	}

	ret = ptr_to_hashval(ptr, &hashval);
	ret = __ptr_to_hashval(ptr, &hashval);
	if (ret) {
		spec.field_width = 2 * sizeof(ptr);
		/* string length must be less than default_width */