[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <eec4210a5d724cccb2931a3f4403e5be@hisilicon.com>
Date: Thu, 29 Jul 2021 06:04:09 +0000
From: "Song Bao Hua (Barry Song)" <song.bao.hua@...ilicon.com>
To: Yury Norov <yury.norov@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
CC: "dave.hansen@...el.com" <dave.hansen@...el.com>,
"linux@...musvillemoes.dk" <linux@...musvillemoes.dk>,
"rafael@...nel.org" <rafael@...nel.org>,
"rdunlap@...radead.org" <rdunlap@...radead.org>,
"agordeev@...ux.ibm.com" <agordeev@...ux.ibm.com>,
"sbrivio@...hat.com" <sbrivio@...hat.com>,
"jianpeng.ma@...el.com" <jianpeng.ma@...el.com>,
"valentin.schneider@....com" <valentin.schneider@....com>,
"peterz@...radead.org" <peterz@...radead.org>,
"bristot@...hat.com" <bristot@...hat.com>,
"guodong.xu@...aro.org" <guodong.xu@...aro.org>,
tangchengchang <tangchengchang@...wei.com>,
"Zengtao (B)" <prime.zeng@...ilicon.com>,
yangyicong <yangyicong@...wei.com>,
"tim.c.chen@...ux.intel.com" <tim.c.chen@...ux.intel.com>,
Linuxarm <linuxarm@...wei.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"andriy.shevchenko@...ux.intel.com"
<andriy.shevchenko@...ux.intel.com>
Subject: RE: [PATCH] bitmap: extend comment to bitmap_print_to_buf
> -----Original Message-----
> From: Yury Norov [mailto:yury.norov@...il.com]
> Sent: Thursday, July 29, 2021 6:59 AM
> To: linux-kernel@...r.kernel.org; gregkh@...uxfoundation.org; Song Bao Hua
> (Barry Song) <song.bao.hua@...ilicon.com>
> Cc: Yury Norov <yury.norov@...il.com>; 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 <tangchengchang@...wei.com>; Zengtao (B)
> <prime.zeng@...ilicon.com>; yangyicong <yangyicong@...wei.com>;
> tim.c.chen@...ux.intel.com; Linuxarm <linuxarm@...wei.com>;
> akpm@...ux-foundation.org; andriy.shevchenko@...ux.intel.com
> Subject: [PATCH] bitmap: extend comment to bitmap_print_to_buf
>
> Extend comment to new function to warn potential users about caveats.
>
> Signed-off-by: Yury Norov <yury.norov@...il.com>
> ---
Looks awesome. Thanks, Yury. I have integrated your patch into
the latest series v8.
> lib/bitmap.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/lib/bitmap.c b/lib/bitmap.c
> index 56bcffe2fa8c..b9f557ca668c 100644
> --- a/lib/bitmap.c
> +++ b/lib/bitmap.c
> @@ -545,6 +545,24 @@ EXPORT_SYMBOL(bitmap_print_to_pagebuf);
> * mainly serves bin_attribute which doesn't work with exact one page, and it
> * can break the size limit of converted decimal list and hexadecimal bitmask.
> *
> + * WARNING!
> + *
> + * This function is not a replacement for sprintf() or
> bitmap_print_to_pagebuf().
> + * It is intended to workaround sysfs limitations discussed above and should
> be
> + * used carefully in general case for the following reasons:
> + * - Time complexity is O(nbits^2/count), comparing to O(nbits) for snprintf().
> + * - Memory complexity is O(nbits), comparing to O(1) for snprintf().
> + * - @off and @count are NOT offset and number of bits to print.
> + * - If printing part of bitmap as list, the resulting string is not a correct
> + * list representation of bitmap. Particularly, some bits within or out of
> + * related interval may be erroneously set or unset. The format of the string
> + * may be broken, so bitmap_parselist-like parser may fail parsing it.
> + * - If printing the whole bitmap as list by parts, user must ensure the order
> + * of calls of the function such that the offset is incremented linearly.
> + * - If printing the whole bitmap as list by parts, user must keep bitmap
> + * unchanged between the very first and very last call. Otherwise concatenated
> + * result may be incorrect, and format may be broken.
> + *
> * Returns the number of characters actually printed to @buf
> */
> int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
> --
> 2.30.2
Thanks
Barry
Powered by blists - more mailing lists