From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1D6FC47082 for ; Thu, 3 Jun 2021 11:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3319613E6 for ; Thu, 3 Jun 2021 11:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbhFCLi7 (ORCPT ); Thu, 3 Jun 2021 07:38:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhFCLi5 (ORCPT ); Thu, 3 Jun 2021 07:38:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C8DD5613AC; Thu, 3 Jun 2021 11:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622720232; bh=0gLZ9g8iAboVpWt2uwfaT+jpDf1d5VdL31sN27J+lvQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1i+2+iavWzxGb0uoilselBTfz0f08un6iuHsY/AZ3hFV//yeOwhtv+RDG5aQfo0gU Yj7VPiMYbjAfy+foMZjWWMHgE6UoPOYks3pdXjXNRWC4+rWXO8uWKK9WOHOfnzwGzO 9aZVagoE9nMiptq0XCoQLmNAh6B3EUZcO4MFVKzc= Date: Thu, 3 Jun 2021 13:37:09 +0200 From: Greg KH To: "tiantao (H)" Cc: Andy Shevchenko , Tian Tao , 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> <95f5e01d-79c1-28f3-f27b-bee4398308de@huawei.com> <0a43ca2a-7563-0bd6-fd1f-3fef208d71ef@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0a43ca2a-7563-0bd6-fd1f-3fef208d71ef@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 03, 2021 at 07:21:30PM +0800, tiantao (H) wrote: > > 在 2021/6/3 18:49, Greg KH 写道: > > On Thu, Jun 03, 2021 at 06:33:25PM +0800, tiantao (H) wrote: > > > 在 2021/6/3 17:50, Andy Shevchenko 写道: > > > > 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? > > > yes, I already test it. > > Great, can you add the test to the patch series as well so that we can > > make sure it does not break in the future? > How do I do this?  Do I need to provide a kselftest ? That would be wonderful, great idea! thanks, greg k-h