Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2268716rwr; Fri, 28 Apr 2023 08:13:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5UDZVRu9c5mBsynJu8yevCvc0k9asRY8mM6POfNrFm01giFsFyiuzxV/Qgy25I6yyurq5Z X-Received: by 2002:a05:6a20:1596:b0:ef:ef0a:f92a with SMTP id h22-20020a056a20159600b000efef0af92amr7552394pzj.25.1682694782370; Fri, 28 Apr 2023 08:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682694782; cv=none; d=google.com; s=arc-20160816; b=mGzuhac5HMWaY0z2bll0EYqW8XrJOVm3bSfAj6XfI715NgA9o2gsvaKPOzhjBTlyl3 kMbLK8VgJEHCDSTK9QUtJidIBtoq0Orhz83FTDbvFCUKX40ZnPbHg+jsWJ4bdy3iKqNc pstGILxqypnT2VDVi9MQkz8pvFrBoj/lmgzvKx/+MjwZv4fT5sdmpgCeb50s/3QhhrYZ qUdV0eA7XxvNpwLjyFD3CuE/SIK1JoV7jK+iJbmUUi9U36GFIMdwBkBV2wF6aaZfULGP 7D1BOrz41Qigy0bYLnuIhsE7pMvEhUb6NSWQUbHC1vdFwXP0KQszkktmLYdMG497MYdJ 1ieQ== 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:dkim-signature:date; bh=6K5PGPkhqqfDzHS0/ulvxssY7bWoPWduvYOiThv73BU=; b=JxWBMkQcufhtswQuUDTP/7iXqEDvOb6rcqsWSMlzUtj7wEYFM9w0wnqq0IC06PnsF7 +9sY5q/GL8EdpERrFGBAUJeQOT9VKUYlBOwqYreE92/d2er8EdaKeq3toDWtAV6Z9/De +YwzrAYZBMpA/ZaRXp3BzQxn40bCQvz03UC76sHP6+nTIWczSiWOhga/Ut8BWvynMLJx Whosb3l6VTaAdNDI7yUeRAF+GVUxe82P1O5ILEQGsM2cK61JvRMHo+t9ktBackQMzbDz 1s19uU5Il4zU92rTT6557RmeKhBBnJQD5Pe/yvDcB6X3+4pL3t7fnmsRRRkVxbCgGGj7 vPAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EagoKORf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l186-20020a6391c3000000b0051b2ba5cb37si22230842pge.437.2023.04.28.08.12.50; Fri, 28 Apr 2023 08:13:02 -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=@linux.dev header.s=key1 header.b=EagoKORf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346341AbjD1PMD (ORCPT + 99 others); Fri, 28 Apr 2023 11:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346289AbjD1PMC (ORCPT ); Fri, 28 Apr 2023 11:12:02 -0400 Received: from out-37.mta0.migadu.com (out-37.mta0.migadu.com [IPv6:2001:41d0:1004:224b::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B0F112D for ; Fri, 28 Apr 2023 08:12:00 -0700 (PDT) Date: Fri, 28 Apr 2023 23:11:55 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1682694718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6K5PGPkhqqfDzHS0/ulvxssY7bWoPWduvYOiThv73BU=; b=EagoKORfAA/gP/NgSqLBPbLwEBKC7pUad6jXfuRyMNNUp8dv1O1Tc9U2mdYpnS+Hiftzfx IT3bgwyh5rlQNyeUqjH+iZVCjUJRDp2aYagi64TLpTED8O+gVQ0ACLkSslgDxVKBeWGaxr ZnS4lWSyeXZhKO9RmEhJqLlUcHtFh00= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Cai Huoqing To: Herbert Xu Cc: 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-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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. 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. > > Cheers, > -- > Email: Herbert Xu > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt