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 CBEF5A00C4; Thu, 28 Jul 2022 11:41:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6FEB9427ED; Thu, 28 Jul 2022 11:41:11 +0200 (CEST) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mails.dpdk.org (Postfix) with ESMTP id C868C40E25 for ; Thu, 28 Jul 2022 11:41:09 +0200 (CEST) Received: by mail-ej1-f50.google.com with SMTP id z23so2191410eju.8 for ; Thu, 28 Jul 2022 02:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ejOaM0fnTtGcdtpBWFFe3XneY3yuBLjDtdcIoawai4E=; b=REZyc8Sx8w/BGVMvqCXxF3MB2vXlhM8LKfJ2a5z1Qsev1rsgH42Nn/EFn+eUY0Ucv2 TuBT92AxA7K+GgiS+CPEFTjQFTW71goO1wENxkwjOTdCJjhW+HbIzFFKAu61q7RwmoRb ToqDLt5ZyQ8fhGQuoPdVJDPW0jklIs1FScYAdNKJKgW/dFb4rInKECdvPUNHtaxY9Z2f 7hudFN2Af/XoXgB3hI8zlX5S3I9iNaNJOwBNbAlHdezYD8bMit1ENdQh060xzHq1ZVWD 1Agrw6Nyo06VrWQXeiMhgdpgj3T7dtIKTr+8YGGN19s71wAiLQbTrxpCP9z024xvGL5e UWqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ejOaM0fnTtGcdtpBWFFe3XneY3yuBLjDtdcIoawai4E=; b=5U0KtEe9IS+qO0tLQI9xGNSUZoOlkCO8CueIjkg3nM+e/XoZnoCTKIb16HZxhwbAOe 2vi8j2V0honyPOnzQdeJedpu6C5S/VOEPVAkX3+V8eO1R0AHoy6zXspCaP+3Olrs8Vbd qBgCGOkMzkRZ2mzw7B5V8CnO2JKn1RbcvbXkYqUuBegXM5EoiWxk0Rx2wYLAEBBDWDPC Z6qoAPbLiHfhJeSqcwfXlxwz6nA+fnKIrUW6ZYOB5JeI6lOa4VVeSDaKFkEHY9dxKXgq Qlpg7scTiJ7zwb5VdPcoFSUSdq77Oc8zvsA0Ah/VtnxJj2kC/xr9CpUg4B78vJvrLB2u tCMA== X-Gm-Message-State: AJIora+YlSZJSEsAxihvy8hekIRFdvcbvRuStFHP0SHx2Q/LlLPsWIaA B2qOyeM4iXK4WjfNZP5EpsMLnt67dFzc X-Google-Smtp-Source: AGRyM1vtFKlL7qLNS8yjaMQoJ46cxE+1BEuVSbJEznhEIG1mF6tQrH9DnvTJqpHEuqTSx2QPr8M0lg== X-Received: by 2002:a17:907:6d99:b0:72e:e7b4:e9cc with SMTP id sb25-20020a1709076d9900b0072ee7b4e9ccmr20364789ejc.315.1659001269476; Thu, 28 Jul 2022 02:41:09 -0700 (PDT) Received: from localhost.localdomain ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id wi7-20020a170906fd4700b0072f03d10fa0sm203105ejb.207.2022.07.28.02.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 02:41:09 -0700 (PDT) From: Fidaullah Noonari To: dmitry.kozliuk@gmail.com Cc: dev@dpdk.org, Fidaullah Noonari Subject: [PATCH v2] eal: change alloc_sz calculation which may cause unnecessarily allocation Date: Thu, 28 Jul 2022 14:41:03 +0500 Message-Id: <20220728094103.137862-1-fidaullah.noonari@emumba.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 mail: http://inbox.dpdk.org/dev/CAEYuUWCnRZNwxiOHEeTHw0Gy9aFJRLZtvAG9g=smuUvUEMcFXg@mail.gmail.com/ 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..d7c410b786 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(elt_size, align) + 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..15d85e2b2b 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->elt_size, ar->align) + MALLOC_ELEM_OVERHEAD, ar->page_sz); n_segs = alloc_sz / ar->page_sz; -- 2.25.1