Commit 35ba8f7083e87602b695d6eaca38a6464d5b74db

Authored by David Woodhouse
Committed by Jens Axboe
1 parent 27b29e86bf

blktrace: simplify flags handling in __blk_add_trace

Let the compiler see what's going on, and it can all get a lot simpler.
On PPC64 this reduces the size of the code calculating these bits by
about 60%. On x86_64 it's less of a win -- only 40%.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>

Showing 1 changed file with 8 additions and 30 deletions Side-by-side Diff

... ... @@ -111,33 +111,11 @@
111 111 */
112 112 static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK_TC_WRITE) };
113 113  
114   -/*
115   - * Bio action bits of interest
116   - */
117   -static u32 bio_act[17] __read_mostly = {
118   - [1] = BLK_TC_ACT(BLK_TC_BARRIER),
119   - [2] = BLK_TC_ACT(BLK_TC_SYNC),
120   - [4] = BLK_TC_ACT(BLK_TC_AHEAD),
121   - [8] = BLK_TC_ACT(BLK_TC_META),
122   - [16] = BLK_TC_ACT(BLK_TC_DISCARD)
123   -};
  114 +/* The ilog2() calls fall out because they're constant */
  115 +#define MASK_TC_BIT(rw, __name) ( (rw & (1 << BIO_RW_ ## __name)) << \
  116 + (ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - BIO_RW_ ## __name) )
124 117  
125 118 /*
126   - * More could be added as needed, taking care to increment the decrementer
127   - * to get correct indexing
128   - */
129   -#define trace_barrier_bit(rw) \
130   - (((rw) & (1 << BIO_RW_BARRIER)) >> (BIO_RW_BARRIER - 0))
131   -#define trace_sync_bit(rw) \
132   - (((rw) & (1 << BIO_RW_SYNC)) >> (BIO_RW_SYNC - 1))
133   -#define trace_ahead_bit(rw) \
134   - (((rw) & (1 << BIO_RW_AHEAD)) << (2 - BIO_RW_AHEAD))
135   -#define trace_meta_bit(rw) \
136   - (((rw) & (1 << BIO_RW_META)) >> (BIO_RW_META - 3))
137   -#define trace_discard_bit(rw) \
138   - (((rw) & (1 << BIO_RW_DISCARD)) >> (BIO_RW_DISCARD - 4))
139   -
140   -/*
141 119 * The worker for the various blk_add_trace*() types. Fills out a
142 120 * blk_io_trace structure and places it in a per-cpu subbuffer.
143 121 */
... ... @@ -155,11 +133,11 @@
155 133 return;
156 134  
157 135 what |= ddir_act[rw & WRITE];
158   - what |= bio_act[trace_barrier_bit(rw)];
159   - what |= bio_act[trace_sync_bit(rw)];
160   - what |= bio_act[trace_ahead_bit(rw)];
161   - what |= bio_act[trace_meta_bit(rw)];
162   - what |= bio_act[trace_discard_bit(rw)];
  136 + what |= MASK_TC_BIT(rw, BARRIER);
  137 + what |= MASK_TC_BIT(rw, SYNC);
  138 + what |= MASK_TC_BIT(rw, AHEAD);
  139 + what |= MASK_TC_BIT(rw, META);
  140 + what |= MASK_TC_BIT(rw, DISCARD);
163 141  
164 142 pid = tsk->pid;
165 143 if (unlikely(act_log_check(bt, what, sector, pid)))