Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame^] | 1 | From 49c603ef2dc6969f4454f0d849af00ee24bb7f04 Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael Jeanson <mjeanson@efficios.com> |
| 3 | Date: Thu, 4 Mar 2021 16:50:12 -0500 |
| 4 | Subject: [PATCH 3/4] fix: mm, tracing: record slab name for kmem_cache_free() |
| 5 | (v5.12) |
| 6 | |
| 7 | See upstream commit: |
| 8 | |
| 9 | commit 3544de8ee6e4817278b15fe08658de49abf58954 |
| 10 | Author: Jacob Wen <jian.w.wen@oracle.com> |
| 11 | Date: Wed Feb 24 12:00:55 2021 -0800 |
| 12 | |
| 13 | mm, tracing: record slab name for kmem_cache_free() |
| 14 | |
| 15 | Currently, a trace record generated by the RCU core is as below. |
| 16 | |
| 17 | ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f3b49a66 |
| 18 | |
| 19 | It doesn't tell us what the RCU core has freed. |
| 20 | |
| 21 | This patch adds the slab name to trace_kmem_cache_free(). |
| 22 | The new format is as follows. |
| 23 | |
| 24 | ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000037f79c8d name=dentry |
| 25 | ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=00000000f78cb7b5 name=sock_inode_cache |
| 26 | ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=0000000018768985 name=pool_workqueue |
| 27 | ... kmem_cache_free: call_site=rcu_core+0x1fd/0x610 ptr=000000006a6cb484 name=radix_tree_node |
| 28 | |
| 29 | We can use it to understand what the RCU core is going to free. For |
| 30 | example, some users maybe interested in when the RCU core starts |
| 31 | freeing reclaimable slabs like dentry to reduce memory pressure. |
| 32 | |
| 33 | Link: https://lkml.kernel.org/r/20201216072804.8838-1-jian.w.wen@oracle.com |
| 34 | |
| 35 | Upstream-status: backport |
| 36 | |
| 37 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> |
| 38 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 39 | Change-Id: I1ee2fc476614cadcc8d3ac5d8feddc7910e1aa3a |
| 40 | --- |
| 41 | instrumentation/events/lttng-module/kmem.h | 27 ++++++++++++++++++++++ |
| 42 | 1 file changed, 27 insertions(+) |
| 43 | |
| 44 | diff --git a/instrumentation/events/lttng-module/kmem.h b/instrumentation/events/lttng-module/kmem.h |
| 45 | index b134620a..d787ea54 100644 |
| 46 | --- a/instrumentation/events/lttng-module/kmem.h |
| 47 | +++ b/instrumentation/events/lttng-module/kmem.h |
| 48 | @@ -87,6 +87,32 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_alloc_node, kmem_cache_alloc_node, |
| 49 | TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node) |
| 50 | ) |
| 51 | |
| 52 | +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,12,0)) |
| 53 | +LTTNG_TRACEPOINT_EVENT(kfree, |
| 54 | + |
| 55 | + TP_PROTO(unsigned long call_site, const void *ptr), |
| 56 | + |
| 57 | + TP_ARGS(call_site, ptr), |
| 58 | + |
| 59 | + TP_FIELDS( |
| 60 | + ctf_integer_hex(unsigned long, call_site, call_site) |
| 61 | + ctf_integer_hex(const void *, ptr, ptr) |
| 62 | + ) |
| 63 | +) |
| 64 | + |
| 65 | +LTTNG_TRACEPOINT_EVENT(kmem_cache_free, |
| 66 | + |
| 67 | + TP_PROTO(unsigned long call_site, const void *ptr, const char *name), |
| 68 | + |
| 69 | + TP_ARGS(call_site, ptr, name), |
| 70 | + |
| 71 | + TP_FIELDS( |
| 72 | + ctf_integer_hex(unsigned long, call_site, call_site) |
| 73 | + ctf_integer_hex(const void *, ptr, ptr) |
| 74 | + ctf_string(name, name) |
| 75 | + ) |
| 76 | +) |
| 77 | +#else |
| 78 | LTTNG_TRACEPOINT_EVENT_CLASS(kmem_free, |
| 79 | |
| 80 | TP_PROTO(unsigned long call_site, const void *ptr), |
| 81 | @@ -114,6 +140,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(kmem_free, kmem_cache_free, |
| 82 | |
| 83 | TP_ARGS(call_site, ptr) |
| 84 | ) |
| 85 | +#endif |
| 86 | |
| 87 | #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,3,0)) |
| 88 | LTTNG_TRACEPOINT_EVENT_MAP(mm_page_free, kmem_mm_page_free, |
| 89 | -- |
| 90 | 2.19.1 |
| 91 | |