From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manish Kumar Singh Subject: RE: [PATCH] bonding: avoid repeated display of same link status change Date: Mon, 24 Sep 2018 00:05:42 -0700 (PDT) Message-ID: References: <20180917072059.32657-1-mk.singh@oracle.com> <33a66a80-22ed-d6b3-f6b2-4463357c5ffa@gmail.com> <78bf3185-fbd1-4a6c-ae32-70da0af2cbb4@default> <05f57c08-3ebb-7ee5-7ab2-519cb5a70bd8@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , linux-kernel@vger.kernel.org To: Eric Dumazet , netdev@vger.kernel.org Return-path: In-Reply-To: <05f57c08-3ebb-7ee5-7ab2-519cb5a70bd8@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org > -----Original Message----- > From: Eric Dumazet [mailto:eric.dumazet@gmail.com] > Sent: 18 =E0=A4=B8=E0=A4=BF=E0=A4=A4=E0=A4=AE=E0=A5=8D=E0=A4=AC=E0=A4=B0 = 2018 19:30 > To: Manish Kumar Singh; Eric Dumazet; netdev@vger.kernel.org > Cc: Jay Vosburgh; Veaceslav Falico; Andy Gospodarek; David S. Miller; lin= ux- > kernel@vger.kernel.org > Subject: Re: [PATCH] bonding: avoid repeated display of same link status > change >=20 >=20 >=20 > On 09/17/2018 10:05 PM, Manish Kumar Singh wrote: > > > > > >> -----Original Message----- > >> From: Eric Dumazet [mailto:eric.dumazet@gmail.com] > >> Sent: 17 =E0=A4=B8=E0=A4=BF=E0=A4=A4=E0=A4=AE=E0=A5=8D=E0=A4=AC=E0=A4= =B0 2018 20:08 > >> To: Manish Kumar Singh; netdev@vger.kernel.org > >> Cc: Jay Vosburgh; Veaceslav Falico; Andy Gospodarek; David S. Miller; > linux- > >> kernel@vger.kernel.org > >> Subject: Re: [PATCH] bonding: avoid repeated display of same link stat= us > >> change > >> > >> > >> > >> On 09/17/2018 12:20 AM, mk.singh@oracle.com wrote: > >>> From: Manish Kumar Singh > >>> > >>> When link status change needs to be committed and rtnl lock couldn't = be > >>> taken, avoid redisplay of same link status change message. > >>> > >>> Signed-off-by: Manish Kumar Singh > >>> --- > >>> drivers/net/bonding/bond_main.c | 6 ++++-- > >>> include/net/bonding.h | 1 + > >>> 2 files changed, 5 insertions(+), 2 deletions(-) > >>> > >>> diff --git a/drivers/net/bonding/bond_main.c > >> b/drivers/net/bonding/bond_main.c > >>> index 217b790d22ed..fb4e3aff1677 100644 > >>> --- a/drivers/net/bonding/bond_main.c > >>> +++ b/drivers/net/bonding/bond_main.c > >>> @@ -2087,7 +2087,7 @@ static int bond_miimon_inspect(struct bonding > >> *bond) > >>> =09=09=09bond_propose_link_state(slave, BOND_LINK_FAIL); > >>> =09=09=09commit++; > >>> =09=09=09slave->delay =3D bond->params.downdelay; > >>> -=09=09=09if (slave->delay) { > >>> +=09=09=09if (slave->delay && !bond->rtnl_needed) { > >>> =09=09=09=09netdev_info(bond->dev, "link status down > for > >> %sinterface %s, disabling it in %d ms\n", > >>> =09=09=09=09=09 (BOND_MODE(bond) =3D=3D > >>> =09=09=09=09=09 BOND_MODE_ACTIVEBACKUP) ? > >>> @@ -2127,7 +2127,7 @@ static int bond_miimon_inspect(struct bonding > >> *bond) > >>> =09=09=09commit++; > >>> =09=09=09slave->delay =3D bond->params.updelay; > >>> > >>> -=09=09=09if (slave->delay) { > >>> +=09=09=09if (slave->delay && !bond->rtnl_needed) { > >>> =09=09=09=09netdev_info(bond->dev, "link status up for > >> interface %s, enabling it in %d ms\n", > >>> =09=09=09=09=09 slave->dev->name, > >>> =09=09=09=09=09 ignore_updelay ? 0 : > >>> @@ -2301,9 +2301,11 @@ static void bond_mii_monitor(struct > >> work_struct *work) > >>> =09=09if (!rtnl_trylock()) { > >>> =09=09=09delay =3D 1; > >>> =09=09=09should_notify_peers =3D false; > >>> +=09=09=09bond->rtnl_needed =3D true; > >> > >> How can you set a shared variable with no synchronization ? > > Thanks Eric for reviewing the patch. rtnl_needed is not a shared variab= le, it > is part of bonding structure, that is one per bonding driver instance. Th= ere > can't be two parallel instances of bond_miimon_inspect for a single =C2= =A0bonding > driver instance at any given point of time. and only bond_miimon_inspect > updates it. That=E2=80=99s why I think there is no need of any synchroniz= ation here. > > > > >=20 > If rtnl_trylock() can not grab RTNL, > there is no way the current thread can set the variable without a race, = if the > word including rtnl_needed is shared by other fields in the structure. >=20 > Your patch adds a subtle possibility of future bugs, even if it runs fine= today. >=20 > Do not pave the way for future bugs, make your code robust, please. Thankyou Eric, we are making the changes and will repost the patch after te= sting it. -Manish >=20 >=20 >=20 >=20 >=20 >=20 >=20