From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35C58EB64D7 for ; Fri, 23 Jun 2023 10:00:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2F0A8D0005; Fri, 23 Jun 2023 06:00:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADD7B8D0001; Fri, 23 Jun 2023 06:00:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CC148D0005; Fri, 23 Jun 2023 06:00:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8E7A18D0001 for ; Fri, 23 Jun 2023 06:00:41 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3AAC4120E63 for ; Fri, 23 Jun 2023 10:00:41 +0000 (UTC) X-FDA: 80933568282.03.B22D202 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 7E17E180016 for ; Fri, 23 Jun 2023 10:00:36 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WvZ2Fz0y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687514437; h=from:from:sender: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:dkim-signature; bh=zP4AKCOOCr3pvthAQvIZ1/UuuvTX3OWbks29gUYE0Ps=; b=E8znsin4KUAgNpcmOEA4btJP48rLQ5xKqN8dt5yh6YLFu27P76k33Ap0XWjw6LIGT5IzUT lwotGgVOyCt/7qErMQqdaYDxDJ3HYOA8OLNBTgfbSrMKk2Qm7MgnoHrqKc1W6/rx1eR5h+ xdm/5qNV1Rr5EoblwTWgeo6wDeHkihw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WvZ2Fz0y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687514437; a=rsa-sha256; cv=none; b=7YCKOVWiukwFX/rK4pzk18L30KDMudMCMXasiIO+lTzXK2pUrmkmHmoBaH2pWucCFUd46f nMfg6p564RBJ5CDatzxWQeZ/2/KjGqMzKy+OtkfKe0QgpJHLZq2rnVsJswLbuFbMgxNkX4 dgCSGEGgvKjwomu27BEAz8fcFZnu0tw= 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-Rspamd-Queue-Id: 7E17E180016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: maz8a16by15wx88esad485hjnaz8a669 X-HE-Tag: 1687514436-987115 X-HE-Meta: U2FsdGVkX19J6FMsqqV51q1emhMDUA9YdHpQS2GwjWNFc5+57kTsIZoElS6XBuqSuuLVdCJHSuVkJKQYzw0od2kJQGTg+tCEkz25fTiYYDOJ9p5U676sjmdxsBzm/sW5xlpr+ywEj+M8EfXs14nJwWDci9xcdcYyhp9a5ELXM2DdEjiqoplWdiyaNrtFv+1IHaxPjsNoiWRvdMqAdbdMk1mrSoAi5Dgxzpyfxek+rJJjs/Vd88dn/671sZcqMEWiLHgxisafo3QboROwV2NZHFNoLe3kkqaqJIchNAGjLgTEEPE2BuYzyRuQaDGmpWlAv+7WxWPtFCToNxzIWbYwQmyW/IJepYKIdSmjVJEyPgXu6CwsRz184euOP86tUY0hExpzXbNqbwW3/RkfUSb/FKfJB2BPdAZcxRokVdCsW4WLeeEvDt5qoGm0hVKzIEc4U4EdC6hQ/PpHNdftKKejILDV2jZC0NRAZHQGCmMhZoP8ndvqJnL/nTAw8XG5E/3T3cfF/NPWG2vvaOAU4OwsHQo23uUSALQUhGKDu7NtMDyx131Uo+k/AVJJXdkpI0YDQHO/TQpoVEi9lxfzdN0afCjaHB3oY3moVcf+RMwOYKX3NlrUVTqi/BGoyX7tbm9fJJxY8LZqYn/bp7OpUqqQdB23veLrmZz9Vn5HIsWDJvWpxKRLZbtU2rCj7EAvsUZ+Y5dOZeZkdXgufN+kkJM+1l1SfDIr4JfZHLmVUGn76Zs2viGxE9Gkjjd8nf94GPKxqL+kG/sV1shZ9TxpyGaInzrqtISMgPs1hvX1DXt66JS2mJstr9iDdt3Q6MvBk8wtU7Nyj3xz7BYchavOvjtEQWH+t2dLUOFS8RfTxYdG7b/ELF38JX1Roz6u0aLDdoz5HkWsoCvNfWKRtHIHjiS3u4LzA8Z9SLjY8HbvusFOB0W7VhSgZMj5kPc1/q4qDm+CxmmQfoI+XthJ4agRXFi UkgIFBQX CgwjlBIORM6B8tvKssYmawcaKvMuilyJxv3vYkvga1wzU2/HKpq6X63YY+mM/9f86FxK4vvTJCD9oESF1n0VGOccSFrGW5DwRaNLrpjR2NP9HH0R8GlxJyzAR0ibDNbgI1we66mZQUGw+EKe8N2Fbz8PFG49jxp7s/IZ+Tu27KnpzVOr45c1jYSVBrhgDoVMCTY1jNmrkuyQkW62NL9hf8fme3LEunbagAmAyrj4sDJL6skbO8Sx56FyuciB3/m9fJbu9Gqgh85KPyT3Q05M+JjQ3u+ejl+hi8jjPSuBNTvJrQDs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.