Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: compudj@krystal.dyndns.org (Mathieu Desnoyers)
Subject: [ltt-dev] [UST PATCH] Add getcpu error validation
Date: Wed, 9 Feb 2011 14:11:11 -0500	[thread overview]
Message-ID: <BLU0-SMTP65988F094CE6D6F8B5112196ED0@phx.gbl> (raw)
In-Reply-To: <1297276960-14345-1-git-send-email-david.goulet@polymtl.ca>

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




      reply	other threads:[~2011-02-09 19:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09 18:42 David Goulet
2011-02-09 19:11 ` Mathieu Desnoyers [this message]

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=BLU0-SMTP65988F094CE6D6F8B5112196ED0@phx.gbl \
    --to=compudj@krystal.dyndns.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