Skip to contentSkip to conversation

Revert "kmemtrace: fix printk format warnings"

PATCH Applied Eduard - Gabriel Munteanu 6 participants 30 messages Aug 19, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 Revert "kmemtrace: fix printk format warnings"

This reverts commit 79cf3d5e207243eecb1c4331c569e17700fa08fa.

The reverted commit, while it fixed printk format warnings, it resulted in marker-probe format mismatches. Another approach should be used to fix these warnings.

---
 include/linux/kmemtrace.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/kmemtrace.h +1 -1
index a865064..2c33201 100644
@@ -31,7 +31,7 @@ static inline void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id,
 					     int node)
 {
 	trace_mark(kmemtrace_alloc, "type_id %d call_site %lu ptr %lu "
-		   "bytes_req %zu bytes_alloc %zu gfp_flags %lu node %d",
+		   "bytes_req %lu bytes_alloc %lu gfp_flags %lu node %d",
 		   type_id, call_site, (unsigned long) ptr,
 		   bytes_req, bytes_alloc, (unsigned long) gfp_flags, node);
 }
Signature · 7 lines
1.5.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

PATCH 2/5 kmemtrace: Better alternative to "kmemtrace: fix printk format warnings".

Fix the problem "kmemtrace: fix printk format warnings" attempted to fix, but resulted in marker-probe format mismatch warnings. Instead of carrying size_t into probes, we get rid of it by casting to unsigned long, just as we did with gfp_t.

This way, we don't need to change marker format strings and we don't have to rely on other format specifiers like "%zu", making for consistent use of more generic data types (since there are no format specifiers for gfp_t, for example).

---
 include/linux/kmemtrace.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/kmemtrace.h +2 -1
index 2c33201..5bea8ea 100644
@@ -33,7 +33,8 @@ static inline void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id,
 	trace_mark(kmemtrace_alloc, "type_id %d call_site %lu ptr %lu "
 		   "bytes_req %lu bytes_alloc %lu gfp_flags %lu node %d",
 		   type_id, call_site, (unsigned long) ptr,
-		   bytes_req, bytes_alloc, (unsigned long) gfp_flags, node);
+		   (unsigned long) bytes_req, (unsigned long) bytes_alloc,
+		   (unsigned long) gfp_flags, node);
 }
 
 static inline void kmemtrace_mark_free(enum kmemtrace_type_id type_id,
Signature · 7 lines
1.5.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw

PATCH 3/5 SLUB: Replace __builtin_return_address(0) with _RET_IP_.

This patch replaces __builtin_return_address(0) with _RET_IP_, since a previous patch moved _RET_IP_ and _THIS_IP_ to include/linux/kernel.h and they're widely available now. This makes for shorter and easier to read code.

---
 mm/slub.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
mm/slub.c +6 -6
index 4f5b961..8f66782 100644
@@ -1612,14 +1612,14 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
 
 void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
 {
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, (void *) _RET_IP_);
 }
 EXPORT_SYMBOL(kmem_cache_alloc);
 
 #ifdef CONFIG_NUMA
 void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)
 {
-	return slab_alloc(s, gfpflags, node, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, node, (void *) _RET_IP_);
 }
 EXPORT_SYMBOL(kmem_cache_alloc_node);
 #endif
@@ -1730,7 +1730,7 @@ void kmem_cache_free(struct kmem_cache *s, void *x)
 
 	page = virt_to_head_page(x);
 
-	slab_free(s, page, x, __builtin_return_address(0));
+	slab_free(s, page, x, (void *) _RET_IP_);
 }
 EXPORT_SYMBOL(kmem_cache_free);
 
@@ -2657,7 +2657,7 @@ void *__kmalloc(size_t size, gfp_t flags)
 	if (unlikely(ZERO_OR_NULL_PTR(s)))
 		return s;
 
-	return slab_alloc(s, flags, -1, __builtin_return_address(0));
+	return slab_alloc(s, flags, -1, (void *) _RET_IP_);
 }
 EXPORT_SYMBOL(__kmalloc);
 
@@ -2685,7 +2685,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
 	if (unlikely(ZERO_OR_NULL_PTR(s)))
 		return s;
 
-	return slab_alloc(s, flags, node, __builtin_return_address(0));
+	return slab_alloc(s, flags, node, (void *) _RET_IP_);
 }
 EXPORT_SYMBOL(__kmalloc_node);
 #endif
@@ -2742,7 +2742,7 @@ void kfree(const void *x)
 		put_page(page);
 		return;
 	}
