lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sun, 30 Apr 2023 11:20:16 +0300
From:   Ido Schimmel <idosch@...sch.org>
To:     Cai Huoqing <cai.huoqing@...ux.dev>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>, kuba@...nel.org,
        davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] netdevsim: fib: Make use of rhashtable_iter

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 <cai.huoqing@...ux.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@...ux.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.

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