Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 89381
b: refs/heads/master
c: 6ee4752
h: refs/heads/master
i:
  89379: cb683df
v: v3
  • Loading branch information
David Chinner authored and Lachlan McIlroy committed Apr 18, 2008
1 parent 19ec836 commit 7824ff9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 44d814ced4cffbfe6a775c5bb8b941a6e734e7d9
refs/heads/master: 6ee4752ffe782be6e86bea1403a2fe0f682aa71a
21 changes: 8 additions & 13 deletions trunk/fs/xfs/support/ktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ktrace_alloc(int nentries, unsigned int __nocast sleep)

ktp->kt_entries = ktep;
ktp->kt_nentries = nentries;
ktp->kt_index = 0;
atomic_set(&ktp->kt_index, 0);
ktp->kt_rollover = 0;
return ktp;
}
Expand Down Expand Up @@ -151,8 +151,6 @@ ktrace_enter(
void *val14,
void *val15)
{
static DEFINE_SPINLOCK(wrap_lock);
unsigned long flags;
int index;
ktrace_entry_t *ktep;

Expand All @@ -161,12 +159,8 @@ ktrace_enter(
/*
* Grab an entry by pushing the index up to the next one.
*/
spin_lock_irqsave(&wrap_lock, flags);
index = ktp->kt_index;
if (++ktp->kt_index == ktp->kt_nentries)
ktp->kt_index = 0;
spin_unlock_irqrestore(&wrap_lock, flags);

index = atomic_add_return(1, &ktp->kt_index);
index = (index - 1) % ktp->kt_nentries;
if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
ktp->kt_rollover = 1;

Expand Down Expand Up @@ -199,11 +193,12 @@ int
ktrace_nentries(
ktrace_t *ktp)
{
if (ktp == NULL) {
int index;
if (ktp == NULL)
return 0;
}

return (ktp->kt_rollover ? ktp->kt_nentries : ktp->kt_index);
index = atomic_read(&ktp->kt_index) % ktp->kt_nentries;
return (ktp->kt_rollover ? ktp->kt_nentries : index);
}

/*
Expand All @@ -228,7 +223,7 @@ ktrace_first(ktrace_t *ktp, ktrace_snap_t *ktsp)
int nentries;

if (ktp->kt_rollover)
index = ktp->kt_index;
index = atomic_read(&ktp->kt_index) % ktp->kt_nentries;
else
index = 0;

Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/xfs/support/ktrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct ktrace_entry {
*/
typedef struct ktrace {
int kt_nentries; /* number of entries in trace buf */
int kt_index; /* current index in entries */
atomic_t kt_index; /* current index in entries */
int kt_rollover;
ktrace_entry_t *kt_entries; /* buffer of entries */
} ktrace_t;
Expand Down

0 comments on commit 7824ff9

Please sign in to comment.