From e7d29486f66dd67cb90392bf94a14f90702724e8 Mon Sep 17 00:00:00 2001 From: Dhanuka Warusadura Date: Tue, 15 Aug 2023 20:59:21 +0530 Subject: [PATCH] memfd_secret: save secretmem stat Adds support to save secretmem page stats when C/R a memfd_secret fd containing process. Updates images/stats.proto to add statistics about C/R memfd_secret fd. Signed-off-by: Dhanuka Warusadura --- criu/include/stats.h | 4 ++++ criu/stats.c | 7 +++++++ images/stats.proto | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/criu/include/stats.h b/criu/include/stats.h index d8dd1599890..3cf97a1728b 100644 --- a/criu/include/stats.h +++ b/criu/include/stats.h @@ -33,6 +33,10 @@ enum { CNT_SHPAGES_SKIPPED_PARENT, CNT_SHPAGES_WRITTEN, + CNT_SECMEMPAGES_SCANNED, + CNT_SECMEMPAGES_SKIPPED_PARENT, + CNT_SECMEMPAGES_WRITTEN, + DUMP_CNT_NR_STATS, }; diff --git a/criu/stats.c b/criu/stats.c index 0a9b4f5d479..5f298f87ece 100644 --- a/criu/stats.c +++ b/criu/stats.c @@ -186,6 +186,13 @@ void write_stats(int what) ds_entry.shpages_written = dstats->counts[CNT_SHPAGES_WRITTEN]; ds_entry.has_shpages_written = true; + ds_entry.secmempages_scanned = dstats->counts[CNT_SECMEMPAGES_SCANNED]; + ds_entry.has_secmempages_scanned = true; + ds_entry.secmempages_skipped_parent = dstats->counts[CNT_SECMEMPAGES_SKIPPED_PARENT]; + ds_entry.has_secmempages_skipped_parent = true; + ds_entry.secmempages_written = dstats->counts[CNT_SECMEMPAGES_WRITTEN]; + ds_entry.has_secmempages_written = true; + name = "dump"; } else if (what == RESTORE_STATS) { stats.restore = &rs_entry; diff --git a/images/stats.proto b/images/stats.proto index 64e46181dad..65473c49578 100644 --- a/images/stats.proto +++ b/images/stats.proto @@ -22,6 +22,10 @@ message dump_stats_entry { optional uint64 shpages_scanned = 12; optional uint64 shpages_skipped_parent = 13; optional uint64 shpages_written = 14; + + optional uint64 secmempages_scanned = 15; + optional uint64 secmempages_skipped_parent = 16; + optional uint64 secmempages_written = 17; } message restore_stats_entry {