Re: [PATCH V5 1/2] base/drivers/arch_topology: Replace mutex with READ_ONCE / WRITE_ONCE

From: Juri Lelli
Date: Thu Nov 29 2018 - 07:40:46 EST


On 29/11/18 11:02, Daniel Lezcano wrote:
> On 29/11/2018 10:58, Juri Lelli wrote:
> > On 29/11/18 10:18, Daniel Lezcano wrote:
> >> On 29/11/2018 08:04, Juri Lelli wrote:
> >>
> >> [ ... ]
> >>
> >>>> With or without this patch, it is the case:
> >>>>
> >>>> task1 task2
> >>>> | |
> >>>> read("/sys/.../cpu1/cpu_capacity) |
> >>>> | write("/sys/.../cpu1/cpu_capacity")
> >>>> read("/sys/.../cpu2/cpu_capacity) |
> >>>>
> >>>>
> >>>> There is no guarantee userspace can have a consistent view of the
> >>>> capacity. As soon as it reads a capacity, it can be changed in its back.
> >>>
> >>> True, but w/o the mutex task1 could read different cpu_capacity values
> >>> for a cluster (it actually can also with current implementation, we
> >>> should grab the mutex in the read path as well if we want to avoid
> >>> this).
> >>
> >> Even if the mutex is on the read path, the userspace can see different
> >> capacities because it will read the cpu_capacity per cpu directory.
> >>
> >> The mutex will be take when reading cpu0/cpu_capacity, not for
> >> cpu[0-9]/cpu_capacity. Between two reads, a write can happen because the
> >> lock is released in between.
> >>
> >> Do you agree with the patch ? Or do you want me to drop it ?
> >
> > I don't actually have cases at hand that are showing regression with it,
> > I was just trying to understand if we might potentially hit problems in
> > the future. So, I'm not against this patch. :-)
>
> not-not-acked-by ? :)

:-)

I'm not maintaining this, so,

Reviewed-by: Juri Lelli <juri.lelli@xxxxxxxxxx>