-	slab_free(page->slab, page, object, __builtin_return_address(0));
+	slab_free(page->slab, page, object, (void *) _RET_IP_);
 }
 EXPORT_SYMBOL(kfree);
 
Signature · 7 lines
1.5.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw

PATCH 4/5 kmemtrace: SLUB hooks.

This adds hooks for the SLUB allocator, to allow tracing with kmemtrace.

---
 include/linux/slub_def.h |   53 +++++++++++++++++++++++++++++++++++--
 mm/slub.c                |   65 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 109 insertions(+), 9 deletions(-)
include/linux/slub_def.h +50 -3
index 2f5c16b..dc28432 100644
@@ -10,6 +10,7 @@
 #include <linux/gfp.h>
 #include <linux/workqueue.h>
 #include <linux/kobject.h>
+#include <linux/kmemtrace.h>
 
 enum stat_item {
 	ALLOC_FASTPATH,		/* Allocation from cpu slab */
@@ -204,13 +205,31 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 void *__kmalloc(size_t size, gfp_t flags);
 
+#ifdef CONFIG_KMEMTRACE
+extern void *kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags);
+#else
+static __always_inline void *
+kmem_cache_alloc_notrace(struct kmem_cache *s, gfp_t gfpflags)
+{
+	return kmem_cache_alloc(s, gfpflags);
+}
+#endif
+
 static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
 {
-	return (void *)__get_free_pages(flags | __GFP_COMP, get_order(size));
+	unsigned int order = get_order(size);
+	void *ret = (void *) __get_free_pages(flags | __GFP_COMP, order);
+
+	kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC, _THIS_IP_, ret,
+			     size, PAGE_SIZE << order, flags);
+
+	return ret;
 }
 
 static __always_inline void *kmalloc(size_t size, gfp_t flags)
 {
+	void *ret;
+
 	if (__builtin_constant_p(size)) {
 		if (size > PAGE_SIZE)
 			return kmalloc_large(size, flags);
@@ -221,7 +240,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
 			if (!s)
 				return ZERO_SIZE_PTR;
 
-			return kmem_cache_alloc(s, flags);
+			ret = kmem_cache_alloc_notrace(s, flags);
+
+			kmemtrace_mark_alloc(KMEMTRACE_TYPE_KMALLOC,
+					     _THIS_IP_, ret,
+					     size, s->size, flags);
+
+			return ret;
 		}
 	}
 	return __kmalloc(size, flags);
@@ -231,8 +256,24 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
 void *__kmalloc_node(size_t size, gfp_t flags, int node);
 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
 
+#ifdef CONFIG_KMEMTRACE
+extern void *kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+					   gfp_t gfpflags,
+					   int node);
+#else
+static __always_inline void *
+kmem_cache_alloc_node_notrace(struct kmem_cache *s,
+			      gfp_t gfpflags,
+			      int node)
+{
+	return kmem_cache_alloc_node(s, gfpflags, node);
+}
+#endif
+
 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 {
+	void *ret;
+
 	if (__builtin_constant_p(size) &&
 		size <= PAGE_SIZE && !(flags & SLUB_DMA)) {
 			struct kmem_cache *s = kmalloc_slab(size);
@@ -240,7 +281,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 		if (!s)
 			return ZERO_SIZE_PTR;
 
-		return kmem_cache_alloc_node(s, flags, node);
+		ret = kmem_cache_alloc_node_notrace(s, flags, node);
+
+		kmemtrace_mark_alloc_node(KMEMTRACE_TYPE_KMALLOC,
+					  _THIS_IP_, ret,
+					  size, s->size, flags, node);
+
+		return ret;
 	}
 	return __kmalloc_node(size, flags, node);
 }
mm/slub.c +59 -6

124 lines not on this page · raw message

Signature · 7 lines
1.5.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#4 lore raw

PATCH 5/5 kmemtrace: Fix 2 typos in documentation.

Corrected the ABI description and the kmemtrace usage guide. Thanks to Randy Dunlap for noticing these errors.

---
 Documentation/ABI/testing/debugfs-kmemtrace |    2 +-
 Documentation/vm/kmemtrace.txt              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/ABI/testing/debugfs-kmemtrace +1 -1
index a5ff9a6..5e6a92a 100644
@@ -63,7 +63,7 @@ Adding new data to the packet (features) is done at the end of the mandatory
 data:
 	Feature size	(2 byte)
 	Feature ID	(1 byte)
-	Feature data	(Feature size - 4 bytes)
+	Feature data	(Feature size - 3 bytes)
 
 
 Users:
