From patchwork Thu Apr 1 12:52:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Teras X-Patchwork-Id: 49215 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DFA37B7CF3 for ; Thu, 1 Apr 2010 23:53:18 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756498Ab0DAMwz (ORCPT ); Thu, 1 Apr 2010 08:52:55 -0400 Received: from mail-ew0-f220.google.com ([209.85.219.220]:54690 "EHLO mail-ew0-f220.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756108Ab0DAMwa (ORCPT ); Thu, 1 Apr 2010 08:52:30 -0400 Received: by ewy20 with SMTP id 20so329244ewy.1 for ; Thu, 01 Apr 2010 05:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=MgzyhSIivauUQl2LoO2Et4CZHD9jdzJLgp2NxUqC1o4=; b=dHvY03KB8f2IVQbODwuXHtl4qX/6eZDDuYHSP9yCyEa9LQHzjoCebizzt1ZqNhInSl XuZq4fY31jp2IcCLjIHPFfToGs7VQLDwj6DZPeUe0fNP2lIGYxFPWdh9LB23fNC/d+PQ amjvd/pkcbWdRfJz8npl0bxkiJa1gi1K0E0J0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=J6RZQGc2zQea2ptnms/oyvo65Xiwe7BRIgwkAj4XLbijd16MEHCkchec0HUeiqaCNZ px9z6c4K1VP4ohvo9rJRSy2CyhNPFeYd5CJrwqQGJsEbd2XBK4VdLYTckHfm/zYlOCaU DJsrRuFJ8nuNPEY4qhv1O0DCFIlpkELyHjSuM= Received: by 10.213.54.74 with SMTP id p10mr444016ebg.44.1270126348647; Thu, 01 Apr 2010 05:52:28 -0700 (PDT) Received: from localhost.localdomain (letku109.adsl.netsonic.fi [194.29.195.109]) by mx.google.com with ESMTPS id 14sm4424514ewy.10.2010.04.01.05.52.27 (version=SSLv3 cipher=RC4-MD5); Thu, 01 Apr 2010 05:52:28 -0700 (PDT) From: Timo Teras To: netdev@vger.kernel.org Cc: Herbert Xu , Timo Teras Subject: [PATCH 3/4] xfrm: remove policy garbage collection Date: Thu, 1 Apr 2010 15:52:19 +0300 Message-Id: <1270126340-30181-4-git-send-email-timo.teras@iki.fi> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1270126340-30181-1-git-send-email-timo.teras@iki.fi> References: <1270126340-30181-1-git-send-email-timo.teras@iki.fi> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Policies are now properly reference counted and destroyed from all code paths. The delayed gc is just an overhead now and can be removed. Signed-off-by: Timo Teras --- net/xfrm/xfrm_policy.c | 39 +++++---------------------------------- 1 files changed, 5 insertions(+), 34 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 3489e2d..0a80978 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -46,9 +46,6 @@ static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO]; static struct kmem_cache *xfrm_dst_cache __read_mostly; -static HLIST_HEAD(xfrm_policy_gc_list); -static DEFINE_SPINLOCK(xfrm_policy_gc_lock); - static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family); static void xfrm_policy_put_afinfo(struct xfrm_policy_afinfo *afinfo); static void xfrm_init_pmtu(struct dst_entry *dst); @@ -289,32 +286,6 @@ void xfrm_policy_destroy(struct xfrm_policy *policy) } EXPORT_SYMBOL(xfrm_policy_destroy); -static void xfrm_policy_gc_kill(struct xfrm_policy *policy) -{ - atomic_inc(&policy->genid); - - if (del_timer(&policy->timer)) - atomic_dec(&policy->refcnt); - - xfrm_pol_put(policy); -} - -static void xfrm_policy_gc_task(struct work_struct *work) -{ - struct xfrm_policy *policy; - struct hlist_node *entry, *tmp; - struct hlist_head gc_list; - - spin_lock_bh(&xfrm_policy_gc_lock); - gc_list.first = xfrm_policy_gc_list.first; - INIT_HLIST_HEAD(&xfrm_policy_gc_list); - spin_unlock_bh(&xfrm_policy_gc_lock); - - hlist_for_each_entry_safe(policy, entry, tmp, &gc_list, bydst) - xfrm_policy_gc_kill(policy); -} -static DECLARE_WORK(xfrm_policy_gc_work, xfrm_policy_gc_task); - /* Rule must be locked. Release descentant resources, announce * entry dead. The rule must be unlinked from lists to the moment. */ @@ -323,11 +294,12 @@ static void xfrm_policy_kill(struct xfrm_policy *policy) { policy->walk.dead = 1; - spin_lock_bh(&xfrm_policy_gc_lock); - hlist_add_head(&policy->bydst, &xfrm_policy_gc_list); - spin_unlock_bh(&xfrm_policy_gc_lock); + atomic_inc(&policy->genid); - schedule_work(&xfrm_policy_gc_work); + if (del_timer(&policy->timer)) + xfrm_pol_put(policy); + + xfrm_pol_put(policy); } static unsigned int xfrm_policy_hashmax __read_mostly = 1 * 1024 * 1024; @@ -2605,7 +2577,6 @@ static void xfrm_policy_fini(struct net *net) audit_info.sessionid = -1; audit_info.secid = 0; xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, &audit_info); - flush_work(&xfrm_policy_gc_work); WARN_ON(!list_empty(&net->xfrm.policy_all));