Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp716539rwd; Thu, 18 May 2023 03:00:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nWluAff6swwdPq1lVIbwxIMkIRTLXhWwHU+/NoHdLwUjXCxPEVNHluUIL+9pkSV+Fqebq X-Received: by 2002:a17:90a:7e90:b0:253:3481:84cf with SMTP id j16-20020a17090a7e9000b00253348184cfmr2015695pjl.10.1684404036321; Thu, 18 May 2023 03:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684404036; cv=none; d=google.com; s=arc-20160816; b=N7OBg0FezTSkYN3pW+UQW1aD57HxiQGDQsO3U1iF1UEfIdTA+LG8pTWFR2/ywiVkqK +7sMrQUSjSnJD/jv6hNgJ2C35bu/nBqno6EGN3PbGLa3KbsfmybZm6u8tg1FhErhb9Sm txsdXN0+QvU72Y1x+ozTHgzoE7e0Zmn4DO5440SeWSdxBnlrzqFTxLBUtvjTLRC4D+8Q BvGoBfZuKfxOdEyW6BMkb0+w2dalwXVaUKBcPfvJ6hOZAlOoaGpfvfXtjYKDV4bmjMWy sEbwN3tRpo2/8KWAs7GOvPrI/tXtuJaE1mqtZP11ZvbDfepAbSKJtuUO7MZvTOHm1NPf FKAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=7yINWos61yS1/Ae1KTt8I7rV0PBzJ6/BJSLEhV5ATss=; b=dSOT/A/DzKvUGX7zSKBroWmg+RCifrWhx2eZwP41wl89ZEmgGt62w6eXVrDp5+pF5J LmgTauQR9qp576JloTxVbPLFMpjdt8IVLqxNKBxg5KUXfK7ppOfy72rgN0BNFdmYOLIy P9eS7i9vZGZr75f3iXav4LKUEdYdk1cgRHsZ8FEiI10muE/O1q8XI/xzny9AhMJ9yxtR rOj3eIJnHwVLUxun+ZgHmGq/K3vLnNV9bya6B0Yww1/8y4GCxGE/zbd7qeXYBm3eqA22 5xd5KBO9nmBnaEkYa4RTFEug8kngWhnTj5k3QWno9HLIbOrw5R+fadVPLRYjS1bZ4WjP BUzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Bf1F/n/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a63b045000000b0053072cbae6bsi1013959pgo.383.2023.05.18.03.00.09; Thu, 18 May 2023 03:00:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@redhat.com header.s=mimecast20190719 header.b="Bf1F/n/A"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230311AbjERJyb (ORCPT + 99 others); Thu, 18 May 2023 05:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbjERJy3 (ORCPT ); Thu, 18 May 2023 05:54:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 183971A4 for ; Thu, 18 May 2023 02:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684403619; 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=7yINWos61yS1/Ae1KTt8I7rV0PBzJ6/BJSLEhV5ATss=; b=Bf1F/n/AaN0W9dK56AY36gGylt71LQRbPtdjJOb7ANE+yDJFcJolRvveyTUq0CiB3d4HmX 0I3cJybCjl+U+M9BSaKnhTsxWIIFUBDYo012GfUq8K0PYIwqb9xTyUYr5kyTXA1rciess7 /bCOtXLnFdj+M1wd8mCSckNOmK5txZU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-146-Gbff7KXbNvW9CLicHQ5d5Q-1; Thu, 18 May 2023 05:53:33 -0400 X-MC-Unique: Gbff7KXbNvW9CLicHQ5d5Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E423A3813F37; Thu, 18 May 2023 09:53:32 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1CAA492C13; Thu, 18 May 2023 09:53:29 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <93aba6cc363e94a6efe433b3c77ec1b6b54f2919.camel@redhat.com> References: <93aba6cc363e94a6efe433b3c77ec1b6b54f2919.camel@redhat.com> <20230515093345.396978-1-dhowells@redhat.com> <20230515093345.396978-4-dhowells@redhat.com> To: Paolo Abeni Cc: dhowells@redhat.com, netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH net-next v7 03/16] net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1347186.1684403608.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 18 May 2023 10:53:28 +0100 Message-ID: <1347187.1684403608@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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-kernel@vger.kernel.org Paolo Abeni wrote: > Minor nit: please respect the reverse x-mas tree order (there are a few > other occurrences around) I hadn't come across that. Normally I only apply that to the types so tha= t the names aren't all over the place. But whatever. > > + if (space =3D=3D 0 && > > + !skb_can_coalesce(skb, skb_shinfo(skb)->nr_frags, > > + pages[0], off)) { > > + iov_iter_revert(iter, len); > > + break; > > + } > = > It looks like the above condition/checks duplicate what the later > skb_append_pagefrags() will perform below. I guess the above chunk > could be removed? Good point. There used to be an allocation between in the case sendpage_o= k() failed and we wanted to copy the data. I've removed that for the moment. > > + ret =3D -EIO; > > + if (!sendpage_ok(page)) > > + goto out; > = > My (limited) understanding is that the current sendpage code assumes > that the caller provides/uses pages suitable for such use. The existing > sendpage_ok() check is in place as way to try to catch possible code > bug - via the WARN_ONCE(). > > I think the same could be done here? Yeah. Okay, I made the attached changes to this patch. David --- diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 56d629ea2f3d..f4a5b51aed22 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6923,10 +6923,10 @@ static void skb_splice_csum_page(struct sk_buff *s= kb, struct page *page, ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter, ssize_t maxsize, gfp_t gfp) { + size_t frag_limit =3D READ_ONCE(sysctl_max_skb_frags); struct page *pages[8], **ppages =3D pages; - unsigned int i; ssize_t spliced =3D 0, ret =3D 0; - size_t frag_limit =3D READ_ONCE(sysctl_max_skb_frags); + unsigned int i; = while (iter->count > 0) { ssize_t space, nr; @@ -6946,20 +6946,13 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, = struct iov_iter *iter, break; } = - if (space =3D=3D 0 && - !skb_can_coalesce(skb, skb_shinfo(skb)->nr_frags, - pages[0], off)) { - iov_iter_revert(iter, len); - break; - } - i =3D 0; do { struct page *page =3D pages[i++]; size_t part =3D min_t(size_t, PAGE_SIZE - off, len); = ret =3D -EIO; - if (!sendpage_ok(page)) + if (WARN_ON_ONCE(!sendpage_ok(page))) goto out; = ret =3D skb_append_pagefrags(skb, page, off, part,