From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF20C43A35; Thu, 1 Feb 2024 11:52:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A484C402A7; Thu, 1 Feb 2024 11:52:24 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2076.outbound.protection.outlook.com [40.107.220.76]) by mails.dpdk.org (Postfix) with ESMTP id 2A60040299 for ; Thu, 1 Feb 2024 11:52:23 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SulkoJ45tafpXwh/NOKXZO9jWPPFasx8jtA+mo2V4PiTWL4i5j3axiaG7sJGhYU/NvgzunogCJ+WwdGYB5zgrmiXFf8hE+6r8M75z3BHlTdy1UyAi5NQ3PufRxuBf4FuPS5yskwd4NqvDBGzHVOq6NCytKsqxrYIm537l77bU5XjLC7KtLg36hmr8SSZ3ZdWENbOEMgikkLAnoVTSRDbaIo4joiACh1vFwG4Vpgpq2bhXpddmCxFG/hLRR2SpSjepW6F6cUp4Ns7fy7WGwEDpsGsIW/1t5MUCbukVbfFiA36MXQ5vr6+ZBgJbC8j/UOKlzs0p2QiyiVEqLSAeaZ0Zg== 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=6QqEEpPrLSyj3JoAZe+XNv6FrqlgaZTISxru0TvZW4Y=; b=NiSARCr7aXoRSqcL/UhBU6GY2Kvj7MiZ549TPW8laeCTy+v7Cl2mnGC56cagd8WV7C3vGNQnoIjKhiRZ4uht0BKsBpqLeLzlEL+JgDtigZ3SACWDaVDb1pxYwtViph8vjK3wwoD/AKxStH6rf5TECZrwtNiOYEMOV/mR4IP01Jw/mEtcBNNxzyl0V0yOFIKGq3qK6983xT8aUKlDKXYb7+0nbP5yerNg4ZZ6/Kj5kOdz1xxTpsvUC7PtE0lrFerlt0U+LeMZ8VS/9AfVpjr7vDAvJU9zQWNxM3Bl/+aQodoPxbtHF8/SA8ScAZZ66DDmX8UCbNt8NOh4/sv612A/9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6QqEEpPrLSyj3JoAZe+XNv6FrqlgaZTISxru0TvZW4Y=; b=dY4PDoBwawrx8mpRroLnFM/TrnEwT0wpVp3ou/FbJElnD4VdWMedjQgL4NhVJr4FKNGYDdozi+P+ROb+sKu/hZ+nz3UHL1PtiQuW+PPQAadnWKkMjouniLNMeZdmxZX89P/arrsfy03OLnRu9LLfrVXn4DYUZDP9wY3ZXm6XaaA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by SA1PR12MB7319.namprd12.prod.outlook.com (2603:10b6:806:2b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.24; Thu, 1 Feb 2024 10:52:20 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::815a:45e6:cf5e:479f]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::815a:45e6:cf5e:479f%4]) with mapi id 15.20.7270.010; Thu, 1 Feb 2024 10:52:19 +0000 Message-ID: <8de3d7e0-6a16-48d2-8cf2-f129441e8a1b@amd.com> Date: Thu, 1 Feb 2024 10:52:14 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [Patch v2] net/mana: use rte_pktmbuf_alloc_bulk for allocating RX WQEs Content-Language: en-US To: Long Li , stephen Cc: Andrew Rybchenko , "dev@dpdk.org" References: <1706150562-23248-1-git-send-email-longli@linuxonhyperv.com> <1706577181-27842-1-git-send-email-longli@linuxonhyperv.com> <20240130084352.56971000@hermes.local> From: Ferruh Yigit Autocrypt: addr=ferruh.yigit@amd.com; keydata= xsFNBGJDD3EBEAC/M7Tk/DfQSmP1K96vyzdhfSBzlCaGtcxNXorq4fALruqVsD3oi0yfyEz9 4YN8x7py0o9EL8ZdpOX0skc0AMCDAaw033uWhCn0GLMeGRKUbfOAPvL6ecSDvGD7CJIO9j0J eZUvasBgPdM/435PEr9DmC6Ggzdzt8IuG4PoLi5jpFSfcqxZFCCxLUDEo/w0nuguk2FTuYJg B2zEZ4JTBZrw7hIHiFh8D8hr6YA6a5uTofq1tr+l048lbtdFUl8TR0aIExVzE4Z8qKZlcE+9 RQaewjK5Al1jLE4sHdmd3GN+IvgDF3D/fLsi25SKJDeGSdeHkOmaX0qGeM4WKIfU6iARRCiQ N3AmBIxZ/A7UXBKLaOyZ+/i3sE6Wb53nrO4i8+0K2Qwyh6LjTeiJAIjYKN43ppxz3DaI+QwQ vI+uyHr4Gg0Da9EPPz/YyKauSeOZCfCB5gIfICO0j6x0SCl8uQ2nLpjxcZkf0gjcwUzP3h+S 3x6NfDji9YEij0zczW/dcSpGgZ6vsFpPrtnP9ZXy6J53yp0kJtOJoOlkEFFdU2yCZnCDseum CoudmGLZVvS0/DzHDJejq+3kK3FDGktZBOxZIIpal+nFqS7lVgOZc4+huVv3jyhzoAUOEyXA XK5j6o7g8STUY+z33QNnHpdLvecMwuzmvqy0jR54yAbZ64mB9QARAQABzSNGZXJydWggWWln aXQgPGZlcnJ1aC55aWdpdEBhbWQuY29tPsLBlwQTAQgAQQIbAwULCQgHAgYVCgkICwIEFgID AQI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xl+8rM/LKBH dZUMTzME5PFCXJIZ83qkZQ795MTe2YScp9dIV7fsS5tpDwIs7BZNVM1l3NAdK+DLHqNxKuyO 8Zk= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0031.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2ae::7) To MN2PR12MB4301.namprd12.prod.outlook.com (2603:10b6:208:1d4::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SA1PR12MB7319:EE_ X-MS-Office365-Filtering-Correlation-Id: d8e3a208-042d-4872-ca00-08dc2313dbfa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: za209B0gN3YwX/Ia0I8ZCnrjeCshuzwnbPMF6VNEEBu+lzHlJw5QfUvYzn+dJgFnnaeiyK3X4ZUgETs3rov2n295uAjNr1I1xRKcEV2lyL1hp8/J6J+XbSJO/n6e8AcL/pg4sEq9ns6Y1+y0qwU69g1XyJq/PHOByLHg4LiIoFJpAjt+RCwdcJ8t5mTNBc6PWJOmYhmtFw04ppS6yn2gByrtgPl4GWkhaPLS4+F3qwq5HSKYJ4rP+Oa+mlxhWrgypmDuZ5HLLkATLGExSUl9zLtEZpMcKd3yBzLyMfloyog828Km4w4xAzsYb3QYPDSb9UoK6m30Bcd5yzajvFMICfE/Ydbhimfpo7H2jH5kkbyPGlB1nS0VzSZ0y8bt25GKhuH44Svz7hJdE4aaEnquIimF4SmwHpg7Wx2Db6JCvgyPYKiyEWRsJmbveI9ViZ+TUn75DcIPIfU6jpYKiE9ZeVpysogCOnG3cRRfQ64/Qb56f3mIz/ydUZlTzX9IPIyuJdoNqAttHKyTgyhZrLaOhaSulZNvbVfQhmz/pSGSxNMPLfHojESZYsc9qbkf9Zk7FHjcJ8K8UFjvSs+SFzs2kIX744icMQENQ4Sfvm1LiGUZ3f1aXlo9CoNJygfgkoG6LLRQkNcQFGLnBmUD3B0KCw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(346002)(39860400002)(366004)(376002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(66556008)(44832011)(2906002)(5660300002)(31696002)(86362001)(6486002)(38100700002)(36756003)(6506007)(478600001)(53546011)(41300700001)(6512007)(83380400001)(26005)(2616005)(6666004)(8936002)(316002)(8676002)(4326008)(66946007)(54906003)(110136005)(31686004)(66476007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U1hsZC9mMkI4NXFTWnhCZFFaU2NDQ0RFU3FQeUJBN3VRWXg2b1FZUCswbjdp?= =?utf-8?B?bjQyUVRTNjdsczdQb2FDS1FHYVltaERZTDNCTGtnSkh1Q1c2eXR1VHdxazE0?= =?utf-8?B?ZVcwV3Z2d0N6ZUJSV21xck40MktrRWM3d2crUStvS1BNOUdQRnlNSGExSi9P?= =?utf-8?B?RUFjbG9qdnRUby80dDE0UjdENHd1UVVzUzh2Y1gzenovcWM1SEp3THcvbXph?= =?utf-8?B?ZnRHN1JzQnlBQ3dxR014L2ZiVnZhVGo0dWpXcVhDcXdFNm9DNFRwYzdxcTVQ?= =?utf-8?B?VWpvTmg2eGU4dE4wb3lKZFdZOUJINmNrMjdJMWMrMFRIaXFqMStkcEFNWDg3?= =?utf-8?B?VmxNeFJSUktNazFzb3R2YUhtSmRwalUxc0tkVFdiRWxmRXl3a0dZd3NmWWxL?= =?utf-8?B?dUhTZ0pVQ29PUVZqUHk3UTlUSWc3a2E0Y1FiYVVzcTQ3R1VRcGhQUHVuUjNx?= =?utf-8?B?YXhQUUhCMFhhUER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z?= =?utf-8?B?YzNUV0Fsb2djTHViaVpVK3lHZ0NadTFna1BwKzdzSVR1a2VpOVF5WWt2QUQw?= =?utf-8?B?RGh2dUovcUlTd1VGVzN6Y0NtajdKNDhnRjVsN0VOMG5Dam1hcjZwSFNFbTRQ?= =?utf-8?B?WGpsY3p6SXh5YkJmbGV4YUpjRnZTZEhCNW5mZHFucEMyNVBHNFo0a0h3bXFx?= =?utf-8?B?cFYrOFM3akRRaURrbmxFYWJBdDVLNmxudjNlMXlTVEdXTFB6eStoekdHbytD?= =?utf-8?B?T3VjOVp4U2E4TVNtSWNSNU9xR3NjRW40WUVUZjF0bzRFc3E3bk44bm5ic2Nv?= =?utf-8?B?WTVJV2cyYTJ1SmRpU2xWRG1EclgyeHhIbFVTZUJOMWJORjdVSjRwWlhjRXhM?= =?utf-8?B?WWU2ZlpaNUZodFppVGNkcEtFRTh2MFdyTCtHWmJzcWxLU1pubnlLTHJFSG0v?= =?utf-8?B?Nno3bHZrdVB0WnhHd3ZOc0FqNUJDR1RObVBYWjNXaGxOUC9IeUFxMFpybG1k?= =?utf-8?B?eDhwMUtENzkzc0RZNXFVOEtRVXg3NjQyRWhtdWlrRUQzbGJnVDVyQjVnOWt3?= =?utf-8?B?SDZvUko0MkMySTRtTW5ydXpzckI2Y3dRQnd0OVdwSmVVdHk4OVNMYk50YUJT?= =?utf-8?B?ZXJSMWh3VUFsOEl2WDFnNW5YMWgzTnluTGJnL04rR1NueEJVK0t5bTRNK1Nj?= =?utf-8?B?ZkxYVlQ4ZzVzNWp1WWJ0M1A2M2Q4VTNKVnh1Z3FvQ1RraXd1T2MxcW56d1lp?= =?utf-8?Q?+vEWKa6Ot3bSO6QdYmR1PuZmj?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8e3a208-042d-4872-ca00-08dc2313dbfa X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4301.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2024 10:52:19.2447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9cul3RFImXhGJqVR3zSSxAyCEhXRZn1ltiQXRESWhtZXo9vLw9n5zOj2Ff39ZCFd X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7319 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 2/1/2024 3:55 AM, Long Li wrote: >>>> 'mbufs' is temporarily storage for allocated mbuf pointers, why not >>>> allocate if from stack instead, can be faster and easier to manage: >>>> "struct rte_mbuf *mbufs[count]" >>> >>> That would introduce a variable length array. >>> VLA's should be removed, they are not supported on Windows and many >>> security tools flag them. The problem is that it makes the code >>> brittle if count gets huge. >>> >>> But certainly regular calloc() or alloca() would work here. >>> >> >> Most of the existing bulk alloc already uses VLA but I can see the problem it is not >> being supported by Windows. >> >> As this mbuf pointer array is short lived within the function, and being in the fast >> path, I think continuous alloc and free can be prevented, >> >> one option can be to define a fixed size, big enough, array which requires >> additional loop for the cases 'count' size is bigger than array size, >> >> or an array can be allocated by driver init in device specific data ,as we know it >> will be required continuously in the datapath, and it can be freed during device >> close()/uninit(). >> >> I think an fixed size array from stack is easier and can be preferred. > > I sent a v3 of the patch, still using alloc(). > > I found two problems with using a fixed array: > 1. the array size needs to be determined in advance. I don't know what a good number should be. If too big, some of them may be wasted. (and maybe make a bigger mess of CPU cache) If too small, it ends up doing multiple allocations, which is the problem this patch trying to solve. > I think default burst size 32 can be used like below: struct rte_mbuf *mbufs[32]; loop: //use do {} while(); if you prefer n = min(32, count); rte_pktmbuf_alloc_bulk(mbufs, n); for (i = 0; i < n; i++) mana_post_rx_wqe(rxq, mbufs[i]); count -= n; if (count > 0) goto loop: This additional loop doesn't make code very complex (I think not more than additional alloc() & free()) and it doesn't waste memory. I suggest doing a performance measurement with above change, it may increase performance, afterwards if you insist to go with original code, we can do it. > 2. if makes the code slightly more complex ,but I think 1 is the main problem. > > I think another approach is to use VLA by default, but for Windows use alloc(). > > Long