Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1302752pxb; Sat, 9 Jan 2021 15:04:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVrfOkOQlqddAPv3Qr8e8IWLpeIc8wa3XpIqBm6aTnlhb0ZcLhj2eFVw1mQfvgyYqsbWq0 X-Received: by 2002:aa7:d999:: with SMTP id u25mr9449922eds.297.1610233445957; Sat, 09 Jan 2021 15:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610233445; cv=none; d=google.com; s=arc-20160816; b=yfZbyEU+CM+IOEHcMdW5nLVpc6PpKUVfsGZjlzWC9MnHVTBYlA4SNq++OQ1hCYSh/N OwsXU+rWOyX8kqRIjyBIJHVvMWeuqlDrSkP9SpnspAEpkvM+AjaaULLnVwF/o5VbckG3 Js/Wo0MUYKemvu3pYXVJKIikLxpuk8UDVomb/aRukw7+wzoH/Vhz10gGMPA63ePrMIPi 44lPUeGdkyCvCwlLeyvI7yoN+oUqpzybT8c0FreTIvMU7hebFyqUtwotuto0XbWqSSOJ Q4+nS40FohXeR7739MfkH4MDOwjlLI2XaJKryOmckx6Evm/nof/9XbAuoRfTiNLKPObS 9mBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:reply-to; bh=bgSuUBiQqS50MgrQAx+/XdUjj3hBaZjg2ohjtvbOYCw=; b=FzhDYJTGaPtlws08cmFyeD+oD6wbl9EiFRirhPcOr+aEIQpPULdT0g0B4I9VTcyR/R OpG3kI53Bu8h5qwNUaWwioIpDgHqpCH9i2K/20b+nBTJoWLjn9nCJF+t67A0FqpfidT9 +QrVCGp24Joa/sJ/Oyoi0EUbH2zWF5XuROtSj/whAOltabiafs5vmDUJAHzo1oEu/Eds 7bpF20KK4lmr65iRqxH4gPUvXmtvODn8YGXz8Qaw6bGrvImSeWB20IJYpTT+cCGnO5si yXUyn4Yqx4b2+EemYKuq/Wb0h27iKUjDpDlqtKJiOQf1EVgct7nusjhazsKnZoF1KlrZ i3uA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si4946603ejg.205.2021.01.09.15.03.42; Sat, 09 Jan 2021 15:04:05 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726390AbhAIXBY (ORCPT + 99 others); Sat, 9 Jan 2021 18:01:24 -0500 Received: from mail-1.ca.inter.net ([208.85.220.69]:60552 "EHLO mail-1.ca.inter.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726281AbhAIXBY (ORCPT ); Sat, 9 Jan 2021 18:01:24 -0500 Received: from localhost (offload-3.ca.inter.net [208.85.220.70]) by mail-1.ca.inter.net (Postfix) with ESMTP id 9D28D2EA01D; Sat, 9 Jan 2021 18:00:42 -0500 (EST) Received: from mail-1.ca.inter.net ([208.85.220.69]) by localhost (offload-3.ca.inter.net [208.85.220.70]) (amavisd-new, port 10024) with ESMTP id RP9EYr1UqlHY; Sat, 9 Jan 2021 17:47:42 -0500 (EST) Received: from [192.168.48.23] (host-104-157-204-209.dyn.295.ca [104.157.204.209]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: dgilbert@interlog.com) by mail-1.ca.inter.net (Postfix) with ESMTPSA id 1599B2EA0BD; Sat, 9 Jan 2021 18:00:42 -0500 (EST) Reply-To: dgilbert@interlog.com Subject: Re: [PATCH v5 4/4] scatterlist: add sgl_memset() To: Jason Gunthorpe Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, target-devel@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, bostroesser@gmail.com, bvanassche@acm.org, ddiss@suse.de References: <20201228234955.190858-1-dgilbert@interlog.com> <20201228234955.190858-5-dgilbert@interlog.com> <20210107174629.GC504133@ziepe.ca> From: Douglas Gilbert Message-ID: <9b727a9a-eb58-ab20-f42b-aa9c9e90a49a@interlog.com> Date: Sat, 9 Jan 2021 18:00:41 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210107174629.GC504133@ziepe.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-CA Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-07 12:46 p.m., Jason Gunthorpe wrote: > On Mon, Dec 28, 2020 at 06:49:55PM -0500, Douglas Gilbert wrote: >> The existing sg_zero_buffer() function is a bit restrictive. For >> example protection information (PI) blocks are usually initialized >> to 0xff bytes. As its name suggests sgl_memset() is modelled on >> memset(). One difference is the type of the val argument which is >> u8 rather than int. Plus it returns the number of bytes (over)written. >> >> Change implementation of sg_zero_buffer() to call this new function. >> >> Reviewed-by: Bodo Stroesser >> Signed-off-by: Douglas Gilbert >> include/linux/scatterlist.h | 3 ++ >> lib/scatterlist.c | 65 +++++++++++++++++++++++++------------ >> 2 files changed, 48 insertions(+), 20 deletions(-) >> >> diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h >> index 71be65f9ebb5..70d3f1f73df1 100644 >> +++ b/include/linux/scatterlist.h >> @@ -333,6 +333,9 @@ bool sgl_compare_sgl_idx(struct scatterlist *x_sgl, unsigned int x_nents, off_t >> struct scatterlist *y_sgl, unsigned int y_nents, off_t y_skip, >> size_t n_bytes, size_t *miscompare_idx); >> >> +size_t sgl_memset(struct scatterlist *sgl, unsigned int nents, off_t skip, >> + u8 val, size_t n_bytes); >> + >> /* >> * Maximum number of entries that will be allocated in one piece, if >> * a list larger than this is required then chaining will be utilized. >> diff --git a/lib/scatterlist.c b/lib/scatterlist.c >> index 9332365e7eb6..f06614a880c8 100644 >> +++ b/lib/scatterlist.c >> @@ -1038,26 +1038,7 @@ EXPORT_SYMBOL(sg_pcopy_to_buffer); >> size_t sg_zero_buffer(struct scatterlist *sgl, unsigned int nents, >> size_t buflen, off_t skip) >> { >> - unsigned int offset = 0; >> - struct sg_mapping_iter miter; >> - unsigned int sg_flags = SG_MITER_ATOMIC | SG_MITER_TO_SG; >> - >> - sg_miter_start(&miter, sgl, nents, sg_flags); >> - >> - if (!sg_miter_skip(&miter, skip)) >> - return false; >> - >> - while (offset < buflen && sg_miter_next(&miter)) { >> - unsigned int len; >> - >> - len = min(miter.length, buflen - offset); >> - memset(miter.addr, 0, len); >> - >> - offset += len; >> - } >> - >> - sg_miter_stop(&miter); >> - return offset; >> + return sgl_memset(sgl, nents, skip, 0, buflen); >> } >> EXPORT_SYMBOL(sg_zero_buffer); > > May as well make this one liner a static inline in the header. Just > rename this function to sgl_memset so the diff is clearer Yes, fine. I can roll a new version. Doug Gilbert