Messages in this thread Patch in this message | | | Date | Wed, 28 Jul 2021 07:53:59 -0700 | From | Yury Norov <> | Subject | Re: [PATCH v7 0/4] use bin_attribute to break the size limitation of cpumap ABI |
| |
On Wed, Jul 28, 2021 at 03:41:00PM +0200, Greg KH wrote: > On Thu, Jul 15, 2021 at 11:58:52PM +1200, Barry Song wrote: > > v7: > > - update doc in code for new APIs according to the comments of > > Andy Shevchenko; > > - other minor cleanup and commit log fix according to the comments > > of Andy Shevchenko > > I'm lost to tell if this is the latest version or if there are more > changes? Can you send this again with the latest changes so I can > review it?
Barry, Greg,
If you decide to keep bitmap_print_to_buf in lib/bitmap.c, could you please add the following patch to the series.
Thanks, Yury
From 58602766dc2877d2103a334db6c2c2e1e6b8c89b Mon Sep 17 00:00:00 2001 From: Yury Norov <yury.norov@gmail.com> Date: Wed, 28 Jul 2021 07:39:30 -0700 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@gmail.com> --- 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() 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
| |