Received: with ECARTIS (v1.0.0; list netdev); Thu, 30 Dec 2004 21:57:57 -0800 (PST) Received: from mx02.cybersurf.com (mx02.cybersurf.com [209.197.145.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id iBV5vRpa029990 for ; Thu, 30 Dec 2004 21:57:49 -0800 Received: from mail.cyberus.ca ([209.197.145.21]) by mx02.cybersurf.com with esmtp (Exim 4.30) id 1CkFvC-0001Ze-A0 for netdev@oss.sgi.com; Fri, 31 Dec 2004 01:05:58 -0500 Received: from cpe0030ab124d2f-cm014500000962.cpe.net.cable.rogers.com ([24.103.99.32] helo=[10.0.0.9]) by mail.cyberus.ca with esmtp (Exim 4.20) id 1CkEw2-0007bw-Dq; Fri, 31 Dec 2004 00:02:46 -0500 Subject: Re: [PATCH 2/9] PKT_SCHED: tc filter extension API From: jamal Reply-To: hadi@cyberus.ca To: Patrick McHardy Cc: Thomas Graf , "David S. Miller" , netdev@oss.sgi.com In-Reply-To: <41D4A4D2.4000109@trash.net> References: <20041230122652.GM32419@postel.suug.ch> <20041230123023.GO32419@postel.suug.ch> <41D4A4D2.4000109@trash.net> Content-Type: text/plain Organization: jamalopolous Message-Id: <1104469362.1049.224.camel@jzny.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 Date: 31 Dec 2004 00:02:42 -0500 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.80/645/Mon Dec 27 14:56:20 2004 clamav-milter version 0.80j on 127.0.0.1 X-Virus-Status: Clean X-archive-position: 13276 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: hadi@cyberus.ca Precedence: bulk X-list: netdev On Thu, 2004-12-30 at 20:01, Patrick McHardy wrote: > > +#ifdef CONFIG_NET_CLS_ACT > > + if (src->action) { > > + if (dst->action) { > > + struct tc_action *act; > > + > > + tcf_tree_lock(tp); > > + act = xchg(&dst->action, src->action); > > + tcf_tree_unlock(tp); > > + > > + tcf_action_destroy(act, TCA_ACT_UNBIND); > > + } else > > + dst->action = src->action; > > This isn't right (its also wrong in the current code). If the > CPU reorders stores and another CPU looks at dst->action at > the wrong time it might see an inconsistent structure. I think an xchg around the else should fix this. > So at > least smp_wmb is required for the unlocked case, or maybe this. > but I think > you should just remove it completely. I also wonder if anyone > actually knows why we need the xchg (here and in all the other > places), it looks totally useless. All these were put in by Alexey and the LinuxWay(tm) took effect. an xchg puts almost a lock and ensures an atomic swap. I dont see any harm in leaving it as is - just needs fixing the else cheers, jamal