ipc: SysVshmem segment can be unaligned

Submitted by Pavel Emelianov on May 30, 2016, 1:26 p.m.

Details

Message ID 574C3F7B.7000908@virtuozzo.com
State Accepted
Series "ipc: SysVshmem segment can be unaligned"
Commit 40ab25a25f52a12666989a576a6695edf8a64fbf
Headers show

Commit Message

Pavel Emelianov May 30, 2016, 1:26 p.m.
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@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

Patch hide | download patch | download mbox

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

Comments

Cyrill Gorcunov May 30, 2016, 1:28 p.m.
On Mon, May 30, 2016 at 04:26:19PM +0300, Pavel Emelyanov wrote:
> 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@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>