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 54C1BA00C2; Mon, 26 Sep 2022 11:18:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A0404069B; Mon, 26 Sep 2022 11:18:44 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B14F2400D7 for ; Mon, 26 Sep 2022 11:18:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664183922; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0+UcIZdA7rSNTTGWidIQLrio97Qs5WTDY8Hw2Yc+k90=; b=Lgy3VyXTN7VAtpOyu437XBm+oYSRByq+TOc/m4tbo6IXpAsoxsqpB4dFVVAmXzzr3pid8f aZVr3b/Fvmk7hh+NbPPksfBiAPAWRGcaUwZPhoiDhZxn1zF5R6tQUj5+mlw+e2WVkhUNIO Jf5qcuV01mSi7eBzgCQzGtgaSoQfLOc= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-587-rwoGA91gOuWn4dahTFZsRg-1; Mon, 26 Sep 2022 05:18:40 -0400 X-MC-Unique: rwoGA91gOuWn4dahTFZsRg-1 Received: by mail-ed1-f72.google.com with SMTP id s17-20020a056402521100b004511c8d59e3so4976611edd.11 for ; Mon, 26 Sep 2022 02:18:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=0+UcIZdA7rSNTTGWidIQLrio97Qs5WTDY8Hw2Yc+k90=; b=mm6yDbubAKHCmTPc9QKXD0rY5EpivCSgLYt55BXrPa7JR6la9Tk04F2RLJ0KHhIK+w CH9P9cq3l+DgTYj+0GydvfT70gtk7btkjiMYocMw3b0RyuKPqCuyAZbGghwB0a2BPWP/ R9mMKBZn5OZ57W7/E5+06F6f4siO9VUbPSOAxnVWHZXepvKCyGCKiM09EWtCxqUWqAsl HL4VI2WY+6S37TrMQf84j0NZMTkHyFmMYqTyXtyklgC4M38IOW3Bs9o9e95j1xktd0xi 3Bo3U3KGYyKM7qPjS2xUPdYAa0oSTNZ9n6YcaYNyT4kPzIuHOu7kopl6JYmAX+xHCzZg oF5Q== X-Gm-Message-State: ACrzQf2ts8gg/WJjZYtvdQdd3SORWYSec7ojIKzH1lmuyB/OJhHbSv6F x+f52KyjbC/QfPp+6gMO32ybwIdyrBK+tHAJr6LUyWNU0U2dPblEYzYKhB/8jKLDXfDn2IP/4HI wemXEjsUNjOhk4Sw0Qnk= X-Received: by 2002:a17:906:fe04:b0:777:b13d:30a6 with SMTP id wy4-20020a170906fe0400b00777b13d30a6mr16942617ejb.248.1664183919807; Mon, 26 Sep 2022 02:18:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM774DdV/534r3ub4D7YpB8Sk0KbyC9ua/WBWLOHZ+/ymL3n5sTTcTi+15eWTDcayIO0ihZt+vAxHrt8/GJ73iw= X-Received: by 2002:a17:906:fe04:b0:777:b13d:30a6 with SMTP id wy4-20020a170906fe0400b00777b13d30a6mr16942598ejb.248.1664183919560; Mon, 26 Sep 2022 02:18:39 -0700 (PDT) MIME-Version: 1.0 References: <20220728094103.137862-1-fidaullah.noonari@emumba.com> <20220728210327.7077be93@sovereign> <20220922015212.03bfde66@sovereign> In-Reply-To: <20220922015212.03bfde66@sovereign> From: David Marchand Date: Mon, 26 Sep 2022 11:18:27 +0200 Message-ID: Subject: Re: [PATCH v2] eal: change alloc_sz calculation which may cause unnecessarily allocation To: Dmitry Kozlyuk Cc: Fidaullah Noonari , dev@dpdk.org, "Burakov, Anatoly" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 Thu, Sep 22, 2022 at 12:52 AM Dmitry Kozlyuk wrote: > > 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; Thanks Dmitry. I'll put a note about this reproducer in the commitlog. > } > -- David Marchand