Documentation/vm/kmemtrace.txt +1 -1
index 75360b1..f656cac 100644
@@ -61,7 +61,7 @@ III. Quick usage guide
 ======================
 
 1) Get a kernel that supports kmemtrace and build it accordingly (i.e. enable
-CONFIG_KMEMTRACE and CONFIG_DEFAULT_ENABLED).
+CONFIG_KMEMTRACE and CONFIG_KMEMTRACE_DEFAULT_ENABLED).
 
 2) Get the userspace tool and build it:
 $ git-clone git://repo.or.cz/kmemtrace-user.git		# current repository
Signature · 7 lines
1.5.6.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Applied
#5 lore raw

Re: [PATCH 5/5] kmemtrace: Fix 2 typos in documentation.

Quoted 4 lines · Eduard - Gabriel Munteanu

Corrected the ABI description and the kmemtrace usage guide. Thanks to Randy Dunlap for noticing these errors.

Applied, thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Applied
#6 lore raw

Re: [PATCH 4/5] kmemtrace: SLUB hooks.

In reply to Eduard - Gabriel Munteanu
Quoted 3 lines · Eduard - Gabriel Munteanu

This adds hooks for the SLUB allocator, to allow tracing with kmemtrace.

Applied, thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#7 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

In reply to Eduard - Gabriel Munteanu

mm/slub.c static __always_inline void *slab_alloc(struct kmem_cache *s, · line 1616

Quoted 5 lines · Eduard - Gabriel Munteanu

void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) {

mm/slub.c +1 -1
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, (void *) _RET_IP_);
 }

Could you get rid of the casts by changing the type of parameter of slab_alloc()?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 9 lines · Christoph Lameter

mm/slub.c static __always_inline void *slab_alloc(struct kmem_cache *s, · line 1616

Quoted 5 lines · Eduard - Gabriel Munteanu

void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) {

mm/slub.c +1 -1
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, (void *) _RET_IP_);
 }

Could you get rid of the casts by changing the type of parameter of slab_alloc()?

I just looked at it and it isn't a trivial change. slab_alloc() calls other functions which expect a void ptr. Even if slab_alloc() were to take an unsigned long and then cast it to a void ptr, other functions do call slab_alloc() with void ptr arguments (so the casts would move there).

I'd rather have this merged as it is and change things later, so that kmemtrace gets some testing from Pekka and others.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 10 lines · Eduard - Gabriel Munteanu
Quoted 8 lines · Christoph Lameter

Review

Quoted 5 lines · Eduard - Gabriel Munteanu

void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) {

(quoted diff) +1 -1
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, (void *) _RET_IP_);
 }

Could you get rid of the casts by changing the type of parameter of slab_alloc()?

Quoted 9 lines

I just looked at it and it isn't a trivial change. slab_alloc() calls other functions which expect a void ptr. Even if slab_alloc() were to take an unsigned long and then cast it to a void ptr, other functions do call slab_alloc() with void ptr arguments (so the casts would move there).

I'd rather have this merged as it is and change things later, so that kmemtrace gets some testing from Pekka and others.

Well maybe this patch will do it then:

Subject: slub: Use _RET_IP and use "unsigned long" for kernel text addresses

Use _RET_IP_ instead of buildint_return_address() and make slub use unsigned long instead of void * for addresses.

---
 mm/slub.c |   46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
mm/slub.c +23 -23
Index: linux-2.6/mm/slub.c
===================================================================
@@ -177,7 +177,7 @@ static LIST_HEAD(slab_caches);
  * Tracking user of a slab.
  */
 struct track {
-	void *addr;		/* Called from address */
+	unsigned long addr;	/* Called from address */
 	int cpu;		/* Was running on cpu */
 	int pid;		/* Pid context */
 	unsigned long when;	/* When did the operation occur */
@@ -366,7 +366,7 @@ static struct track *get_track(struct km
 }
 
 static void set_track(struct kmem_cache *s, void *object,
-				enum track_item alloc, void *addr)
+				enum track_item alloc, unsigned long addr)
 {
 	struct track *p;
 
@@ -390,8 +390,8 @@ static void init_tracking(struct kmem_ca
 	if (!(s->flags & SLAB_STORE_USER))
 		return;
 
-	set_track(s, object, TRACK_FREE, NULL);
-	set_track(s, object, TRACK_ALLOC, NULL);
+	set_track(s, object, TRACK_FREE, 0L);
+	set_track(s, object, TRACK_ALLOC, 0L);
 }
 
 static void print_track(const char *s, struct track *t)
@@ -399,7 +399,7 @@ static void print_track(const char *s, s
 	if (!t->addr)
 		return;
 
-	printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
+	printk(KERN_ERR "INFO: %s in %lxS age=%lu cpu=%u pid=%d\n",
 		s, t->addr, jiffies - t->when, t->cpu, t->pid);
 }
 
@@ -865,7 +865,7 @@ static void setup_object_debug(struct km
 }
 
 static int alloc_debug_processing(struct kmem_cache *s, struct page *page,
-						void *object, void *addr)
+						void *object, unsigned long addr)
 {
 	if (!check_slab(s, page))
 		goto bad;
@@ -905,7 +905,7 @@ bad:
 }
 
 static int free_debug_processing(struct kmem_cache *s, struct page *page,
-						void *object, void *addr)
+						void *object, unsigned long addr)
 {
 	if (!check_slab(s, page))
 		goto fail;
@@ -1028,10 +1028,10 @@ static inline void setup_object_debug(st
 			struct page *page, void *object) {}
 
 static inline int alloc_debug_processing(struct kmem_cache *s,
-	struct page *page, void *object, void *addr) { return 0; }
+	struct page *page, void *object, unsigned long addr) { return 0; }
 
 static inline int free_debug_processing(struct kmem_cache *s,
-	struct page *page, void *object, void *addr) { return 0; }
+	struct page *page, void *object, unsigned long) { return 0; }
 
 static inline int slab_pad_check(struct kmem_cache *s, struct page *page)
 			{ return 1; }
