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 3646CA0543; Mon, 18 Jul 2022 06:12:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCBF340A87; Mon, 18 Jul 2022 06:12:04 +0200 (CEST) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by mails.dpdk.org (Postfix) with ESMTP id 257874069F for ; Mon, 18 Jul 2022 06:12:03 +0200 (CEST) Received: by mail-ed1-f41.google.com with SMTP id y8so13643132eda.3 for ; Sun, 17 Jul 2022 21:12:03 -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=8a2e+LitURKIW27ywS2AE/InOW3UvUMiQxhoYPDvF+E=; b=EGOBE/UaBPfgJMk7DP63aR8AyTY2yoi2KztkdYSx/3VF2i1zKkklQ3yEafWX3ekMTD DG2p86CMJmoR6Wjl+7aUrED6MI80AYK4DZs5h+InlZKs3qdCIx4jfFdSKPAzAdkwxLqD gwb0hEGIun5nLWxI4egBMjIy+ACmBj0s9qush+pYflWNbmXlrcBEE0gPqimro/EwX+OX IXzIY4DLntIAwDW0YKcxSUNNwqmF3WSirAGmNKUu6pIfpS/ZmbjWCOnoG+I19+bB83s0 kAJCBRnRi3dTbFk1gjFTFAEBhN4TiPECQSPCT2JSWsq+1CFUcx718463jmvrNV3Xe0fH 5zkQ== 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=8a2e+LitURKIW27ywS2AE/InOW3UvUMiQxhoYPDvF+E=; b=dl51AAwBO+Pv/NolMU2m/scc4V+npjFSzjwZXeTS7CqLPDmgBW5Oo9RCbquk/Awrne XtQNLe7aYjc9i/i72fX56uSDKeDoMe24X09Q4TFDbw0Hwo3Lr4/H9IRv4rl2lTcPcMyb bBL7apS3ENaVCOiIQ3VIYc63oVXlUIFjyW23R+N1nw3WgNCPZii3fN/zT64gYCIz89Wo 3qq3LQRpp6nozVtzTCp0lSRYEsQamwt/OEWT8MUyouMwZzDkHXe81lYGhqre5DNxf8L6 OwnlZPjImJ7agCghdIMssUR9nIfV9QsyvYTi20qnpJNrJq5BFf1Te9Clr0t0nwonIff9 NbUA== X-Gm-Message-State: AJIora+MxgKkBaFZMOZ3k1rVwVbDqXsWMR/YI9t1Wl4w3cjZPUW/VIHB U95Phxhf7M9Bj6cOpmT4dsFL X-Google-Smtp-Source: AGRyM1sFgl0nv2frkQRNlNkbgJywy3C5T/Ajr1WUOZBNJyHiXLEdEQUK/MWQdfpPn81/YUEVWmp41A== X-Received: by 2002:a05:6402:5114:b0:43a:d072:83b9 with SMTP id m20-20020a056402511400b0043ad07283b9mr35357719edd.260.1658117522855; Sun, 17 Jul 2022 21:12:02 -0700 (PDT) Received: from emumba-Inspiron-3580.Home ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id k16-20020aa7c050000000b0043af8007e7fsm7884562edo.3.2022.07.17.21.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jul 2022 21:12:02 -0700 (PDT) From: Fidaullah Noonari To: dmitry.kozliuk@gmail.com Cc: dev@dpdk.org, Fidaullah Noonari Subject: [PATCH] eal: change alloc_sz calculation which may cause unnecessarily allocation Date: Mon, 18 Jul 2022 09:11:42 +0500 Message-Id: <20220718041142.411770-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 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 In response to this mail: 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; -- 2.25.1