linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Christoph Lameter <cl@linux.com>
Cc: dhowells@redhat.com, linux-mm@kvack.org
Subject: [PATCH] Add a slab corruption tracepoint
Date: Thu, 08 Aug 2019 15:11:51 +0100	[thread overview]
Message-ID: <26518.1565273511@warthog.procyon.org.uk> (raw)

    
Add a tracepoint to log slab corruption messages to the trace log also so
that it's easier to correlate with other trace messages that are being used
to track refcounting.

Signed-off-by: David Howells <dhowells@redhat.com>
---
 include/trace/events/kmem.h |   23 +++++++++++++++++++++++
 mm/slab.c                   |    2 ++
 2 files changed, 25 insertions(+)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index eb57e3037deb..c96f3b03a6e2 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -315,6 +315,29 @@ TRACE_EVENT(mm_page_alloc_extfrag,
 		__entry->change_ownership)
 );
 
+TRACE_EVENT(slab_corruption,
+	TP_PROTO(const char *slab, void *object, unsigned int size, unsigned int offset),
+
+	TP_ARGS(slab, object, size, offset),
+
+	TP_STRUCT__entry(
+		__field(	void *,		object		)
+		__field(	unsigned int,	size		)
+		__field(	unsigned int,	offset		)
+		__array(	char,		slab, 16	)
+	),
+
+	TP_fast_assign(
+		strlcpy(__entry->slab, slab, sizeof(__entry->slab));
+		__entry->object		= object;
+		__entry->size		= size;
+		__entry->offset		= offset;
+	),
+
+	TP_printk("slab=%s obj=%px size=%x off=%x",
+		  __entry->slab, __entry->object, __entry->size, __entry->offset)
+);
+
 #endif /* _TRACE_KMEM_H */
 
 /* This part must be outside protection */
diff --git a/mm/slab.c b/mm/slab.c
index 9df370558e5d..47c5a86e39be 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1527,6 +1527,8 @@ static void check_poison_obj(struct kmem_cache *cachep, void *objp)
 				       print_tainted(), cachep->name,
 				       realobj, size);
 				print_objinfo(cachep, objp, 0);
+				trace_slab_corruption(cachep->name, realobj,
+						      size, i);
 			}
 			/* Hexdump the affected line */
 			i = (i / 16) * 16;


             reply	other threads:[~2019-08-08 14:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08 14:11 David Howells [this message]
2019-08-12 15:03 ` Vlastimil Babka
2019-08-19  9:03 ` David Howells
2019-08-19  9:22   ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26518.1565273511@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=cl@linux.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox