Commit 112f158f authored by Mike Snitzer's avatar Mike Snitzer Committed by Jens Axboe

block: stop passing 'cpu' to all percpu stats methods

All of part_stat_* and related methods are used with preempt disabled,
so there is no need to pass cpu around to allow of them.  Just call
smp_processor_id() as needed.
Suggested-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent dbd3bbd2
...@@ -1668,11 +1668,12 @@ void generic_start_io_acct(struct request_queue *q, int op, ...@@ -1668,11 +1668,12 @@ void generic_start_io_acct(struct request_queue *q, int op,
unsigned long sectors, struct hd_struct *part) unsigned long sectors, struct hd_struct *part)
{ {
const int sgrp = op_stat_group(op); const int sgrp = op_stat_group(op);
int cpu = part_stat_lock();
part_round_stats(q, cpu, part); part_stat_lock();
part_stat_inc(cpu, part, ios[sgrp]);
part_stat_add(cpu, part, sectors[sgrp], sectors); part_round_stats(q, part);
part_stat_inc(part, ios[sgrp]);
part_stat_add(part, sectors[sgrp], sectors);
part_inc_in_flight(q, part, op_is_write(op)); part_inc_in_flight(q, part, op_is_write(op));
part_stat_unlock(); part_stat_unlock();
...@@ -1684,10 +1685,11 @@ void generic_end_io_acct(struct request_queue *q, int req_op, ...@@ -1684,10 +1685,11 @@ void generic_end_io_acct(struct request_queue *q, int req_op,
{ {
unsigned long duration = jiffies - start_time; unsigned long duration = jiffies - start_time;
const int sgrp = op_stat_group(req_op); const int sgrp = op_stat_group(req_op);
int cpu = part_stat_lock();
part_stat_add(cpu, part, nsecs[sgrp], jiffies_to_nsecs(duration)); part_stat_lock();
part_round_stats(q, cpu, part);
part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration));
part_round_stats(q, part);
part_dec_in_flight(q, part, op_is_write(req_op)); part_dec_in_flight(q, part, op_is_write(req_op));
part_stat_unlock(); part_stat_unlock();
......
...@@ -584,14 +584,14 @@ struct request *blk_get_request(struct request_queue *q, unsigned int op, ...@@ -584,14 +584,14 @@ struct request *blk_get_request(struct request_queue *q, unsigned int op,
} }
EXPORT_SYMBOL(blk_get_request); EXPORT_SYMBOL(blk_get_request);
static void part_round_stats_single(struct request_queue *q, int cpu, static void part_round_stats_single(struct request_queue *q,
struct hd_struct *part, unsigned long now, struct hd_struct *part, unsigned long now,
unsigned int inflight) unsigned int inflight)
{ {
if (inflight) { if (inflight) {
__part_stat_add(cpu, part, time_in_queue, __part_stat_add(part, time_in_queue,
inflight * (now - part->stamp)); inflight * (now - part->stamp));
__part_stat_add(cpu, part, io_ticks, (now - part->stamp)); __part_stat_add(part, io_ticks, (now - part->stamp));
} }
part->stamp = now; part->stamp = now;
} }
...@@ -599,7 +599,6 @@ static void part_round_stats_single(struct request_queue *q, int cpu, ...@@ -599,7 +599,6 @@ static void part_round_stats_single(struct request_queue *q, int cpu,
/** /**
* part_round_stats() - Round off the performance stats on a struct disk_stats. * part_round_stats() - Round off the performance stats on a struct disk_stats.
* @q: target block queue * @q: target block queue
* @cpu: cpu number for stats access
* @part: target partition * @part: target partition
* *
* The average IO queue length and utilisation statistics are maintained * The average IO queue length and utilisation statistics are maintained
...@@ -613,7 +612,7 @@ static void part_round_stats_single(struct request_queue *q, int cpu, ...@@ -613,7 +612,7 @@ static void part_round_stats_single(struct request_queue *q, int cpu,
* /proc/diskstats. This accounts immediately for all queue usage up to * /proc/diskstats. This accounts immediately for all queue usage up to
* the current jiffies and restarts the counters again. * the current jiffies and restarts the counters again.
*/ */
void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part) void part_round_stats(struct request_queue *q, struct hd_struct *part)
{ {
struct hd_struct *part2 = NULL; struct hd_struct *part2 = NULL;
unsigned long now = jiffies; unsigned long now = jiffies;
...@@ -635,9 +634,9 @@ void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part) ...@@ -635,9 +634,9 @@ void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part)
part_in_flight(q, part, inflight); part_in_flight(q, part, inflight);
if (stats & 2) if (stats & 2)
part_round_stats_single(q, cpu, part2, now, inflight[1]); part_round_stats_single(q, part2, now, inflight[1]);
if (stats & 1) if (stats & 1)
part_round_stats_single(q, cpu, part, now, inflight[0]); part_round_stats_single(q, part, now, inflight[0]);
} }
EXPORT_SYMBOL_GPL(part_round_stats); EXPORT_SYMBOL_GPL(part_round_stats);
...@@ -1362,11 +1361,10 @@ void blk_account_io_completion(struct request *req, unsigned int bytes) ...@@ -1362,11 +1361,10 @@ void blk_account_io_completion(struct request *req, unsigned int bytes)
if (blk_do_io_stat(req)) { if (blk_do_io_stat(req)) {
const int sgrp = op_stat_group(req_op(req)); const int sgrp = op_stat_group(req_op(req));
struct hd_struct *part; struct hd_struct *part;
int cpu;
cpu = part_stat_lock(); part_stat_lock();
part = req->part; part = req->part;
part_stat_add(cpu, part, sectors[sgrp], bytes >> 9); part_stat_add(part, sectors[sgrp], bytes >> 9);
part_stat_unlock(); part_stat_unlock();
} }
} }
...@@ -1381,14 +1379,13 @@ void blk_account_io_done(struct request *req, u64 now) ...@@ -1381,14 +1379,13 @@ void blk_account_io_done(struct request *req, u64 now)
if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) { if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) {
const int sgrp = op_stat_group(req_op(req)); const int sgrp = op_stat_group(req_op(req));
struct hd_struct *part; struct hd_struct *part;
int cpu;
cpu = part_stat_lock(); part_stat_lock();
part = req->part; part = req->part;
part_stat_inc(cpu, part, ios[sgrp]); part_stat_inc(part, ios[sgrp]);
part_stat_add(cpu, part, nsecs[sgrp], now - req->start_time_ns); part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
part_round_stats(req->q, cpu, part); part_round_stats(req->q, part);
part_dec_in_flight(req->q, part, rq_data_dir(req)); part_dec_in_flight(req->q, part, rq_data_dir(req));
hd_struct_put(part); hd_struct_put(part);
...@@ -1400,16 +1397,15 @@ void blk_account_io_start(struct request *rq, bool new_io) ...@@ -1400,16 +1397,15 @@ void blk_account_io_start(struct request *rq, bool new_io)
{ {
struct hd_struct *part; struct hd_struct *part;
int rw = rq_data_dir(rq); int rw = rq_data_dir(rq);
int cpu;
if (!blk_do_io_stat(rq)) if (!blk_do_io_stat(rq))
return; return;
cpu = part_stat_lock(); part_stat_lock();
if (!new_io) { if (!new_io) {
part = rq->part; part = rq->part;
part_stat_inc(cpu, part, merges[rw]); part_stat_inc(part, merges[rw]);
} else { } else {
part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
if (!hd_struct_try_get(part)) { if (!hd_struct_try_get(part)) {
...@@ -1424,7 +1420,7 @@ void blk_account_io_start(struct request *rq, bool new_io) ...@@ -1424,7 +1420,7 @@ void blk_account_io_start(struct request *rq, bool new_io)
part = &rq->rq_disk->part0; part = &rq->rq_disk->part0;
hd_struct_get(part); hd_struct_get(part);
} }
part_round_stats(rq->q, cpu, part); part_round_stats(rq->q, part);
part_inc_in_flight(rq->q, part, rw); part_inc_in_flight(rq->q, part, rw);
rq->part = part; rq->part = part;
} }
......
...@@ -685,12 +685,11 @@ static void blk_account_io_merge(struct request *req) ...@@ -685,12 +685,11 @@ static void blk_account_io_merge(struct request *req)
{ {
if (blk_do_io_stat(req)) { if (blk_do_io_stat(req)) {
struct hd_struct *part; struct hd_struct *part;
int cpu;
cpu = part_stat_lock(); part_stat_lock();
part = req->part; part = req->part;
part_round_stats(req->q, cpu, part); part_round_stats(req->q, part);
part_dec_in_flight(req->q, part, rq_data_dir(req)); part_dec_in_flight(req->q, part, rq_data_dir(req));
hd_struct_put(part); hd_struct_put(part);
......
...@@ -1326,7 +1326,6 @@ static int diskstats_show(struct seq_file *seqf, void *v) ...@@ -1326,7 +1326,6 @@ static int diskstats_show(struct seq_file *seqf, void *v)
struct hd_struct *hd; struct hd_struct *hd;
char buf[BDEVNAME_SIZE]; char buf[BDEVNAME_SIZE];
unsigned int inflight[2]; unsigned int inflight[2];
int cpu;
/* /*
if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next) if (&disk_to_dev(gp)->kobj.entry == block_class.devices.next)
...@@ -1338,8 +1337,8 @@ static int diskstats_show(struct seq_file *seqf, void *v) ...@@ -1338,8 +1337,8 @@ static int diskstats_show(struct seq_file *seqf, void *v)
disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0); disk_part_iter_init(&piter, gp, DISK_PITER_INCL_EMPTY_PART0);
while ((hd = disk_part_iter_next(&piter))) { while ((hd = disk_part_iter_next(&piter))) {
cpu = part_stat_lock(); part_stat_lock();
part_round_stats(gp->queue, cpu, hd); part_round_stats(gp->queue, hd);
part_stat_unlock(); part_stat_unlock();
part_in_flight(gp->queue, hd, inflight); part_in_flight(gp->queue, hd, inflight);
seq_printf(seqf, "%4d %7d %s " seq_printf(seqf, "%4d %7d %s "
......
...@@ -121,10 +121,9 @@ ssize_t part_stat_show(struct device *dev, ...@@ -121,10 +121,9 @@ ssize_t part_stat_show(struct device *dev,
struct hd_struct *p = dev_to_part(dev); struct hd_struct *p = dev_to_part(dev);
struct request_queue *q = part_to_disk(p)->queue; struct request_queue *q = part_to_disk(p)->queue;
unsigned int inflight[2]; unsigned int inflight[2];
int cpu;
cpu = part_stat_lock(); part_stat_lock();
part_round_stats(q, cpu, p); part_round_stats(q, p);
part_stat_unlock(); part_stat_unlock();
part_in_flight(q, p, inflight); part_in_flight(q, p, inflight);
return sprintf(buf, return sprintf(buf,
......
...@@ -334,7 +334,6 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio) ...@@ -334,7 +334,6 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
const int sgrp = op_stat_group(bio_op(bio)); const int sgrp = op_stat_group(bio_op(bio));
struct mddev *mddev = q->queuedata; struct mddev *mddev = q->queuedata;
unsigned int sectors; unsigned int sectors;
int cpu;
blk_queue_split(q, &bio); blk_queue_split(q, &bio);
...@@ -359,9 +358,9 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio) ...@@ -359,9 +358,9 @@ static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio)
md_handle_request(mddev, bio); md_handle_request(mddev, bio);
cpu = part_stat_lock(); part_stat_lock();
part_stat_inc(cpu, &mddev->gendisk->part0, ios[sgrp]); part_stat_inc(&mddev->gendisk->part0, ios[sgrp]);
part_stat_add(cpu, &mddev->gendisk->part0, sectors[sgrp], sectors); part_stat_add(&mddev->gendisk->part0, sectors[sgrp], sectors);
part_stat_unlock(); part_stat_unlock();
return BLK_QC_T_NONE; return BLK_QC_T_NONE;
......
...@@ -295,8 +295,8 @@ extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, ...@@ -295,8 +295,8 @@ extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk,
#define part_stat_lock() ({ rcu_read_lock(); get_cpu(); }) #define part_stat_lock() ({ rcu_read_lock(); get_cpu(); })
#define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0) #define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0)
#define __part_stat_add(cpu, part, field, addnd) \ #define __part_stat_add(part, field, addnd) \
(per_cpu_ptr((part)->dkstats, (cpu))->field += (addnd)) (per_cpu_ptr((part)->dkstats, smp_processor_id())->field += (addnd))
#define part_stat_read(part, field) \ #define part_stat_read(part, field) \
({ \ ({ \
...@@ -333,7 +333,7 @@ static inline void free_part_stats(struct hd_struct *part) ...@@ -333,7 +333,7 @@ static inline void free_part_stats(struct hd_struct *part)
#define part_stat_lock() ({ rcu_read_lock(); 0; }) #define part_stat_lock() ({ rcu_read_lock(); 0; })
#define part_stat_unlock() rcu_read_unlock() #define part_stat_unlock() rcu_read_unlock()
#define __part_stat_add(cpu, part, field, addnd) \ #define __part_stat_add(part, field, addnd) \
((part)->dkstats.field += addnd) ((part)->dkstats.field += addnd)
#define part_stat_read(part, field) ((part)->dkstats.field) #define part_stat_read(part, field) ((part)->dkstats.field)
...@@ -362,19 +362,19 @@ static inline void free_part_stats(struct hd_struct *part) ...@@ -362,19 +362,19 @@ static inline void free_part_stats(struct hd_struct *part)
part_stat_read(part, field[STAT_WRITE]) + \ part_stat_read(part, field[STAT_WRITE]) + \
part_stat_read(part, field[STAT_DISCARD])) part_stat_read(part, field[STAT_DISCARD]))
#define part_stat_add(cpu, part, field, addnd) do { \ #define part_stat_add(part, field, addnd) do { \
__part_stat_add((cpu), (part), field, addnd); \ __part_stat_add((part), field, addnd); \
if ((part)->partno) \ if ((part)->partno) \
__part_stat_add((cpu), &part_to_disk((part))->part0, \ __part_stat_add(&part_to_disk((part))->part0, \
field, addnd); \ field, addnd); \
} while (0) } while (0)
#define part_stat_dec(cpu, gendiskp, field) \ #define part_stat_dec(gendiskp, field) \
part_stat_add(cpu, gendiskp, field, -1) part_stat_add(gendiskp, field, -1)
#define part_stat_inc(cpu, gendiskp, field) \ #define part_stat_inc(gendiskp, field) \
part_stat_add(cpu, gendiskp, field, 1) part_stat_add(gendiskp, field, 1)
#define part_stat_sub(cpu, gendiskp, field, subnd) \ #define part_stat_sub(gendiskp, field, subnd) \
part_stat_add(cpu, gendiskp, field, -subnd) part_stat_add(gendiskp, field, -subnd)
void part_in_flight(struct request_queue *q, struct hd_struct *part, void part_in_flight(struct request_queue *q, struct hd_struct *part,
unsigned int inflight[2]); unsigned int inflight[2]);
...@@ -399,7 +399,7 @@ static inline void free_part_info(struct hd_struct *part) ...@@ -399,7 +399,7 @@ static inline void free_part_info(struct hd_struct *part)
} }
/* block/blk-core.c */ /* block/blk-core.c */
extern void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part); extern void part_round_stats(struct request_queue *q, struct hd_struct *part);
/* block/genhd.c */ /* block/genhd.c */
extern void device_add_disk(struct device *parent, struct gendisk *disk, extern void device_add_disk(struct device *parent, struct gendisk *disk,
......
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