[CRIU] [PATCH] ipc: SysVshmem segment can be unaligned

Pavel Emelyanov xemul at virtuozzo.com
Mon May 30 06:26:19 PDT 2016


It's possible to create sysvshmem segment with size not being
multiple of page_size. And this very size will be reported
everywhere in the interfaces.

Support this type of segments too.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/shmem.c                        | 2 +-
 test/zdtm/.gitignore                | 1 +
 test/zdtm/static/Makefile           | 4 ++++
 test/zdtm/static/shm-unaligned.c    | 1 +
 test/zdtm/static/shm-unaligned.desc | 1 +
 5 files changed, 8 insertions(+), 1 deletion(-)
 create mode 120000 test/zdtm/static/shm-unaligned.c
 create mode 120000 test/zdtm/static/shm-unaligned.desc

diff --git a/criu/shmem.c b/criu/shmem.c
index b017a7c..d3ad1a8 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -161,7 +161,7 @@ int fixup_sysv_shmems(void)
 			 * Same thing is checked in open_shmem_sysv() for
 			 * intermediate holes.
 			 */
-			if (att->first->start + si->size != att->prev_end) {
+			if (att->first->start + round_up(si->size, page_size()) != att->prev_end) {
 				pr_err("Sysv shmem %lx with tail hole not supported\n", si->shmid);
 				return -1;
 			}
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index 8534d69..5cd455d 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -137,6 +137,7 @@
 /static/session02
 /static/session03
 /static/shm
+/static/shm-unaligned
 /static/shm-mp
 /static/sigaltstack
 /static/signalfd00
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index eab3cba..b6ed8f3 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -45,6 +45,7 @@ TST_NOFILE	=				\
 		inotify_system			\
 		inotify_system_nodel		\
 		shm				\
+		shm-unaligned			\
 		shm-mp				\
 		ptrace_sig			\
 		pipe00				\
@@ -298,6 +299,9 @@ $(TST_DIR_FILE:%=%.pid):	%.pid:	%
 cmdlinenv00.pid: cmdlinenv00
 	$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --arg1=arg1 --arg2=arg2 --arg3=arg3
 
+shm-unaligned.pid: shm-unaligned
+	$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --shmem_size=5000
+
 env00.pid:	env00
 	$(<D)/$(<F) --pidfile=$@ --outfile=$<.out --envname=ENV_00_TEST
 umask00.pid:	umask00
diff --git a/test/zdtm/static/shm-unaligned.c b/test/zdtm/static/shm-unaligned.c
new file mode 120000
index 0000000..7e1c916
--- /dev/null
+++ b/test/zdtm/static/shm-unaligned.c
@@ -0,0 +1 @@
+shm.c
\ No newline at end of file
diff --git a/test/zdtm/static/shm-unaligned.desc b/test/zdtm/static/shm-unaligned.desc
new file mode 120000
index 0000000..be44f8a
--- /dev/null
+++ b/test/zdtm/static/shm-unaligned.desc
@@ -0,0 +1 @@
+shm.desc
\ No newline at end of file
-- 
2.5.0


More information about the CRIU mailing list