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 0E5E942D14; Wed, 21 Jun 2023 14:05:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D6D744068E; Wed, 21 Jun 2023 14:05:51 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 999ED4003C for ; Wed, 21 Jun 2023 14:05:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687349149; x=1718885149; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=yHHzxFrtDbQpM/BP5o9UCJzc0pVdqAQ5cAncx29J/zk=; b=J3N1YI7wX4LrlquTpG6sBwQrSvmaW96WACTUi7LwKz2sBVoc/5bVexSR 4Mi3HMCSNrJt8dXlO9F1egFbjJDHk0QYYFVny6F4j1JLrvaIfQYDnRGPB s2ssAlxKCPwTHOTCG8a6E3cT86Id/4HPVWO3/BerLyiNzC6jcly5ra7Um EDelbT3t5ZepjcLdCq0YOwVnQWYH8b/Krzk088HRh2mogf3g0WO+hKRAf qSOq4/pYN1HH3xVUB3oimjGoaUZUjhDku7+G/bkMWx64O2RKvruQRN1q9 GIE9N1UKqJDdnaGmPaBp0mTAvV7PH/AW+XB5vsw+f5lXglbTe1c8HsuZ0 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="349882683" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="349882683" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2023 05:05:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10747"; a="714455739" X-IronPort-AV: E=Sophos;i="6.00,260,1681196400"; d="scan'208";a="714455739" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga002.jf.intel.com with ESMTP; 21 Jun 2023 05:05:45 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 21 Jun 2023 05:05:44 -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; Wed, 21 Jun 2023 05:05:44 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.170) 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; Wed, 21 Jun 2023 05:05:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C5yjoNiH0iQyqJZPxOFItAUy4mGGCCtyiiuHZPl2xy1JVFCyPtFyCmqoNywyQn2+W5HVJCJsMNvqZRxjVDHfAUUiPfiS8Ekbfc6La28weW5+ZetQEGUoSVeQhnAoSG+GzIk4m6F8RSsQ0u8IIk3QrtDGG/n8Pi6mxkPr0DiKnMhXyTIxhnNLnUvfGy7LjtlXw8a4q8NZw0oG0mpUCZgteIwJH8mVaDeoFDSKm2FQmSpntFslBcSOPsAQW0K09fS/2+kPNsj6JP3M431gnvmPoN5UghzL+nV+5BskA8QdIdwHKUgFVqH+hyVhq6LyosM/VsuxZKaRwB0Kcz5Ij4apJg== 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=RDZg39YTlh2xaAlsU65jQ5hB5scIuBQlOCX43feWIr0=; b=O71xVMSOowI3pjhwQa5OEE9tsiq/BIq4ZGJoJ4Lqagp8LqXS3fHce+LP38EMk/gng4lNLiZ3zZDDMl76dW1JgW2H1vPQ6w6azODN2GQ0MkXjkZobuw5Q0TsaMfb9ez7IIet99DErEbQvpQoGdpV4Fut8N1ZgGfT5o57bmTCnH63QdXAPFYPRlUwkZMJmeAzgNk2p+YsyXalmKgWMtFKZlUYe2ZUf7uLsZIV3z9FZr7EKuTbfbTfetKif7zFYg/Fyz1as5Uple/X90zI53GFH5hjCnT9kc/CIceDyK+ch66d7EfnMgT84q2QObri3Ccs7e9zwJTjX93hHhO3UL9x25g== 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 DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) by SA1PR11MB8350.namprd11.prod.outlook.com (2603:10b6:806:387::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 21 Jun 2023 12:05:42 +0000 Received: from DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::49c0:aa4c:e5b4:e718]) by DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::49c0:aa4c:e5b4:e718%7]) with mapi id 15.20.6521.023; Wed, 21 Jun 2023 12:05:42 +0000 Message-ID: <73b511f7-b7f2-c3b4-9e2e-19b2f61bfa3f@intel.com> Date: Wed, 21 Jun 2023 13:05:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.12.0 Subject: Re: [PATCH v14 1/6] memarea: introduce memarea library Content-Language: en-US To: Chengwen Feng , , CC: , , , , , References: <20220721044648.6817-1-fengchengwen@huawei.com> <20230209063610.35501-1-fengchengwen@huawei.com> <20230209063610.35501-2-fengchengwen@huawei.com> From: "Burakov, Anatoly" In-Reply-To: <20230209063610.35501-2-fengchengwen@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DUZPR01CA0042.eurprd01.prod.exchangelabs.com (2603:10a6:10:468::9) To DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB6502:EE_|SA1PR11MB8350:EE_ X-MS-Office365-Filtering-Correlation-Id: 84755bf9-6488-4147-55e6-08db724fd5eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gohS0zTqre+EZN+1R8b2iuGAKrD/8MsjdlyasoBOKYYX1c1kmrLajykL7KoJu29nx2yHEyurxwcnyOVZRpMssTz1ocI9iN1Uq2siRums0wTezX9/0Fn2HMIYf3zsNdoVZNwOKjfbCUgAUOOtRKECm57RFuHvQcI0Vzj5hFsJl94iPyKpQgONseTyHoReARtrvke9MDQxVilE06ltqsglYHQeG0Ep3To6IkqMpEW6TqOWaZTsf5cG65MmM4wvdjO7qouMQbPh3s4FlggADYqEZL/lEnTH6rvYMOqAW9RJ7S6KKKVmQtyeGNzeshRtMwuxxROwLC1XSYN1QYqfP3BPYu6er1wVzCuwF5G03aeBi+ZpIs2oo0v0g2LsLaKk7k3ElSbsq/TOl6xj7U7rnoiuH9rE+2UvNUzNO7HqPqYfBbH6efVpRTDRWbDDFPBPRuI4ayDymA/UY6xnjgEu3+7kKQiVn0e+48xPPslJ4ueY/aR0w+3cByeP3NMfVpADf7Jd64AK7tlcVpo/NMNPOSiOwj1BBJXoS5izZi9MjcWWrSQ4jW6LdOgiBub26E+5VcT8cNXHw8tm9STZvujXnFc7Xh2ybyuOhADc3ZZNJG/hGpnZZq4npu7CrtLn96xJOWGZjwwa5UzrWDiXOefPKYfbmA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB6502.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(346002)(366004)(136003)(376002)(39860400002)(396003)(451199021)(82960400001)(36756003)(38100700002)(31696002)(86362001)(31686004)(6486002)(41300700001)(8676002)(5660300002)(26005)(6506007)(8936002)(53546011)(478600001)(2616005)(186003)(2906002)(316002)(66946007)(6666004)(4326008)(66476007)(6512007)(66556008)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Nk1HM2pBNTNteFRMLzJrT2VRUVpnQUdLendpakVCZWJZTHhzTmZhR2FJN3I3?= =?utf-8?B?MytWRjhYYytyc05aSkxJdXhQMXpsaEtKMmtyVjhPL2pTSCt0KzJLZWhMZFJO?= =?utf-8?B?WFQ3YnhIY25SZUVwVm95R3dtNmVONUdFL2U1bmRKVklvYVIwVFVpdzkwNy9E?= =?utf-8?B?ZjNwNThxaTZSMjRKOE5KOEVkbjRQM3hEWjhNRGs4WlUxd1BCV3VKTk9zY0dE?= =?utf-8?B?eFo4azJsenY5K3E3UC9sYUhtcS95dG05RjhOeDNob0k2S1kzc0hXWmlIVUtG?= =?utf-8?B?NVVLMVZNRDB4ck5pYXgwSldUM3l3Z1A3ZklIRFV6UHlTZXBzSVFBZytxZmQ4?= =?utf-8?B?YTVURDQwRC9LUEl1Qm9UeGJnZFNDTmp4SXBxTG9xYjBjSTBFWHpBeExIeERJ?= =?utf-8?B?UHVidEc0RXc0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change-CrossTenant-AuthSource: DM4PR11MB6502.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2023 12:05:42.2420 (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: 7DKOlLslR3sR8IAQBFG4eokE73+Te56Qk9A5rsLaD9+IusmKI6a6ixiHYbmY4aKnh+BSBtzcb+u0AY4wHBabD97Zt4i80/bJt4qn9LUMjYo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB8350 X-OriginatorOrg: intel.com 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/9/2023 6:36 AM, Chengwen Feng wrote: > The memarea library is an allocator of variable-size object which based > on a memory region. > > This patch provides rte_memarea_create() and rte_memarea_destroy() API. > > Signed-off-by: Chengwen Feng > Reviewed-by: Dongdong Liu > Acked-by: Morten Brørup > --- > +static int > +memarea_check_param(const struct rte_memarea_param *init) > +{ > +#define MEMAREA_MIN_SIZE 1024 > + size_t len; > + > + if (init == NULL) { > + RTE_MEMAREA_LOG(ERR, "init param is NULL!"); > + return -EINVAL; > + } > + > + len = strnlen(init->name, RTE_MEMAREA_NAMESIZE); > + if (len == 0 || len >= RTE_MEMAREA_NAMESIZE) { > + RTE_MEMAREA_LOG(ERR, "name size: %zu invalid!", len); > + return -EINVAL; > + } > + > + if (init->source != RTE_MEMAREA_SOURCE_HEAP && > + init->source != RTE_MEMAREA_SOURCE_LIBC && > + init->source != RTE_MEMAREA_SOURCE_MEMAREA) { > + RTE_MEMAREA_LOG(ERR, "%s source: %d not supported!", > + init->name, init->source); > + return -EINVAL; > + } > + > + if (init->total_sz < MEMAREA_MIN_SIZE) { > + RTE_MEMAREA_LOG(ERR, "%s total-size: %zu too small!", > + init->name, init->total_sz); > + return -EINVAL; > + } > + > + if (init->source == RTE_MEMAREA_SOURCE_MEMAREA && init->src_ma == NULL) { > + RTE_MEMAREA_LOG(ERR, "%s source memarea is NULL!", init->name); > + return -EINVAL; > + } > + > + if (init->alg != RTE_MEMAREA_ALGORITHM_NEXTFIT) { > + RTE_MEMAREA_LOG(ERR, "%s algorithm: %d not supported!", > + init->name, init->alg); > + return -EINVAL; > + } Also, you're returning a lot of `errno` type values from this function, but you do not appear to use these values anywhere. I think it'd be better if you used the return value to set `rte_errno` to indicate what kind of error there was. The entire API could benefit from doing a pass on setting rte_errno in error cases, and documenting them. -- Thanks, Anatoly