Skip to content

Commit e39b536

Browse files
Mikulas Patockagregkh
authored andcommitted
dm stats: add cond_resched when looping over entries
commit bfe2b01 upstream. dm-stats can be used with a very large number of entries (it is only limited by 1/4 of total system memory), so add rescheduling points to the loops that iterate over the entries. Cc: [email protected] Signed-off-by: Mikulas Patocka <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4617778 commit e39b536

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/md/dm-stats.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ void dm_stats_cleanup(struct dm_stats *stats)
224224
atomic_read(&shared->in_flight[READ]),
225225
atomic_read(&shared->in_flight[WRITE]));
226226
}
227+
cond_resched();
227228
}
228229
dm_stat_free(&s->rcu_head);
229230
}
@@ -313,6 +314,7 @@ static int dm_stats_create(struct dm_stats *stats, sector_t start, sector_t end,
313314
for (ni = 0; ni < n_entries; ni++) {
314315
atomic_set(&s->stat_shared[ni].in_flight[READ], 0);
315316
atomic_set(&s->stat_shared[ni].in_flight[WRITE], 0);
317+
cond_resched();
316318
}
317319

318320
if (s->n_histogram_entries) {
@@ -325,6 +327,7 @@ static int dm_stats_create(struct dm_stats *stats, sector_t start, sector_t end,
325327
for (ni = 0; ni < n_entries; ni++) {
326328
s->stat_shared[ni].tmp.histogram = hi;
327329
hi += s->n_histogram_entries + 1;
330+
cond_resched();
328331
}
329332
}
330333

@@ -345,6 +348,7 @@ static int dm_stats_create(struct dm_stats *stats, sector_t start, sector_t end,
345348
for (ni = 0; ni < n_entries; ni++) {
346349
p[ni].histogram = hi;
347350
hi += s->n_histogram_entries + 1;
351+
cond_resched();
348352
}
349353
}
350354
}
@@ -474,6 +478,7 @@ static int dm_stats_list(struct dm_stats *stats, const char *program,
474478
}
475479
DMEMIT("\n");
476480
}
481+
cond_resched();
477482
}
478483
mutex_unlock(&stats->mutex);
479484

@@ -750,6 +755,7 @@ static void __dm_stat_clear(struct dm_stat *s, size_t idx_start, size_t idx_end,
750755
local_irq_enable();
751756
}
752757
}
758+
cond_resched();
753759
}
754760
}
755761

@@ -865,6 +871,8 @@ static int dm_stats_print(struct dm_stats *stats, int id,
865871

866872
if (unlikely(sz + 1 >= maxlen))
867873
goto buffer_overflow;
874+
875+
cond_resched();
868876
}
869877

870878
if (clear)

0 commit comments

Comments
 (0)