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 71522A00C2; Thu, 6 Oct 2022 12:04:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 124FE42BE3; Thu, 6 Oct 2022 12:04:31 +0200 (CEST) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mails.dpdk.org (Postfix) with ESMTP id 6A7AB42BCC for ; Thu, 6 Oct 2022 12:04:29 +0200 (CEST) Received: by mail-ed1-f49.google.com with SMTP id y100so2063449ede.6 for ; Thu, 06 Oct 2022 03:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emumba-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QfE+rI0fmlSj7vKx0J8UWKVxqOWY7r9/yAurkoT6tG4=; b=zIPwwRAbNaGmmxcXwUVXPkgvCNjx1LTd9EMnxWYBafvdJUIEEAwqNFUR/KunyaguFx Ztf0pcYjBlCLxpa3h2oV6CWfiGFbERqEwRpJGMPNc9Ln5TL/RDccIr8rhzR2xPL5uU7l 4FuRwX72TCr2U9XuTBgnr3dx5lNE5Y318sknp3pxvrRrqeHrtIMmKcxgXzJMu3Kna6JN pFrnGdTX0LHfHuGTRdFuAPEDFfAXP+lfPVK5ZDZeCZH3hhkMzBrdb9aV8liNvpw/XTFa N1VN04G9r5w7hdT2ZBapR6PHOKIBlPLCuthyeSRxi8UHRSJrCsoTB+8t1BMKUgzybhiX xoGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QfE+rI0fmlSj7vKx0J8UWKVxqOWY7r9/yAurkoT6tG4=; b=eNdXNwYjAw0WOgLU4tGDCCNbCks8+YRnigKnVkOe2G//Hvz4af0aIsPXgcc7DJV/Ul BU0iDbwL+O8P6ZgPONhpPX3vRup8XAr6iz11JRsdOtU0+qTt0lFenwaF1mHlgfmVGJn1 VvRwzY76gTxejPh9WlSiOY648xM8IlUSv0e1ZewvkAEus8UnUv6zMxh+IjUP5A5xWplE C8QM+kD5G9sXo4r1ZIwYEd4CgS87OxbKcAV1uSmF6DCzX+EP9hHua9bdv4ll8HMZaqAP 4CaHh34RRFK78qxVv7Q46oanXHDr8q6XtGFNQbIaNDY9wr850RGCOpbTZK14b+p/YEye C3Ig== X-Gm-Message-State: ACrzQf3Pz5hd7NawNQcrW/3bxeGLh64nH4ovx0vcuGBn9d+3lynneuSq ueIJezEZFaLK4p1LJTNiIDOWaA== X-Google-Smtp-Source: AMsMyM5XaHhA/59XsjbxynK56IbydCVRR0E4e7Hm0gvXK/6e+4M3iMgJCSXltcAAypLzI7o6jxLdUA== X-Received: by 2002:aa7:cb18:0:b0:452:9071:aff with SMTP id s24-20020aa7cb18000000b0045290710affmr3781057edt.194.1665050669111; Thu, 06 Oct 2022 03:04:29 -0700 (PDT) Received: from bts2.localdomain ([182.191.83.208]) by smtp.gmail.com with ESMTPSA id aj9-20020a1709069a4900b0078b4801c40bsm6627426ejc.216.2022.10.06.03.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 03:04:28 -0700 (PDT) From: "huzaifa.rahman" To: anatoly.burakov@intel.com Cc: dev@dpdk.org, stephen@networkplumber.org, "huzaifa.rahman" Subject: [PATCH] mem: close rtemap files Date: Thu, 6 Oct 2022 10:04:05 +0000 Message-Id: <20221006100405.2809898-1-huzaifa.rahman@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 Bugzilla ID: 560 The memory subsystem is leaving open a file descriptor for each rtemap file. This can lead to hundreds of extra open file descriptors which has negative side effects. For example, the application may go over its maximum file descriptor limit, or the application may be using limited API's like select that only allow 1024 file descriptors. The EAL memory subsystem does not need to hold the file open. Probably the original intention was to keep the file locked, but that is not necessary. The Linux kernel keeps a reference count on the file, and the mmap counts is a reference and therefore maintains the file as locked. The fix is just to close the file after it is setup. Signed-off-by: huzaifa.rahman --- lib/eal/linux/eal_memalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index f8b1588cae..955c4e4f95 100644 --- a/lib/eal/linux/eal_memalloc.c +++ b/lib/eal/linux/eal_memalloc.c @@ -679,6 +679,9 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, huge_recover_sigbus(); + close(fd); + fd_list[list_idx].fds[seg_idx] = -1; + ms->addr = addr; ms->hugepage_sz = alloc_sz; ms->len = alloc_sz; -- 2.25.1