From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6B52FA04DC; Mon, 19 Oct 2020 17:42:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB643FC5F; Mon, 19 Oct 2020 17:42:46 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 004A1FC5E for ; Mon, 19 Oct 2020 17:42:45 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id t18so5181593plo.1 for ; Mon, 19 Oct 2020 08:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nKyQC9PesDnLV6bYFXWTQKiEk4P+vgryl9BowQW1H0Y=; b=NzgBrl7SwQV7juUHwb8Rj7AhIhFQWRwoNxwByDijWn3be8E8rQsi4K95Pu9zI+3Cz7 I/zGPgV2F2nrCIGPWcjs9u8WOPq3LLmfOJRR9b33qP+mCkOgdwZbegMxVjMhGqk9Gh3L spTBJXTtFdw+jUZnMyS3tCovlnhICWta2Hp2b+jfeidtt2N1tQn44D274HTdqgWn1zxW XM4IWg1+YJXo80qa1/TTeoN6B9O0nI87i7T3kUdlPlFPPEARRw+R6fDJZsCPu2Qg0ySs YDEIRsx6MoCz0DS1EXm4bOiaYR+9cmMuUqLsQrG5XpBfkoRtQfVX9DVto8bZ/1/iSVwz NU4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nKyQC9PesDnLV6bYFXWTQKiEk4P+vgryl9BowQW1H0Y=; b=eZcGsACH4KNEiHBKXzS7OH/keodUFfffcamy4FbfTxJ+GdgBMfD5kG0IeZqJLUetKK qILv3K0oGZ972/Jh3VYw2eBFDD1LoEE0XRmgQNHKq5r/0DYBKHkrvAFt2OgXrzonFKXE PoZV8jFu0kLZWGkxyH5xBBPkhOl43KKypgMTxDfr/wlUDTBeC8VimU/DT/HCpBzC1A0O OdTpHusTpZk0g7VGjsiYhtYdiWQBEHOMHRTKpGlTKysIlVAv1ZTkKxnCdSLlDl3vs4N1 /kxHHgmQ0O9RIPDLECu80IUAhefnsiLe/0Ismz2S/qNfhhgfq78fk4uajk99sCIOAAV9 yuNw== X-Gm-Message-State: AOAM532GjjT5CjX6PKCzNTUrhWlgei3Ei64KJY5IpZpBCnra04qfA2r7 kEwHA8xYo0PSsxNU/G9vbVa7HdlV8oHm1w== X-Google-Smtp-Source: ABdhPJynRTTWfxf9EuCedKK/iSR16KT+QhcfBMwv2aRua1SqBSG4urTqhEmyUO1a7DkO6KE5K4kC4g== X-Received: by 2002:a17:902:7242:b029:d4:c719:79ce with SMTP id c2-20020a1709027242b02900d4c71979cemr495888pll.26.1603122163488; Mon, 19 Oct 2020 08:42:43 -0700 (PDT) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id i25sm91349pgi.9.2020.10.19.08.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:42:42 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Anatoly Burakov , Stephen Hemminger Date: Mon, 19 Oct 2020 08:42:35 -0700 Message-Id: <20201019154235.17799-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] mem: close rtemap files X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 one line just close the file after it is setup. Fixes: 582bed1e1d1d ("mem: support mapping hugepages at runtime") Cc: anatoly.burakov@intel.com Signed-off-by: Stephen Hemminger --- lib/librte_eal/linux/eal_memalloc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/librte_eal/linux/eal_memalloc.c b/lib/librte_eal/linux/eal_memalloc.c index 6dc1b2baecdc..99600adda568 100644 --- a/lib/librte_eal/linux/eal_memalloc.c +++ b/lib/librte_eal/linux/eal_memalloc.c @@ -651,6 +651,12 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, __func__); #endif + /* + * reference count is held by mmap() now + * don't need to hold file open to keep it locked + */ + close(fd); + ms->addr = addr; ms->hugepage_sz = alloc_sz; ms->len = alloc_sz; -- 2.27.0