* [ltt-dev] [UST PATCH] Add getcpu error validation
@ 2011-02-09 18:42 David Goulet
2011-02-09 19:11 ` Mathieu Desnoyers
0 siblings, 1 reply; 2+ messages in thread
From: David Goulet @ 2011-02-09 18:42 UTC (permalink / 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ltt-dev] [UST PATCH] Add getcpu error validation
2011-02-09 18:42 [ltt-dev] [UST PATCH] Add getcpu error validation David Goulet
@ 2011-02-09 19:11 ` Mathieu Desnoyers
0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2011-02-09 19:11 UTC (permalink / raw)
I did commit 8f09cb9340387a52b483752c5d2d6c36035b26bc which replaces
this patch. It's a cleanup on the style. Please look at the style of my
version to see coding style tricks to make code cleaner in with #ifdef:
usually, ifdefs wrap whole functions only.
Thanks,
Mathieu
* David Goulet (david.goulet at polymtl.ca) wrote:
> 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
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
>
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-09 19:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09 18:42 [ltt-dev] [UST PATCH] Add getcpu error validation David Goulet
2011-02-09 19:11 ` Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox