Skip to content

Commit b75ca67

Browse files
KAGA-KOKOrostedt
authored andcommitted
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 3f2ef2c commit b75ca67

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)
@@ -6781,6 +6783,7 @@ static int raid456_cpu_up_prepare(unsigned int cpu, struct hlist_node *node)
67816783
__func__, cpu);
67826784
return -ENOMEM;
67836785
}
6786+
spin_lock_init(&per_cpu_ptr(conf->percpu, cpu)->lock);
67846787
return 0;
67856788
}
67866789

@@ -6791,7 +6794,6 @@ static int raid5_alloc_percpu(struct r5conf *conf)
67916794
conf->percpu = alloc_percpu(struct raid5_percpu);
67926795
if (!conf->percpu)
67936796
return -ENOMEM;
6794-
67956797
err = cpuhp_state_add_instance(CPUHP_MD_RAID5_PREPARE, &conf->node);
67966798
if (!err) {
67976799
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)