Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12230696rwd; Fri, 23 Jun 2023 03:18:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yI0TWXv9iFd/if5vZTmeYaWTjJEaqQFAobdZ8fPCz1GaHO9nUjiIKQUZAIalW0PwO0wfz X-Received: by 2002:a05:6870:7401:b0:1a9:e679:7eee with SMTP id x1-20020a056870740100b001a9e6797eeemr14196385oam.11.1687515529520; Fri, 23 Jun 2023 03:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687515529; cv=none; d=google.com; s=arc-20160816; b=zME3HNi1MCwIPeEUxbLQpqroPAjULRrrvsFjcCJH1rSs+aXNMFy0FHO5EJs0JFd6zW cBZvjtLMmFYVMKqE6o4g+mDZGZFLZ417LBgmBVSJOhkaB6pthP7o5N1jPhPGhXHulCDP 4hNgTOHaQnSIGhbY7LgffsCz6GKq/y0lgi/4oVQTf6KuxsDk2rTp/79mZIEWZKM701PK 4d4xQxQ3HMRUqQHLFMSn0ODLqhSYBu237dm00zxBnlr2aHJ6lPdueOU7MZVfOsagVrLR WJSpOR40wQ8Iszsx4GGhrCmeryhDxfqpd80QZVbSA70+b4IHwA0M9rBekqGokuCRHogy lzwg== 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 :mime-version:subject:cc:to:references:in-reply-to:from:organization :dkim-signature; bh=zP4AKCOOCr3pvthAQvIZ1/UuuvTX3OWbks29gUYE0Ps=; b=dfBrHbBBs78lIaguKoqu07+9uY4l0RJ/89ktm/nhxRnG06v0znHbG7L7RkUjnbBNXG TT9CbD9XkKIJ/PGNcNXBMQCgFF0Zo4P0d3xXFItgzfEDzlqGptp3Z9KS6aHnYoTbGWmM PlaYqGxSITMosD2IZ+fMvzFXJTjDKYIUD7Kz7jNpWyzTN/InmCud86M+imoNlYu7N4SL P8HJMV6vNCRPw9WQzngPvAPjT1HhN1EW78tdWpuerC9bnPMuKPbSJ65h0cVRhUH9ryHb +Mn7nup1QoV0E3rDY7lFxN9rmvq8VrrWTqFbbAC0j5vBSMSTit/23C4Coh43QBWYUR8L 8t0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WvZ2Fz0y; 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 bs129-20020a632887000000b0054ff739cfa2si8109702pgb.449.2023.06.23.03.18.36; Fri, 23 Jun 2023 03:18:49 -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=WvZ2Fz0y; 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 S231840AbjFWKBc (ORCPT + 99 others); Fri, 23 Jun 2023 06:01:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbjFWKBW (ORCPT ); Fri, 23 Jun 2023 06:01:22 -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 048F7C6 for ; Fri, 23 Jun 2023 03:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687514436; 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=zP4AKCOOCr3pvthAQvIZ1/UuuvTX3OWbks29gUYE0Ps=; b=WvZ2Fz0ybKhXdfL3zgV1gRTzbAPkq5GGVrgvSFiksUeGGuqr8UEbDKXDuZeN0pGidNvDlb 0eyJ/ezyoykj1kQL82V0QXRe13LeEeR9X6rbTSfRG36QUAIVDHOEIi+23rhMV/3NLeMLgU JGBcSiwaZOsN6n2SoMaToZ+x1AjbCSo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-302-SIClFxpKM26PS55qx0QLEw-1; Fri, 23 Jun 2023 06:00:33 -0400 X-MC-Unique: SIClFxpKM26PS55qx0QLEw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4A278CC202; Fri, 23 Jun 2023 10:00:29 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADE904087C6D; Fri, 23 Jun 2023 10:00:27 +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: <6cf2ea121c4fdbd04682224c5acf6c73cc47f2f7.camel@redhat.com> References: <6cf2ea121c4fdbd04682224c5acf6c73cc47f2f7.camel@redhat.com> <634c885ccfb2e49e284aedc60e157bb12e5f3530.camel@redhat.com> <20230620145338.1300897-1-dhowells@redhat.com> <20230620145338.1300897-2-dhowells@redhat.com> <1969720.1687511219@warthog.procyon.org.uk> To: Paolo Abeni Cc: dhowells@redhat.com, netdev@vger.kernel.org, Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: Re: [PATCH net-next v3 01/18] net: Copy slab data for sendmsg(MSG_SPLICE_PAGES) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 23 Jun 2023 11:00:26 +0100 Message-ID: <2048396.1687514426@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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: > > Maybe. I was trying to put the fast path up at the top without the slo= w path > > bits in it, but I can put the "insufficient_space" bit there. >=20 > I *think* you could move the insufficient_space in a separate helped, > that should achieve your goal with fewer labels and hopefully no > additional complexity. It would require moving things in and out of variables more, but that's probably fine in the slow path. The code I derived this from seems to do i= ts best only to touch memory when it absolutely has to. But doing what you suggest would certainly make this more readable, I think. > > > What if fragsz > PAGE_SIZE, we are consistently unable to allocate an > > > high order page, but order-0, pfmemalloc-ed page allocation is > > > successful? It looks like this could become an unbounded loop? > >=20 > > It shouldn't. It should go: > >=20 > > try_again: > > if (fragsz > offset) > > goto insufficient_space; > > insufficient_space: > > /* See if we can refurbish the current folio. */ > > ... >=20 > I think the critical path is with pfmemalloc-ed pages: >=20 > if (unlikely(cache->pfmemalloc)) { > __folio_put(folio); > goto get_new_folio; > } I see what you're getting at. I was thinking that you meant that the criti= cal bit was that we got into a loop because we never managed to allocate a folio big enough. Inserting a check in the event that we fail to allocate an order-3 folio wo= uld take care of that, I think. After that point, we have a spare folio of sufficient capacity, even if the folio currently in residence is marked pfmemalloc. > > > will go through that for every page, even if the expected use-case is > > > always !PageSlub(page). compound_head() could be costly if the head > > > page is not hot on cache and I'm not sure if that could be the case f= or > > > tcp 0-copy. The bottom line is that I fear a possible regression here. > >=20 > > I can put the PageSlab() check inside the sendpage_ok() so the page fla= g is > > only checked once. =C2=A0 >=20 > Perhaps I'm lost again, but AFAICS: >=20 > __PAGEFLAG(Slab, slab, PF_NO_TAIL) > ... > PF_POISONED_CHECK(compound_head(page)); }) >=20 > It looks at compound_head in the end ?!? Fair point. Those macros are somewhat hard to read. Hopefully, all the compound_head() calls will go away soon-ish.