Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp135795pxj; Thu, 3 Jun 2021 02:53:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSQDrsa/ztaBEPPVltmNXsl3cMvwufnOQ5fqFJt8J8eX8af2+Z1Ko3bd9JXCEK3Ltn/c7s X-Received: by 2002:a17:906:6981:: with SMTP id i1mr37949563ejr.289.1622713984704; Thu, 03 Jun 2021 02:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622713984; cv=none; d=google.com; s=arc-20160816; b=RUHORsmYNNb32hAhIFiukuOTg+VY3RnIgpsjotYcyX1hrhtq1zvDEqPSrFub5t4gzI uCCJcKLsuD+tMIl8av1LGqjHRQV0w5/iZhzk0ULbEFjBKA5pcLdsMEGFOje2+K/6eA80 C005sEwWaXm9FdkOTO8kcg7mcDvfeTSxF0mkMjDBflJCDCSMpu6/l8JBAfKYrznK2ZII ilMDq9TSYHxv4gSnCYYfs8NdMhR9NwXkAE1LnE6NMe2zWrQ7dlhpDHAwcYCrjWFYYBcM jTdZaV6cNNtRIj9vOMZaEbK2Hl2c/B4mExXhiny06WDfPexqzDzXGs9ZNfM/JdfbmkE1 CzoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=MvjSABdCQYlvkzFhQS97OeD8xuo86hq4kt6QSSjX4zs=; b=Mxpujlg0dPQqBMZUylMK6XRaxvwffRIHfTgdT8iQa5JFZImCp/mEiVxAQnHArMKvcy aHwiy32KFfTU6J0fdZNt//Abi7LFCrOYWbazjPVZKvSE9urleFR2/DuiyPppk++A/Nfg oBi0SrsnQwzmBNq0ls1MnLCeZ4AmNIme47pj5g0gtEW6CzH2AwBdurYo0PWxNFLvsPm0 HOtE89qLwDPvaaNSYX2tIL2OqO5vwTVALRK2gcrh7Ms0ThhdCUk0wpzGjI7AByTNycwY q3doGrsbPNv/WBOseHL3E8V/ZLdQkw0Fsr+XFUN8pFPXgR/qwNH73JywqRkajhIpPKxO lPMA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf28si2109543edb.71.2021.06.03.02.52.41; Thu, 03 Jun 2021 02:53:04 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbhFCJwq (ORCPT + 99 others); Thu, 3 Jun 2021 05:52:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:7576 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbhFCJwp (ORCPT ); Thu, 3 Jun 2021 05:52:45 -0400 IronPort-SDR: jcHeadFD4jmcVkjxTAhoJF/rRfGGL7VBd8pz9xBQlOCeH8U0wxqV/re5Oz9Pxyas5gzelFfzWe G5C/tXGBg4Uw== X-IronPort-AV: E=McAfee;i="6200,9189,10003"; a="289637732" X-IronPort-AV: E=Sophos;i="5.83,244,1616482800"; d="scan'208";a="289637732" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2021 02:50:48 -0700 IronPort-SDR: egrW79uVlQVySoOBpQjcExImZeWGgQciy1ymwqfJNC0je8AQlvRDGBB5mWJGsR5mM1hxLbqETO bhmZXxDnoNQA== X-IronPort-AV: E=Sophos;i="5.83,244,1616482800"; d="scan'208";a="467905605" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2021 02:50:44 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lojzt-00GuV7-Hf; Thu, 03 Jun 2021 12:50:41 +0300 Date: Thu, 3 Jun 2021 12:50:41 +0300 From: Andy Shevchenko To: Tian Tao Cc: gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, jonathan.cameron@huawei.com, song.bao.hua@hisilicon.com, Randy Dunlap , Stefano Brivio , Alexander Gordeev , "Ma, Jianpeng" , Yury Norov , Valentin Schneider , Peter Zijlstra , Daniel Bristot de Oliveira Subject: Re: [PATCH v3 1/3] lib: bitmap: introduce bitmap_print_to_buf Message-ID: References: <1622712162-7028-1-git-send-email-tiantao6@hisilicon.com> <1622712162-7028-2-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1622712162-7028-2-git-send-email-tiantao6@hisilicon.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 03, 2021 at 05:22:40PM +0800, Tian Tao wrote: > New API bitmap_print_to_buf() with bin_attribute to avoid maskp > exceeding PAGE_SIZE. bitmap_print_to_pagebuf() is a special case > of bitmap_print_to_buf(), so in bitmap_print_to_pagebuf() call > bitmap_print_to_buf(). ... > /** > + * bitmap_print_to_buf - convert bitmap to list or hex format ASCII string > + * @list: indicates whether the bitmap must be list > + * @buf: the kernel space buffer to read to > + * @maskp: pointer to bitmap to convert > + * @nmaskbits: size of bitmap, in bits > + * @off: offset in data buffer below > + * @count: the maximum number of bytes to print > + * > + * The role of bitmap_print_to_buf() and bitmap_print_to_pagebuf() is > + * the same, the difference is that buf of bitmap_print_to_buf() > + * can be more than one pagesize. > + */ > +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; > + > + if (off == LLONG_MAX && count == PAGE_SIZE - offset_in_page(buf)) > + return scnprintf(buf, count, fmt, nmaskbits, maskp); > + > + data = kasprintf(GFP_KERNEL, fmt, nmaskbits, maskp); > + if (!data) > + return -ENOMEM; > + > + size = memory_read_from_buffer(buf, count, &off, data, strlen(data) + 1); Are you sure you have put parameters in the correct order? > + kfree(data); > + > + return size; > +} I guess you have to provide the test case(s). -- With Best Regards, Andy Shevchenko