io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
To: axboe@kernel.dk, io-uring@vger.kernel.org
Subject: [PATCH v2 06/10] test/buffer-share: add private memory option
Date: Fri, 22 Jan 2021 14:54:55 -0800	[thread overview]
Message-ID: <1611356099-60732-7-git-send-email-bijan.mottahedeh@oracle.com> (raw)
In-Reply-To: <1611356099-60732-1-git-send-email-bijan.mottahedeh@oracle.com>

Signed-off-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
---
 test/buffer-share.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/test/buffer-share.c b/test/buffer-share.c
index 81e0537..cbfbfb2 100644
--- a/test/buffer-share.c
+++ b/test/buffer-share.c
@@ -18,6 +18,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <linux/fs.h>
+#include <malloc.h>
 
 #include "liburing.h"
 
@@ -71,7 +72,8 @@ unsigned long shm_sz = SZ_2M;
 
 int no_read;
 int warned;
-int verbose = 0;
+int private;
+int verbose;
 
 enum {
 	REG_NOP = 0,
@@ -1120,8 +1122,11 @@ main(int argc, char *argv[])
 	int shmid, pid, ret = 0;
 	char c;
 
-	while ((c = getopt(argc, argv, "s:v:")) != -1)
+	while ((c = getopt(argc, argv, "ps:v:")) != -1)
 		switch (c) {
+		case 'p':
+			private++;
+			break;
 		case 's':
 			shm_sz = atoi(optarg) * SZ_2M;
 			break;
@@ -1155,10 +1160,19 @@ main(int argc, char *argv[])
 	if (shmid < 0)
 		exit(1);
 
-	shmbuf = shm_attach(shmid);
-	if (shmbuf == MAP_FAILED) {
-		shm_destroy(shmid, shmbuf);
-		exit(1);
+	if (private) {
+		printf("private\n");
+		shmbuf = memalign(4096, shm_sz);
+		if (shmbuf == NULL) {
+			perror("memalign");
+			exit(1);
+		}
+	} else {
+		shmbuf = shm_attach(shmid);
+		if (shmbuf == MAP_FAILED) {
+			shm_destroy(shmid, shmbuf);
+			exit(1);
+		}
 	}
 
 	create_buffers(shmbuf);
@@ -1178,7 +1192,8 @@ main(int argc, char *argv[])
 	ret |= test(TEST_IO,  FD, REG_NOP, REG_ATT, TEST_DFLT,  EFAULT);
 	ret |= test(TEST_IO,  FD, REG_PIN, REG_ATT, TEST_EXIT,  NONE);
 
-	shm_destroy(shmid, shmbuf);
+	if (!private)
+		shm_destroy(shmid, shmbuf);
 
 	return ret;
 }
-- 
1.8.3.1


  parent reply	other threads:[~2021-01-22 22:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22 22:54 [PATCH v2 00/10] liburing: buffer registration enhancements Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 01/10] liburing: support buffer registration updates Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 02/10] liburing: support buffer registration sharing Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 03/10] test/buffer-register: add buffer registration test Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 04/10] test/buffer-update: add buffer registration update test Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 05/10] test/buffer-share: add buffer registration sharing test Bijan Mottahedeh
2021-01-22 22:54 ` Bijan Mottahedeh [this message]
2021-01-22 22:54 ` [PATCH v2 07/10] test/buffer-share: add interruptible deadlock test Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 08/10] man/io_uring_setup.2: document buffer registration sharing Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 09/10] man/io_uring_register.2: document buffer registration updates Bijan Mottahedeh
2021-01-22 22:54 ` [PATCH v2 10/10] man/io_uring_enter.2: document IORING_OP_BUFFERS_UPDATE Bijan Mottahedeh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1611356099-60732-7-git-send-email-bijan.mottahedeh@oracle.com \
    --to=bijan.mottahedeh@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).