From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH] conntrack: Reduce conntrack count in nf_conntrack_free() Date: Tue, 24 Mar 2009 14:47:57 +0100 Message-ID: <49C8E48D.2070501@cosmosbay.com> References: <49C77D71.8090709@trash.net> <49C780AD.70704@trash.net> <49C7CB9B.1040409@trash.net> <49C8A415.1090606@cosmosbay.com> <49C8CCF4.5050104@cosmosbay.com> <49C8D13D.10307@cosmosbay.com> <49C8D58A.6060401@trash.net> <49C8E0D3.1010202@cosmosbay.com> <49C8E268.6090507@trash.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Joakim Tjernlund , avorontsov@ru.mvista.com, netdev@vger.kernel.org, "Paul E. McKenney" To: Patrick McHardy Return-path: Received: from gw1.cosmosbay.com ([212.99.114.194]:50647 "EHLO gw1.cosmosbay.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751766AbZCXNso convert rfc822-to-8bit (ORCPT ); Tue, 24 Mar 2009 09:48:44 -0400 In-Reply-To: <49C8E268.6090507@trash.net> Sender: netdev-owner@vger.kernel.org List-ID: Patrick McHardy a =E9crit : > Eric Dumazet wrote: >> Patrick McHardy a =E9crit : >>>> I forgot to say this is what we do for 'struct file' freeing as >>>> well. We >>>> decrement nr_files in file_free(), not in file_free_rcu() >>> >>> While temporarily exceeding the limit by up to 10000 entries is >>> quite a lot, I guess the important thing is that it can't grow >>> unbounded, so I think this patch is fine. >>> >> >> Maybe we could use SLAB_DESTROY_BY_RCU thing and no more call_rcu() >> queueing >> problem. That would better use CPU caches as well... >=20 > I'm not sure I understand the rules correctly, but we'd still > have to wait for the grace period before an object can be reused, > no? No we dont have to, but we must do additionnal checks after getting a reference on object found on lookup. (We must re-check the keys used during search) This re-check is not very expensive since everything is hot in cpu cach= e. Check Documentation/RCU/rculist_nulls.txt for some documentation. 1) Lookup algo -------------- rcu_read_lock() begin: obj =3D lockless_lookup(key); if (obj) { if (!try_get_ref(obj)) // might fail for free objects goto begin; /* * Because a writer could delete object, and a writer could * reuse these object before the RCU grace period, we * must check key after geting the reference on object */ if (obj->key !=3D key) { // not the object we expected put_ref(obj); goto begin; } } rcu_read_unlock();