Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1622660rwl; Wed, 12 Apr 2023 16:14:24 -0700 (PDT) X-Google-Smtp-Source: AKy350ZXGIFUrsS/9soA9UKzS1leUjkcSqgcwlzbXZazI/gMd2zRFVS5ihJDWMA4vwgbj80zV4Qc X-Received: by 2002:a17:906:5450:b0:94a:82ca:12e5 with SMTP id d16-20020a170906545000b0094a82ca12e5mr498628ejp.45.1681341263981; Wed, 12 Apr 2023 16:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681341263; cv=none; d=google.com; s=arc-20160816; b=vutSM2YMY2lXDeee00f6HoVFxe2GTWfeMGeaKdKZ0khpLi9li0MVk1x3TCWq9f5DET 9G7vjxkK2kXr7+/DQh0Zc+9J4rjNag/xwh/kslXFS22bV/PwEMvhWVfnBu4CMutbynYV xZZYsqhYTbXO5jhvyv6Htmyda09ODKVKhYvSPWffgw1t0Jcql46VHSwkP8F41Y69LFRA g40E6nn8NGbigFurX8vzdm52aVtpSEY62K0pMdNrSC+MDBvWSxyZ6Mea0L0cZnVU755B Xm210bJrhwD21xRagCcSf4mdku6KCOqicMdXbVUf1JOmW7kf1kpR9cjSmxSZRSeeaS7s sNLg== 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-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=DqjVx8DdVE7yyHJKc/GaG9WLw8shGI6NpWmfl69SUoE=; b=eXp3CYNq7jRBHnNcE6MfvMcuHq86PY7uP8B0oJ1ckLADYLWeUuGJ4Hn2iP2rsrW8vO CK65Ml6TYw0N4309UhgUNhNUNKTipHZKD01so40vGa9fLRv9avR0iTc/e/ZCLIPeJn7+ F2sZJuEZ9jT0ZI0w1CCpMEVB6feW3D5NGLIFkS15giBDO5ZD6AGyb1xAVTWN1y3YdkUg 5lqvan1dznpfECC8eAlQCzRF+c/kYw2eIEykY61xhYydf479zUh8SyJnsfc0gJtY3Guu 0TCg67d/lT+yIa7HsYOM/0Ha9TXVVLPkrGCd3SlYo4OshQlIi9grOu2vnwGTuZm660Mx ofZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bOyUPGtu; 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 mf23-20020a1709071a5700b0094a698a7a28si103056ejc.666.2023.04.12.16.13.59; Wed, 12 Apr 2023 16:14:23 -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=bOyUPGtu; 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 S229911AbjDLXNl (ORCPT + 99 others); Wed, 12 Apr 2023 19:13:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbjDLXNi (ORCPT ); Wed, 12 Apr 2023 19:13:38 -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 B9DF21BE1 for ; Wed, 12 Apr 2023 16:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681341171; 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=bOyUPGtujdSlzeygurislRRvLpTQ85GAd4UMhkuI8lKbgCkz8XcxkgER+OEFor7Hl1WTOR bKSGT/QXqa/DR1Dfu+z+2H+kf2QV7g0apQGxL2b0iYEoZ+ITLRzzkTteE4zG07bYx5tmnE 2zA32RAXw35Q1iCH1Y2+0FKeUZEtPDM= 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-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 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 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