Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp199783pxj; Thu, 3 Jun 2021 04:40:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydzoDHJycwnaxe2+Q92P3DrHx8GxthC0D9NhBnk2QTLS7iXYR5krcvs4DQYip2BgHt1iN1 X-Received: by 2002:a17:906:9512:: with SMTP id u18mr16975736ejx.61.1622720418251; Thu, 03 Jun 2021 04:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622720418; cv=none; d=google.com; s=arc-20160816; b=PVHIGojcp4YSqORoP44CYbbO+/FycGW3y/Le0807/BYGLOOBwe127VISozcbZ61U1y ZYAxtph7QE9maVjmNwm7QfSEY7fEjpRlvY4QlZu+WPjNpzSqiRwX61d+k9CNhFd8u6TO UmsQKE3v6ouqfJDHFQAWNYS/dofHJjicq1btgZY6Vsa0y5lD4eQl1aZ8vt6mEEiREqpW GrgzBJU6zSVlWkooQYVpyZwOrmzw47Lf32ANLC6Zv2q73ppfjaWrU7bBt2C2uq/B7XlP nKf7HwOJ4TwxWOYqXi0kNkDdCM5axzWZeR2t+yoYef0NHibR+E3vK+W2BRnKH28qI35H 14FQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kYAfJ7rz9zHlt6DOkSIljmHSwAWRwk53VJCTNH+XtR4=; b=rWyvrHBt3Q65IjY1CF9KflzvGFVFEH5J0Cjcm8bHzPT+jnnXg/eGa2FZd7CnGv+euY b4Su7GiQOGeREUXCaijzixIX+XKUb0gnAMtnaEbpouC5EO9w4MOhzFrvfxYeNsdAz1vO nKTgdNrrh2HaI855gk7CuG7XDaJIfPzDCSO/KNBj6jM1QSZurQpFXf/5ag5u9J2J6b75 7czpyMvJyqt88zNQIwWhGb6Q0J+fmQ8AhLt9Rn33V4IBHuOch5rLK8FM9jO/MRVU8c3V sggcSU+K5kiMf5VPGHvPWR/24wNvUvUkaXmzkVyMDcf4MjtdWxJ834+ImbmjBFUxQ886 jjfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1urpEkwA; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z25si2287930edq.402.2021.06.03.04.39.55; Thu, 03 Jun 2021 04:40:18 -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=@linuxfoundation.org header.s=korg header.b=1urpEkwA; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbhFCLkE (ORCPT + 99 others); Thu, 3 Jun 2021 07:40:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:38342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229697AbhFCLkE (ORCPT ); Thu, 3 Jun 2021 07:40:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AED63613AC; Thu, 3 Jun 2021 11:38:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622720283; bh=XYkSTdSwKrmOV+bXH1aSs5Xi0fdya8CkNHPLXC3OmxQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1urpEkwAZ7bfc2p7qpc/0yOaPN+wqVywQz30wgfYHIwSjUXFLOvBKHt+a/mukfeCn pWOf9zj3ja+judDLFY6djQNBJdM6l8LNO4JecwQHt9NSy5FDRyFmRkh0AKuC72W+FM oTPx7B6uEL7vP5Wcxkm73u6X2k+CAMRKRgB8N9HU= Date: Thu, 3 Jun 2021 13:38:00 +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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 03, 2021 at 01:37:09PM +0200, Greg KH wrote: > 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! Or, as this is an internal kernel api, using kunit might be easier. Obviously you tested this somehow, so just take advantage of the code you wrote for that. thanks, greg k-h