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 5D8C9A0540; Thu, 22 Sep 2022 00:52:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2DBC40691; Thu, 22 Sep 2022 00:52:16 +0200 (CEST) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by mails.dpdk.org (Postfix) with ESMTP id 2AAD94067C for ; Thu, 22 Sep 2022 00:52:15 +0200 (CEST) Received: by mail-lf1-f49.google.com with SMTP id i26so11647141lfp.11 for ; Wed, 21 Sep 2022 15:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date; bh=PuoqRTNVL5ZGTbTs/Rg91rM933xgdsmUCIOFOeqz2Ds=; b=mpekSe3zIovv1ki+Cym05ui2ZJKteyMPKiMSQ1BjKiTmbwOVbInL3F1H7ec14jOlC5 4IIQwu6MYtsYYtch9wCZm1PY4At4y/UdHoajNR1S2MDBQ0L7WzdX3de1YSSMGAWPUM2b kOUuS0zc5ZCZi35qaxrgZgFZ30XynK8NLkdxYmRT4t6CJ6MpVaOyVVU59Eoqcs0J1RkS QM9E4BchyAmLrhAB+kb08rS326F3Nw8f8C86e5mLMcVnvX3qoVhGE7ulO1ElVdXvoQvN WI7yWwolPewGEaotihFG7htWb+o9e4X1YCxY+wINi3MTIA4thiOIhNKoRNcgCxf5aLkI gFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=PuoqRTNVL5ZGTbTs/Rg91rM933xgdsmUCIOFOeqz2Ds=; b=2NZYWbPSAxgmYpnRPtAgLrA0itCUD6Udzw5+1smy0n9y/n8yrnbDwg7Crh8UHhzpL4 a00aTeGR2IiDT1YYZMWFepu8ThJhXKEhGrAmOduGHnAMX0vJcj2t0NJFIei3Oud/rIxo mgukKh565uxAxEWh2WoWh7V4u6JmleaqvR/x6uhpKMCbswBAHIoj7rhDr2CK9iwEaIWv ElGkZ3tyaI906bI3bRelOC1gdi0FoQgY+hyyZCcKuHDq8kasL79MSJaF6hAcyzczVuwd mqReIsZvJ2+2RyCFqHliUyN3hJEYzD7zOJi5S3hhnEZUSPoZloDJU4m4Hrf/FkaGqoA1 Yvgw== X-Gm-Message-State: ACrzQf1xjPpw0L3Ku/UU4MVqrl2feaIh2Rjn0iOikKr1TZm9CkvEe5eH tR7//vWkfFD51Lab5h4maLA= X-Google-Smtp-Source: AMsMyM6QvvNOLIFwv1OFDSIZwdBBFqj4FzigI92gnuN0gTm6vTFdNmT6K9R5IuWEjak1oBnc9h6l4w== X-Received: by 2002:ac2:44ca:0:b0:499:b6ff:bc75 with SMTP id d10-20020ac244ca000000b00499b6ffbc75mr142903lfm.233.1663800734510; Wed, 21 Sep 2022 15:52:14 -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 q2-20020ac25a02000000b004991437990esm631579lfn.11.2022.09.21.15.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 15:52:13 -0700 (PDT) Date: Thu, 22 Sep 2022 01:52:12 +0300 From: Dmitry Kozlyuk To: David Marchand Cc: Fidaullah Noonari , dev@dpdk.org, "Burakov, Anatoly" Subject: Re: [PATCH v2] eal: change alloc_sz calculation which may cause unnecessarily allocation Message-ID: <20220922015212.03bfde66@sovereign> In-Reply-To: References: <20220728094103.137862-1-fidaullah.noonari@emumba.com> <20220728210327.7077be93@sovereign> 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-09-21 15:35 (UTC+0200), David Marchand: > On Thu, Jul 28, 2022 at 8:03 PM Dmitry Kozlyuk wrote: > > > > 2022-07-28 14:41 (UTC+0500), Fidaullah Noonari: > > > 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 > > > > Acked-by: Dmitry Kozlyuk > > > > Do you have a reproducer? > This sounds like a fix, should we backport it? We should, thanks for the catch. Reproducer: #include #include #include int main(int argc, char **argv) { static const size_t hugepage_sz = 2 * (1 << 20); static const size_t malloc_elem_overhead = 128; static const size_t size = hugepage_sz - malloc_elem_overhead; struct rte_malloc_socket_stats stats_before, stats_after; size_t alloc_delta; int ret; ret = rte_eal_init(argc, argv); if (ret < 0) rte_panic("Cannot init EAL\n"); rte_malloc_get_socket_stats(0, &stats_before); (void)rte_malloc(NULL, size, 0); rte_malloc_get_socket_stats(0, &stats_after); alloc_delta = stats_after.heap_totalsz_bytes - stats_before.heap_totalsz_bytes; puts(alloc_delta == hugepage_sz ? "fixed" : "affected"); rte_eal_cleanup(); return 0; }