diff mbox series

[RFC] xen: Annotate printk() as cold

Message ID 20230220131325.1524786-1-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series [RFC] xen: Annotate printk() as cold | expand

Commit Message

Andrew Cooper Feb. 20, 2023, 1:13 p.m. UTC
There is no such thing as a fastpath with a printk() on it, making printk() an
excellent heuristic for slowpaths.

Net delta is:

  add/remove: 595/2 grow/shrink: 56/762 up/down: 70879/-87331 (-16452)
  Total: Before=4085425, After=4068973, chg -0.40%

because cold functions are optimised differently.  For example, one function
with a particularly large swing is:

  vmcs_dump_vcpu.cold                            -    2172   +2172
  vmcs_dump_vcpu                              7030     408   -6622

with a net delta of 7030 down to 4450.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
CC: Bertrand Marquis <bertrand.marquis@arm.com>

There are other functions which will be good heuristics to annotate, but we
probaby want to collect .cold together in one location rather than having them
spread out across all translation units.
---
 xen/include/xen/lib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Beulich Feb. 21, 2023, 11:08 a.m. UTC | #1
On 20.02.2023 14:13, Andrew Cooper wrote:
> There is no such thing as a fastpath with a printk() on it, making printk() an
> excellent heuristic for slowpaths.
> 
> Net delta is:
> 
>   add/remove: 595/2 grow/shrink: 56/762 up/down: 70879/-87331 (-16452)
>   Total: Before=4085425, After=4068973, chg -0.40%
> 
> because cold functions are optimised differently.  For example, one function
> with a particularly large swing is:
> 
>   vmcs_dump_vcpu.cold                            -    2172   +2172
>   vmcs_dump_vcpu                              7030     408   -6622
> 
> with a net delta of 7030 down to 4450.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

> There are other functions which will be good heuristics to annotate, but we
> probaby want to collect .cold together in one location rather than having them
> spread out across all translation units.

Doesn't the compiler put it in .text.cold? Or is that compiler variant
and/or version dependent?

Jan
diff mbox series

Patch

diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 05ee1e18af6b..11ef287c1ed9 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -115,7 +115,7 @@  debugtrace_printk(const char *fmt, ...) {}
 /* Allows us to use '%p' as general-purpose machine-word format char. */
 #define _p(_x) ((void *)(unsigned long)(_x))
 extern void printk(const char *format, ...)
-    __attribute__ ((format (printf, 1, 2)));
+    __attribute__ ((format (printf, 1, 2), cold));
 
 #define printk_once(fmt, args...)               \
 ({                                              \