From: Amir Vadai Date: Thu, 14 Apr 2011 11:27:43 +0000 (+0300) Subject: sdp: Fix issues in sdpprf X-Git-Tag: v4.1.12-92~264^2~5^2~12 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=934ef0c4ab4b9ef67c7400500abd887e8d8ea7ce;p=users%2Fjedix%2Flinux-maple.git sdp: Fix issues in sdpprf Signed-off-by: Amir Vadai --- diff --git a/drivers/infiniband/ulp/sdp/sdp_bcopy.c b/drivers/infiniband/ulp/sdp/sdp_bcopy.c index 2304bebf4233..064d8c38a44b 100644 --- a/drivers/infiniband/ulp/sdp/sdp_bcopy.c +++ b/drivers/infiniband/ulp/sdp/sdp_bcopy.c @@ -95,7 +95,8 @@ void _dump_packet(const char *func, int line, struct sock *sk, char *str, break; } buf[len] = 0; - _sdp_printk(func, line, KERN_WARNING, sk, "%s: %s\n", str, buf); + if (sdp_data_debug_level & 0x1) + _sdp_printk(func, line, KERN_WARNING, sk, "%s: %s\n", str, buf); _sdp_prf(sk, skb, func, line, "%s: %s", str, buf); } #endif diff --git a/drivers/infiniband/ulp/sdp/sdp_dbg.h b/drivers/infiniband/ulp/sdp/sdp_dbg.h index d058e25e71c4..3526d676ea71 100644 --- a/drivers/infiniband/ulp/sdp/sdp_dbg.h +++ b/drivers/infiniband/ulp/sdp/sdp_dbg.h @@ -131,7 +131,6 @@ extern int sdp_data_debug_level; } while (0) #define SDP_DUMP_PACKET(sk, str, skb, h) \ do { \ - if (sdp_data_debug_level & 0x1) \ dump_packet(sk, str, skb, h); \ } while (0) #else diff --git a/drivers/infiniband/ulp/sdp/sdp_proc.c b/drivers/infiniband/ulp/sdp/sdp_proc.c index c0dbb6627e31..e502b37f8581 100644 --- a/drivers/infiniband/ulp/sdp/sdp_proc.c +++ b/drivers/infiniband/ulp/sdp/sdp_proc.c @@ -485,12 +485,23 @@ static inline void remove_newline(char *s) } } +static int inline sdpprf_first_idx(int count) +{ + return max(0, count - SDPPRF_LOG_SIZE) & (SDPPRF_LOG_SIZE - 1); +} + static int sdpprf_show(struct seq_file *m, void *v) { struct sdpprf_log *l = v; unsigned long usec_rem, t; + int count = atomic_read(&sdpprf_log_count); + int first = sdpprf_first_idx(count); + int idx = l - &sdpprf_log[0]; - if (!atomic_read(&sdpprf_log_count)) { + if (idx == first) + seq_printf(m, "Num log entries: %d\n", count); + + if (!count) { seq_printf(m, "No performance logs\n"); goto out; } @@ -509,25 +520,20 @@ out: static void *sdpprf_start(struct seq_file *p, loff_t *pos) { - int idx = *pos; + int count = atomic_read(&sdpprf_log_count); + int first = sdpprf_first_idx(count); struct sdpprf_log *l = NULL; - if (!*pos && !atomic_read(&sdpprf_log_count)) - return SEQ_START_TOKEN; - if (*pos >= atomic_read(&sdpprf_log_count)) - return NULL; + if (!count) + return SEQ_START_TOKEN; - if (atomic_read(&sdpprf_log_count) > 0 && - *pos >= MIN(atomic_read(&sdpprf_log_count), SDPPRF_LOG_SIZE)) + if (*pos >= MIN(count, SDPPRF_LOG_SIZE)) return NULL; - if (atomic_read(&sdpprf_log_count) > SDPPRF_LOG_SIZE) - idx = atomic_read(&sdpprf_log_count) - SDPPRF_LOG_SIZE; + l = &sdpprf_log[(first + *pos) & (SDPPRF_LOG_SIZE - 1)]; - l = &sdpprf_log[idx & (SDPPRF_LOG_SIZE - 1)]; + start_t = l->time; - if (*pos == 0) - start_t = l->time; return l; }