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 5EFCEA00C4; Wed, 27 Jul 2022 10:23:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51E2940141; Wed, 27 Jul 2022 10:23:42 +0200 (CEST) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by mails.dpdk.org (Postfix) with ESMTP id 4F54B400D7 for ; Wed, 27 Jul 2022 10:23:41 +0200 (CEST) Received: by mail-lj1-f170.google.com with SMTP id q7so3567496ljp.13 for ; Wed, 27 Jul 2022 01:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x8lFsGWmsgsaqc/BrH0b4P2tPzu2aUQrg9Jpo+/+NvA=; b=AZsCRXwP3yN6UX1u0c9xah4fZcpktb6xZlKLq/WXiOybFiSNmLccGmiWEoJR8pZMf2 4BTvnJC1lx1c9/qQ00T3BjLsqOnFsLM3eDIcWyo5z4SmC5v0uUctoi+ZcQ95jfdY8dLC Ijz8rYkfTc21P3qTDlT2qW5lKSSeXD0OYl8vqQqispR4HjCmBKYBcxG60DG9IkVh1QgP a3AzsS3eWKZ8fCXb5KYjUA/EPCYJDsOCctiD8NTdIx5of0IAPfvf9RPeIgT0GhuEXPz3 JCV23u6X9vHQbWfHSwRC57Y593P+/yHC/yapO46iXp9UN0S0gb+5c15I1s+dJT0lAyBm ewxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x8lFsGWmsgsaqc/BrH0b4P2tPzu2aUQrg9Jpo+/+NvA=; b=MGh4jHlP2H4/wD9kPtMLMoxXYY59iNnpe1MGya0cALGZpTfQnwYY5Kk2z3sl61PnKi nbTh5Q0hjZ715iW6ERLR3Du0aJiWYqpyprwzdhMO1ejpmQmUGvXYBqEFXDt1fgcNwFFX 8+otH67PgpGUmacSn53o6/Ue0SvKE8srHygA/aIakCbyXdUbvDpbHTsE/DFQO25tmgkS MmdEaRTy+KBlaj4b7tnSlkXpzRwj8xvIisbThPpmX2RPEO6Tdg+Sopq4Mfq9j4Cbi8HE xm6Us6SrMzaZNn73GHtiEmykFdDMn1rlGEOphuyYhNiSRXFYlXjVQbqLpcUuwJcp0Y01 g6pg== X-Gm-Message-State: AJIora/np7k4EHUWBhgeZ9k5/J+ZS7z9CuxtSG1NjASwxiYzC9h3p+yp oMz+AUe6kXeJ8DUUb4c0zjY= X-Google-Smtp-Source: AGRyM1v2OXfRefkIBz9Z0G3YuwqyEB4Y5b+7bS+k22V+jrP9L/ULt6qNgUDLSQi7czjHp85cAfolIg== X-Received: by 2002:a2e:780a:0:b0:25d:f5af:856d with SMTP id t10-20020a2e780a000000b0025df5af856dmr6931145ljc.222.1658910220585; Wed, 27 Jul 2022 01:23:40 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id f14-20020a19ae0e000000b0048a79e3dd6csm2844676lfc.26.2022.07.27.01.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jul 2022 01:23:40 -0700 (PDT) Date: Wed, 27 Jul 2022 11:23:39 +0300 From: Dmitry Kozlyuk To: Fidaullah Noonari Cc: dev@dpdk.org Subject: Re: [PATCH] eal: change alloc_sz calculation which may cause unnecessarily allocation Message-ID: <20220727112339.3bc5e9b1@sovereign> In-Reply-To: <20220718041142.411770-1-fidaullah.noonari@emumba.com> References: <20220718041142.411770-1-fidaullah.noonari@emumba.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 2022-07-18 09:11 (UTC+0500), Fidaullah Noonari: > In try_expand_heap() alloc_sz is calculated > which may result in unnecessary allocation of whole huge page, > this may cause allocation limit from system or eal Let me suggest a rewording: The amount of memory to allocate from the system for heap expansion was calculated in a way that may yield one page more than needed. This could hit the allocation limit from the system or EAL. The allocation would fail despite enough memory being available. > In response to this mail: > Proper links to mails.dpdk.org or inbox.dpdk.org are preferred. > > Signed-off-by: Fidaullah Noonari > --- > lib/eal/common/malloc_heap.c | 2 +- > lib/eal/common/malloc_mp.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c > index 27a52266ad..e348e385e4 100644 > --- a/lib/eal/common/malloc_heap.c > +++ b/lib/eal/common/malloc_heap.c > @@ -402,7 +402,7 @@ try_expand_heap_primary(struct malloc_heap *heap, uint64_t pg_sz, > int n_segs; > bool callback_triggered = false; > > - alloc_sz = RTE_ALIGN_CEIL(align + elt_size + > + alloc_sz = RTE_ALIGN_CEIL(RTE_ALIGN_CEIL(align, elt_size) + > MALLOC_ELEM_OVERHEAD, pg_sz); > n_segs = alloc_sz / pg_sz; > > diff --git a/lib/eal/common/malloc_mp.c b/lib/eal/common/malloc_mp.c > index 2b8eb51067..1b79ed5e21 100644 > --- a/lib/eal/common/malloc_mp.c > +++ b/lib/eal/common/malloc_mp.c > @@ -249,7 +249,7 @@ handle_alloc_request(const struct malloc_mp_req *m, > return -1; > } > > - alloc_sz = RTE_ALIGN_CEIL(ar->align + ar->elt_size + > + alloc_sz = RTE_ALIGN_CEIL(RTE_ALIGN_CEIL(ar->align, ar->elt_size) + > MALLOC_ELEM_OVERHEAD, ar->page_sz); > n_segs = alloc_sz / ar->page_sz; > Wrong argument order for RTE_ALIGN_CEIL(size, alignment) in both places.