block: always use a percpu variable for disk stats
percpu variables have a perfectly fine working stub implementation for UP kernels, so use that. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:

committed by
Jens Axboe

parent
9123bf6f21
commit
58d4f14fc3
@@ -4,19 +4,23 @@
|
||||
|
||||
#include <linux/genhd.h>
|
||||
|
||||
struct disk_stats {
|
||||
u64 nsecs[NR_STAT_GROUPS];
|
||||
unsigned long sectors[NR_STAT_GROUPS];
|
||||
unsigned long ios[NR_STAT_GROUPS];
|
||||
unsigned long merges[NR_STAT_GROUPS];
|
||||
unsigned long io_ticks;
|
||||
local_t in_flight[2];
|
||||
};
|
||||
|
||||
/*
|
||||
* Macros to operate on percpu disk statistics:
|
||||
*
|
||||
* {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters
|
||||
* and should be called between disk_stat_lock() and
|
||||
* disk_stat_unlock().
|
||||
* {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters and should
|
||||
* be called between disk_stat_lock() and disk_stat_unlock().
|
||||
*
|
||||
* part_stat_read() can be called at any time.
|
||||
*
|
||||
* part_stat_{add|set_all}() and {init|free}_part_stats are for
|
||||
* internal use only.
|
||||
*/
|
||||
#ifdef CONFIG_SMP
|
||||
#define part_stat_lock() ({ rcu_read_lock(); get_cpu(); })
|
||||
#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
|
||||
|
||||
@@ -44,43 +48,6 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
|
||||
sizeof(struct disk_stats));
|
||||
}
|
||||
|
||||
static inline int init_part_stats(struct hd_struct *part)
|
||||
{
|
||||
part->dkstats = alloc_percpu(struct disk_stats);
|
||||
if (!part->dkstats)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void free_part_stats(struct hd_struct *part)
|
||||
{
|
||||
free_percpu(part->dkstats);
|
||||
}
|
||||
|
||||
#else /* !CONFIG_SMP */
|
||||
#define part_stat_lock() ({ rcu_read_lock(); 0; })
|
||||
#define part_stat_unlock() rcu_read_unlock()
|
||||
|
||||
#define part_stat_get(part, field) ((part)->dkstats.field)
|
||||
#define part_stat_get_cpu(part, field, cpu) part_stat_get(part, field)
|
||||
#define part_stat_read(part, field) part_stat_get(part, field)
|
||||
|
||||
static inline void part_stat_set_all(struct hd_struct *part, int value)
|
||||
{
|
||||
memset(&part->dkstats, value, sizeof(struct disk_stats));
|
||||
}
|
||||
|
||||
static inline int init_part_stats(struct hd_struct *part)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline void free_part_stats(struct hd_struct *part)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
#define part_stat_read_accum(part, field) \
|
||||
(part_stat_read(part, field[STAT_READ]) + \
|
||||
part_stat_read(part, field[STAT_WRITE]) + \
|
||||
|
Reference in New Issue
Block a user