提交 fa23f552 编写于 作者: M Mikulas Patocka 提交者: Xie XiuQi

block: switch to per-cpu in-flight counters

mainline inclusion
from mainline-5.0-rc1
commit 1226b8dd
category: bugfix
bugzilla: 18695
CVE: NA

---------------------------

Now when part_round_stats is gone, we can switch to per-cpu in-flight
counters.

We use the local-atomic type local_t, so that if part_inc_in_flight or
part_dec_in_flight is reentrantly called from an interrupt, the value will
be correct.

The other counters could be corrupted due to reentrant interrupt, but the
corruption only results in slight counter skew - the in_flight counter
must be exact, so it needs local_t.

Conflicts:
  include/linux/genhd.h
Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: NZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7f9f8fb1
...@@ -308,6 +308,12 @@ extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, ...@@ -308,6 +308,12 @@ 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_get_cpu(part, field, cpu) \
(per_cpu_ptr((part)->dkstats, (cpu))->field)
#define part_stat_get(part, field) \
part_stat_get_cpu(part, field, smp_processor_id())
#define __part_stat_add(cpu, part, field, addnd) \ #define __part_stat_add(cpu, part, field, addnd) \
(per_cpu_ptr((part)->dkstats, (cpu))->field += (addnd)) (per_cpu_ptr((part)->dkstats, (cpu))->field += (addnd))
...@@ -346,6 +352,8 @@ static inline void free_part_stats(struct hd_struct *part) ...@@ -346,6 +352,8 @@ 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_get(part, field) ((part)->dkstats.field)
#define __part_stat_add(cpu, part, field, addnd) \ #define __part_stat_add(cpu, part, field, addnd) \
((part)->dkstats.field += addnd) ((part)->dkstats.field += addnd)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册