[dpdk-dev] vhost: reduce size of coredump file

Message ID 20180209174017.14644-1-tomaszx.kulasek@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Kulasek Feb. 9, 2018, 5:40 p.m. UTC
  If application coredumps with vhost-user devices connected to it,
the generated coredump file size is huge.

To limit its size, this patch adds call to madvise() with MADV_DONTDUMP
on memory regions mapped from the VM.

Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
---
 lib/librte_vhost/vhost_user.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Jianfeng Tan Feb. 11, 2018, 4:34 a.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
> Sent: Saturday, February 10, 2018 1:40 AM
> To: yliu@fridaylinux.org
> Cc: dev@dpdk.org; Basierski, SebastianX
> Subject: [dpdk-dev] [PATCH] vhost: reduce size of coredump file
> 
> If application coredumps with vhost-user devices connected to it,
> the generated coredump file size is huge.
> 
> To limit its size, this patch adds call to madvise() with MADV_DONTDUMP
> on memory regions mapped from the VM.

As virtqueue is on guest memory, by this patch, the vq information will not be available in the coredump.

Just wonder if adjusting /proc/pid/coredump_filter can help your case?

Thanks,
Jianfeng

> 
> Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> ---
>  lib/librte_vhost/vhost_user.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 65ee33919..fc1f1a948 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -723,6 +723,11 @@ vhost_user_set_mem_table(struct virtio_net *dev,
> struct VhostUserMsg *pmsg)
>  			goto err_mmap;
>  		}
> 
> +		if (madvise(mmap_addr, mmap_size,
> MADV_DONTDUMP) != 0) {
> +			RTE_LOG(INFO, VHOST_CONFIG,
> +				"MADV_DONTDUMP advice setting
> failed.\n");
> +		}
> +
>  		reg->mmap_addr = mmap_addr;
>  		reg->mmap_size = mmap_size;
>  		reg->host_user_addr = (uint64_t)(uintptr_t)mmap_addr +
> --
> 2.14.1
  
Maxime Coquelin March 28, 2018, 8:48 a.m. UTC | #2
On 02/11/2018 05:34 AM, Tan, Jianfeng wrote:
> 
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tomasz Kulasek
>> Sent: Saturday, February 10, 2018 1:40 AM
>> To: yliu@fridaylinux.org
>> Cc: dev@dpdk.org; Basierski, SebastianX
>> Subject: [dpdk-dev] [PATCH] vhost: reduce size of coredump file
>>
>> If application coredumps with vhost-user devices connected to it,
>> the generated coredump file size is huge.
>>
>> To limit its size, this patch adds call to madvise() with MADV_DONTDUMP
>> on memory regions mapped from the VM.
> 
> As virtqueue is on guest memory, by this patch, the vq information will not be available in the coredump.
> 
> Just wonder if adjusting /proc/pid/coredump_filter can help your case?

Yes it helps as by default I never have the guest memory in the
coredumps I receive.

Maxime

> Thanks,
> Jianfeng
> 
>>
>> Signed-off-by: Sebastian Basierski <sebastianx.basierski@intel.com>
>> Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
>> ---
>>   lib/librte_vhost/vhost_user.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
>> index 65ee33919..fc1f1a948 100644
>> --- a/lib/librte_vhost/vhost_user.c
>> +++ b/lib/librte_vhost/vhost_user.c
>> @@ -723,6 +723,11 @@ vhost_user_set_mem_table(struct virtio_net *dev,
>> struct VhostUserMsg *pmsg)
>>   			goto err_mmap;
>>   		}
>>
>> +		if (madvise(mmap_addr, mmap_size,
>> MADV_DONTDUMP) != 0) {
>> +			RTE_LOG(INFO, VHOST_CONFIG,
>> +				"MADV_DONTDUMP advice setting
>> failed.\n");
>> +		}
>> +
>>   		reg->mmap_addr = mmap_addr;
>>   		reg->mmap_size = mmap_size;
>>   		reg->host_user_addr = (uint64_t)(uintptr_t)mmap_addr +
>> --
>> 2.14.1
>
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 65ee33919..fc1f1a948 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -723,6 +723,11 @@  vhost_user_set_mem_table(struct virtio_net *dev, struct VhostUserMsg *pmsg)
 			goto err_mmap;
 		}
 
+		if (madvise(mmap_addr, mmap_size, MADV_DONTDUMP) != 0) {
+			RTE_LOG(INFO, VHOST_CONFIG,
+				"MADV_DONTDUMP advice setting failed.\n");
+		}
+
 		reg->mmap_addr = mmap_addr;
 		reg->mmap_size = mmap_size;
 		reg->host_user_addr = (uint64_t)(uintptr_t)mmap_addr +