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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 6 Aug 2021 15:22:19 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Barry Song <song.bao.hua@...ilicon.com>
Cc:     andriy.shevchenko@...ux.intel.com, yury.norov@...il.com,
        linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
        dave.hansen@...el.com, linux@...musvillemoes.dk, rafael@...nel.org,
        rdunlap@...radead.org, agordeev@...ux.ibm.com, sbrivio@...hat.com,
        jianpeng.ma@...el.com, valentin.schneider@....com,
        peterz@...radead.org, bristot@...hat.com, guodong.xu@...aro.org,
        tangchengchang@...wei.com, prime.zeng@...ilicon.com,
        yangyicong@...wei.com, tim.c.chen@...ux.intel.com,
        linuxarm@...wei.com, Tian Tao <tiantao6@...ilicon.com>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v9 1/5] cpumask: introduce
 cpumap_print_list/bitmask_to_buf to support large bitmask and list

On Fri, Aug 06, 2021 at 11:02:47PM +1200, Barry Song wrote:
> From: Tian Tao <tiantao6@...ilicon.com>
> 
> The existing cpumap_print_to_pagebuf() is used by cpu topology and other
> drivers to export hexadecimal bitmask and decimal list to userspace by
> sysfs ABI.
> 
> Right now, those drivers are using a normal attribute for this kind of
> ABIs. A normal attribute typically has show entry as below:
> 
> static ssize_t example_dev_show(struct device *dev,
>                 struct device_attribute *attr, char *buf)
> {
> 	...
> 	return cpumap_print_to_pagebuf(true, buf, &pmu_mmdc->cpu);
> }
> show entry of attribute has no offset and count parameters and this
> means the file is limited to one page only.
> 
> cpumap_print_to_pagebuf() API works terribly well for this kind of
> normal attribute with buf parameter and without offset, count:
> 
> static inline ssize_t
> cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
> {
> 	return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask),
> 				       nr_cpu_ids);
> }
> 
> The problem is once we have many cpus, we have a chance to make bitmask
> or list more than one page. Especially for list, it could be as complex
> as 0,3,5,7,9,...... We have no simple way to know it exact size.
> 
> It turns out bin_attribute is a way to break this limit. bin_attribute
> has show entry as below:
> static ssize_t
> example_bin_attribute_show(struct file *filp, struct kobject *kobj,
>              struct bin_attribute *attr, char *buf,
>              loff_t offset, size_t count)
> {
> 	...
> }
> 
> With the new offset and count parameters, this makes sysfs ABI be able
> to support file size more than one page. For example, offset could be
> >= 4096.
> 
> This patch introduces cpumap_print_bitmask/list_to_buf() and their bitmap
> infrastructure bitmap_print_bitmask/list_to_buf() so that those drivers
> can move to bin_attribute to support large bitmask and list. At the same
> time, we have to pass those corresponding parameters such as offset, count
> from bin_attribute to this new API.
> 
> Signed-off-by: Tian Tao <tiantao6@...ilicon.com>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Cc: Randy Dunlap <rdunlap@...radead.org>
> Cc: Stefano Brivio <sbrivio@...hat.com>
> Cc: Alexander Gordeev <agordeev@...ux.ibm.com>
> Cc: "Ma, Jianpeng" <jianpeng.ma@...el.com>
> Cc: Yury Norov <yury.norov@...il.com>
> Cc: Valentin Schneider <valentin.schneider@....com>
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Daniel Bristot de Oliveira <bristot@...hat.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@...wei.com>
> Signed-off-by: Barry Song <song.bao.hua@...ilicon.com>
> ---
>  include/linux/bitmap.h  |   6 +++
>  include/linux/cpumask.h |  38 +++++++++++++++
>  lib/bitmap.c            | 103 ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 147 insertions(+)
> 
> diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
> index a36cfcec4e77..37f36dad18bd 100644
> --- a/include/linux/bitmap.h
> +++ b/include/linux/bitmap.h
> @@ -227,6 +227,12 @@ unsigned int bitmap_ord_to_pos(const unsigned long *bitmap, unsigned int ord, un
>  int bitmap_print_to_pagebuf(bool list, char *buf,
>  				   const unsigned long *maskp, int nmaskbits);
>  
> +extern int bitmap_print_bitmask_to_buf(char *buf, const unsigned long *maskp,
> +				      int nmaskbits, loff_t off, size_t count);
> +
> +extern int bitmap_print_list_to_buf(char *buf, const unsigned long *maskp,
> +				      int nmaskbits, loff_t off, size_t count);
> +

Why are you adding bitmap_print_list_to_buf() when no one uses it in
this patch series?

Did I miss it somewhere?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