#define SDPPRF_LOG_SIZE 0x20000 /* must be a power of 2 */
extern struct sdpprf_log sdpprf_log[SDPPRF_LOG_SIZE];
-extern int sdpprf_log_count;
+extern atomic_t sdpprf_log_count;
#define _sdp_prf(sk, s, _func, _line, format, arg...) ({ \
+ int idx = atomic_add_return(1, &sdpprf_log_count); \
struct sdpprf_log *l = \
- &sdpprf_log[sdpprf_log_count++ & (SDPPRF_LOG_SIZE - 1)]; \
+ &sdpprf_log[idx & (SDPPRF_LOG_SIZE - 1)]; \
preempt_disable(); \
- l->idx = sdpprf_log_count - 1; \
+ l->idx = idx; \
l->pid = current->pid; \
l->sk_num = (sk) ? inet_sk(sk)->num : -1; \
l->sk_dport = (sk) ? ntohs(inet_sk(sk)->dport) : -1; \
#ifdef SDP_PROFILING
struct sdpprf_log sdpprf_log[SDPPRF_LOG_SIZE];
-int sdpprf_log_count;
+atomic_t sdpprf_log_count;
static cycles_t start_t;
struct sdpprf_log *l = v;
unsigned long usec_rem, t;
- if (!sdpprf_log_count) {
+ if (!atomic_read(&sdpprf_log_count)) {
seq_printf(m, "No performance logs\n");
goto out;
}
int idx = *pos;
if (!*pos) {
- if (!sdpprf_log_count)
+ if (!atomic_read(&sdpprf_log_count))
return SEQ_START_TOKEN;
}
- if (*pos >= MIN(sdpprf_log_count, SDPPRF_LOG_SIZE - 1))
+ if (*pos >= MIN(atomic_read(&sdpprf_log_count), SDPPRF_LOG_SIZE - 1))
return NULL;
- if (sdpprf_log_count >= SDPPRF_LOG_SIZE - 1) {
- int off = sdpprf_log_count & (SDPPRF_LOG_SIZE - 1);
+ if (atomic_read(&sdpprf_log_count) >= SDPPRF_LOG_SIZE - 1) {
+ int off = atomic_read(&sdpprf_log_count) & (SDPPRF_LOG_SIZE - 1);
idx = (idx + off) & (SDPPRF_LOG_SIZE - 1);
}
{
struct sdpprf_log *l = v;
- if (++*pos >= MIN(sdpprf_log_count, SDPPRF_LOG_SIZE - 1))
+ if (++*pos >= MIN(atomic_read(&sdpprf_log_count), SDPPRF_LOG_SIZE - 1))
return NULL;
++l;
static ssize_t sdpprf_write(struct file *file, const char __user *buf,
size_t count, loff_t *offs)
{
- sdpprf_log_count = 0;
+ atomic_set(&sdpprf_log_count, 0);
printk(KERN_INFO "Cleared sdpprf statistics\n");
return count;