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-next>] [day] [month] [year] [list]
Date:   Sat, 30 Mar 2019 21:54:36 +0300
From:   Yury Norov <yury.norov@...il.com>
To:     Rasmus Villemoes <linux@...musvillemoes.dk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     linux-kernel@...r.kernel.org, Yury Norov <yury.norov@...il.com>,
        Yury Norov <ynorov@...vell.com>
Subject: Re: PATCH 2/2] lib/bitmap.c: guard exotic bitmap functions by
 CONFIG_NUMA

Hi Rasmus!

> From: Rasmus Villemoes <linux@...musvillemoes.dk>
> Sent: Saturday, March 30, 2019 12:53:51 AM
> To: Rasmus Villemoes; Andrew Morton; Andy Shevchenko
> Cc: Yury Norov; linux-kernel@...r.kernel.org
> Subject: [PATCH 2/2] lib/bitmap.c: guard exotic bitmap functions by CONFIG_NUMA
> 
> The bitmap_remap, _bitremap, _onto and _fold functions are only used,
> via their node_ wrappers, in mm/mempolicy.c, which is only built for
> CONFIG_NUMA. The helper bitmap_ord_to_pos used by these functions is
> global, but its only external caller is node_random() in lib/nodemask.c,
> which is also guarded by CONFIG_NUMA.

Nice catch. I think you should protect declaration of those functions
in include/linux/bitmap.h as well.

I'm concerned about pollution of such a generic portion of code with
subsystem-related #ifdefs. Would it make more sense to move numa-specific
stuff to lib/bitmap_numa.c and include/linux/bitmap_numa.h (or *_nodemask.h,
or whatever)?

Yury

> For !CONFIG_NUMA:
> 
> add/remove: 0/6 grow/shrink: 0/0 up/down: 0/-621 (-621)
> Function                                     old     new   delta
> bitmap_pos_to_ord                             20       -     -20
> bitmap_ord_to_pos                             70       -     -70
> bitmap_bitremap                               81       -     -81
> bitmap_fold                                  113       -    -113
> bitmap_onto                                  123       -    -123
> bitmap_remap                                 214       -    -214
> Total: Before=4776, After=4155, chg -13.00%
> 
> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
> ---
>  lib/bitmap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index 66421f304f7d..3f3b8051f342 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -649,6 +649,7 @@ int bitmap_parselist_user(const char __user *ubuf,
>  EXPORT_SYMBOL(bitmap_parselist_user);
> 
> 
> +#ifdef CONFIG_NUMA
>  /**
>   * bitmap_pos_to_ord - find ordinal of set bit at given position in bitmap
>   *     @buf: pointer to a bitmap
> @@ -952,6 +953,7 @@ void bitmap_fold(unsigned long *dst, const unsigned long *orig,
>          for_each_set_bit(oldbit, orig, nbits)
>                  set_bit(oldbit % sz, dst);
>  }
> +#endif /* CONFIG_NUMA */
> 
>  /*
>   * Common code for bitmap_*_region() routines.
> --
> 2.20.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