Skip to contentSkip to conversation

Jan Kiszka : nucleus: Include all heaps in statistics

Xenomai-core Gilles Chanteperdrix 2 participants 4 messages Nov 16, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Review

Quoted 10 lines · GIT version control
(quoted diff) +10 -0
+void xnheap_set_label(xnheap_t *heap, const char *label, ...)
+{
+	va_list args;
+	spl_t s;
+
+	va_start(args, label);
+
+	xnlock_get_irqsave(&nklock, s);
+	vsnprintf(heap->label, sizeof(heap->label), label, args);
+	xnlock_put_irqrestore(&nklock, s);

Why do we need locking here ?

Signature · 1 line
                                          Gilles
#2 lore raw
Quoted 14 lines · Gilles Chanteperdrix

Review

Quoted 10 lines · GIT version control
(quoted diff) +10 -0
+void xnheap_set_label(xnheap_t *heap, const char *label, ...)
+{
+	va_list args;
+	spl_t s;
+
+	va_start(args, label);
+
+	xnlock_get_irqsave(&nklock, s);
+	vsnprintf(heap->label, sizeof(heap->label), label, args);
+	xnlock_put_irqrestore(&nklock, s);

Why do we need locking here ?

We already registered the heap, so I want to avoid that someone dumping /proc sees an inconsistent string - or even an unterminated one.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#3 lore raw
Quoted 15 lines · Jan Kiszka
Quoted 13 lines · Gilles Chanteperdrix

Review

Quoted 10 lines · GIT version control
(quoted diff) +10 -0
+void xnheap_set_label(xnheap_t *heap, const char *label, ...)
+{
+	va_list args;
+	spl_t s;
+
+	va_start(args, label);
+
+	xnlock_get_irqsave(&nklock, s);
+	vsnprintf(heap->label, sizeof(heap->label), label, args);
+	xnlock_put_irqrestore(&nklock, s);

Why do we need locking here ?

Quoted 2 lines

We already registered the heap, so I want to avoid that someone dumping /proc sees an inconsistent string - or even an unterminated one.

There are other ways to avoid that, but, I am over-reacting to printf. But it is not really a printf, it is an snprintf, which is not that heavy.

Signature · 1 line
                                          Gilles
#4 lore raw
Quoted 15 lines · Gilles Chanteperdrix
Quoted 14 lines · Jan Kiszka
Quoted 13 lines · Gilles Chanteperdrix

Review

Quoted 10 lines · GIT version control
(quoted diff) +10 -0
+void xnheap_set_label(xnheap_t *heap, const char *label, ...)
+{
+	va_list args;
+	spl_t s;
+
+	va_start(args, label);
+
+	xnlock_get_irqsave(&nklock, s);
+	vsnprintf(heap->label, sizeof(heap->label), label, args);
+	xnlock_put_irqrestore(&nklock, s);

Why do we need locking here ?

Quoted 5 lines
Quoted 2 lines

We already registered the heap, so I want to avoid that someone dumping /proc sees an inconsistent string - or even an unterminated one.

There are other ways to avoid that, but, I am over-reacting to printf. But it is not really a printf, it is an snprintf, which is not that heavy.

Right, this was a lazy approach due to the fact that we call snprintf under nklock already.

Jan

PS: I just force-updated my queue for a cosmetic change ("unlabeled (%p)" -> "unlabeled @0x%p").

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux