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 127BAC77B6E for ; Wed, 12 Apr 2023 23:12:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B96C900003; Wed, 12 Apr 2023 19:12:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46918900002; Wed, 12 Apr 2023 19:12:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 330AD900003; Wed, 12 Apr 2023 19:12:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 243A3900002 for ; Wed, 12 Apr 2023 19:12:55 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 016E21A0296 for ; Wed, 12 Apr 2023 23:12:54 +0000 (UTC) X-FDA: 80674291110.28.586FEE9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 0AB1914000C for ; Wed, 12 Apr 2023 23:12:52 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ul1REi1B; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681341173; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DqjVx8DdVE7yyHJKc/GaG9WLw8shGI6NpWmfl69SUoE=; b=kZIheC/+XXevY4JPKagU4zYFe1xOMczUnJOhKrHJbEHZc6Wifi8a3oS3yA0OENc3mluYjf CWGsjBFs5QVeUhR3TeyHQ0SsipV600DAt5L3CHqRNFk/Il9Yjd+eAyLj4Qk67bfB1GvcQz PklGW3aMB5CCN2AlNkOAn7q7YlfAUus= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Ul1REi1B; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681341173; a=rsa-sha256; cv=none; b=u3EXAkW/C/RHDKgVs9aV/JSsvgzobQx931TOObQISCB5XMJ67U3tb9IVG3UHEhIqcGyDIP OosjuO7GawCAZpBswrDbesmhHGceO3MWw2x5H0JwZNQTb4MtuEAhNqluggE2I+dBZV0ynv cC2ddo/pnI6lmmhOB14zA8ubtoipyGM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681341172; 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: in-reply-to:in-reply-to:references:references; bh=DqjVx8DdVE7yyHJKc/GaG9WLw8shGI6NpWmfl69SUoE=; b=Ul1REi1B1iO802GDi6BT9Qa+0QVAWVZaz4rsg9hy21JFjThRpI39VSqxrA5/IJxRe1Wm6b CRH9OOjNCIA1secVbDredfhBM8eUEYV9RTuWKGqXnEOhjeXywv7ME5W+5vwfdiJAKn5uzF d3M5Duke1ZGAL9HkN4EBJEhnMd2V06o= 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-578-RzSsyzYVPU2T4nYnBVXo7Q-1; Wed, 12 Apr 2023 19:12:47 -0400 X-MC-Unique: RzSsyzYVPU2T4nYnBVXo7Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D72A7101A550; Wed, 12 Apr 2023 23:12:45 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78B9A2166B26; Wed, 12 Apr 2023 23:12:41 +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: References: <20230411160902.4134381-1-dhowells@redhat.com> <20230411160902.4134381-5-dhowells@redhat.com> To: Christoph Hellwig Cc: dhowells@redhat.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , Jeroen de Borst , Catherine Sullivan , Shailend Chand , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Andrew Morton , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v6 04/18] mm: Make the page_frag_cache allocator use per-cpu MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <399349.1681341160.1@warthog.procyon.org.uk> Date: Thu, 13 Apr 2023 00:12:40 +0100 Message-ID: <399350.1681341160@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Stat-Signature: esaejtbbjswymcd3yd39fzikzmtmw3dr X-Rspam-User: X-Rspamd-Queue-Id: 0AB1914000C X-Rspamd-Server: rspam06 X-HE-Tag: 1681341172-318588 X-HE-Meta: U2FsdGVkX19tA7IhFnJEifsm0I3G0wRmaVD1juQVsIxJ5hEK8mlSQ46Yp752+9QEcG6jKhZCe7r1CcKUX6sjxmkG0nZo7F6cS6VjUyReNMhQTpEAwL3T0SYqTUa0sMnk671hBjERK7fKxdMVqa6URF0qacac0x1hN0eW4zUGZvnYFoHGLGHshSEhqA74kD5gpvsTTX9T0FFLqFYd47Q9L07HafuvtJD25UodhyfUN6Cw+9kGBSUNGMhlpueiicOumP1ML+7AuRfHXWGNEBSG2ESoqe6EDhJPA7YAH2fk/vCD0nXmjD7KBRFPD74JcExST3hSLOZzBH+M8kHn4B1ENZPfL04VetD/+GlCLaN0ZpLGjH3Avkdk+5TXjqwGyQ1gX7CmyceBM/eQam0JSjq1oQtBUo2bj1ogGvvVdov1XwCAnziI2o++Fv4aoul5vDMXQExwa70uIlBtz/K1EtzNEP3J/20/tbMmRNfdpgMktm50+qBEdJNYNJhFP/xwrwR00Ihfu7iLvaHWNuKeAdtXAapGIRMHKv57zLSUBuLzcXtwS/NNo1QRmbAaz2OgVbrb9MJR7W5v1CRL5eWO5FePGzDhuUAWIXe1CyHyOkDQYbWn1mNBhuYx2UT0fhFoWMmBELzz4PRtpYoBruC+ezBKVPRhOGv3+lFaNiIZOqUDlpfbZ4x8HnOzT+iGSn5ghi4XR3SaEflsTA3+ZSQf7bt+DB1TFrChDDcw65u1jrAARCftWrFDdENBjgWiqqqWvYaxpdkmsZkcyY7sWIPBYODhLXsgl1bohshisolL32FFl761BN8tEahH8iXgmBI0+sVT11oZDJd6gz7oUoY0K4DknPM4KCfuLbYt17rh+7cMJJIoKjfX3jNgXEpKr0ktsHiRz6dG0Dr4INWDlkle69UDa1knJHDB3ViSFWYtueCy3PcmZ39cZAgDV2+i/QKtRq8i2rER5RYtBZx/nUGgP4C aS+JWF+6 LIWREE+04U09duhkeeGLjNEpf81trF2nPBg/QhF6u7+t6M+hjTCXqQ7uEn4sQIpqi6m1/yw90SBc7cQdZ4dJKEZkwmBRQNo76fne1ka6nBDCuK7a58WncYm0+YOJ1GRVdFH6Mza2BOeYYnT64vlD6LvEtZQ8W0jRQnnMmhqc0CMsvEYZg/Xl8vhp0RvhgEVO3UlxuB6yDp3PEWzw2JUtZNeHvgy6m41zYij0dekCpfUI4vzX5avbqBRYDzikljrTxbFjtUoaAe2EYyB3ylndKrpKkLdyNOxUWHTHHAZrinsmHuaw2rBhEVsj41hXMBaTC36h3zuDKp956gtgmogoVRhwGa99lobv7dQUep31Q32OGEzNwWTV8KiVme5eQH9ndU6ZgmBsqH6ND2ZA= 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: Christoph Hellwig wrote: > On Tue, Apr 11, 2023 at 05:08:48PM +0100, David Howells wrote: > > Make the page_frag_cache allocator have a separate allocation bucket for > > each cpu to avoid racing. This means that no lock is required, other than > > preempt disablement, to allocate from it, though if a softirq wants to > > access it, then softirq disablement will need to be added. > ... > Let me ask a third time as I've not got an answer the last two times: Sorry about that. I think the problem is that the copy of the message from you directly to me arrives after the first copy that comes via a mailing list and google then deletes the direct one - as obviously no one could possibly want duplicates, right? :-/ - and so you usually get consigned to the linux-kernel or linux-fsdevel mailing list folder. > > Make the NVMe, mediatek and GVE drivers pass in NULL to page_frag_cache() > > and use the default allocation buckets rather than defining their own. > > why are these callers treated different from the others? There are only four users of struct page_frag_cache, the one these patches modify:: (1) GVE. (2) Mediatek. (3) NVMe. (4) skbuff. Note that things are slightly confused by there being three very similarly named frag allocators (page_frag and page_frag_1k in addition to page_frag_cache) and the __page_frag_cache_drain() function gets used for things other than just page_frag_cache. I've replaced the single allocation buckets with per-cpu allocation buckets for (1), (2) and (3) so that no locking[*] is required other than pinning it to the cpu temporarily - but I can't test them as I don't have hardware. [*] Note that what's upstream doesn't have locking, and I'm not sure all the users of it are SMP-safe. That leaves (4). Upstream, skbuff.c creates two separate per-cpu frag caches and I've elected to retain that, except that the per-cpu bits are now inside the frag allocator as I'm not entirely sure of the reason that there's a separate napi frag cache to the netdev_alloc_cache. The general page_frag_cache allocator is used by skb_splice_from_iter() if it encounters a page it can't take a ref on, so it has been tested through that using sunrpc, sunrpc+siw and cifs+siw. > Can you show any performance numbers? As far as I can tell, it doesn't make any obvious difference to directly pumping data through TCP or TLS over TCP or transferring data over a network filesystem such as sunrpc or cifs using siw/TCP. I've tested this between two machines over a 1G and a 10G link. I can generate some actual numbers tomorrow. Actually, I probably can drop these patches 2-4 from this patchset and just use the netdev_alloc_cache in skb_splice_from_iter() for now. Since that copies unspliceable data, I no longer need to allocate frags in the next layer up. David