patches for DPDK stable branches
 help / color / mirror / Atom feed
* [PATCH] mem: exclude used memory from core dump by config
@ 2021-12-14 11:41 Gaoxiang Liu
  2021-12-14 12:08 ` [PATCH v2] " Gaoxiang Liu
  2021-12-14 12:08 ` [PATCH] mem: exclude used memory from core dump by config Jerin Jacob
  0 siblings, 2 replies; 8+ messages in thread
From: Gaoxiang Liu @ 2021-12-14 11:41 UTC (permalink / raw)
  To: dev, Anatoly Burakov; +Cc: liugaoxiang, Gaoxiang Liu, stable

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 <liugaoxiang@huawei.com>
---
 lib/eal/common/eal_internal_cfg.h |  1 +
 lib/eal/common/eal_options.h      |  3 ++-
 lib/eal/linux/eal.c               |  3 +++
 lib/eal/linux/eal_memalloc.c      | 10 ++++++++++
 4 files changed, 16 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..eeab5e4f3d 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -816,6 +816,9 @@ eal_parse_args(int argc, char **argv)
 		case OPT_MATCH_ALLOCATIONS_NUM:
 			internal_conf->match_allocations = 1;
 			break;
+		case OPT_HUGE_DONT_DUMP_NUM:
+			internal_config->huge_dont_dump_flag = 1;
+			break;
 
 		default:
 			if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
index 337f2bc739..13ca1cf58c 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_config->huge_dont_dump_flag) {
+		if (madvise(addr, alloc_sz, EAL_DONTDUMP)) {
+			RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) failed: %s\n",
+					virt, size, flags, strerror(rte_errno));
+		} else {
+			RTE_LOG(INFO, EAL, "%s(): madvise(MADV_DONTDUMP) memory success.(len=%zu)\n",
+					__func__, alloc_sz);
+		}
+	}
+
 	return 0;
 
 mapped:
-- 
2.32.0



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] mem: exclude used memory from core dump by config
  2021-12-14 11:41 [PATCH] mem: exclude used memory from core dump by config Gaoxiang Liu
@ 2021-12-14 12:08 ` Gaoxiang Liu
  2021-12-14 15:18   ` [PATCH v3] eal: allow to exclude memseg from core dump Gaoxiang Liu
  2021-12-14 12:08 ` [PATCH] mem: exclude used memory from core dump by config Jerin Jacob
  1 sibling, 1 reply; 8+ messages in thread
From: Gaoxiang Liu @ 2021-12-14 12:08 UTC (permalink / raw)
  To: dev, Anatoly Burakov; +Cc: liugaoxiang, Gaoxiang Liu, stable

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 <liugaoxiang@huawei.com>

---
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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mem: exclude used memory from core dump by config
  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 12:08 ` Jerin Jacob
  2021-12-14 12:21   ` Gaoxiang Liu
  1 sibling, 1 reply; 8+ messages in thread
From: Jerin Jacob @ 2021-12-14 12:08 UTC (permalink / raw)
  To: Gaoxiang Liu; +Cc: dpdk-dev, Anatoly Burakov, liugaoxiang, dpdk stable

On Tue, Dec 14, 2021 at 5:12 PM Gaoxiang Liu <gaoxiangliu0@163.com> wrote:
>
> Some DPDK application is allolcateed storage partition of 8G(or smaller)

allocated

> 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

Probably subject can be changed to: eal: allow to exclude memseg from core dump

>
> Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
> ---
>  lib/eal/common/eal_internal_cfg.h |  1 +
>  lib/eal/common/eal_options.h      |  3 ++-
>  lib/eal/linux/eal.c               |  3 +++
>  lib/eal/linux/eal_memalloc.c      | 10 ++++++++++

freebsd support can be updated,
Please update doc/guides/linux_gsg/linux_eal_parameters.rst and
doc/guides/freebsd_gsg/freebsd_eal_parameters.rst.


>  4 files changed, 16 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;

Volatile may not be needed. it can be changed to bool as well.


>         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..eeab5e4f3d 100644
> --- a/lib/eal/linux/eal.c
> +++ b/lib/eal/linux/eal.c
> @@ -816,6 +816,9 @@ eal_parse_args(int argc, char **argv)
>                 case OPT_MATCH_ALLOCATIONS_NUM:
>                         internal_conf->match_allocations = 1;
>                         break;
> +               case OPT_HUGE_DONT_DUMP_NUM:
> +                       internal_config->huge_dont_dump_flag = 1;
> +                       break;
>
>                 default:
>                         if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
> diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
> index 337f2bc739..13ca1cf58c 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_config->huge_dont_dump_flag) {
> +               if (madvise(addr, alloc_sz, EAL_DONTDUMP)) {
> +                       RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) failed: %s\n",
> +                                       virt, size, flags, strerror(rte_errno));
> +               } else {
> +                       RTE_LOG(INFO, EAL, "%s(): madvise(MADV_DONTDUMP) memory success.(len=%zu)\n",
> +                                       __func__, alloc_sz);
> +               }

I think, you can use eal_mem_set_dump()

> +       }
> +
>         return 0;
>
>  mapped:
> --
> 2.32.0
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mem: exclude used memory from core dump by config
  2021-12-14 12:08 ` [PATCH] mem: exclude used memory from core dump by config Jerin Jacob
