Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4184719rwr; Sun, 30 Apr 2023 01:59:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dh1ihbLITgRvj6Dopv0M+0GLNNAmRKzgT2ksbCGoePbcIshcjtkgqjt3s78c4ggYS0VC8 X-Received: by 2002:a17:90a:1983:b0:23d:1bef:8594 with SMTP id 3-20020a17090a198300b0023d1bef8594mr9536523pji.1.1682845163955; Sun, 30 Apr 2023 01:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682845163; cv=none; d=google.com; s=arc-20160816; b=N3WGYV/cZOfr9/q+ahzOtLDf5DJRf+2vtj7kjXyOC7D3c1+ro202lWHKwzcdG9YI8j N2D0LiX4y06951JlS7alQjteWZg2GJt/r8MlA4nXq7Frd0fdyAvEvP36o/eev06N6MX1 C50MuRvv+goZYg12FWZ4Oz/gfnGQvWuk+xRt749JX7aV2f+BqUoBYTU3nnqwbGIvF0gM ma48OSwPa9FoEKoq+ggtG3TUnW0f7GfYfH6+Zw0T5dSt8IPaJ1XEL4znpbGi4ss6XQGO rHWL/CUID5ttk6B7VVDgvELnDrm8kuBqkUHPQfo3l0H2ll+HGBqjMMlzZya1f5Iy5JQc SeUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=FtoIgx0IqE4PIcUscvctGI7W1hQLnKYUYIevTAA9fVk=; b=nnnHYlkNojT9QtnTxnE/yjCWGTz4hNWFU55rpcncAwg2X3QTqj8gkKimkx/Sj4mFth RQqyQgkaFbn770N+b5Cqog1HbxUBlO7Qxd4O9scAzbJwvrW0/QjmJsibxTHDtvD7pMnQ gbaqE1iKSmkrxPt27VisDhX9Akwwxfb/IeNZufVWO+sHObhm3DmXxmP7cjZBdwqCId2D cryl2PdsZT13/k5tzogAAVWHWfSeDaBdu9GNlYWeJr0iiaWiTC+6UXXR97sXmGCDO7w1 156ppRMiaCNAoU7FM4hTzsGt388ycU4gfXuBiyUdVnUEh3028oyZrX8EJuxVZQUDqP+0 GJVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=jz9kukz3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq11-20020a17090b380b00b002475bc0a186si29771005pjb.69.2023.04.30.01.59.03; Sun, 30 Apr 2023 01:59:23 -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=pass header.i=@messagingengine.com header.s=fm3 header.b=jz9kukz3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229570AbjD3IU1 (ORCPT + 99 others); Sun, 30 Apr 2023 04:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjD3IU0 (ORCPT ); Sun, 30 Apr 2023 04:20:26 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7396D26A5; Sun, 30 Apr 2023 01:20:24 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 5160E5C0101; Sun, 30 Apr 2023 04:20:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 30 Apr 2023 04:20:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1682842821; x=1682929221; bh=FtoIgx0IqE4PIcUscvctGI7W1hQLnKYUYIe vTAA9fVk=; b=jz9kukz3E/TCjbKIb4KphaN8Ifhn8QMeqX4lzgM6Wvv6wo+VvY2 qhJaDGqfC8Y/rpMqNlIR9mAA7GLBsb/7NXcUvrqIOk2sCQZqZc4EfSHVGyeJG8Hf UpOQvAFxOBjM1ZPVo+oS1abkLcswk6LPb1xiMolwa/jxUAySWuvzXyRbpeE3bpiM 0nJbZ3XmISTyfTu7BnBsCE36SW/ZbT5QXWtfvUYrt3uuHKoFLFMVqbcfev5fIcz5 dCbWJQ9xX4dYtteULC2TOOJEb4Ud3je67ENV9RCPic0sZvO7NO7iiUI53cvccuc3 NsCts6pH5dYt776u/X42fbFQxOGqSIFbKdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedvvddgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtkeertddttdejnecuhfhrohhmpefkugho ucfutghhihhmmhgvlhcuoehiughoshgthhesihguohhstghhrdhorhhgqeenucggtffrrg htthgvrhhnpeekgefggefhuedvgeettdegvdeuvdfhudejvddvjeetledvuedtheehleel hffhudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hiughoshgthhesihguohhstghhrdhorhhg X-ME-Proxy: Feedback-ID: i494840e7:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 30 Apr 2023 04:20:19 -0400 (EDT) Date: Sun, 30 Apr 2023 11:20:16 +0300 From: Ido Schimmel To: Cai Huoqing Cc: Herbert Xu , kuba@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] netdevsim: fib: Make use of rhashtable_iter Message-ID: References: <20230425144556.98799-1-cai.huoqing@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE,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 On Fri, Apr 28, 2023 at 11:11:55PM +0800, Cai Huoqing wrote: > On 26 4月 23 17:37:49, Herbert Xu wrote: > > Cai Huoqing wrote: > > > Iterating 'fib_rt_ht' by rhashtable_walk_next and rhashtable_iter directly > > > instead of using list_for_each, because each entry of fib_rt_ht can be > > > found by rhashtable API. And remove fib_rt_list. > > > > > > Signed-off-by: Cai Huoqing > > > --- > > > drivers/net/netdevsim/fib.c | 37 ++++++++++++++++++------------------- > > > 1 file changed, 18 insertions(+), 19 deletions(-) > > > > What is the rationale for this patch? Are you trying to save > > memory? > Hi > Thanks for your reply, > > I think not need to use two structs to link fib_rt node, > fib_rt_list is redundant. There are cases where we want to iterate over the objects without destroying the hashtable itself. > > Thanks, > Cai- > > > > > > @@ -1099,9 +1090,12 @@ static void nsim_fib_dump_inconsistent(struct notifier_block *nb) > > > /* The notifier block is still not registered, so we do not need to > > > * take any locks here. > > > */ > > > - list_for_each_entry_safe(fib_rt, fib_rt_tmp, &data->fib_rt_list, list) { > > > - rhashtable_remove_fast(&data->fib_rt_ht, &fib_rt->ht_node, > > > + rhashtable_walk_enter(&data->fib_rt_ht, &hti); > > > + rhashtable_walk_start(&hti); > > > + while ((pos = rhashtable_walk_next(&hti))) { > > > + rhashtable_remove_fast(&data->fib_rt_ht, hti.p, > > > nsim_fib_rt_ht_params); > > > + fib_rt = rhashtable_walk_peek(&hti); > > > nsim_fib_rt_free(fib_rt, data); > > > } > > > > In general rhashtable walks are not stable. You may miss entries > > or see entries twice. They should be avoided unless absolutely > > necessary. > Agree, but how about using rhashtable_free_and_destroy here > instead of rhashtable_walk_next in this patch. We don't want to destroy the hashtable in this case, only free the objects.