Skip to content

Commit 215acd0

Browse files
KAGA-KOKOTiejun Chen
authored and
Tiejun Chen
committed
md: raid5: Make raid5_percpu handling RT aware
__raid_run_ops() disables preemption with get_cpu() around the access to the raid5_percpu variables. That causes scheduling while atomic spews on RT. Serialize the access to the percpu data with a lock and keep the code preemptible. Reported-by: Udo van den Heuvel <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Udo van den Heuvel <[email protected]>
1 parent 83232bc commit 215acd0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/md/raid5.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,8 +2067,9 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
20672067
struct raid5_percpu *percpu;
20682068
unsigned long cpu;
20692069

2070-
cpu = get_cpu();
2070+
cpu = get_cpu_light();
20712071
percpu = per_cpu_ptr(conf->percpu, cpu);
2072+
spin_lock(&percpu->lock);
20722073
if (test_bit(STRIPE_OP_BIOFILL, &ops_request)) {
20732074
ops_run_biofill(sh);
20742075
overlap_clear++;
@@ -2127,7 +2128,8 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
21272128
if (test_and_clear_bit(R5_Overlap, &dev->flags))
21282129
wake_up(&sh->raid_conf->wait_for_overlap);
21292130
}
2130-
put_cpu();
2131+
spin_unlock(&percpu->lock);
2132+
put_cpu_light();
21312133
}
21322134

21332135
static void free_stripe(struct kmem_cache *sc, struct stripe_head *sh)
@@ -6796,6 +6798,7 @@ static int raid456_cpu_up_prepare(unsigned int cpu, struct hlist_node *node)
67966798
__func__, cpu);
67976799
return -ENOMEM;
67986800
}
6801+
spin_lock_init(&per_cpu_ptr(conf->percpu, cpu)->lock);
67996802
return 0;
68006803
}
68016804

@@ -6806,7 +6809,6 @@ static int raid5_alloc_percpu(struct r5conf *conf)
68066809
conf->percpu = alloc_percpu(struct raid5_percpu);
68076810
if (!conf->percpu)
68086811
return -ENOMEM;
6809-
68106812
err = cpuhp_state_add_instance(CPUHP_MD_RAID5_PREPARE, &conf->node);
68116813
if (!err) {
68126814
conf->scribble_disks = max(conf->raid_disks,

drivers/md/raid5.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,7 @@ struct r5conf {
624624
int recovery_disabled;
625625
/* per cpu variables */
626626
struct raid5_percpu {
627+
spinlock_t lock; /* Protection for -RT */
627628
struct page *spare_page; /* Used when checking P/Q in raid6 */
628629
struct flex_array *scribble; /* space for constructing buffer
629630
* lists and performing address

0 commit comments

Comments
 (0)