Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4721605ybi; Mon, 15 Jul 2019 13:40:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaOlUPKzU6W90wiFDHbfEn0h4ClMnbm0mcOJJmLDwVr5qJ0M+gLNcJHoRlTOzifBdbKroC X-Received: by 2002:a65:6546:: with SMTP id a6mr19164153pgw.220.1563223258542; Mon, 15 Jul 2019 13:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563223258; cv=none; d=google.com; s=arc-20160816; b=0+kwmSot4ma5+Lp+V+fYEDP0nKN3LhjzkJedZMSk44JsKhAHHSRP7WVf6QDzMsmwYC irCUyTRkNTgpOBODANgGHDHf7vV7qxkNx9a9ikb3wndED1+zIFOUL8RS67G1p3AoTRzR LzGGOPdwagde7qU7vTt0PQUo5C/r11fDBnxcw8O1ZhwmCj+cZ6nhSSqQvLM4N1X1gjcN hzwa/W/ULghVshL5gGRyVKM4O0mv8b+a4AWV0Pme3VaPlJ8RLEK+03Zq7zG4XyH72kW4 Ly4FApkGs0hFph/Rt8glw/O8uy/Ef7A7lbUQ5hot0F8VpDZafJ4qsWvL320v4Qx8nAkO ofkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=dPrunFFJrPizQKFIDgr8rsgKIlgb6C6TJh6nF7O3N30=; b=PbOmIrHw2NeCVN9XsfvDQL6yeQFjX5Vvl+AmA+llbl8wlM06Ub8GYpQwoFK72PGAEk U86EGkBKeLczdUXJHHs/TmnnlWwLopRmEFBIBMIX1UL0o9TMgLywybjoZ3Gs50aHdfhZ e6oSitsScHnC3H7dfZoc2ItXwukb/YYJYXb0rd8KTlzT3x3dzgFKXjdxzrZ2X993qmkE l40XKaJNpf3IDV1TEegCsbj+V5kOF0GvAsWUnnTL+NR2hPwN0fpIz/WqGSW2737a2Oku HYsirc5rpIuhl9r4h6gVlyNrJVt9KcJR8eTmySf7KocFUiSCUxedpfo0EA2dJGGW4Yg3 yuDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si10676730pgb.166.2019.07.15.13.40.42; Mon, 15 Jul 2019 13:40:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732165AbfGOUkQ (ORCPT + 99 others); Mon, 15 Jul 2019 16:40:16 -0400 Received: from ja.ssi.bg ([178.16.129.10]:33272 "EHLO ja.ssi.bg" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730258AbfGOUkQ (ORCPT ); Mon, 15 Jul 2019 16:40:16 -0400 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by ja.ssi.bg (8.15.2/8.15.2) with ESMTP id x6FKdqBF006984; Mon, 15 Jul 2019 23:39:53 +0300 Date: Mon, 15 Jul 2019 23:39:52 +0300 (EEST) From: Julian Anastasov To: Haishuang Yan cc: "David S. Miller" , Pablo Neira Ayuso , Simon Horman , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org Subject: Re: [net-next 1/2] ipvs: batch __ip_vs_cleanup In-Reply-To: <1563031186-2101-2-git-send-email-yanhaishuang@cmss.chinamobile.com> Message-ID: References: <1563031186-2101-1-git-send-email-yanhaishuang@cmss.chinamobile.com> <1563031186-2101-2-git-send-email-yanhaishuang@cmss.chinamobile.com> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Sat, 13 Jul 2019, Haishuang Yan wrote: > It's better to batch __ip_vs_cleanup to speedup ipvs > connections dismantle. > > Signed-off-by: Haishuang Yan > --- > include/net/ip_vs.h | 2 +- > net/netfilter/ipvs/ip_vs_core.c | 29 +++++++++++++++++------------ > net/netfilter/ipvs/ip_vs_ctl.c | 13 ++++++++++--- > 3 files changed, 28 insertions(+), 16 deletions(-) > > diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h > index 3759167..93e7a25 100644 > --- a/include/net/ip_vs.h > +++ b/include/net/ip_vs.h > @@ -1324,7 +1324,7 @@ static inline void ip_vs_control_del(struct ip_vs_conn *cp) > void ip_vs_control_net_cleanup(struct netns_ipvs *ipvs); > void ip_vs_estimator_net_cleanup(struct netns_ipvs *ipvs); > void ip_vs_sync_net_cleanup(struct netns_ipvs *ipvs); > -void ip_vs_service_net_cleanup(struct netns_ipvs *ipvs); > +void ip_vs_service_nets_cleanup(struct list_head *net_list); > > /* IPVS application functions > * (from ip_vs_app.c) > diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c > index 46f06f9..b4d79b7 100644 > --- a/net/netfilter/ipvs/ip_vs_core.c > +++ b/net/netfilter/ipvs/ip_vs_core.c > @@ -2402,18 +2402,23 @@ static int __net_init __ip_vs_init(struct net *net) > return -ENOMEM; > } > > -static void __net_exit __ip_vs_cleanup(struct net *net) > +static void __net_exit __ip_vs_cleanup_batch(struct list_head *net_list) > { > - struct netns_ipvs *ipvs = net_ipvs(net); > - > - ip_vs_service_net_cleanup(ipvs); /* ip_vs_flush() with locks */ > - ip_vs_conn_net_cleanup(ipvs); > - ip_vs_app_net_cleanup(ipvs); > - ip_vs_protocol_net_cleanup(ipvs); > - ip_vs_control_net_cleanup(ipvs); > - ip_vs_estimator_net_cleanup(ipvs); > - IP_VS_DBG(2, "ipvs netns %d released\n", ipvs->gen); > - net->ipvs = NULL; > + struct netns_ipvs *ipvs; > + struct net *net; > + LIST_HEAD(list); > + > + ip_vs_service_nets_cleanup(net_list); /* ip_vs_flush() with locks */ > + list_for_each_entry(net, net_list, exit_list) { How much faster is to replace list_for_each_entry in ops_exit_list() with this one. IPVS can waste time in calls such as kthread_stop() and del_timer_sync() but I'm not sure we can solve it easily. What gain do you see in benchmarks? > + ipvs = net_ipvs(net); > + ip_vs_conn_net_cleanup(ipvs); > + ip_vs_app_net_cleanup(ipvs); > + ip_vs_protocol_net_cleanup(ipvs); > + ip_vs_control_net_cleanup(ipvs); > + ip_vs_estimator_net_cleanup(ipvs); > + IP_VS_DBG(2, "ipvs netns %d released\n", ipvs->gen); > + net->ipvs = NULL; > + } > } Regards -- Julian Anastasov