@@ -1499,7 +1499,7 @@ static inline int node_match(struct kmem
  * a call to the page allocator and the setup of a new slab.
  */
 static void *__slab_alloc(struct kmem_cache *s,
-		gfp_t gfpflags, int node, void *addr, struct kmem_cache_cpu *c)
+		gfp_t gfpflags, int node, unsigned long addr, struct kmem_cache_cpu *c)
 {
 	void **object;
 	struct page *new;
@@ -1583,7 +1583,7 @@ debug:
  * Otherwise we can simply pick the next object from the lockless free list.
  */
 static __always_inline void *slab_alloc(struct kmem_cache *s,
-		gfp_t gfpflags, int node, void *addr)
+		gfp_t gfpflags, int node, unsigned long addr)
 {
 	void **object;
 	struct kmem_cache_cpu *c;
@@ -1612,14 +1612,14 @@ static __always_inline void *slab_alloc(
 
 void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags)
 {
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, _RET_IP_);
 }
 EXPORT_SYMBOL(kmem_cache_alloc);
 
 #ifdef CONFIG_NUMA
 void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t gfpflags, int node)
 {
-	return slab_alloc(s, gfpflags, node, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, node, _RET_IP_);
 }
 EXPORT_SYMBOL(kmem_cache_alloc_node);
 #endif
@@ -1633,7 +1633,7 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
  * handling required then we can return immediately.
  */
 static void __slab_free(struct kmem_cache *s, struct page *page,
-				void *x, void *addr, unsigned int offset)
+				void *x, unsigned long addr, unsigned int offset)
 {
 	void *prior;
 	void **object = (void *)x;
@@ -1703,7 +1703,7 @@ debug:
  * with all sorts of special processing.
  */
 static __always_inline void slab_free(struct kmem_cache *s,
-			struct page *page, void *x, void *addr)
+			struct page *page, void *x, unsigned long addr)
 {
 	void **object = (void *)x;
 	struct kmem_cache_cpu *c;
@@ -1730,7 +1730,7 @@ void kmem_cache_free(struct kmem_cache *
 
 	page = virt_to_head_page(x);
 
-	slab_free(s, page, x, __builtin_return_address(0));
+	slab_free(s, page, x, _RET_IP_);
 }
 EXPORT_SYMBOL(kmem_cache_free);
 
@@ -2657,7 +2657,7 @@ void *__kmalloc(size_t size, gfp_t flags
 	if (unlikely(ZERO_OR_NULL_PTR(s)))
 		return s;
 
-	return slab_alloc(s, flags, -1, __builtin_return_address(0));
+	return slab_alloc(s, flags, -1, _RET_IP_);
 }
 EXPORT_SYMBOL(__kmalloc);
 
@@ -2685,7 +2685,7 @@ void *__kmalloc_node(size_t size, gfp_t
 	if (unlikely(ZERO_OR_NULL_PTR(s)))
 		return s;
 
-	return slab_alloc(s, flags, node, __builtin_return_address(0));
+	return slab_alloc(s, flags, node, _RET_IP_);
 }
 EXPORT_SYMBOL(__kmalloc_node);
 #endif
@@ -2742,7 +2742,7 @@ void kfree(const void *x)
 		put_page(page);
 		return;
 	}
