Commit 6be11c82 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] fix diskstats_show() accounting with PREEMPT

There is another (minor) bug that the smp_processor_id() debugger
unearthed: diskstats_show() could do a disk_round_stats() ->
disk_stat_add() with preemption enabled - possibly resulting in losing
statistics updates.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cdb14b0c
...@@ -365,7 +365,9 @@ static ssize_t disk_size_read(struct gendisk * disk, char *page) ...@@ -365,7 +365,9 @@ static ssize_t disk_size_read(struct gendisk * disk, char *page)
static ssize_t disk_stats_read(struct gendisk * disk, char *page) static ssize_t disk_stats_read(struct gendisk * disk, char *page)
{ {
preempt_disable();
disk_round_stats(disk); disk_round_stats(disk);
preempt_enable();
return sprintf(page, return sprintf(page,
"%8u %8u %8llu %8u " "%8u %8u %8llu %8u "
"%8u %8u %8llu %8u " "%8u %8u %8llu %8u "
...@@ -494,7 +496,9 @@ static int diskstats_show(struct seq_file *s, void *v) ...@@ -494,7 +496,9 @@ static int diskstats_show(struct seq_file *s, void *v)
"\n\n"); "\n\n");
*/ */
preempt_disable();
disk_round_stats(gp); disk_round_stats(gp);
preempt_enable();
seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n", seq_printf(s, "%4d %4d %s %u %u %llu %u %u %u %llu %u %u %u %u\n",
gp->major, n + gp->first_minor, disk_name(gp, n, buf), gp->major, n + gp->first_minor, disk_name(gp, n, buf),
disk_stat_read(gp, reads), disk_stat_read(gp, read_merges), disk_stat_read(gp, reads), disk_stat_read(gp, read_merges),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment