diff mbox series

[1/2] xen/sched: fix locking in a653sched_free_vdata()

Message ID 20190925070503.13850-2-jgross@suse.com (mailing list archive)
State New, archived
Headers show
Series xen/sched: fix freeing of per-vcpu data | expand

Commit Message

Jürgen Groß Sept. 25, 2019, 7:05 a.m. UTC
The arinc653 scheduler's free_vdata() function is missing proper
locking: as it is modifying the scheduler's private vcpu list it needs
to take the scheduler lock during that operation.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched_arinc653.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Jan Beulich Sept. 25, 2019, 8:41 a.m. UTC | #1
On 25.09.2019 09:05, Juergen Gross wrote:
> The arinc653 scheduler's free_vdata() function is missing proper
> locking: as it is modifying the scheduler's private vcpu list it needs
> to take the scheduler lock during that operation.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>
(and maybe also Suspected-by)
Dario Faggioli Sept. 25, 2019, 10:59 a.m. UTC | #2
On Wed, 2019-09-25 at 09:05 +0200, Juergen Gross wrote:
> The arinc653 scheduler's free_vdata() function is missing proper
> locking: as it is modifying the scheduler's private vcpu list it
> needs
> to take the scheduler lock during that operation.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com>

Regards
Jürgen Groß Sept. 27, 2019, 7:23 a.m. UTC | #3
On 25.09.19 12:59, Dario Faggioli wrote:
> On Wed, 2019-09-25 at 09:05 +0200, Juergen Gross wrote:
>> The arinc653 scheduler's free_vdata() function is missing proper
>> locking: as it is modifying the scheduler's private vcpu list it
>> needs
>> to take the scheduler lock during that operation.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>
> Reviewed-by: Dario Faggioli <dfaggioli@suse.com>

As this patch is a prerequisite for my core scheduling series I'd really
appreciate if it could be committed rather sooner than later.

Josh, Robert, could you please comment?

Or is Dario's R-b (and Jan's as well) enough in this rather simple and
obvious case?


Juergen
Jan Beulich Sept. 27, 2019, 8:20 a.m. UTC | #4
On 27.09.2019 09:23, Jürgen Groß  wrote:
> On 25.09.19 12:59, Dario Faggioli wrote:
>> On Wed, 2019-09-25 at 09:05 +0200, Juergen Gross wrote:
>>> The arinc653 scheduler's free_vdata() function is missing proper
>>> locking: as it is modifying the scheduler's private vcpu list it
>>> needs
>>> to take the scheduler lock during that operation.
>>>
>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>
>> Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
> 
> As this patch is a prerequisite for my core scheduling series I'd really
> appreciate if it could be committed rather sooner than later.
> 
> Josh, Robert, could you please comment?
> 
> Or is Dario's R-b (and Jan's as well) enough in this rather simple and
> obvious case?

I was more or less planning to time out on waiting for their ack
later today.

Jan
Jürgen Groß Sept. 27, 2019, 8:27 a.m. UTC | #5
On 27.09.19 10:20, Jan Beulich wrote:
> On 27.09.2019 09:23, Jürgen Groß  wrote:
>> On 25.09.19 12:59, Dario Faggioli wrote:
>>> On Wed, 2019-09-25 at 09:05 +0200, Juergen Gross wrote:
>>>> The arinc653 scheduler's free_vdata() function is missing proper
>>>> locking: as it is modifying the scheduler's private vcpu list it
>>>> needs
>>>> to take the scheduler lock during that operation.
>>>>
>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>>
>>> Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
>>
>> As this patch is a prerequisite for my core scheduling series I'd really
>> appreciate if it could be committed rather sooner than later.
>>
>> Josh, Robert, could you please comment?
>>
>> Or is Dario's R-b (and Jan's as well) enough in this rather simple and
>> obvious case?
> 
> I was more or less planning to time out on waiting for their ack
> later today.

Thanks.


Juergen
diff mbox series

Patch

diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c
index 72b988ea5f..d47b747ef4 100644
--- a/xen/common/sched_arinc653.c
+++ b/xen/common/sched_arinc653.c
@@ -442,16 +442,22 @@  a653sched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd)
 static void
 a653sched_free_vdata(const struct scheduler *ops, void *priv)
 {
+    a653sched_priv_t *sched_priv = SCHED_PRIV(ops);
     arinc653_vcpu_t *av = priv;
+    unsigned long flags;
 
     if (av == NULL)
         return;
 
+    spin_lock_irqsave(&sched_priv->lock, flags);
+
     if ( !is_idle_vcpu(av->vc) )
         list_del(&av->list);
 
     xfree(av);
     update_schedule_vcpus(ops);
+
+    spin_unlock_irqrestore(&sched_priv->lock, flags);
 }
 
 /**