Re: [PATCH v3 2/2] net/ibmvnic: prevent more than one thread from running in reset

2019-09-18 Thread Juliet Kim


On 9/18/19 1:12 AM, Michael Ellerman wrote:
> Hi Juliet,
>
> Juliet Kim  writes:
>> Signed-off-by: Juliet Kim 
>> ---
>>  drivers/net/ethernet/ibm/ibmvnic.c | 23 ++-
>>  drivers/net/ethernet/ibm/ibmvnic.h |  3 +++
>>  2 files changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
>> b/drivers/net/ethernet/ibm/ibmvnic.c
>> index ba340aaff1b3..f344ccd68ad9 100644
>> --- a/drivers/net/ethernet/ibm/ibmvnic.c
>> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
>> @@ -2054,6 +2054,13 @@ static void __ibmvnic_reset(struct work_struct *work)
>>  
>>  adapter = container_of(work, struct ibmvnic_adapter, ibmvnic_reset);
>>  
>> +if (adapter->resetting) {
>> +schedule_delayed_work(>ibmvnic_delayed_reset,
>> +  IBMVNIC_RESET_DELAY);
>> +return;
>> +}
>> +
>> +adapter->resetting = true;
>>  reset_state = adapter->state;
> Is there some locking/serialisation around this?
>
> Otherwise that looks very racy. ie. two CPUs could both see
> adapter->resetting == false, then both set it to true, and then continue
> executing and stomp on each other.
>
> cheers

I agree there may be a race here. Thank you for reviewing.

I will address it in the next version.



Re: [PATCH v3 2/2] net/ibmvnic: prevent more than one thread from running in reset

2019-09-18 Thread Michael Ellerman
Hi Juliet,

Juliet Kim  writes:
> Signed-off-by: Juliet Kim 
> ---
>  drivers/net/ethernet/ibm/ibmvnic.c | 23 ++-
>  drivers/net/ethernet/ibm/ibmvnic.h |  3 +++
>  2 files changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
> b/drivers/net/ethernet/ibm/ibmvnic.c
> index ba340aaff1b3..f344ccd68ad9 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -2054,6 +2054,13 @@ static void __ibmvnic_reset(struct work_struct *work)
>  
>   adapter = container_of(work, struct ibmvnic_adapter, ibmvnic_reset);
>  
> + if (adapter->resetting) {
> + schedule_delayed_work(>ibmvnic_delayed_reset,
> +   IBMVNIC_RESET_DELAY);
> + return;
> + }
> +
> + adapter->resetting = true;
>   reset_state = adapter->state;

Is there some locking/serialisation around this?

Otherwise that looks very racy. ie. two CPUs could both see
adapter->resetting == false, then both set it to true, and then continue
executing and stomp on each other.

cheers