@ 2021-12-14 12:21   ` Gaoxiang Liu
  0 siblings, 0 replies; 8+ messages in thread
From: Gaoxiang Liu @ 2021-12-14 12:21 UTC (permalink / raw)
  To: jerinjacobk; +Cc: dev, anatoly.burakov, liugaoxiang, stable

[-- Attachment #1: Type: text/plain, Size: 4354 bytes --]

Hi Jerin,
I will fix the issues.

Thanks.
Gaoxiang.



---- 回复的原邮件 ----
| 发件人 | Jerin Jacob<jerinjacobk@gmail.com> |
| 日期 | 2021年12月14日 20:08 |
| 收件人 | Gaoxiang Liu<gaoxiangliu0@163.com> |
| 抄送至 | dpdk-dev<dev@dpdk.org>、Anatoly Burakov<anatoly.burakov@intel.com>、liugaoxiang@huawei.com<liugaoxiang@huawei.com>、dpdk stable<stable@dpdk.org> |
| 主题 | Re: [PATCH] mem: exclude used memory from core dump by config |
On Tue, Dec 14, 2021 at 5:12 PM Gaoxiang Liu <gaoxiangliu0@163.com> wrote:
>
> Some DPDK application is allolcateed storage partition of 8G(or smaller)

allocated

> 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

Probably subject can be changed to: eal: allow to exclude memseg from core dump

>
> Signed-off-by: Gaoxiang Liu <liugaoxiang@huawei.com>
> ---
>  lib/eal/common/eal_internal_cfg.h |  1 +
>  lib/eal/common/eal_options.h      |  3 ++-
>  lib/eal/linux/eal.c               |  3 +++
>  lib/eal/linux/eal_memalloc.c      | 10 ++++++++++

freebsd support can be updated,
Please update doc/guides/linux_gsg/linux_eal_parameters.rst and
doc/guides/freebsd_gsg/freebsd_eal_parameters.rst.


>  4 files changed, 16 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;

Volatile may not be needed. it can be changed to bool as well.


>         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..eeab5e4f3d 100644
> --- a/lib/eal/linux/eal.c
> +++ b/lib/eal/linux/eal.c
> @@ -816,6 +816,9 @@ eal_parse_args(int argc, char **argv)
>                 case OPT_MATCH_ALLOCATIONS_NUM:
>                         internal_conf->match_allocations = 1;
>                         break;
> +               case OPT_HUGE_DONT_DUMP_NUM:
> +                       internal_config->huge_dont_dump_flag = 1;
> +                       break;
>
>                 default:
>                         if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
> diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
> index 337f2bc739..13ca1cf58c 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_config->huge_dont_dump_flag) {
> +               if (madvise(addr, alloc_sz, EAL_DONTDUMP)) {
> +                       RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) failed: %s\n",
> +                                       virt, size, flags, strerror(rte_errno));
> +               } else {
> +                       RTE_LOG(INFO, EAL, "%s(): madvise(MADV_DONTDUMP) memory success.(len=%zu)\n",
> +                                       __func__, alloc_sz);
> +               }

I think, you can use eal_mem_set_dump()

> +       }
> +
>         return 0;
>
>  mapped:
> --
> 2.32.0
>
>

[-- Attachment #2: Type: text/html, Size: 9451 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3] eal: allow to exclude memseg from core dump
  2021-12-14 12:08 ` [PATCH v2] " Gaoxiang Liu
