Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp1252866qto; Thu, 27 Jul 2023 09:00:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlFsVnu4uVMo77BCJdnm3fS5YtcKsR5YXzJnvyc5QV1LT8SH4n1cVYcaI0+UrT0LJj2PL0Qp X-Received: by 2002:a17:906:5da5:b0:982:2586:f85 with SMTP id n5-20020a1709065da500b0098225860f85mr2142277ejv.65.1690473656791; Thu, 27 Jul 2023 09:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690473656; cv=none; d=google.com; s=arc-20160816; b=nN2sqcdDh3cdwFUXOLuT4DgoQipHOlGW+IaQF+/pW1JZt0auYicLP01Aq1DF+U+zS8 u0Hj1CkVs1Dlr7QbE7G3vW6RsIf823ruWROFvgYZlnmAZYiyoDH+Ll6rb2d699IehZn4 C55qFzaf2TZENwHawWV6HAk3TFDRuMc6ATUdR/hUau/7N+cI2GKeDmUu/yl+E6maiv/g qtiw1D1kPINRBnv1oAzBelf9R/IQi7bp64CJn+yP+k/shZI/kbDpqEr3wEzMP7IYkNF7 NzVJiIuy3V8iWl/n0lMVzSIUvko4D73/tjiuSs2slKBD4quplUNK3FMPO7MtUprdpZAn hQRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a6uz0/98z0hvHTrzfEb2t1bDNi0CoSOtc/ifICcaiJw=; fh=3HE1xXs4s0z3NpKSg+MkyPw1+1QpKlxno2HY1HR9bAc=; b=rUOBgoOjXyNnt+J3pzPc/6DvATWPn0Iep4htGstxH6FrNAcfV01KK+tNihVqixM1Fa KWo+BbHYzv4cFZ1HmLsyKLIl4LTYpmtU7sWAcpVrYL/bNkhhJaaKZALPfXinDCPRnCwg BYW6T9mmIYogkt4rkk6aSjm64pkOLtvU77gTRiihGKTvEM3ByhHRCeS4Hed9NM358tQS r487gOQZNfDyKSMpdDTR3q8dVCCXE1ZmJCqoC6Z9tCMxCbpSXNoM6VTuPvouao+WxuoN lZocSL8TlBmAIAhztlzn38GFVrUBLmynKyKR10oUVaE84L0z+2n5T1juP66HpulU4wbT 6qCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WlpcAYbY; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a1709064dc500b009889cad765dsi1379521ejw.352.2023.07.27.09.00.31; Thu, 27 Jul 2023 09:00:56 -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=@intel.com header.s=Intel header.b=WlpcAYbY; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233962AbjG0Opv (ORCPT + 99 others); Thu, 27 Jul 2023 10:45:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233918AbjG0Opn (ORCPT ); Thu, 27 Jul 2023 10:45:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A40530D2; Thu, 27 Jul 2023 07:45:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690469142; x=1722005142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=31u+MUzH6+dKE9DPXFl5YBb0OxGcml0B6f7mnB7yaio=; b=WlpcAYbYb2itepcebcCzJdE+7Xr1o+J7p5mmk+RsDk2OoGdVqIdgWKP7 Gu0EhIDNa3AVXk3VlG8Ibl+0ArAiR25cMz52Oc+bsDBxrtjVTAf1DExYp YginGj2IVwqLAKKldByUxSy2FFLDFoEN9dKzrdrAZJcZv/Q4rGiw8XYYq 8zlzextyfBj97FKeTeCQu6epq0M85d0Q0jycG2kCvCCc3ewRTAauw3ZP9 G0P7PUHe/wI5G0RhX5xHFIuGCk+xenkmeECSEZgBpILEScsOm3K2e0vUO aWQJMzOyUbjnFRqaE6VMdmKvauyGxuQI7quEyvQ8fYxDAWFSQoE5D79Ne A==; X-IronPort-AV: E=McAfee;i="6600,9927,10784"; a="432139720" X-IronPort-AV: E=Sophos;i="6.01,235,1684825200"; d="scan'208";a="432139720" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2023 07:45:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10784"; a="817119899" X-IronPort-AV: E=Sophos;i="6.01,235,1684825200"; d="scan'208";a="817119899" Received: from newjersey.igk.intel.com ([10.102.20.203]) by FMSMGA003.fm.intel.com with ESMTP; 27 Jul 2023 07:45:38 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Maciej Fijalkowski , Larysa Zaremba , Yunsheng Lin , Alexander Duyck , Jesper Dangaard Brouer , Ilias Apalodimas , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/9] page_pool: place frag_* fields in one cacheline Date: Thu, 27 Jul 2023 16:43:30 +0200 Message-ID: <20230727144336.1646454-4-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727144336.1646454-1-aleksander.lobakin@intel.com> References: <20230727144336.1646454-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 On x86_64, frag_* fields of struct page_pool are scattered across two cachelines despite the summary size of 24 bytes. All three fields are used in pretty much the same places, but the last field, ::frag_users, is pushed out to the next CL, provoking unwanted false-sharing on hotpath (frags allocation code). There are some holes and cold members to move around. Move frag_* one block up, placing them right after &page_pool_params perfectly at the beginning of CL2. This doesn't do any meaningful to the second block, as those are some destroy-path cold structures, and doesn't do anything to ::alloc_stats, which still starts at 200-byte offset, 8 bytes after CL3 (still fitting into 1 cacheline). On my setup, this yields 1-2% of Mpps when using PP frags actively. When it comes to 32-bit architectures with 32-byte CL: &page_pool_params plus ::pad is 44 bytes, the block taken care of is 16 bytes within one CL, so there should be at least no regressions from the actual change. ::pages_state_hold_cnt is not related directly to that triple, but is paired currently with ::frags_offset and decoupling them would mean either two 4-byte holes or more invasive layout changes. Signed-off-by: Alexander Lobakin --- include/net/page_pool/types.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index c7aef6c75935..664a787948e1 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -94,16 +94,16 @@ struct page_pool_stats { struct page_pool { struct page_pool_params p; + long frag_users; + struct page *frag_page; + unsigned int frag_offset; + u32 pages_state_hold_cnt; + struct delayed_work release_dw; void (*disconnect)(void *); unsigned long defer_start; unsigned long defer_warn; - u32 pages_state_hold_cnt; - unsigned int frag_offset; - struct page *frag_page; - long frag_users; - #ifdef CONFIG_PAGE_POOL_STATS /* these stats are incremented while in softirq context */ struct page_pool_alloc_stats alloc_stats; -- 2.41.0