]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sdp: Fix issues in sdpprf
authorAmir Vadai <amirv@mellanox.co.il>
Thu, 14 Apr 2011 11:27:43 +0000 (14:27 +0300)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:05:50 +0000 (05:05 -0700)
Signed-off-by: Amir Vadai <amirv@mellanox.co.il>
drivers/infiniband/ulp/sdp/sdp_bcopy.c
drivers/infiniband/ulp/sdp/sdp_dbg.h
drivers/infiniband/ulp/sdp/sdp_proc.c

index 2304bebf42331ad483177872d77b24a7afb410ed..064d8c38a44b0e8b98678d996c172a742d4d424b 100644 (file)
@@ -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
index d058e25e71c4c423c2fbd8fca20c64d72e2d8068..3526d676ea7108fdfb14283498cfe0824ed5cffb 100644 (file)
@@ -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
index c0dbb6627e31ebdca2979a7810b5f83e87830c96..e502b37f85815bdc6ba1019f41e4793066ae4b07 100644 (file)
@@ -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;
 }