@ 2021-12-14 15:18   ` Gaoxiang Liu
  2021-12-15 12:06     ` Jerin Jacob
  2021-12-15 15:46     ` Dmitry Kozlyuk
  0 siblings, 2 replies; 8+ messages in thread
From: Gaoxiang Liu @ 2021-12-14 15:18 UTC (permalink / raw)
  To: dev, Anatoly Burakov; +Cc: liugaoxiang, Gaoxiang Liu, stable

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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] eal: allow to exclude memseg from core dump
  2021-12-14 15:18   ` [PATCH v3] eal: allow to exclude memseg from core dump Gaoxiang Liu
@ 2021-12-15 12:06     ` Jerin Jacob
  2021-12-15 14:34       ` Dmitry Kozlyuk
  2021-12-15 15:46     ` Dmitry Kozlyuk
  1 sibling, 1 reply; 8+ messages in thread
From: Jerin Jacob @ 2021-12-15 12:06 UTC (permalink / raw)
  To: Gaoxiang Liu; +Cc: dpdk-dev, Anatoly Burakov, liugaoxiang, dpdk stable

On Tue, Dec 14, 2021 at 8:49 PM Gaoxiang Liu <gaoxiangliu0@163.com> wrote:
>
> 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")

This is patch is a feature, not a fix. So you can remove this

> Cc: stable@dpdk.org

This is patch is a feature, not a fix. So you can remove this


>
> 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

Since you are adding it in unix/eal_unix_memory.c it is applicable for
freebsd too.
Please update options and documentation for freebsd.

> 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));

probably ERR instead of INFO.


>                 rte_errno = errno;
> -       }
> +       } else
> +               RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) success: %s\n",
> +                               virt, size, flags, __func__);

This should be DEBUG. Not INFO.

With above changes
Reviewed-by: Jerin Jacob <jerinj@marvell.com>


> +
>         return ret;
>  }
>
> --
> 2.32.0
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] eal: allow to exclude memseg from core dump
  2021-12-15 12:06     ` Jerin Jacob
@ 2021-12-15 14:34       ` Dmitry Kozlyuk
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Kozlyuk @ 2021-12-15 14:34 UTC (permalink / raw)
  To: Jerin Jacob, Gaoxiang Liu
  Cc: dpdk-dev, Anatoly Burakov, liugaoxiang, dpdk stable

2021-12-15 17:36 (UTC+0530), Jerin Jacob:
[...]
> > 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));  
> 
> probably ERR instead of INFO.
> 
> 
> >                 rte_errno = errno;
> > -       }
> > +       } else
> > +               RTE_LOG(INFO, EAL, "madvise(%p, %#zx, %d) success: %s\n",
> > +                               virt, size, flags, __func__);  
> 
> This should be DEBUG. Not INFO.

Usually errors from OS API are reported as DEBUG in EAL,
so the first one should also remain DEBUG.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3] eal: allow to exclude memseg from core dump
  2021-12-14 15:18   ` [PATCH v3] eal: allow to exclude memseg from core dump Gaoxiang Liu
  2021-12-15 12:06     ` Jerin Jacob
@ 2021-12-15 15:46     ` Dmitry Kozlyuk
  1 sibling, 0 replies; 8+ messages in thread
From: Dmitry Kozlyuk @ 2021-12-15 15:46 UTC (permalink / raw)
  To: Gaoxiang Liu; +Cc: dev, Anatoly Burakov, liugaoxiang, stable

2021-12-14 23:18 (UTC+0800), Gaoxiang Liu:
> 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.

Does it need to be a DPDK option?
If eal_mem_set_dump() is exposed as rte_mem_set_dump(),
this feature can be implemented by the application using
rte_mem_event_callback_register().
On Linux only and for all hugepages (not only DPDK ones),
administrator can reset bits 5 and 6 of /proc/[pid]/core_filter
to solve the task without any programming at all.
https://man7.org/linux/man-pages/man5/core.5.html

[...]
> 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.
> +

"Memory segment" is something that is understood by programmers, not users.
Suggesting --no-huge-dump, in line with --no-huge and --huge-unlink.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-15 15:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH v3] eal: allow to exclude memseg from core dump Gaoxiang Liu
2021-12-15 12:06     ` 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

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git