From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 142C7A04E4; Tue, 11 Aug 2020 22:50:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D781A1C023; Tue, 11 Aug 2020 22:50:02 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80041.outbound.protection.outlook.com [40.107.8.41]) by dpdk.org (Postfix) with ESMTP id 75D8E1C022 for ; Tue, 11 Aug 2020 22:50:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Yfy4nFBMmwR1WkjCd0M9lGc41cGXZq/LuBIOVoMTD/k=; b=A4CUDSF2+kNS+h9x57SFKfBmUGUiYEk+npw/ZTOQ23M886iXk2rt/q1E+GcOpZmzyusuoIesm1w2sURqWUD8m5GqeBYEjCm4hn5IkwKzaWxWktUmCYy4g6tnbvhws4Y0Hgeh+nDKYxcbL38mjjVxiH00R/pARSXY+2sYP/b6p5E= Received: from AM5PR0502CA0008.eurprd05.prod.outlook.com (2603:10a6:203:91::18) by AM7PR08MB5431.eurprd08.prod.outlook.com (2603:10a6:20b:10c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.17; Tue, 11 Aug 2020 20:49:59 +0000 Received: from VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:91:cafe::ff) by AM5PR0502CA0008.outlook.office365.com (2603:10a6:203:91::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.18 via Frontend Transport; Tue, 11 Aug 2020 20:49:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT009.mail.protection.outlook.com (10.152.18.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16 via Frontend Transport; Tue, 11 Aug 2020 20:49:59 +0000 Received: ("Tessian outbound e8cdb8c6f386:v64"); Tue, 11 Aug 2020 20:49:58 +0000 X-CR-MTA-TID: 64aa7808 Received: from 173775a0d347.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ADD4D6D0-BDC2-4951-B916-8A3D1535277D.1; Tue, 11 Aug 2020 20:49:53 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 173775a0d347.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Aug 2020 20:49:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pl5aerz4iNk66HvmHEWeGGENab6RGsOjcR4OauX2jrCH7BwF/zA+IGiLnQ/Q8pa0xSax60PgDBwbzWMNFG1t+OOuDsyDPjAc1oNUgBGKwOjc6uBtavZWBmy3yVJ4kkZ5uKmwzkw91rn0d4oAtGvxunaBNlIv+OzLYzjnaxvSl4kHviympZ0MJF9dxEqBXe1C/IwdC0Dg4/XadCyPcES356ep+s9eGXCk4T66hiJu/xQbEgnoSaE5O/+TfFEQpfAVBRoJa8Fkn15q4WbgAyRhL6xpesi6NkWvQYqGcicJ4gM7H0NHlytLj3BnT0BBd3WgJZHLD5c3UNisObM90zArGw== 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-SenderADCheck; bh=Yfy4nFBMmwR1WkjCd0M9lGc41cGXZq/LuBIOVoMTD/k=; b=jRChQd3zrqmsDOchGiCMDSNkLM0vET0mS9blm7dzgb+T8SLqV8hX4t5V3QUY9CzfyVw9YmjESTpF7xFe0mXEn58zew+yWKcO1Yat1lG6lnNOVe+1qA0EgesfyZFIA0CjQBSqxTGfA51sG4LSjuE3ySOk6GPkdsTC37HfZOHrpM6u8A9Cz7vDN9dTKGPJ+Ni/Yb9K4jptLaSVHHYlq9u5F5H/YUn4WlLBKljdZXKz/tvInNXzRuek6hxI9u/bp/fP6JMUzF7eOScNKsn88f48olU6kZvnPlPqWpZGfkCI5V99i7Rp98OXbJlZryFRHgFkL4m+4Zh0dt7zoK46Lni6Cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Yfy4nFBMmwR1WkjCd0M9lGc41cGXZq/LuBIOVoMTD/k=; b=A4CUDSF2+kNS+h9x57SFKfBmUGUiYEk+npw/ZTOQ23M886iXk2rt/q1E+GcOpZmzyusuoIesm1w2sURqWUD8m5GqeBYEjCm4hn5IkwKzaWxWktUmCYy4g6tnbvhws4Y0Hgeh+nDKYxcbL38mjjVxiH00R/pARSXY+2sYP/b6p5E= Received: from VI1PR0802MB2447.eurprd08.prod.outlook.com (2603:10a6:800:af::16) by VE1PR08MB5568.eurprd08.prod.outlook.com (2603:10a6:800:1a8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Tue, 11 Aug 2020 20:49:50 +0000 Received: from VI1PR0802MB2447.eurprd08.prod.outlook.com ([fe80::d464:b0dd:5f2e:ccb]) by VI1PR0802MB2447.eurprd08.prod.outlook.com ([fe80::d464:b0dd:5f2e:ccb%5]) with mapi id 15.20.3261.025; Tue, 11 Aug 2020 20:49:50 +0000 From: Honnappa Nagarahalli To: Stephen Hemminger , "Eads, Gage" CC: Steven Lariau , Olivier Matz , "dev@dpdk.org" , Dharmik Thakkar , nd , Honnappa Nagarahalli , nd Thread-Topic: [dpdk-dev] [PATCH 1/4] test/stack: avoid trivial memory allocations Thread-Index: AQHWa0ExNi/kf6Kvika0viajLaWEb6kzYTkAgAAHJACAAAIaYA== Date: Tue, 11 Aug 2020 20:49:50 +0000 Message-ID: References: <20200805155721.19808-1-steven.lariau@arm.com> <20200805155721.19808-2-steven.lariau@arm.com> <20200811133858.04ec8369@hermes.lan> In-Reply-To: <20200811133858.04ec8369@hermes.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 12c8ffb6-cc3b-4e58-841e-359e56836f69.0 x-checkrecipientchecked: true Authentication-Results-Original: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=arm.com; x-originating-ip: [70.112.90.121] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 588676da-9b9d-46fa-8c1b-08d83e381c94 x-ms-traffictypediagnostic: VE1PR08MB5568:|AM7PR08MB5431: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:883;OLM:883; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: MZ4k6XuCXukKYMnNzU7MqK2hk21o1pT6iIbz233IsbzQM55sbEI/4Q8mYJ7YIQhpDiPxCDtXSBf1KRP4z6Dwaj8XxGT4jLshofqgLyfInR0YWpEZnn3dRPlDlREsjXbQp2tp7bLU9hYZIBldCov+kZzNzIsZ9r2n24wp6GL1u8LxkMfiN3VRwO77TOI/+RTo0X9jkl+jShfkvD0nsugUf+Z52k3N6t/Q51MInGPFxkVLNGA3tXfVaniZWrj0ceoTvYqaEr3lrSQwb7NZEUZB0+Kk3+ag89LmZ8ZoaG/d1tJbSozvB4uCUjaXW1YwwF+r X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0802MB2447.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(396003)(346002)(39860400002)(376002)(7696005)(2906002)(478600001)(55016002)(71200400001)(86362001)(54906003)(9686003)(8676002)(66556008)(110136005)(66476007)(316002)(26005)(83380400001)(64756008)(66446008)(8936002)(186003)(52536014)(66946007)(5660300002)(4326008)(6506007)(33656002)(76116006); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: iPm17ls/H3kvI7Nmqr6vAfGPVk3exS20Mx1Z/A/Iv6YD3ILqha6L6Fxu3fxvTpU4WiO2Zt/3yXWs+x79Xo2S+d5fl9Y1BKrUJTgPusPojQX/aygbx+oF4iDUA1Ec67N/jFkPwk4JDMG62yUVODe8JDPzPadKhb66bJM0jDhqN1nB8dt2kjBP/OlA6lJg79tBO96ujf9/lpfdgusq5xgbGvhVwqSRgaoYvybssFl8OseGU6IXJVS/d7cbHmTMX+WKxS0htPGlclg0say+29v/O7+uUStBPmM4q0H/AsI5zU+u7uwmcEBqo6R6pDKHnIPWHG2UeVFeRpwFIg3yza2JADQZe2GDyFgysfLqSqjJ0eLPEq9lGFGK+qgnFIaFjuACx6gNtaBV3bE00XHUoTYSibAc3MRb2k841L0igEfln6V0zt8LEVa3ugOsYTGufKKI+LYZpG5vzK10KxNdLBLrDzQ4ZAmT0TMXak6vfeq5KXgVlK6zYyAnGR9AsJezdUkvdtjoP04x2FDxtbp/MWwmP2Z1WizQbAvx1kxzD1PKPXPfDl6K7up77k7vlsWb1V9J+7QgYIK7Sn7Qub8jT8qCmhhzcaIwMJ1WQTflGlrAHg2/XbzwDHG89PVsetb8AO9XGROk6tMgg0NfEGMWgLjiTg== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5568 Original-Authentication-Results: networkplumber.org; dkim=none (message not signed) header.d=none; networkplumber.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: b11b8b6d-a0c5-4304-f1a8-08d83e381764 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ktFZjLaeY7id9aLNXd3y6l7ciCwR519MwRA9c8hT0jpNGl+Npbg2fLz++XsL1W1r7i5gI2dH3Gr4UIMNEoiycrfOEgR3+uh5JeFP+YwLLfcYD5gNXnYooOqsS+qaHnxfo/8yjEhViMErYZfIql5onY79RMy/vqt8+SwumugZ2dSvwTU6TN6Kf4gfKkkmITrupYfMspnsF4R0gvgAIFCZxds6u/ZbaIsKY1O1BbPmiec0guXNPIMYw52gMWFXq4E9+KSv02BK4DzakX2BWDQNHRGylrgXjdiSjSiS3jY1MqMKK4ineFzNnkRNJ9R6Qu7ufDfVnrSuwtwndnxGM8TVjdEtQCf7UYkXhP/nEYNndyM51R+BP71rtxnCOCWlIWF06RfcPk68+erTx+GQ2tL9sw== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(376002)(39860400002)(346002)(396003)(136003)(46966005)(83380400001)(2906002)(6506007)(36906005)(316002)(186003)(356005)(26005)(70206006)(4326008)(70586007)(81166007)(52536014)(8676002)(7696005)(54906003)(9686003)(82740400003)(478600001)(86362001)(82310400002)(336012)(55016002)(33656002)(47076004)(110136005)(8936002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2020 20:49:59.0413 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 588676da-9b9d-46fa-8c1b-08d83e381c94 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5431 Subject: Re: [dpdk-dev] [PATCH 1/4] test/stack: avoid trivial memory allocations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > > > > > > Replace the arguments array by one argument. > > > All objects in the args array have the same values, so there is no > > > need to use an array, only one struct is enough. > > > The args object is a lot smaller, and the allocation can be replaced > > > with a stack variable. > > > > > > The allocation of obj_table isn't needed either, because MAX_BULK is > > > small. The allocation can instead be replaced with a static array. > > > > > > Signed-off-by: Steven Lariau > > > Reviewed-by: Dharmik Thakkar > > > Reviewed-by: Phil Yang > > > Reviewed-by: Ruifeng Wang > > > --- > > > app/test/test_stack.c | 39 ++++++--------------------------------- > > > 1 file changed, 6 insertions(+), 33 deletions(-) > > > > > > diff --git a/app/test/test_stack.c b/app/test/test_stack.c index > > > c8dac1f55..5a7273a7d 100644 > > > --- a/app/test/test_stack.c > > > +++ b/app/test/test_stack.c > > > @@ -280,16 +280,9 @@ static int > > > stack_thread_push_pop(void *args) > > > { > > > struct test_args *t =3D args; > > > - void **obj_table; > > > + void *obj_table[MAX_BULK]; > > > int i; > > > > > > - obj_table =3D rte_calloc(NULL, STACK_SIZE, sizeof(void *), 0); > > > - if (obj_table =3D=3D NULL) { > > > - printf("[%s():%u] failed to calloc %zu bytes\n", > > > - __func__, __LINE__, STACK_SIZE * sizeof(void *)); > > > - return -1; > > > - } > > > - > > > for (i =3D 0; i < NUM_ITERS_PER_THREAD; i++) { > > > unsigned int success, num; > > > > > > @@ -310,28 +303,25 @@ stack_thread_push_pop(void *args) > > > if (rte_stack_push(t->s, obj_table, num) !=3D num) { > > > printf("[%s():%u] Failed to push %u pointers\n", > > > __func__, __LINE__, num); > > > - rte_free(obj_table); > > > return -1; > > > } > > > > > > if (rte_stack_pop(t->s, obj_table, num) !=3D num) { > > > printf("[%s():%u] Failed to pop %u pointers\n", > > > __func__, __LINE__, num); > > > - rte_free(obj_table); > > > return -1; > > > } > > > > > > rte_atomic64_sub(t->sz, num); > > > } > > > > > > - rte_free(obj_table); > > > return 0; > > > } > > > > Agreed, the dynamic allocation is unnecessary. > > > > > > > > static int > > > test_stack_multithreaded(uint32_t flags) { > > > - struct test_args *args; > > > + struct test_args args; > > > unsigned int lcore_id; > > > struct rte_stack *s; > > > rte_atomic64_t size; > > > @@ -344,45 +334,28 @@ test_stack_multithreaded(uint32_t flags) > > > printf("[%s():%u] Running with %u lcores\n", > > > __func__, __LINE__, rte_lcore_count()); > > > > > > - args =3D rte_malloc(NULL, sizeof(struct test_args) * RTE_MAX_LCORE, > > > 0); > > > - if (args =3D=3D NULL) { > > > - printf("[%s():%u] failed to malloc %zu bytes\n", > > > - __func__, __LINE__, > > > - sizeof(struct test_args) * RTE_MAX_LCORE); > > > - return -1; > > > - } > > > - > > > s =3D rte_stack_create("test", STACK_SIZE, rte_socket_id(), flags); > > > if (s =3D=3D NULL) { > > > printf("[%s():%u] Failed to create a stack\n", > > > __func__, __LINE__); > > > - rte_free(args); > > > return -1; > > > } > > > > > > rte_atomic64_init(&size); > > > + args.s =3D s; > > > + args.sz =3D &size; > > > > > > RTE_LCORE_FOREACH_SLAVE(lcore_id) { > > > - args[lcore_id].s =3D s; > > > - args[lcore_id].sz =3D &size; > > > - > > > if (rte_eal_remote_launch(stack_thread_push_pop, > > > - &args[lcore_id], lcore_id)) > > > + &args, lcore_id)) > > > rte_panic("Failed to launch lcore %d\n", lcore_id); > > > } > > > > > > In general we shouldn't pass a stack variable to other threads. Though > > your code here looks fine, I'd rather err on the safe side in case > > this is ever used as a template/basis for some other > > code...particularly since there's no performance/correctness/etc. penal= ty to > using dynamically allocated memory. > > > > To support patch 2/4, you can instead convert the rte_malloc to > > allocate a single shared test_args structure. Or perhaps move patch 4 > > earlier in the series, and simply pass the stack pointer instead. > > > > Thanks, > > Gage >=20 > There is no gain to using rte_malloc unless you are doing primary/seconda= ry > process or trying to test rte_malloc. Why not use regular malloc which ha= s > good tools and library support. I think making 'args' a global variable is enough in this case.