From: david.goulet@polymtl.ca (David Goulet)
Subject: [ltt-dev] [UST PATCH] Add getcpu error validation
Date: Wed, 9 Feb 2011 13:42:40 -0500 [thread overview]
Message-ID: <1297276960-14345-1-git-send-email-david.goulet@polymtl.ca> (raw)
This check is important for the case where getcpu(2) is not
implemented by the Kernel. So, the CPU 0 is the fallback.
Signed-off-by: David Goulet <david.goulet at polymtl.ca>
---
libust/tracer.h | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/libust/tracer.h b/libust/tracer.h
index 64996b2..dd524af 100644
--- a/libust/tracer.h
+++ b/libust/tracer.h
@@ -345,8 +345,14 @@ static __inline__ void ltt_write_trace_header(struct ust_trace *trace,
static __inline__ int ust_get_cpu(void)
{
+ int cpu = 0;
#ifndef UST_VALGRIND
- return sched_getcpu();
+ if ((cpu = sched_getcpu()) < 0) {
+ /* If getcpu(2) is not implemented in the Kernel
+ * use CPU 0 as fallback.
+ */
+ cpu = 0;
+ }
#else
/* Valgrind does not support the sched_getcpu() vsyscall.
* It causes it to detect a segfault in the program and stop it.
@@ -354,7 +360,7 @@ static __inline__ int ust_get_cpu(void)
* from using this call. TODO: it would probably be better to return
* other values too, to better test it.
*/
- return 0;
+ return cpu;
#endif
}
--
1.7.4
next reply other threads:[~2011-02-09 18:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-09 18:42 David Goulet [this message]
2011-02-09 19:11 ` Mathieu Desnoyers
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=1297276960-14345-1-git-send-email-david.goulet@polymtl.ca \
--to=david.goulet@polymtl.ca \
/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