Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp852827pxv; Thu, 15 Jul 2021 17:59:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW0j1MnG6mFIcO4IegzMGPmk6G5ZH6fZrUuD/JmNM/UmIl1PWpSQkYglb6AHy324wrJaxh X-Received: by 2002:a05:6402:1057:: with SMTP id e23mr11031975edu.352.1626397167177; Thu, 15 Jul 2021 17:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626397167; cv=none; d=google.com; s=arc-20160816; b=PqaKYs6F2/XWpugU+KV84kAbw6NGaRu35MHGPl4odaEkQFncq8mD9ZrQqP2f65n+9Z /BsuzB/+xmuettwtCU3Gcpgd9hKAITClAf4sd+HMuBbLwOJ1xGJzkWuhd52RUqEm3aNk XrcSO2IFfe4zteT87hUVuSQWTiiLyOCMgTojvirI7so76VNpcccWFALPP9jduIOUdNtJ x0iuJWS2h52p4YdDxRSYSK4RhbGOwjWIjZcTceXz8i0Es53HhPe9l3SKhCjDSK2ADBBR p0DJCrhk272X7oXmHA82CyRlHM8mU2yLG8pIzuU7R6NBA9bOelypcpOXFpLYCyhxrCLi jn8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=Y6JMucWwOwALdIrV9QzIV11dmh3AyljSMphUTZDCri0=; b=rBbakRnZjqO2Js+IsI54iBJzbMt1MkimMsAuXwhTyqpPahTSfzG2fnhT9NQsoUxzDw h7QUhU7K9+e61IgWEF0SHyixK06jd5NUEuzlEI03yX9IdA6JWvJOAN7PFH+GcnQb6aQ4 1LvCm+P8dffdRJwx9oL3tx1OEY7imFZ8tiGhcJrSlpEp0McN9YlmptpTtLa2s0QNM4mf oWlKKkEDmAhv9j3YrU/G5FXDFvUUm/VfNrBPCXY3LF8kBmlrTa4dSOTe2P+EmIi+IVtH ATDvlydwRN49kK5/gA25k1oAdjgirY45JmTJaMufF4/DxINsndjUm9IuIG5BBklIKNxo lvhg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j18si8913253edq.104.2021.07.15.17.59.03; Thu, 15 Jul 2021 17:59:27 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232428AbhGPBAk convert rfc822-to-8bit (ORCPT + 99 others); Thu, 15 Jul 2021 21:00:40 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:11428 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbhGPBAk (ORCPT ); Thu, 15 Jul 2021 21:00:40 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GQt6n3Ty2zcdgN; Fri, 16 Jul 2021 08:54:25 +0800 (CST) Received: from dggema721-chm.china.huawei.com (10.3.20.85) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 08:57:44 +0800 Received: from dggemi761-chm.china.huawei.com (10.1.198.147) by dggema721-chm.china.huawei.com (10.3.20.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Fri, 16 Jul 2021 08:57:43 +0800 Received: from dggemi761-chm.china.huawei.com ([10.9.49.202]) by dggemi761-chm.china.huawei.com ([10.9.49.202]) with mapi id 15.01.2176.012; Fri, 16 Jul 2021 08:57:43 +0800 From: "Song Bao Hua (Barry Song)" To: Yury Norov CC: "gregkh@linuxfoundation.org" , "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 , "Zengtao (B)" , yangyicong , "tim.c.chen@linux.intel.com" , Linuxarm , "tiantao (H)" Subject: RE: [PATCH v7 1/4] cpumask: introduce cpumap_print_to_buf to support large bitmask and list Thread-Topic: [PATCH v7 1/4] cpumask: introduce cpumap_print_to_buf to support large bitmask and list Thread-Index: AQHXeXDit9Gt0OAGGEazhWq8ex3QcatDoywAgADd7JCAAETwQA== Date: Fri, 16 Jul 2021 00:57:43 +0000 Message-ID: References: <20210715115856.11304-1-song.bao.hua@hisilicon.com> <20210715115856.11304-2-song.bao.hua@hisilicon.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.202.67] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Song Bao Hua (Barry Song) > Sent: Friday, July 16, 2021 9:08 AM > To: 'Yury Norov' > Cc: gregkh@linuxfoundation.org; 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 > ; Zengtao (B) ; > yangyicong ; tim.c.chen@linux.intel.com; Linuxarm > ; tiantao (H) > Subject: RE: [PATCH v7 1/4] cpumask: introduce cpumap_print_to_buf to support > large bitmask and list > > > > > -----Original Message----- > > From: Yury Norov [mailto:yury.norov@gmail.com] > > Sent: Friday, July 16, 2021 3:29 AM > > To: Song Bao Hua (Barry Song) > > Cc: gregkh@linuxfoundation.org; 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 > > ; Zengtao (B) ; > > yangyicong ; tim.c.chen@linux.intel.com; Linuxarm > > ; tiantao (H) > > Subject: Re: [PATCH v7 1/4] cpumask: introduce cpumap_print_to_buf to support > > large bitmask and list > > > > On Thu, Jul 15, 2021 at 11:58:53PM +1200, Barry Song wrote: > > > (10.1.198.147) > > > X-CFilter-Loop: Reflected > > > Status: O > > > Content-Length: 10263 > > > Lines: 252 > > > > > > From: Tian Tao > > > > [...] > > > > > +int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp, > > > + int nmaskbits, loff_t off, size_t count) > > > +{ > > > + const char *fmt = list ? "%*pbl\n" : "%*pb\n"; > > > + ssize_t size; > > > + void *data; > > > + > > > + data = kasprintf(GFP_KERNEL, fmt, nmaskbits, maskp); > > > + if (!data) > > > + return -ENOMEM; > > > + > > > + size = memory_read_from_buffer(buf, count, &off, data, strlen(data) + > 1); > > > + kfree(data); > > > + > > > + return size; > > > +} > > > +EXPORT_SYMBOL(bitmap_print_to_buf); > > > > In discussion to v4 of this series I've pointed out inefficiency of > > this approach. Now it's v7, but the problem is still there. > > > > 1. You make user of your API guess aboout proper @count without any > > hint. This is worse than how it works now with pure vsnprintf(). > > This isn't true. While this count comes from sysfs bin_attribute, > sysfs show() entry guarantee the count is proper and inside the > valid range of the buffer. Otherwise, sysfs bin_attribute has totally > broken for all users. In addition, "You make user of your API guess about proper @count without any hint" isn't true either. For a sysfs ABI and other files, users will get EOF when it arrives the end of the file. This is exactly the hint for users to stop further reading. The new APIs are serving ABI purpose. hardly other kernel modules will want a printed list. Thanks Barry