From: Eldad Zinger Date: Tue, 28 Sep 2010 11:28:50 +0000 (+0200) Subject: sdp: fix for timestamping values in debug messages X-Git-Tag: v4.1.12-92~264^2~5^2~100 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a63ee605427139b77249490e6ee5573ba22fe0b8;p=users%2Fjedix%2Flinux-maple.git sdp: fix for timestamping values in debug messages Signed-off-by: Eldad Zinger --- diff --git a/drivers/infiniband/ulp/sdp/sdp.h b/drivers/infiniband/ulp/sdp/sdp.h index 1f916c247b413..598a1d5f208a0 100644 --- a/drivers/infiniband/ulp/sdp/sdp.h +++ b/drivers/infiniband/ulp/sdp/sdp.h @@ -518,6 +518,17 @@ static inline int tx_slots_free(struct sdp_sock *ssk) return min_free - SDP_MIN_TX_CREDITS; }; +static inline unsigned sdp_cycles_to_usecs(unsigned long c) +{ +#ifdef CONFIG_PPC + return c / tb_ticks_per_usec; +#elif defined(__ia64__) + return c / local_cpu_data->cyc_per_usec; +#else + return c * 1000 / cpu_khz; +#endif +} + /* utilities */ static inline char *mid2str(int mid) { diff --git a/drivers/infiniband/ulp/sdp/sdp_dbg.h b/drivers/infiniband/ulp/sdp/sdp_dbg.h index 7353da0cce120..f9a8a637e2611 100644 --- a/drivers/infiniband/ulp/sdp/sdp_dbg.h +++ b/drivers/infiniband/ulp/sdp/sdp_dbg.h @@ -6,7 +6,6 @@ #ifdef CONFIG_INFINIBAND_SDP_DEBUG_DATA #define SDP_PROFILING #endif -//#define GETNSTIMEODAY_SUPPORTED #define SDP_WARN_ON(x) WARN_ON(x) @@ -48,7 +47,7 @@ struct sdpprf_log { struct sk_buff *skb; char msg[256]; - unsigned long long time; + cycles_t time; const char *func; int line; @@ -59,17 +58,6 @@ struct sdpprf_log { extern struct sdpprf_log sdpprf_log[SDPPRF_LOG_SIZE]; extern int sdpprf_log_count; -#ifdef GETNSTIMEODAY_SUPPORTED -static inline unsigned long long current_nsec(void) -{ - struct timespec tv; - getnstimeofday(&tv); - return tv.tv_sec * NSEC_PER_SEC + tv.tv_nsec; -} -#else -#define current_nsec() jiffies_to_usecs(jiffies) -#endif - #define _sdp_prf(sk, s, _func, _line, format, arg...) ({ \ struct sdpprf_log *l = \ &sdpprf_log[sdpprf_log_count++ & (SDPPRF_LOG_SIZE - 1)]; \ @@ -81,7 +69,7 @@ static inline unsigned long long current_nsec(void) l->cpu = smp_processor_id(); \ l->skb = s; \ snprintf(l->msg, sizeof(l->msg) - 1, format, ## arg); \ - l->time = current_nsec(); \ + l->time = get_cycles(); \ l->func = _func; \ l->line = _line; \ preempt_enable(); \ diff --git a/drivers/infiniband/ulp/sdp/sdp_main.c b/drivers/infiniband/ulp/sdp/sdp_main.c index aefd386a8c356..d8ddce62afd1e 100644 --- a/drivers/infiniband/ulp/sdp/sdp_main.c +++ b/drivers/infiniband/ulp/sdp/sdp_main.c @@ -1373,17 +1373,6 @@ static inline cycles_t sdp_usec_to_cycles(int usecs) #endif } -static inline unsigned sdp_cycles_to_usecs(unsigned long c) -{ -#ifdef CONFIG_PPC - return c / tb_ticks_per_usec; -#elif defined(__ia64__) - return c / local_cpu_data->cyc_per_usec; -#else - return c * 1000 / cpu_khz; -#endif -} - static inline int poll_recv_cq(struct sock *sk) { cycles_t start = get_cycles(); diff --git a/drivers/infiniband/ulp/sdp/sdp_proc.c b/drivers/infiniband/ulp/sdp/sdp_proc.c index 9f94c2b4390fe..99006dd7e7278 100644 --- a/drivers/infiniband/ulp/sdp/sdp_proc.c +++ b/drivers/infiniband/ulp/sdp/sdp_proc.c @@ -393,7 +393,7 @@ static struct file_operations sdpstats_fops = { struct sdpprf_log sdpprf_log[SDPPRF_LOG_SIZE]; int sdpprf_log_count; -static unsigned long long start_t; +static cycles_t start_t; static inline void remove_newline(char *s) { @@ -407,19 +407,19 @@ static inline void remove_newline(char *s) static int sdpprf_show(struct seq_file *m, void *v) { struct sdpprf_log *l = v; - unsigned long nsec_rem, t; + unsigned long usec_rem, t; if (!sdpprf_log_count) { seq_printf(m, "No performance logs\n"); goto out; } - t = l->time - start_t; - nsec_rem = do_div(t, 1000000000); + t = sdp_cycles_to_usecs(l->time - start_t); + usec_rem = do_div(t, USEC_PER_SEC); remove_newline(l->msg); seq_printf(m, "%-6d: [%5lu.%06lu] %-50s - [%d{%d} %d:%d] " "skb: %p %s:%d\n", - l->idx, (unsigned long)t, nsec_rem/1000, + l->idx, t, usec_rem, l->msg, l->pid, l->cpu, l->sk_num, l->sk_dport, l->skb, l->func, l->line); out: