From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-2?Q?Micha=B3_Miros=B3aw?= Subject: Re: [PATCH v3 03/22] netconsole: Introduce 'enabled' state-machine Date: Wed, 15 Dec 2010 00:21:53 +0100 Message-ID: References: <20101214212846.17022.64836.stgit@mike.mtv.corp.google.com> <20101214212909.17022.96801.stgit@mike.mtv.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <20101214212909.17022.96801.stgit-tzAwxxnF6Tt6FDdRrpk8kO4/NqBCd+6Q@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mike Waychison Cc: simon.kagstrom-vI6UBbBVNY+JA8cjQkG2/g@public.gmane.org, davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org, nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org, Matt Mackall , adurbin-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, chavey-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, Greg KH , netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, =?ISO-8859-1?Q?Am=E9rico_Wang?= , akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-api@vger.kernel.org 2010/12/14 Mike Waychison : > Representing the internal state within netconsole isn't really a bool= ean > value, but rather a state machine with transitions. [...] > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > index 6e16888..288a025 100644 > --- a/drivers/net/netconsole.c > +++ b/drivers/net/netconsole.c [...] > @@ -350,9 +362,9 @@ static ssize_t store_enabled(struct netconsole_ta= rget *nt, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0err =3D netpoll_setup(&nt->np); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spin_lock_irqsave(&target_list_lock, f= lags); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (err) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nt->enabled =3D 0; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nt->np_state =3D NETPOL= L_DISABLED; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nt->enabled =3D 1; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nt->np_state =3D NETPOL= L_ENABLED; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spin_unlock_irqrestore(&target_list_lo= ck, flags); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (err) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return err; [...] Since the spinlock protects only nt->np_state setting, you might be able to remove it altogether and use cmpxchg() where nt->np_state transitions from enabled or disabled state. Maybe the locking scheme just needs more thought altogether? Best Regards, Micha=B3 Miros=B3aw