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] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z0bKT9nbSlw9WeM_@gpd3>
Date: Wed, 27 Nov 2024 08:29:19 +0100
From: Andrea Righi <arighi@...dia.com>
To: Yury Norov <yury.norov@...il.com>
Cc: Tejun Heo <tj@...nel.org>, David Vernet <void@...ifault.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] nodemask: Introduce
 for_each_node_mask_from/for_each_node_state_from()

On Tue, Nov 26, 2024 at 05:23:46PM -0800, Yury Norov wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Tue, Nov 26, 2024 at 10:56:39AM +0100, Andrea Righi wrote:
> > Introduce NUMA node iterators to support circular iteration, starting
> > from a specified node.
> 
> We have a special suffix for circular iterators - "wrap".

Ok.

> 
> > Signed-off-by: Andrea Righi <arighi@...dia.com>
> > ---
> >  include/linux/nodemask.h | 18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
> > diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
> > index b61438313a73..35f1fcdd6a84 100644
> > --- a/include/linux/nodemask.h
> > +++ b/include/linux/nodemask.h
> > @@ -392,6 +392,21 @@ static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
> >       for ((node) = 0; (node) < 1 && !nodes_empty(mask); (node)++)
> >  #endif /* MAX_NUMNODES */
> >
> > +#if MAX_NUMNODES > 1
> > +#define for_each_node_mask_from(node, mask, start, cnt)                      \
> 
> You can just use for_each_set_bit_wrap() here, and avoid this ugly
> 'cnt' in the interface.
> 
>  #define for_each_node_mask_wrap(node, nodemask, start)                 \
>         for_each_set_bit_wrap((node), (nodemask)->bits, (start))
> 
> (not tested though)

Ah this looks much better, I'll test this one.

Thanks,
-Andrea

> 
> Thanks,
> Yury
> 
> > +     for ((node) = (start), (cnt) = 0;                               \
> > +          (cnt) == 0 || (node) != (start);                           \
> > +          (cnt)++, (node) =                                          \
> > +                     next_node((node), (mask)) >= MAX_NUMNODES ?     \
> > +                             first_node(mask) :                      \
> > +                             next_node((node), (mask)))
> > +#else /* MAX_NUMNODES == 1 */
> > +#define for_each_node_mask_from(node, mask, start, cnt)                      \
> > +     for ((node) = 0;                                                \
> > +          (node) < 1 && !nodes_empty(mask);                          \
> > +          (node)++, (void)(start), (void)(cnt))
> > +#endif /* MAX_NUMNODES */
> > +
> >  /*
> >   * Bitmasks that are kept for all the nodes.
> >   */
> > @@ -441,6 +456,9 @@ static inline int num_node_state(enum node_states state)
> >  #define for_each_node_state(__node, __state) \
> >       for_each_node_mask((__node), node_states[__state])
> >
> > +#define for_each_node_state_from(__node, __state, __start, __cnt) \
> > +     for_each_node_mask_from((__node), node_states[__state], __start, __cnt)
> > +
> >  #define first_online_node    first_node(node_states[N_ONLINE])
> >  #define first_memory_node    first_node(node_states[N_MEMORY])
> >  static inline unsigned int next_online_node(int nid)
> > --
> > 2.47.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