Skip to content

Commit

Permalink
Try to keep rate and spinlock in the same cacheline
Browse files Browse the repository at this point in the history
  • Loading branch information
jvimal committed Feb 15, 2012
1 parent e533271 commit 49a66f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rl.c
Expand Up @@ -66,7 +66,7 @@ void iso_rl_show(struct iso_rl *rl, struct seq_file *s) {
struct iso_rl_queue *q;
int i, first = 1;

seq_printf(s, "ip %x rate %llu total_tokens %llu last %llx %p\n",
seq_printf(s, "ip %x rate %u total_tokens %llu last %llx %p\n",
rl->ip, rl->rate, rl->total_tokens, *(u64 *)&rl->last_update_time, rl);

for_each_online_cpu(i) {
Expand Down Expand Up @@ -98,7 +98,7 @@ inline void iso_rl_clock(struct iso_rl *rl) {
rl->total_tokens += (rl->rate * us) >> 3;

/* This is needed if we have TSO. MIN_BURST_BYTES will be ~64K */
cap = max((rl->rate * ISO_MAX_BURST_TIME_US) >> 3, (u64)ISO_MIN_BURST_BYTES);
cap = max((rl->rate * ISO_MAX_BURST_TIME_US) >> 3, (u32)ISO_MIN_BURST_BYTES);
rl->total_tokens = min(cap, rl->total_tokens);

rl->last_update_time = now;
Expand Down
6 changes: 4 additions & 2 deletions rl.h
Expand Up @@ -46,14 +46,16 @@ struct iso_rl_queue {
};

struct iso_rl {
/* Try to keep rate and spinlock in the same cacheline */
u32 rate;
spinlock_t spinlock;

__le32 ip;
u64 rate;
u64 total_tokens;
u64 accum_xmit;
u64 accum_enqueued;

ktime_t last_update_time;
spinlock_t spinlock;

struct iso_rl_queue __percpu *queue;
struct hlist_node hash_node;
Expand Down

0 comments on commit 49a66f0

Please sign in to comment.