Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7151967rwd; Tue, 6 Jun 2023 07:05:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VbNYWuGJT0lBTNeF4WT1OA38rjw05+fnnnHwfZWvepx3jg6eCD1fwUixcedKYZ7iPKk/q X-Received: by 2002:a05:620a:9d6:b0:75d:4de8:aec0 with SMTP id y22-20020a05620a09d600b0075d4de8aec0mr1729299qky.3.1686060303722; Tue, 06 Jun 2023 07:05:03 -0700 (PDT) Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o16-20020a05620a111000b0075d59dec7desi3282827qkk.456.2023.06.06.07.04.24; Tue, 06 Jun 2023 07:05:03 -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=hNiAo4vH; arc=fail (signature failed); 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 S238146AbjFFNUw (ORCPT + 99 others); Tue, 6 Jun 2023 09:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237522AbjFFNUu (ORCPT ); Tue, 6 Jun 2023 09:20:50 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E596712F; Tue, 6 Jun 2023 06:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686057649; x=1717593649; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=PObT+021SCqQmTDTw/JkTLF81cltE8Uwq3zNznT29X0=; b=hNiAo4vH0L12V/58cvA46JtCu08AIUPDEY9T/eK1EYdouXfFpXuoknrd 9MAAA6WuebO4svCONYYefpii2NnSrDMGrZZCJXe8ESZQ+2E83lodfcYVZ THQyQKo0TKyzyrApKeIRMBCAv+bu4Rd45Whmmmcpt0bNPf2Egc9il75kW 1Eryo9g1Pr2HlGVSpjBHN4gyVfSy82yvrEgXhfDEKqwQeo270wq5Wov/V 3DmQelRjv5vZlZ8TfQY/ZCuPBglQwH4HQjls9StXgNJTJ/HpOeWjcU6D8 haM5zcGyLrwsW8kLcL1nuEAvyOpa3x6y8OQnLXMltcTR52HWxrp1CTirq w==; X-IronPort-AV: E=McAfee;i="6600,9927,10732"; a="422495276" X-IronPort-AV: E=Sophos;i="6.00,221,1681196400"; d="scan'208";a="422495276" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2023 06:15:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10732"; a="798843620" X-IronPort-AV: E=Sophos;i="6.00,221,1681196400"; d="scan'208";a="798843620" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by FMSMGA003.fm.intel.com with ESMTP; 06 Jun 2023 06:15:49 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 06:15:48 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 06:15:48 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Tue, 6 Jun 2023 06:15:48 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Tue, 6 Jun 2023 06:15:47 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P5iK/bKb6+NXam6sTKt+2dlE7NMBAeUoKKs+RlSpTcy48GYW+Q+SBlui6zU7CmO/q+e/V8jbjISx3YfbySGtduAV/vVB70pVAZpTiHbc/P+Lw5uSvDQ3zjoqKBN2jduealaSGLwU0aq8FouhCgJcfNnGTdbXAFlIH5i2Hik0J9fG2P+uxItBy7cpn7IRzA4I98Zjz5PZN/0wP/4CAjv/yK7zUCAUvwheEajWPzl+tc3TXMyNbgMMqxJrfSkN0yxTXQXcb5pb2c9PuxC+Vb6kY5Wu/aPhxFnwF6pGmKoMhAEtw4Y2Rxt8DAFbnuOaqayYW/K05m74D3q/tyvKKlFB0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8gso4AurVdREySNFKTMcwviiJlcNtlWHn1XlrP9kKf4=; b=YFprucg6iQB8lII9E1YC22fXl9Q6OcpykdHqbKT8wljnepjz5Eu4Ctj52nNBygPt+I8UzPn6X3+iu7S+L0exZiWNUfGSvl4r6E6LW05+AU4M1DyTHwN0z/MZCV6StW4pUzNZljmbt4F3FdHsKJ1ESg7gpIMhAX5tQP68zfu20prwvJjbTFcFC29Mpn3bYURoCbFmkdYKPyFRVo43zB4+Lr4KWN5OdPP5fCAvDyhe2qN8E/1r8fdBfd++mn4t6stECUQLt1hf3tsYL21vPTdcW2Eni+anshmwjZ8mjiNDYeyBOjzsAx5yp67TOeRVCSDtnmnfAXZudW81r3Mii561BQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM6PR11MB3625.namprd11.prod.outlook.com (2603:10b6:5:13a::21) by DM4PR11MB5342.namprd11.prod.outlook.com (2603:10b6:5:391::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.19; Tue, 6 Jun 2023 13:15:46 +0000 Received: from DM6PR11MB3625.namprd11.prod.outlook.com ([fe80::82b6:7b9d:96ce:9325]) by DM6PR11MB3625.namprd11.prod.outlook.com ([fe80::82b6:7b9d:96ce:9325%6]) with mapi id 15.20.6455.030; Tue, 6 Jun 2023 13:15:45 +0000 Message-ID: Date: Tue, 6 Jun 2023 15:13:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH net-next v3 09/12] iavf: switch to Page Pool Content-Language: en-US To: Alexander Duyck CC: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , "Maciej Fijalkowski" , Magnus Karlsson , Michal Kubiak , "Larysa Zaremba" , Jesper Dangaard Brouer , Ilias Apalodimas , "Christoph Hellwig" , Paul Menzel , , , References: <20230530150035.1943669-1-aleksander.lobakin@intel.com> <20230530150035.1943669-10-aleksander.lobakin@intel.com> <0962a8a8493f0c892775cda8affb93c20f8b78f7.camel@gmail.com> <51f558e3-7ccd-45cd-d944-73997765fd12@intel.com> From: Alexander Lobakin In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0059.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::7) To DM6PR11MB3625.namprd11.prod.outlook.com (2603:10b6:5:13a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR11MB3625:EE_|DM4PR11MB5342:EE_ X-MS-Office365-Filtering-Correlation-Id: c99b4853-8e01-4d31-2488-08db669022c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QxC+/l2Wx7p7J5O6AyXC41QZjzpK2AvfnVihFggfvDFS4Fh+/5Y0UsPDgNmg/4mlamr5E4dY9Bi1z18ixrV5cWWn6xmvx4AWGKfrDv+r75/EPzY4m3cmb7tFYh2B/7QZevKmB8Qwv8C/iywE1HvgRffS6cbgXHwvSOCFUSsJZ5MRMtBpyquu7DmQY363ULGAXbAZTdiajHV5QTyqk4I8mRDSp7Kw9HQONJlLH0YPCkwqtfVBkZF11hGa+umQ5Dl5ITV48n+3s5EGYlENP0Q6gVAcfDATDqQ+DGIhpN8BvwxCZIu74+n4AZcxmzFKShbVbD6IAfBB3MmeSd1DzYkCdo1k8IX6mm4ajAjAAqfeCPN24YcLhIzkUp2xHNqFTk6QSvdzIgDZKJQtAHDhzEfh1OyEvkLygghjPqmDCDdqaHTezQFcBsqioilVYm9ipvlVfUD5dLgDARaRNHEjq3qJCnyUCRk1fXQZWM0dQG3uqw9HfsZFWhSKSRipuLOicnAJsUBVm6VqU3pkrYAuVSAZA6lNv67MnUGZLtTqC7pAU+AI+iYk4sZrCw4WHL6xuRpU3TLmuaYuW8fUepWR2HttpL2+HZSs5hIB4BKbf3mv3zE7pVA5SkW+eoK8fAAiqBajj4y824u0pUFEqqEDToDExA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB3625.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(346002)(136003)(376002)(396003)(366004)(451199021)(36756003)(478600001)(5660300002)(54906003)(6666004)(8936002)(8676002)(316002)(6916009)(4326008)(66946007)(66556008)(66476007)(41300700001)(38100700002)(2906002)(31686004)(7416002)(82960400001)(26005)(6506007)(6512007)(31696002)(53546011)(86362001)(186003)(2616005)(83380400001)(6486002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U0lua0JmZzc1bnFQbTljRFlvbGVHb2dtRWUzeENJS1Q3VTVpQ1lqbHdCR25T?= =?utf-8?B?U2UrcGpiUWk0REVCbitIcnVNcHJodVhoYytMRDB3QzZwVEhTRTZOZTBKVDdX?= =?utf-8?B?ZnJ5ek5PQ1UvRGxUMVVYOUZyZDhrYStCK0N0b1NKM3B6a1ViMkszdkMvNkJv?= =?utf-8?B?UkxqMkVuOTdLV2lXZVFjd1BMSEg0VzFrQXV0dXNabFhyWkR3MGo5dlp4TVdE?= =?utf-8?B?WHp4a0g5QUplZTFLUTE4U0xkb0EvMFFQelBvMUswMVIrdnMyeTZQVkYvNHRM?= =?utf-8?B?WE4wNHREVkE2d21wV0ZXYVJyQTY1b1l1cS9qeU1LSlRqam1oYSthdmU0YS9J?= =?utf-8?B?V083VENHczVTNDloTmROYUVUZHVMejk5cmd1VmFOZHZkL0N5RmpXbFlKUmhF?= =?utf-8?B?VG5uRitJTUl0NjZBZnA3UXR5MHdOQUVwbGZaNmFQOXJRSUg5LzlRcW5kd1Bu?= =?utf-8?B?QWZ3NGNtMktUMVBhb1o4b1EzZUtkczZJMVUrcU5QSXVHa2FSb0VDS3pnVDIr?= =?ut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RUXplelQvZmlBNit0?= =?utf-8?B?WmhaVVNlRGp6VkZ2MGlsdFQ3bVNLSElrTDVVRXgxeFoyYmc5enUrVjVqUnJO?= =?utf-8?B?SWhic0JZY1BJY2tlMFdjeDNuaGkzRTkrVjQ0L0NBL1dzaFB3Q1MrNVpIOEph?= =?utf-8?B?L0ZTR0VQaFlSN3JycnZZTyt5OW15WDNxQ1YxNUNXZkltWXpuaUZXc2FwSTIz?= =?utf-8?B?Qmx0MTZtMlJWUloyd0R5RXA2anZHVTJOUCtHVTZvMkMvTDJydEVxZUx1MzJV?= =?utf-8?B?bS8yaFJGYzlqOVBydElXelIvdWdGNzloVnVINVU3Vll5VlBuL2VXUGNGbEMy?= =?utf-8?B?RGdoaXZoM3p0d3FUVmlNZU4zZzFnSCtVUytzNmIvWHJvVUJETHRwZzdXdFJL?= =?utf-8?B?WUpXdU1VdlV4KzR3em8vcUl2Ujc3bXlkU1NXY0dKZElBWjJ4L0dMZUVLNTdk?= =?utf-8?B?cEt2UTJXVHFRaFdvUldQdVkwYlpHWnp1N0U5UVNTeTk1aW5VcHNMMlNOSlYz?= =?utf-8?B?d0ZOMlF2QzlueStTZzF6cTB4OUtLalF1RUt2ZVdFK3ZLQy9mdTd1RzczZE5t?= =?utf-8?B?NmZhVDRNOWJaS25yWG5hWXIwNFZPbjliTTZzbm9wY1FZQVl6QUY0WFhtZk1l?= =?utf-8?B?M2hadnVSSWF4MUx1YllaTkJoVTZhQWhBVkhSSjdueEhJNlN5Y2hhTko5SDkz?= =?utf-8?B?WEZoZjYrcHYwVCsvQ0JIUlBxUmJkNXhyQ0lWUUgzNHpNOE91Y0ZJZnBaQitR?= =?utf-8?B?aXc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: c99b4853-8e01-4d31-2488-08db669022c3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB3625.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2023 13:15:45.5798 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aYp7ORTLQI1Ufuuu1xNtYqFrn2seCrC8eA5UW5Oindm7VR6h7frGe2zU5uQjZ8k2q8qxfdRPLsylki8+3t7qkLk2cVCudu+GCHNZviA6gVA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5342 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, 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 From: Alexander Duyck Date: Fri, 2 Jun 2023 11:00:07 -0700 > On Fri, Jun 2, 2023 at 9:31 AM Alexander Lobakin > wrote: [...] >>> Not a fan of this switching back and forth between being a page pool >>> pointer and a dev pointer. Seems problematic as it is easily >>> misinterpreted. I would say that at a minimum stick to either it is >>> page_pool(Rx) or dev(Tx) on a ring type basis. >> >> The problem is that page_pool has lifetime from ifup to ifdown, while >> its ring lives longer. So I had to do something with this, but also I >> didn't want to have 2 pointers at the same time since it's redundant and >> +8 bytes to the ring for nothing. > > It might be better to just go with NULL rather than populating it w/ > two different possible values. Then at least you know if it is an > rx_ring it is a page_pool and if it is a tx_ring it is dev. You can > reset to the page pool when you repopulate the rest of the ring. IIRC I did that to have struct device pointer at the moment of creating page_pools. But sounds reasonable, I'll take a look. > >>> This setup works for iavf, however for i40e/ice you may run into issues >>> since the setup_rx_descriptors call is also used to setup the ethtool >>> loopback test w/o a napi struct as I recall so there may not be a >>> q_vector. >> >> I'll handle that. Somehow :D Thanks for noticing, I'll take a look >> whether I should do something right now or it can be done later when >> switching the actual mentioned drivers. >> >> [...] >> >>>> @@ -240,7 +237,10 @@ struct iavf_rx_queue_stats { >>>> struct iavf_ring { >>>> struct iavf_ring *next; /* pointer to next ring in q_vector */ >>>> void *desc; /* Descriptor ring memory */ >>>> - struct device *dev; /* Used for DMA mapping */ >>>> + union { >>>> + struct page_pool *pool; /* Used for Rx page management */ >>>> + struct device *dev; /* Used for DMA mapping on Tx */ >>>> + }; >>>> struct net_device *netdev; /* netdev ring maps to */ >>>> union { >>>> struct iavf_tx_buffer *tx_bi; >>> >>> Would it make more sense to have the page pool in the q_vector rather >>> than the ring? Essentially the page pool is associated per napi >>> instance so it seems like it would make more sense to store it with the >>> napi struct rather than potentially have multiple instances per napi. >> >> As per Page Pool design, you should have it per ring. Plus you have >> rxq_info (XDP-related structure), which is also per-ring and >> participates in recycling in some cases. So I wouldn't complicate. >> I went down the chain and haven't found any place where having more than >> 1 PP per NAPI would break anything. If I got it correctly, Jakub's >> optimization discourages having 1 PP per several NAPIs (or scheduling >> one NAPI on different CPUs), but not the other way around. The goal was >> to exclude concurrent access to one PP from different threads, and here >> it's impossible. > > The xdp_rxq can be mapped many:1 to the page pool if I am not mistaken. > > The only reason why I am a fan of trying to keep the page_pool tightly > associated with the napi instance is because the napi instance is what > essentially is guaranteeing the page_pool is consistent as it is only > accessed by that one napi instance. Here we can't have more than one NAPI instance accessing one page_pool, so I did that unconditionally. I'm a fan of what you've said, too :p > >> Lemme know. I can always disable NAPI optimization for cases when one >> vector is shared by several queues -- and it's not a usual case for >> these NICs anyway -- but I haven't found a reason for that. > > I suppose we should be fine if we have a many to one mapping though I > suppose. As you said the issue would be if multiple NAPI were > accessing the same page pool. Thanks, Olek