-	slab_free(page->slab, page, object, __builtin_return_address(0));
+	slab_free(page->slab, page, object, _RET_IP_);
 }
 EXPORT_SYMBOL(kfree);
 
@@ -3210,7 +3210,7 @@ void *__kmalloc_track_caller(size_t size
 	if (unlikely(ZERO_OR_NULL_PTR(s)))
 		return s;
 
-	return slab_alloc(s, gfpflags, -1, caller);
+	return slab_alloc(s, gfpflags, -1, (unsigned long)caller);
 }
 
 void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
@@ -3226,7 +3226,7 @@ void *__kmalloc_node_track_caller(size_t
 	if (unlikely(ZERO_OR_NULL_PTR(s)))
 		return s;
 
-	return slab_alloc(s, gfpflags, node, caller);
+	return slab_alloc(s, gfpflags, node, (unsigned long)caller);
 }
 
 #ifdef CONFIG_SLUB_DEBUG
@@ -3425,7 +3425,7 @@ static void resiliency_test(void) {};
 
 struct location {
 	unsigned long count;
-	void *addr;
+	unsigned long addr;
 	long long sum_time;
 	long min_time;
 	long max_time;
@@ -3473,7 +3473,7 @@ static int add_location(struct loc_track
 {
 	long start, end, pos;
 	struct location *l;
-	void *caddr;
+	unsigned long caddr;
 	unsigned long age = jiffies - track->when;
 
 	start = -1;

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 20 lines · Christoph Lameter
Quoted 9 lines · Eduard - Gabriel Munteanu
Quoted 8 lines · Christoph Lameter

mm/slub.c static __always_inline void *slab_alloc( · line 1616

Quoted 5 lines · Eduard - Gabriel Munteanu

void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) {

mm/slub.c +1 -1
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, (void *) _RET_IP_);
 }

Could you get rid of the casts by changing the type of parameter of slab_alloc()?

Quoted 9 lines

I just looked at it and it isn't a trivial change. slab_alloc() calls other functions which expect a void ptr. Even if slab_alloc() were to take an unsigned long and then cast it to a void ptr, other functions do call slab_alloc() with void ptr arguments (so the casts would move there).

I'd rather have this merged as it is and change things later, so that kmemtrace gets some testing from Pekka and others.

Quoted 8 lines

Well maybe this patch will do it then:

Subject: slub: Use _RET_IP and use "unsigned long" for kernel text addresses

Use _RET_IP_ instead of buildint_return_address() and make slub use unsigned long instead of void * for addresses.

Heh, heh. I'm happy to take your patch or alternatively you can ACK mine (which is slightly different):

http://lkml.org/lkml/2008/8/19/336

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

In reply to Christoph Lameter
Quoted 4 lines · Christoph Lameter

Well maybe this patch will do it then:

Subject: slub: Use _RET_IP and use "unsigned long" for kernel text addresses

Quoted 8 lines

Use _RET_IP_ instead of buildint_return_address() and make slub use unsigned long instead of void * for addresses.

---
 mm/slub.c |   46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

It seems Pekka just submitted something like this. Though I think using 0L should be replaced with 0UL to be fully correct.

Pekka, should I test one of these variants and resubmit, or will you merge it by yourself?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 9 lines · Eduard - Gabriel Munteanu
Quoted 7 lines · Christoph Lameter

Well maybe this patch will do it then:

Subject: slub: Use _RET_IP and use "unsigned long" for kernel text addresses

Use _RET_IP_ instead of buildint_return_address() and make slub use unsigned long instead of void * for addresses.

Quoted 8 lines
Quoted 5 lines
---
 mm/slub.c |   46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

It seems Pekka just submitted something like this. Though I think using 0L should be replaced with 0UL to be fully correct.

Fixed, thanks!

Quoted 2 lines

Pekka, should I test one of these variants and resubmit, or will you merge it by yourself?

I'm merging my patch to the kmemtrace branch now.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#13 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

In reply to Christoph Lameter

mm/slub.c static void print_track(const char *s, s · line 403

Quoted 8 lines · Christoph Lameter

static void print_track(const char *s, struct track *t)

mm/slub.c +1 -1
@@ -399,7 +399,7 @@ static void print_track(const char *s, s
 	if (!t->addr)
 		return;
 
-	printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
+	printk(KERN_ERR "INFO: %s in %lxS age=%lu cpu=%u pid=%d\n",
 		s, t->addr, jiffies - t->when, t->cpu, t->pid);

This looks wrong. The '%pS' thingy has a special purpose:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7daf705f362e349983e92037a198b8821db198af

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 3 lines · Pekka Enberg

This looks wrong. The '%pS' thingy has a special purpose:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7daf705f362e349983e92037a198b8821db198af

True. Just had 10 minutes to do the patch. Can someone stitch all of the good things from all three patches together?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 8 lines · Christoph Lameter
Quoted 3 lines · Pekka Enberg

This looks wrong. The '%pS' thingy has a special purpose:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7daf705f362e349983e92037a198b8821db198af

True. Just had 10 minutes to do the patch. Can someone stitch all of the good things from all three patches together?

I already did that:

http://git.kernel.org/?p=linux/kernel/git/penberg/slab-2.6.git;a=commitdiff;h=3c0a0d0e24234704387f6356ffc7b47758dc1e05

It's compiled-tested too. I had to do some changes to include/linux/slab.h as well.

Pekka

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#16 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 2 lines · Pekka Enberg

It's compiled-tested too. I had to do some changes to include/linux/slab.h as well.

Please recompile with CONFIG_SLUB_DEBUG off to find some breakage. F.e.

static inline int alloc_debug_processing(struct kmem_cache *s,

        struct page *page, void *object, void *addr) { return 0; }

static inline int free_debug_processing(struct kmem_cache *s,

        struct page *page, void *object, void *addr) { return 0; }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#17 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

Quoted 5 lines · Christoph Lameter
Quoted 2 lines · Pekka Enberg

It's compiled-tested too. I had to do some changes to include/linux/slab.h as well.

Quoted 7 lines

Please recompile with CONFIG_SLUB_DEBUG off to find some breakage. F.e.

static inline int alloc_debug_processing(struct kmem_cache *s,

        struct page *page, void *object, void *addr) { return 0; }

static inline int free_debug_processing(struct kmem_cache *s,

        struct page *page, void *object, void *addr) { return 0; }

Fixed, thanks.

http://git.kernel.org/?p=linux/kernel/git/penberg/slab-2.6.git;a=commitdiff;h=04be8567dab2a793f4ec8050c65af6845e6e3af3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#18 lore raw

Re: [PATCH 3/5] SLUB: Replace __builtin_return_address(0) with _RET_IP_.

In reply to Christoph Lameter
Quoted 5 lines · Eduard - Gabriel Munteanu
Quoted 5 lines

void *kmem_cache_alloc(struct kmem_cache *s, gfp_t gfpflags) {

(quoted diff) +1 -1
-	return slab_alloc(s, gfpflags, -1, __builtin_return_address(0));
+	return slab_alloc(s, gfpflags, -1, (void *) _RET_IP_);
 }
Quoted 1 line · Christoph Lameter

Could you get rid of the casts by changing the type of parameter of slab_alloc()?

Yeah. How about something like this?

Pekka

Applied
#19 lore raw

Re: [PATCH 2/5] kmemtrace: Better alternative to "kmemtrace: fix printk format warnings".

In reply to Eduard - Gabriel Munteanu
Quoted 11 lines · Eduard - Gabriel Munteanu

Fix the problem "kmemtrace: fix printk format warnings" attempted to fix, but resulted in marker-probe format mismatch warnings. Instead of carrying size_t into probes, we get rid of it by casting to unsigned long, just as we did with gfp_t.

This way, we don't need to change marker format strings and we don't have to rely on other format specifiers like "%zu", making for consistent use of more generic data types (since there are no format specifiers for gfp_t, for example).

Applied, thanks!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#20 lore raw
In reply to Eduard - Gabriel Munteanu
Quoted 5 lines · Eduard - Gabriel Munteanu

This reverts commit 79cf3d5e207243eecb1c4331c569e17700fa08fa.

The reverted commit, while it fixed printk format warnings, it resulted in marker-probe format mismatches. Another approach should be used to fix these warnings.

Such as what?

Can marker probes be fixed instead?

After seeing & fixing lots of various warnings in the last few days, I'm thinking that people don't look at/heed warnings nowadays. Sad. Maybe there are just so many that they are lost in the noise.

Quoted 18 lines
---
 include/linux/kmemtrace.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/kmemtrace.h +1 -1
index a865064..2c33201 100644
@@ -31,7 +31,7 @@ static inline void kmemtrace_mark_alloc_node(enum kmemtrace_type_id type_id,
 					     int node)
 {
 	trace_mark(kmemtrace_alloc, "type_id %d call_site %lu ptr %lu "
-		   "bytes_req %zu bytes_alloc %zu gfp_flags %lu node %d",
+		   "bytes_req %lu bytes_alloc %lu gfp_flags %lu node %d",
 		   type_id, call_site, (unsigned long) ptr,
 		   bytes_req, bytes_alloc, (unsigned long) gfp_flags, node);
 }
Signature · 7 lines
~Randy

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#21 lore raw
Quoted 8 lines · Randy.Dunlap
Quoted 5 lines · Eduard - Gabriel Munteanu

This reverts commit 79cf3d5e207243eecb1c4331c569e17700fa08fa.

The reverted commit, while it fixed printk format warnings, it resulted in marker-probe format mismatches. Another approach should be used to fix these warnings.

Quoted 7 lines

Such as what?

Can marker probes be fixed instead?

After seeing & fixing lots of various warnings in the last few days, I'm thinking that people don't look at/heed warnings nowadays. Sad. Maybe there are just so many that they are lost in the noise.

Hi,

Check the next patch in the series, it provides the alternate fix. I favor this approach more because it involves fewer changes and we don't have to use things like "%zu" (which make data type size less apparent).

Cheers,
Eduard

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#22 lore raw
Quoted 17 lines · * Eduard - Gabriel Munteanu ([email protected]) wrote:
Quoted 8 lines · Randy.Dunlap
Quoted 5 lines · Eduard - Gabriel Munteanu

This reverts commit 79cf3d5e207243eecb1c4331c569e17700fa08fa.

The reverted commit, while it fixed printk format warnings, it resulted in marker-probe format mismatches. Another approach should be used to fix these warnings.

Quoted 7 lines

Such as what?

Can marker probes be fixed instead?

After seeing & fixing lots of various warnings in the last few days, I'm thinking that people don't look at/heed warnings nowadays. Sad. Maybe there are just so many that they are lost in the noise.

Quoted 7 lines

Hi,

Check the next patch in the series, it provides the alternate fix. I favor this approach more because it involves fewer changes and we don't have to use things like "%zu" (which make data type size less apparent).

Question :

Is this kmemtrace marker meant to be exposed to userspace ?

I suspect not. In all case, not directly. I expect in-kernel probes to be connected on these markers which will get the arguments they need, and maybe access the inner data structures. Anyhow, tracepoints should be used for that, not markers. You can later put markers in the probes which are themselves connected to tracepoints.

Tracepoints = in-kernel tracing API.

Markers = Data-formatting tracing API, meant to export the data either to user-space in text or binary format.

See

http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=shortlog

tracepoint-related patches.

Mathieu

Quoted 4 lines

Cheers,
Eduard

Signature · 8 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#23 lore raw
Quoted 12 lines · Mathieu Desnoyers

Question :

Is this kmemtrace marker meant to be exposed to userspace ?

I suspect not. In all case, not directly. I expect in-kernel probes to be connected on these markers which will get the arguments they need, and maybe access the inner data structures. Anyhow, tracepoints should be used for that, not markers. You can later put markers in the probes which are themselves connected to tracepoints.

Tracepoints = in-kernel tracing API.

Quoted 8 lines

Markers = Data-formatting tracing API, meant to export the data either to user-space in text or binary format.

See

http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=shortlog

tracepoint-related patches.

I think we're ready to try tracepoints. Pekka, could you merge Mathieu's tracepoints or otherwise provide a branch where I could submit a tracepoint conversion patch for kmemtrace?

Quoted 2 lines

Mathieu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#24 lore raw
Quoted 18 lines · Eduard - Gabriel Munteanu
Quoted 17 lines · Mathieu Desnoyers

Question :

Is this kmemtrace marker meant to be exposed to userspace ?

I suspect not. In all case, not directly. I expect in-kernel probes to be connected on these markers which will get the arguments they need, and maybe access the inner data structures. Anyhow, tracepoints should be used for that, not markers. You can later put markers in the probes which are themselves connected to tracepoints.

Tracepoints = in-kernel tracing API.

Markers = Data-formatting tracing API, meant to export the data either to user-space in text or binary format.

See

Quoted 7 lines
Quoted 3 lines

http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=shortlog

tracepoint-related patches.

I think we're ready to try tracepoints. Pekka, could you merge Mathieu's tracepoints or otherwise provide a branch where I could submit a tracepoint conversion patch for kmemtrace?

Sorry, that's too much of a hassle for me. I'll happily take your conversion patch once tracepoints hit mainline. Mathieu, are you aiming for 2.6.28?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#25 lore raw
Quoted 21 lines · * Pekka Enberg ([email protected]) wrote:
Quoted 20 lines · Eduard - Gabriel Munteanu
Quoted 19 lines · Mathieu Desnoyers

Question :

Is this kmemtrace marker meant to be exposed to userspace ?

I suspect not. In all case, not directly. I expect in-kernel probes to be connected on these markers which will get the arguments they need, and maybe access the inner data structures. Anyhow, tracepoints should be used for that, not markers. You can later put markers in the probes which are themselves connected to tracepoints.

Tracepoints = in-kernel tracing API.

Markers = Data-formatting tracing API, meant to export the data either to user-space in text or binary format.

See

http://git.kernel.org/?p=linux/kernel/git/compudj/linux-2.6-lttng.git;a=shortlog

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

tracepoint-related patches.

I think we're ready to try tracepoints. Pekka, could you merge Mathieu's tracepoints or otherwise provide a branch where I could submit a tracepoint conversion patch for kmemtrace?

Sorry, that's too much of a hassle for me. I'll happily take your conversion patch once tracepoints hit mainline. Mathieu, are you aiming for 2.6.28?

Probably. it's in -tip right now, and the new ftrace depends on it. So at least 2.6.28 yes.

Mathieu

Signature · 8 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#26 lore raw
In reply to Mathieu Desnoyers
Quoted 7 lines · Mathieu Desnoyers

[...]
Is this kmemtrace marker meant to be exposed to userspace ? I suspect not.
[...]
Tracepoints = in-kernel tracing API.
Markers = Data-formatting tracing API, meant to export the data either to user-space in text or binary format.

FWIW, that was certainly not the intent of markers. It was to try to satisfy both sorts of uses with relative type-safety and a minimum of code. Tracepoints may be nice if one needs somewhat (how much?) more performance, and is willing to burden someone else with the necessary extra code (such as tracepoint-to-marker conversion modules) to expose the same data to "userspace" tools like lttng/systemtap.

- FChE

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#27 lore raw
In reply to Eduard - Gabriel Munteanu
Quoted 5 lines · Eduard - Gabriel Munteanu
Quoted 4 lines · Randy.Dunlap
Quoted 2 lines · Eduard - Gabriel Munteanu

This reverts commit 79cf3d5e207243eecb1c4331c569e17700fa08fa.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

The reverted commit, while it fixed printk format warnings, it resulted in marker-probe format mismatches. Another approach should be used to fix these warnings.

Such as what?

Can marker probes be fixed instead?

Did you answer this?

Quoted 7 lines
Quoted 3 lines

After seeing & fixing lots of various warnings in the last few days, I'm thinking that people don't look at/heed warnings nowadays. Sad. Maybe there are just so many that they are lost in the noise.

Hi,

Check the next patch in the series, it provides the alternate fix.

Yep, I saw that later.

Quoted 3 lines

I favor this approach more because it involves fewer changes and we don't have to use things like "%zu" (which make data type size less apparent).

%zu is regular C language. I.e., I don't get the data type not being apparent issue...

Maybe kmemtrace should just make everything be long long... :(

Signature · 7 lines
~Randy

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#28 lore raw
Quoted 6 lines · Randy.Dunlap
Quoted 4 lines
Quoted 4 lines

Such as what?

Can marker probes be fixed instead?

Did you answer this?

Yes, they can be fixed, but the probe functions will likely show warnings unless the way we parse vargs is fixed as well.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

After seeing & fixing lots of various warnings in the last few days, I'm thinking that people don't look at/heed warnings nowadays. Sad. Maybe there are just so many that they are lost in the noise.

Hi,

Check the next patch in the series, it provides the alternate fix.

Quoted 8 lines

Yep, I saw that later.

Quoted 3 lines

I favor this approach more because it involves fewer changes and we don't have to use things like "%zu" (which make data type size less apparent).

%zu is regular C language. I.e., I don't get the data type not being apparent issue...

Yes, I know. But I feel like using unsigned long is consistent with the way we handle the call site pointers and gfp_t. Pointers are cast to unsigned long (in _RET_IP_) and size_t's actual range and size is more apparent if it's cast to unsigned long as well (since allocation sizes should scale the same as pointers do, and we know sizeof(unsigned long) == sizeof(void *) on GCC).

Quoted 1 line

Maybe kmemtrace should just make everything be long long... :(

I was merely trying to sort this out faster and more consistent.

Quoted 2 lines
Signature · 1 line
~Randy

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#29 lore raw
In reply to Eduard - Gabriel Munteanu
Quoted 5 lines · Eduard - Gabriel Munteanu

This reverts commit 79cf3d5e207243eecb1c4331c569e17700fa08fa.

The reverted commit, while it fixed printk format warnings, it resulted in marker-probe format mismatches. Another approach should be used to fix these warnings.

I simply dropped Randy's patch so the revert wasn't needed.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>