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 BA00CA00C3; Tue, 14 Dec 2021 13:08:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D96C541147; Tue, 14 Dec 2021 13:08:44 +0100 (CET) Received: from m12-14.163.com (m12-14.163.com [220.181.12.14]) by mails.dpdk.org (Postfix) with ESMTP id 8C1FD4003C; Tue, 14 Dec 2021 13:08:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=Qk+Fj PShaZaTPDfJTnhtvNS8ov/EObUWNniRt0VOeJs=; b=TxCVQQdG9f2FTVUNWYOGf C7J2PRLnrfrDCwCbgQBs/0E5mhGf1ecMNP6szfdk8uzzXroDLp8CSqK1bozcZ4i0 yXduZ0Yc73BKvVNKhXl8k6SzoIbqGmS4h6c5TQ1OJTCPKrbwtDr0WyXQ4Vls0LIA uN6i28vC9qwNPYOBkxR1pc= Received: from DESKTOP-ONA2IA7.localdomain (unknown [223.104.244.167]) by smtp10 (Coremail) with SMTP id DsCowAB3LcIzibhhSVneCA--.35759S4; Tue, 14 Dec 2021 20:08:28 +0800 (CST) From: Gaoxiang Liu To: dev@dpdk.org, Anatoly Burakov Cc: liugaoxiang@huawei.com, Gaoxiang Liu , stable@dpdk.org Subject: [PATCH v2] mem: exclude used memory from core dump by config Date: Tue, 14 Dec 2021 20:08:16 +0800 Message-Id: <20211214120817.1476-1-gaoxiangliu0@163.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211214114151.1298-1-gaoxiangliu0@163.com> References: <20211214114151.1298-1-gaoxiangliu0@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: DsCowAB3LcIzibhhSVneCA--.35759S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxZF1DWr43XFWxAFyDCFW7urg_yoW5Cr48pF ZrCFy5XFy7tr1S93srXw40va1rKa4fGF1UG3y7Xw1qvrZxt3yfW34DKa4aga43ZrWUJF4D Zr18KFZ09a4UAw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jx8n5UUUUU= X-Originating-IP: [223.104.244.167] X-CM-SenderInfo: xjdr5xxdqjzxjxq6il2tof0z/xtbBQhxpOl++OUPVKQAAsq 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 Some DPDK application is allolcateed storage partition of 8G(or smaller) If coredump happens, the application doesn't work because of insufficient storage space. The patch provides a config that means whether the huge used memory needs to be not dumped in core dump. The DPDK application can choose to open it according to the actual situation. Fixes: d72e4042c5eb ("mem: exclude unused memory from core dump") Cc: stable@dpdk.org Signed-off-by: Gaoxiang Liu --- v2: * Fixed compile issues. --- lib/eal/common/eal_internal_cfg.h | 1 + lib/eal/common/eal_options.h | 3 ++- lib/eal/linux/eal.c | 4 ++++ lib/eal/linux/eal_memalloc.c | 10 ++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h index d6c0470eb8..f9cd300f86 100644 --- a/lib/eal/common/eal_internal_cfg.h +++ b/lib/eal/common/eal_internal_cfg.h @@ -87,6 +87,7 @@ struct internal_config { /**< user defined mbuf pool ops name */ unsigned num_hugepage_sizes; /**< how many sizes on this system */ struct hugepage_info hugepage_info[MAX_HUGEPAGE_SIZES]; + volatile unsigned huge_dont_dump_flag; enum rte_iova_mode iova_mode ; /**< Set IOVA mode on this system */ rte_cpuset_t ctrl_cpuset; /**< cpuset for ctrl threads */ volatile unsigned int init_complete; diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h index 8e4f7202a2..6b9a24f0f9 100644 --- a/lib/eal/common/eal_options.h +++ b/lib/eal/common/eal_options.h @@ -87,7 +87,8 @@ enum { OPT_NO_TELEMETRY_NUM, #define OPT_FORCE_MAX_SIMD_BITWIDTH "force-max-simd-bitwidth" OPT_FORCE_MAX_SIMD_BITWIDTH_NUM, - +#define OPT_HUGE_DONT_DUMP "huge-dont-dump" + OPT_HUGE_DONT_DUMP_NUM, OPT_LONG_MAX_NUM }; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b4924838..d496e7bab9 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -817,6 +817,10 @@ eal_parse_args(int argc, char **argv) internal_conf->match_allocations = 1; break; + case OPT_HUGE_DONT_DUMP_NUM: + internal_conf->huge_dont_dump_flag = 1; + break; + default: if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { RTE_LOG(ERR, EAL, "Option %c is not supported " diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c index 337f2bc739..01e010e2c1 100644 --- a/lib/eal/linux/eal_memalloc.c +++ b/lib/eal/linux/eal_memalloc.c @@ -663,6 +663,16 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, ms->iova = iova; ms->socket_id = socket_id; + if (internal_conf->huge_dont_dump_flag) { + if (madvise(addr, alloc_sz, MADV_DONTDUMP)) { + RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) failed: %s\n", + addr, alloc_sz, flags, strerror(rte_errno)); + } else { + RTE_LOG(INFO, EAL, "%s(): madvise(MADV_DONTDUMP) memory success.(len=%#zx)\n", + __func__, alloc_sz); + } + } + return 0; mapped: -- 2.32.0