Skip to content

Commit 67b7b64

Browse files
a-darwishPeter Zijlstra
authored andcommitted
iocost: Use sequence counter with associated spinlock
A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 0a87b25 commit 67b7b64

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

block/blk-iocost.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ struct ioc {
406406
enum ioc_running running;
407407
atomic64_t vtime_rate;
408408

409-
seqcount_t period_seqcount;
409+
seqcount_spinlock_t period_seqcount;
410410
u32 period_at; /* wallclock starttime */
411411
u64 period_at_vtime; /* vtime starttime */
412412

@@ -873,7 +873,6 @@ static void ioc_now(struct ioc *ioc, struct ioc_now *now)
873873

874874
static void ioc_start_period(struct ioc *ioc, struct ioc_now *now)
875875
{
876-
lockdep_assert_held(&ioc->lock);
877876
WARN_ON_ONCE(ioc->running != IOC_RUNNING);
878877

879878
write_seqcount_begin(&ioc->period_seqcount);
@@ -2001,7 +2000,7 @@ static int blk_iocost_init(struct request_queue *q)
20012000

20022001
ioc->running = IOC_IDLE;
20032002
atomic64_set(&ioc->vtime_rate, VTIME_PER_USEC);
2004-
seqcount_init(&ioc->period_seqcount);
2003+
seqcount_spinlock_init(&ioc->period_seqcount, &ioc->lock);
20052004
ioc->period_at = ktime_to_us(ktime_get());
20062005
atomic64_set(&ioc->cur_period, 0);
20072006
atomic_set(&ioc->hweight_gen, 0);

0 commit comments

Comments
 (0)