Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35759531rwd; Mon, 10 Jul 2023 12:08:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlFQiQ6bn38Y/IE+bbq8gjye+pDofTCdwwXiNInL4oqesqAx4itXy2AJ356PObDxFbkH9kuo X-Received: by 2002:a17:90b:a15:b0:262:c9f4:141 with SMTP id gg21-20020a17090b0a1500b00262c9f40141mr13398331pjb.42.1689016129917; Mon, 10 Jul 2023 12:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689016129; cv=none; d=google.com; s=arc-20160816; b=smDIaDWjP0O9o/isUDSWXYdoO6fZh978UQnIsCAaTo2VFByQFTPdp7P5PL2UaQxQID i8OC1WQuTeCtcwOekIJKcKyXOe4t82xF+hXcTU8iL1qGwnxYrkiqxLCg6XJg//8QSoQt XhQsB6/pszPwJxbPFJTeU6RY/c8MdTXbEwoaPEl0AGKNtxN39SJHu+lyldKZ/NlanPQn QCTssGvYJ+p/iTPb/CkVGwKwq/HkCfYFrZCLFQWqx8Yutp94bn5mqKYv9Hz7rpzwjbAb Tisroyga4hYzf5NfFRxKC7oaF6G33xk69rPgxK5+apl5zWI2iPnunhA4pe/ZsQdZAHau 4CYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=MpE+kBls/Zwuo24PYcx2ywUSes16FRzLnZNaT1iWA8Y=; fh=L21r8RNTNCYrZsrq3dQzRraD8n7pt2fVHjqT/nyFXQ0=; b=uXXwoH2cjrnj5gqsKZqFlTL6xcyRkqqdGjry5TQWX94nKd2DeB1wV9SQ319EE4gvd5 xeXRC8SQYTpjy+GhXwjpWbDbKe/EGefOxVxq5kJAxXF7QyO5zMtYxj7OZSXc+hR+brcP a9vtKgDzJI5e+MJweeHC6/lC3iCdJXQt3GUvK1l0aXPg5Zik4byMC+jpj5/bQ5+GrMmB LYLdkaMksq7Mnij4BygXXvD8lVvREY9sxEyD+Dnk4rjXTsrAbwOzR5HVdUe6EeFFn9B4 /2ydBzMB1PGrNEBAs0Zb3ECgKTUuvXEGMZ2WxGgWtcaUxsTsn9tOBONZ+sWKo0c+fp7C m7TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ssi.bg header.s=ink header.b=o+Pqd5sL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ssi.bg Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l16-20020a635b50000000b00553b9b18882si74349pgm.574.2023.07.10.12.08.37; Mon, 10 Jul 2023 12:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@ssi.bg header.s=ink header.b=o+Pqd5sL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ssi.bg Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbjGJRaz (ORCPT + 99 others); Mon, 10 Jul 2023 13:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231543AbjGJRat (ORCPT ); Mon, 10 Jul 2023 13:30:49 -0400 Received: from mg.ssi.bg (mg.ssi.bg [193.238.174.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEC43C4; Mon, 10 Jul 2023 10:30:47 -0700 (PDT) Received: from mg.bb.i.ssi.bg (localhost [127.0.0.1]) by mg.bb.i.ssi.bg (Proxmox) with ESMTP id 7D8AE18F34; Mon, 10 Jul 2023 20:30:44 +0300 (EEST) Received: from ink.ssi.bg (ink.ssi.bg [193.238.174.40]) by mg.bb.i.ssi.bg (Proxmox) with ESMTPS id 63C5D191B4; Mon, 10 Jul 2023 20:30:44 +0300 (EEST) Received: from ja.ssi.bg (unknown [213.16.62.126]) by ink.ssi.bg (Postfix) with ESMTPSA id 625F53C0803; Mon, 10 Jul 2023 20:30:37 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ssi.bg; s=ink; t=1689010240; bh=GTzycfPTuL6xYhwrHAUqSMOXS9y7swYh/taQTI/rhUo=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=o+Pqd5sLAlDt8AtdXenR/ZT1D2AWctaPbUeBWEAqkXC277L3wKh8qIR5/cvopEjSx hd1gczybHTnm13BnmtgUTSJVA1FcgYkLuqscDKNjNxWmLxCsa2AuEGPFC/iQ/r3ysR WT6rOpnXNWqqPyl/GuJD13mSWkL/7J/Pc38M4X/A= Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by ja.ssi.bg (8.17.1/8.17.1) with ESMTP id 36AHUYve107992; Mon, 10 Jul 2023 20:30:36 +0300 Date: Mon, 10 Jul 2023 20:30:34 +0300 (EEST) From: Julian Anastasov To: Dust Li cc: Jiejian Wu , Simon Horman , "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: Re: [PATCH net-next] ipvs: make ip_vs_svc_table and ip_vs_svc_fwm_table per netns In-Reply-To: <20230710152809.GD6751@linux.alibaba.com> Message-ID: <3d37360e-846a-3b01-f2ad-9c1c5720a568@ssi.bg> References: <20230707020708.75168-1-dust.li@linux.alibaba.com> <28a87ee9-5f94-2506-3cb9-8a19144e2061@ssi.bg> <20230710152809.GD6751@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, 10 Jul 2023, Dust Li wrote: > On Sun, Jul 09, 2023 at 08:45:19PM +0300, Julian Anastasov wrote: > > > > Hello, > > > >On Fri, 7 Jul 2023, Dust Li wrote: > > > >> @@ -2303,9 +2293,9 @@ static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos) > >> > >> /* look in hash by protocol */ > >> for (idx = 0; idx < IP_VS_SVC_TAB_SIZE; idx++) { > >> - hlist_for_each_entry_rcu(svc, &ip_vs_svc_table[idx], s_list) { > >> + hlist_for_each_entry_rcu(svc, &ipvs->ip_vs_svc_table[idx], s_list) { > >> if ((svc->ipvs == ipvs) && pos-- == 0) { > >> - iter->table = ip_vs_svc_table; > >> + iter->table = ipvs->ip_vs_svc_table; > > > > We can change iter->table to int table_id, 0 (ip_vs_svc_table) > >and 1 (ip_vs_svc_fwm_table), for all these ip_vs_info_* funcs. > > Sorry, I don't get this. Why do we need to change this ? It is a hint which table to walk, no need for such dereferences. For example: iter->table = ip_vs_svc_table; becomes iter->table_id = 0; iter->table = ip_vs_svc_fwm_table; becomes iter->table_id = 1; etc > >> @@ -3392,9 +3384,9 @@ static int ip_vs_genl_dump_services(struct sk_buff *skb, > >> struct net *net = sock_net(skb->sk); > >> struct netns_ipvs *ipvs = net_ipvs(net); > >> > >> - mutex_lock(&__ip_vs_mutex); > >> + mutex_lock(&ipvs->service_mutex); > > > > While do_ip_vs_get_ctl is a reader that can block we > >can not use RCU but in ip_vs_genl_dump_services() we can replace > >the __ip_vs_mutex with rcu_read_lock because we just fill the skb. > > > > I think we can replace mutex in ip_vs_genl_dump_services() by RCU. > Do you prefer replacing it in this patch or later ? You can include these RCU conversions > > Also, there is more work if we want independent > >namespaces and to give power to users: > > > >- account memory: GFP_KERNEL -> GFP_KERNEL_ACCOUNT > > > >- the connections table is still global but it should be possible > >to make all tables per-net and to grow on load from NULL to max bits > > > >- convert GENL_ADMIN_PERM -> GENL_UNS_ADMIN_PERM and make > >sysctls visible to other namespaces > > > > If the plan is to have multiple netns loaded with many > >conns may be I can follow your patch with more optimization > >patches. > > Yes, we do missed those details. I think moving those into different > netns is good, besides we already have netns supported. So why not do > it more completely ? > > If it is convenient for you to do more optimizations, we would greatly > appreciate it ! Yes, I'll prepare more patches on top of your patch. Regards -- Julian Anastasov