Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5312226pxv; Wed, 28 Jul 2021 07:59:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4dz/eymmB0T3lIR2T4FHb5/NHDoAI11wAtmFc7/2Nyf/MRGgzGl8MWb5Sgk5wob0qlttZ X-Received: by 2002:a05:6402:124e:: with SMTP id l14mr280133edw.356.1627484359852; Wed, 28 Jul 2021 07:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627484359; cv=none; d=google.com; s=arc-20160816; b=OpYhBvHV4vKdXUl/dQfBV2gBjC+Vq0WOBEZUb//ubUj0YswH4KlnuoCtqb/hSV8AZF 5G58zyiAqM9rGWckCMxc0hItQYzKwX9GRMrTZQJtgb7W8GFdNtg89Gl8aLQPQ7LRE1xf 8tGx7MZJXI9keDUsI0PkOG3/O7E5x+5ymbDcILf4eIfR6p7IjjizAYoosPTA+6LoG36M BTlo0JjsLeFIeRGWTL018fFNwoglDYYeRvyfglYBGEzL5nCLwALrnnBEOD7bmg8wk2ma QaSR8KnoJCaW6+toBp2yEQnDXYfkaTNt0fs/nvwql76UAoG22fMME1KvXI4/vkkLTMy1 TBug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3gMnfS3ZVPibbkuXLiFXnyctHVfxY7ctQKEATYt20pA=; b=N6+HgVinL5F6rZyv14F5z8zbkpcyz1u32F6wSdk3rygNatjFgSoadYWzcXNRomU4rc Zpgt2KfnPUkwLLL5+XP9t/IZOE2p+lMlwX3OkHQK9kPisYFvROfDFxckHGcjQL3vlZQ3 m+uuDV1nHGnep7/5bhvknHu2mmskSVmsjLHiIyXj/f0Zrnkk7jCfvRxG62N97wMBR9zX cL84TMuJySsEDWm8n2+FmI4+O6t2cyvEFiSwuvltiqKYiiW4j10is3tc7mnpAvafm5V3 pbFCd+SSIxeO/SpCdOuNZu3n3OgUxWEjBtW4qknMfLJLsT3WPvLQPCWyxrGitlycaOw/ 2Lpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pfmsI8yp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fy13si21328ejb.660.2021.07.28.07.58.56; Wed, 28 Jul 2021 07:59:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pfmsI8yp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237505AbhG1Oyo (ORCPT + 99 others); Wed, 28 Jul 2021 10:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237501AbhG1OyV (ORCPT ); Wed, 28 Jul 2021 10:54:21 -0400 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2119BC06179E for ; Wed, 28 Jul 2021 07:54:02 -0700 (PDT) Received: by mail-io1-xd2f.google.com with SMTP id 185so3288593iou.10 for ; Wed, 28 Jul 2021 07:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3gMnfS3ZVPibbkuXLiFXnyctHVfxY7ctQKEATYt20pA=; b=pfmsI8yptPK+F+zbmH/P7nV1g0VhxrPr4niolekbbZBhxJKGiaFoWV2z2gtp8YBtC7 PKMaIyED6eHRroP2XLWVBXV5hAF+lKLqHegvbZHaC/fAmPL/JBtUjhFxawliGMz0+EJx Mj8QAwJGOBXV9qnQ7Ua/11wG+BDQfvKf9eXDFp2JLKJT9YKO2vz6vcoxgaNaDTXVXmfz l6rvfe2XRfLurX73zSvO0YRTdc7F7p+AgGlaSeYUkCcQVPodx6KwUYdWmnR8G/FBPWm2 LlFGgGgEl4/WVjDxN+67QjYe8llra2D5rWRw9fnFmVvn4lQ80dXid0o7OKrAbMqR40U8 Dk3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3gMnfS3ZVPibbkuXLiFXnyctHVfxY7ctQKEATYt20pA=; b=QER3eUNOg2tssi3BPJ2aJinNMxVclRlUGM8ScWcr5lBTeCx6Di8SyHPej3gSwS5n5d n+GZ9kHsVjYvf35PgjuLybornppCLA/6k/YSi2srM9uYxeDjAerO5khBSUwH1za9xW3u bAWM9BtJKbUewv/pJg47Cq/kQaPovbiCctBM+PaWm9pR2+8EVrmh30jI/r+4zH25VK9t Dh6InSVDdDPAzV8s67HKIch4K5gK8t6vFC3dLctxw4VnpCa/fXt6O4vn5Bilh/SYrYy1 bhFXGqsvPh4Tt7qe+qqF+HPeTKPYc01Sfm/hhXYysn5BtUzGgDUYamw6xxQAT1Jm6Scq f+Kw== X-Gm-Message-State: AOAM532JLJRGsPMHrmqQ40Ir/8W8G00STHkGKPSohbme1fl8/MQyT2O3 BDbPzVa12Lf1OjWq0dp3jGQ= X-Received: by 2002:a6b:b24e:: with SMTP id b75mr24185896iof.94.1627484041557; Wed, 28 Jul 2021 07:54:01 -0700 (PDT) Received: from localhost ([12.28.44.171]) by smtp.gmail.com with ESMTPSA id a1sm79496ilp.1.2021.07.28.07.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jul 2021 07:54:01 -0700 (PDT) Date: Wed, 28 Jul 2021 07:53:59 -0700 From: Yury Norov To: Greg KH Cc: Barry Song , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, linux-kernel@vger.kernel.org, dave.hansen@intel.com, linux@rasmusvillemoes.dk, rafael@kernel.org, rdunlap@infradead.org, agordeev@linux.ibm.com, sbrivio@redhat.com, jianpeng.ma@intel.com, valentin.schneider@arm.com, peterz@infradead.org, bristot@redhat.com, guodong.xu@linaro.org, tangchengchang@huawei.com, prime.zeng@hisilicon.com, yangyicong@huawei.com, tim.c.chen@linux.intel.com, linuxarm@huawei.com Subject: Re: [PATCH v7 0/4] use bin_attribute to break the size limitation of cpumap ABI Message-ID: References: <20210715115856.11304-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 --- 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