DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaoxiang Liu <gaoxiangliu0@163.com>
To: dev@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>
Cc: liugaoxiang@huawei.com, Gaoxiang Liu <gaoxiangliu0@163.com>,
	stable@dpdk.org
Subject: [PATCH v3] eal: allow to exclude memseg from core dump
Date: Tue, 14 Dec 2021 23:18:49 +0800	[thread overview]
Message-ID: <20211214151850.1183-1-gaoxiangliu0@163.com> (raw)
In-Reply-To: <20211214120817.1476-1-gaoxiangliu0@163.com>

Some DPDK application is allocated 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 memseg memory
is allowed to exclude from 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 <liugaoxiang@huawei.com>

---
v2:
* Fixed compile issues.

v3:
* Fixed review issues. madvise is replaced by eal_mem_set_dump(),
* and The type of huge_dont_dump_flag has been changed to bool.
---
 doc/guides/linux_gsg/linux_eal_parameters.rst | 4 ++++
 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                  | 3 +++
 lib/eal/unix/eal_unix_memory.c                | 7 +++++--
 6 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/doc/guides/linux_gsg/linux_eal_parameters.rst b/doc/guides/linux_gsg/linux_eal_parameters.rst
index 74df2611b5..b6805bc6df 100644
--- a/doc/guides/linux_gsg/linux_eal_parameters.rst
+++ b/doc/guides/linux_gsg/linux_eal_parameters.rst
@@ -93,6 +93,10 @@ Memory-related options
 
     Free hugepages back to system exactly as they were originally allocated.
 
+*   ``--memseg-dont-dump``
+
+    Allow to exclude memseg from core dump.
+
 Other options
 ~~~~~~~~~~~~~
 
diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h
index d6c0470eb8..a7c34b88db 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];
+	bool memseg_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..013aad4cfc 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_MEMSEG_DONT_DUMP     "memseg-dont-dump"
+	OPT_MEMSEG_DONT_DUMP_NUM,
 	OPT_LONG_MAX_NUM
 };
 
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 60b4924838..8a47bf758a 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_MEMSEG_DONT_DUMP_NUM:
+			internal_conf->memseg_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..8e41537355 100644
--- a/lib/eal/linux/eal_memalloc.c
+++ b/lib/eal/linux/eal_memalloc.c
@@ -663,6 +663,9 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id,
 	ms->iova = iova;
 	ms->socket_id = socket_id;
 
+	if (internal_conf->memseg_dont_dump_flag)
+		eal_mem_set_dump(addr, alloc_sz, false);
+
 	return 0;
 
 mapped:
diff --git a/lib/eal/unix/eal_unix_memory.c b/lib/eal/unix/eal_unix_memory.c
index 68ae93bd6e..44227aee95 100644
--- a/lib/eal/unix/eal_unix_memory.c
+++ b/lib/eal/unix/eal_unix_memory.c
@@ -83,10 +83,13 @@ eal_mem_set_dump(void *virt, size_t size, bool dump)
 	int flags = dump ? EAL_DODUMP : EAL_DONTDUMP;
 	int ret = madvise(virt, size, flags);
 	if (ret) {
-		RTE_LOG(DEBUG, EAL, "madvise(%p, %#zx, %d) failed: %s\n",
+		RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) failed: %s\n",
 				virt, size, flags, strerror(rte_errno));
 		rte_errno = errno;
-	}
+	} else
+		RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) success: %s\n",
+				virt, size, flags, __func__);
+
 	return ret;
 }
 
-- 
2.32.0



  reply	other threads:[~2021-12-14 15:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 11:41 [PATCH] mem: exclude used memory from core dump by config Gaoxiang Liu
2021-12-14 12:08 ` [PATCH v2] " Gaoxiang Liu
2021-12-14 15:18   ` Gaoxiang Liu [this message]
2021-12-15 12:06     ` [PATCH v3] eal: allow to exclude memseg from core dump Jerin Jacob
2021-12-15 14:34       ` Dmitry Kozlyuk
2021-12-15 15:46     ` Dmitry Kozlyuk
2021-12-14 12:08 ` [PATCH] mem: exclude used memory from core dump by config Jerin Jacob
2021-12-14 12:21   ` Gaoxiang Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211214151850.1183-1-gaoxiangliu0@163.com \
    --to=gaoxiangliu0@163.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=liugaoxiang@huawei.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).