Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp3377931rwb; Sun, 30 Jul 2023 06:29:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlGbfQXa/y5AIs5gC045mW2qBGpHCQlAFF8s9sfrokz5GqMPKnMGHA75KKfRLBeVYWSoXRlP X-Received: by 2002:a17:907:75dc:b0:99b:f8ab:f675 with SMTP id jl28-20020a17090775dc00b0099bf8abf675mr3852185ejc.14.1690723788212; Sun, 30 Jul 2023 06:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690723788; cv=none; d=google.com; s=arc-20160816; b=jLFPbOVNAfrKwUlbfAMDiBucxUvcu8DgVSQikGEcabobicXdkeCq3740CsYFNYpBBH PgCQYiRdNA7wDKXthU/HqpQuzuDVX/VF68v9dmBTnlHzShGlXNI9fjDa8HyF2ccOaTxD USW8I0td/eCsuZjs8736bVGDVfsPcMHq8iWIaDRK1kLc4D+q7PTOX5QtTevFyNiDLQd0 GX2LoDD0Di+NL3RxhEdXVRuDoH9bpfQ0bIF9KSx6i5XTSwxQevi50VODzLvx0iwOhDfW F18oj+gy4mpRY4d+r3GUMt9j2ZUz7W86VzEQZ7sgOkvYQrSvvhvepEzzrhN0Pm1AfVq7 xIXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:mime-version:date:dkim-signature :message-id; bh=YDqItS6TsBITc0ogQeiO9zs2cfijso9HiN6zsa9jo50=; fh=qTGzHVWl/OtiIJBDVuyqDkjjlZysaMuqHVNtaTrKc88=; b=iN0FM4vdsvVhGe4k4BKACPDahAO3BVNt2oIl0xoDMbAsEcC8BkZtcvk4KQuAFu1iXk xPqXj15hSYKTVWDuQq1GRU8ltlXzHbYOiT7weRfSLvc8PaJ5RRPeJeXQpdShN5pMamMV H61iApJfXRYMsrsNlCCBfPt5rfPVFYO1PP0xSMByyyWQD/v7VLXWy1c7it5V6tn5SPWq Uapaad/4l+GXIlxqxReNl3X+3z6Rz0BG/e7sHtMZH0wDOcM5YXkkJDxAHflFgcnVH2Vy 5g3RYu9YQlqUoNeoSC38nRbK3S0D1J9V7X7RUs2d3Bef+MT66OOk0Tm/CLK2NJhVmvXX HTaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XpXFu6Wx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a170906940d00b009939d1b60bdsi5130911ejx.67.2023.07.30.06.29.23; Sun, 30 Jul 2023 06:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XpXFu6Wx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229951AbjG3LH3 (ORCPT + 99 others); Sun, 30 Jul 2023 07:07:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjG3LH1 (ORCPT ); Sun, 30 Jul 2023 07:07:27 -0400 X-Greylist: delayed 346 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 30 Jul 2023 04:07:23 PDT Received: from out-78.mta0.migadu.com (out-78.mta0.migadu.com [91.218.175.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F421310FA for ; Sun, 30 Jul 2023 04:07:23 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690714895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YDqItS6TsBITc0ogQeiO9zs2cfijso9HiN6zsa9jo50=; b=XpXFu6WxU3V13MvRIEnz/7Ji7DORifqqz168/epr0ILzyigpBFV+A4z4oGIVSkBtUeOFgh diNqH0zw0JE5/uCXG3B6N+tvcHXMpKZsZ6s0eKFzsZ+X7f+mOxmtYIXl0uv700u7SMTX1R uLBVb66nh3KObdbTdSfDQ/9rS/J3C2k= Date: Sun, 30 Jul 2023 19:01:26 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 03/13] scatterlist: Add sg_set_folio() To: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Andrew Morton Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org References: <20230621164557.3510324-1-willy@infradead.org> <20230621164557.3510324-4-willy@infradead.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zhu Yanjun In-Reply-To: <20230621164557.3510324-4-willy@infradead.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 在 2023/6/22 0:45, Matthew Wilcox (Oracle) 写道: > This wrapper for sg_set_page() lets drivers add folios to a scatterlist > more easily. We could, perhaps, do better by using a different page > in the folio if offset is larger than UINT_MAX, but let's hope we get > a better data structure than this before we need to care about such > large folios. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/scatterlist.h | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h > index ec46d8e8e49d..77df3d7b18a6 100644 > --- a/include/linux/scatterlist.h > +++ b/include/linux/scatterlist.h > @@ -141,6 +141,30 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, > sg->length = len; > } > > +/** > + * sg_set_folio - Set sg entry to point at given folio > + * @sg: SG entry > + * @folio: The folio > + * @len: Length of data > + * @offset: Offset into folio > + * > + * Description: > + * Use this function to set an sg entry pointing at a folio, never assign > + * the folio directly. We encode sg table information in the lower bits > + * of the folio pointer. See sg_page() for looking up the page belonging > + * to an sg entry. > + * > + **/ > +static inline void sg_set_folio(struct scatterlist *sg, struct folio *folio, > + size_t len, size_t offset) > +{ > + WARN_ON_ONCE(len > UINT_MAX); > + WARN_ON_ONCE(offset > UINT_MAX); > + sg_assign_page(sg, &folio->page); > + sg->offset = offset; > + sg->length = len; > +} > + https://elixir.bootlin.com/linux/latest/source/lib/scatterlist.c#L451 Does the following function have folio version? " int sg_alloc_append_table_from_pages(struct sg_append_table *sgt_append, struct page **pages, unsigned int n_pages, unsigned int offset, unsigned long size, unsigned int max_segment, unsigned int left_pages, gfp_t gfp_mask) " Thanks a lot. Zhu Yanjun > static inline struct page *sg_page(struct scatterlist *sg) > { > #ifdef CONFIG_DEBUG_SG