Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754138AbZDUIRT (ORCPT ); Tue, 21 Apr 2009 04:17:19 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751485AbZDUIRB (ORCPT ); Tue, 21 Apr 2009 04:17:01 -0400 Received: from broadrack.ru ([195.178.208.66]:47178 "EHLO tservice.net.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392AbZDUIQ7 (ORCPT ); Tue, 21 Apr 2009 04:16:59 -0400 Date: Tue, 21 Apr 2009 12:16:49 +0400 From: Evgeniy Polyakov To: Lai Jiangshan Cc: Stephen Hemminger , Eric Dumazet , Paul Mackerras , paulmck@linux.vnet.ibm.com, David Miller , kaber@trash.net, torvalds@linux-foundation.org, jeff.chua.linux@gmail.com, mingo@elte.hu, jengelh@medozas.de, r000n@r000n.net, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, benh@kernel.crashing.org, mathieu.desnoyers@polymtl.ca Subject: Re: [PATCH] netfilter: use per-cpu recursive lock (v11) Message-ID: <20090421081649.GA16782@ioremap.net> References: <49ECBE0A.7010303@cosmosbay.com> <18924.59347.375292.102385@cargo.ozlabs.ibm.com> <20090420215827.GK6822@linux.vnet.ibm.com> <18924.64032.103954.171918@cargo.ozlabs.ibm.com> <20090420160121.268a8226@nehalam> <49ED406F.2040401@cn.fujitsu.com> <49ED4407.8010200@cosmosbay.com> <49ED5813.1000803@cn.fujitsu.com> <20090420224540.30d7b0ed@nehalam> <49ED6D2E.5060808@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49ED6D2E.5060808@cn.fujitsu.com> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1447 Lines: 50 Hi. On Tue, Apr 21, 2009 at 02:52:30PM +0800, Lai Jiangshan (laijs@cn.fujitsu.com) wrote: > > +void xt_info_rdlock_bh(void) > > > +{ > > > + struct xt_info_lock *lock; > > > + > > > + preempt_disable(); > > > + lock = &__get_cpu_var(xt_info_locks); > > > + if (likely(++lock->depth == 0)) > > So what happen when xt_info_rdlock_bh() called recursively here? > > > > + spin_lock_bh(&lock->lock); > > > + preempt_enable_no_resched(); > > > +} > > > +EXPORT_SYMBOL_GPL(xt_info_rdlock_bh); > > > + > > ---------- > Is this OK? (Now I suppose we can enter the read-side critical region > in irq context) > > void xt_info_rdlock_bh(void) > { > unsigned long flags; > struct xt_info_lock *lock; > > local_irq_save(flags); > lock = &__get_cpu_var(xt_info_locks); > if (likely(++lock->depth == 0)) > spin_lock_bh(&lock->lock); > local_irq_restore(flags); > } Netfilter as long as other generic network pathes are never accessed from interrupt context, but your analysis looks right for the softirq case. Stephen, should preempt_disable() be replaced with local_bh_disable() to prevent softirq to race on the same cpu for the lock's depth field? Or can it be made atomic? -- Evgeniy Polyakov -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/