Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp523921rwr; Wed, 26 Apr 2023 02:42:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6x1mUuCiR9xVTduq+vxKZhyzd+Nlu91qyBcBgYpz8Xa7uQf89KC4FEJ8MKOjydbfH/DfRO X-Received: by 2002:a17:902:f14d:b0:19e:b2ed:6fff with SMTP id d13-20020a170902f14d00b0019eb2ed6fffmr1595927plb.31.1682502139024; Wed, 26 Apr 2023 02:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682502139; cv=none; d=google.com; s=arc-20160816; b=Zton7eTzDcQQISHl+iOx3fBTWJuAzARAmJl4GoQ9urA+jr0zH0XYcZfV0WmrKBJmNP URXlQFQqO/D10YEeDMdSN7O9hGf4dh7pxOo4B8Qv7fGt0whxy9s4qh+PpwDaCOfnCDFT /MyTGSYuy7JGi8ny4NAo+KNGXWiqNmGXdUSYVLXmouJkXnxVUGMpUqCGyw73ormQAszC kkeUpxjKjBvkCQ71QRxbSVWb7Vzna7GGNFzx/ZinhhJ25LVQ0qluZz6vCkiRULMne8J3 vorE5JeH+kJ6J1RRDrPuKgIOt7ObdWEpik9yJRLNXB12ER/QUSgtyxHwEzSpnUpj2Q+W P5vw== 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-disposition:mime-version :message-id:subject:cc:to:from:date; bh=HzJ4B1VuG6H81d0D+/lRIjfCmagGy4yzW38ZQ6hJCn8=; b=c4CZ7LlcfrYk/KKrquuNMa9NaZR2wK/ZNy+KnUoMtQ/fERbLvznBWZH3RZp7km5xC5 KtegL+9ncqyq3QTPfXrZkI/tQzMyJxxhLMhLz+NoyecUn007P4sEsjLVCz0TpxctWOqQ PRNBrlUxZeh8fD0bVdWRqCBP4rGCL92Pz2tDR2X8qRoTsmQoAt3H8F+b2tp74OlQpmCa 8SjkZVAozwLx6Ipb7mYdsbf5o1tNy6fcWzttq3i2e/W1cx1F7ah3R+J4phPK5Kk3iGRv lO8l/VzClrtWzqeKvHfBr3EWi0ETgOljCWYLwl4G/v4msx8rc2gH4o1SbD4xCbwEUI3y 2QLA== ARC-Authentication-Results: i=1; mx.google.com; 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 t1-20020a17090aba8100b0023670bc014dsi18573632pjr.110.2023.04.26.02.42.05; Wed, 26 Apr 2023 02:42:19 -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; 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 S240143AbjDZJiQ (ORCPT + 99 others); Wed, 26 Apr 2023 05:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240044AbjDZJiM (ORCPT ); Wed, 26 Apr 2023 05:38:12 -0400 Received: from 167-179-156-38.a7b39c.syd.nbn.aussiebb.net (167-179-156-38.a7b39c.syd.nbn.aussiebb.net [167.179.156.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA81393; Wed, 26 Apr 2023 02:38:10 -0700 (PDT) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1prbau-002Wmo-RS; Wed, 26 Apr 2023 17:37:51 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Wed, 26 Apr 2023 17:37:49 +0800 Date: Wed, 26 Apr 2023 17:37:49 +0800 From: Herbert Xu To: Cai Huoqing Cc: cai.huoqing@linux.dev, 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: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230425144556.98799-1-cai.huoqing@linux.dev> X-Newsgroups: apana.lists.os.linux.kernel,apana.lists.os.linux.netdev X-Spam-Status: No, score=2.7 required=5.0 tests=BAYES_00,HELO_DYNAMIC_IPADDR2, RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS,TVD_RCVD_IP,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** 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 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? > @@ -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. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt