Skip to content

Commit

Permalink
md: raid5: Make raid5_percpu handling RT aware
Browse files Browse the repository at this point in the history
__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 <udovdh@xs4all.nl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Udo van den Heuvel <udovdh@xs4all.nl>
  • Loading branch information
KAGA-KOKO authored and Tiejun Chen committed Feb 24, 2018
1 parent 42088c3 commit 774075f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -2067,8 +2067,9 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
struct raid5_percpu *percpu;
unsigned long cpu;

cpu = get_cpu();
cpu = get_cpu_light();
percpu = per_cpu_ptr(conf->percpu, cpu);
spin_lock(&percpu->lock);
if (test_bit(STRIPE_OP_BIOFILL, &ops_request)) {
ops_run_biofill(sh);
overlap_clear++;
Expand Down Expand Up @@ -2127,7 +2128,8 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request)
if (test_and_clear_bit(R5_Overlap, &dev->flags))
wake_up(&sh->raid_conf->wait_for_overlap);
}
put_cpu();
spin_unlock(&percpu->lock);
put_cpu_light();
}

static void free_stripe(struct kmem_cache *sc, struct stripe_head *sh)
Expand Down Expand Up @@ -6796,6 +6798,7 @@ static int raid456_cpu_up_prepare(unsigned int cpu, struct hlist_node *node)
__func__, cpu);
return -ENOMEM;
}
spin_lock_init(&per_cpu_ptr(conf->percpu, cpu)->lock);
return 0;
}

Expand All @@ -6806,7 +6809,6 @@ static int raid5_alloc_percpu(struct r5conf *conf)
conf->percpu = alloc_percpu(struct raid5_percpu);
if (!conf->percpu)
return -ENOMEM;

err = cpuhp_state_add_instance(CPUHP_MD_RAID5_PREPARE, &conf->node);
if (!err) {
conf->scribble_disks = max(conf->raid_disks,
Expand Down
1 change: 1 addition & 0 deletions drivers/md/raid5.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ struct r5conf {
int recovery_disabled;
/* per cpu variables */
struct raid5_percpu {
spinlock_t lock; /* Protection for -RT */
struct page *spare_page; /* Used when checking P/Q in raid6 */
struct flex_array *scribble; /* space for constructing buffer
* lists and performing address
Expand Down

0 comments on commit 774075f

Please sign in to comment.