All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cai Huoqing <cai.huoqing@linux.dev>
To: Herbert Xu <herbert@gondor.apana.org.au>
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
Date: Fri, 28 Apr 2023 23:11:55 +0800	[thread overview]
Message-ID: <ZEviO+NPFP/IoiO2@chq-MS-7D45> (raw)
In-Reply-To: <ZEjw7XXFro6zYYXz@gondor.apana.org.au>

On 26 4月 23 17:37:49, Herbert Xu wrote:
> Cai Huoqing <cai.huoqing@linux.dev> 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 <cai.huoqing@linux.dev>
> > ---
> > 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 <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2023-04-28 15:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 14:45 [PATCH] netdevsim: fib: Make use of rhashtable_iter Cai Huoqing
2023-04-25 15:41 ` Jakub Kicinski
2023-04-26  9:37 ` Herbert Xu
2023-04-28 15:11   ` Cai Huoqing [this message]
2023-04-30  8:20     ` Ido Schimmel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZEviO+NPFP/IoiO2@chq-MS-7D45 \
    --to=cai.huoqing@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.