Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp312509rwb; Fri, 4 Aug 2023 13:10:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFragOyHu+fdL1xblVtf30wUIoEeiFqLk+2/QtyYA34d5PizPLZq6+yhKEv4MrnQwDdhmeJ X-Received: by 2002:a5d:5242:0:b0:314:dc0:2fca with SMTP id k2-20020a5d5242000000b003140dc02fcamr1990667wrc.29.1691179811331; Fri, 04 Aug 2023 13:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691179811; cv=none; d=google.com; s=arc-20160816; b=wi3jrZ01oCE5tL9HJCfBtb4EyiTKcuZndaeTkYC0wpUAiJ2fB5Wg7VKk7hIMIZPVeU zjfspZI0/i7iIGxDXBvdPUnNekH1ot/cJytNsmFUybDne9EgQgPUNIVLxGmUJfhoxnzb YwVtAkLG3/M+RMnoC5M0hpz14BgFnGqaCJqQh1zPbRtnTo8RTHorzJpqpnW8ry0kVeC5 TZzH+IFX85pHfzVmXUoAGWfGmvzDubNvtsdlMyGEuFVc2f0UHftJn2vfWmNwjriQlIGM 07OIfr2SiIU/dJdcd5LjDCa7HhUZrGbvVXAHIUKWDiEH0Gx4c9ENIdOXAnAEBoC8rsl/ G23g== 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=V/QyLp9yrrtSuU4ykVgUyy3tTAg+9s58fdqf+i+63n4=; fh=3HE1xXs4s0z3NpKSg+MkyPw1+1QpKlxno2HY1HR9bAc=; b=qJ8Uo5FAJltFVuFaaFKbHJQOOQknVF71B5fT16DxR+GATCAm+yKBTDW6giT/63J80b 4zRfgVdb80gPhc8TW4/M6ZBfTPvO2eOcpqB3IwxGsuRQ+UOXK4/u5S/7Zr/RjBo3m0b+ GQpoKNR9XRiWouwZWypyFW+HrkoQn4vdGzED02fvkcI7zM/K/B6mPW6TsaaxCRFhIhrC s7jUAQUF3qXfdyTVD3fhfpJ8tyqqcC5iRW9LE9q2fysaJJhXPz7iX37rBqv/EG31N+xE 9bgX9blUB5375vVvML4ikEKt0DDBGBB0zD/aBtrwUp/jWXr7iYey2OoOiWql1CEJtCDU Ajew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JmVFWa6o; 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 m15-20020a50ef0f000000b0052317adaaf8si2091198eds.435.2023.08.04.13.09.46; Fri, 04 Aug 2023 13:10:11 -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=JmVFWa6o; 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 S230160AbjHDSG1 (ORCPT + 99 others); Fri, 4 Aug 2023 14:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230086AbjHDSGT (ORCPT ); Fri, 4 Aug 2023 14:06:19 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FCC049F0; Fri, 4 Aug 2023 11:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691172377; x=1722708377; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/RvGeZgasgv1mj7dNoL3ueQcvj+u+ttPutxwUs7TTE0=; b=JmVFWa6oXC9zl89Dvzna6VxhujROHwdUfPxnyQgOyGiU5QHHX/lCHtVb QXdZV3Hix8YqM4PYl+AkvvMQx5/64qBpThB4bh2m5YOK8sCUViFTaaCsq aB/ZP9Pjr29vW6/dpZWhtKMas8fMXeSO1jJgpmC7VN8w1R/raz3CeotYP t0WeTOfnA79HN4m5iR8C0VijiUWG2UA+mpvtulYkuEB5994UGIqJX6FAB XiGulyMlQhBy/FyV3dnHqnoKNSJkMPz7zHFlIcdknA+fd6CfSVa4Zpge7 syVKY8A1xdYqxSZsYvAVWAyhlkhO1nEfDrMJ7Dh5YqwGtBI41/+TkoD8k A==; X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="434061677" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="434061677" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 11:06:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10792"; a="759673591" X-IronPort-AV: E=Sophos;i="6.01,255,1684825200"; d="scan'208";a="759673591" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orsmga008.jf.intel.com with ESMTP; 04 Aug 2023 11:06:12 -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 v4 3/6] page_pool: place frag_* fields in one cacheline Date: Fri, 4 Aug 2023 20:05:26 +0200 Message-ID: <20230804180529.2483231-4-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230804180529.2483231-1-aleksander.lobakin@intel.com> References: <20230804180529.2483231-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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 fcb846523398..887e7946a597 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -123,16 +123,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 *pool); 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