public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: <linux-kernel@vger.kernel.org>
Cc: "'Andrew Morton'" <akpm@osdl.org>, "'Jens Axboe'" <axboe@suse.de>
Subject: RE: Direct io on block device has performance regression on 2.6.x kernel
Date: Tue, 8 Mar 2005 17:53:36 -0800	[thread overview]
Message-ID: <200503090153.j291rbg16445@unix-os.sc.intel.com> (raw)
In-Reply-To: 

OK, last one in the series: user level test programs that stress
the kernel I/O stack.  Pretty dull stuff.

- Ken



diff -Nur zero/aio_null.c blknull_test/aio_null.c
--- zero/aio_null.c	1969-12-31 16:00:00.000000000 -0800
+++ blknull_test/aio_null.c	2005-03-08 00:46:17.000000000 -0800
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <linux/ioctl.h>
+#include <libaio.h>
+
+#define MAXAIO		1024
+
+char	buf[4096] __attribute__((aligned(4096)));
+
+io_context_t	io_ctx;
+struct iocb	iocbpool[MAXAIO];
+struct io_event	ioevent[MAXAIO];
+
+void aio_setup(int n)
+{
+	int res = io_queue_init(n, &io_ctx);
+	if (res != 0) {
+		printf("io_queue_setup(%d) returned %d (%s)\n",
+			n, res, strerror(-res));
+		exit(0);
+	}
+}
+
+main(int argc, char* argv[])
+{
+	int	fd, i, status, batch;
+	struct iocb* iocbbatch[MAXAIO];
+	int	devidx;
+	off_t	offset;
+	unsigned long start, end;
+
+	batch = argc < 2 ? 100: atoi(argv[1]);
+	if (batch >= MAXAIO)
+		batch = MAXAIO;
+
+	aio_setup(MAXAIO);
+	fd = open("/dev/raw/raw1", O_RDONLY);
+
+	if (fd == -1) {
+		perror("error opening\n");
+		exit (0);
+	}
+	for (i=0; i<batch; i++) {
+		iocbbatch[i] = iocbpool+i;
+		io_prep_pread(iocbbatch[i], fd, buf, 4096, 0);
+	}
+
+	while (1) {
+		struct timespec	ts={30,0};
+		int bufidx;
+		int reap;
+
+		status = io_submit(io_ctx, i, iocbbatch);
+		if (status != i) {
+			printf("bad io_submit: %d [%s]\n", status,
+				strerror(-status));
+		}
+
+		// reap at least batch count back
+		reap = io_getevents(io_ctx, batch, MAXAIO, ioevent, &ts);
+		if (reap < batch) {
+			printf("io_getevents returned=%d [%s]\n", reap,
+				strerror(-reap));
+		}
+
+		// check the return result of each event
+		for (i=0; i<reap; i++)
+			if (ioevent[i].res != 4096)
+				printf("error in read: %lx\n", ioevent[i].res);
+	} /* while (1) */
+}
diff -Nur zero/pread_null.c blknull_test/pread_null.c
--- zero/pread_null.c	1969-12-31 16:00:00.000000000 -0800
+++ blknull_test/pread_null.c	2005-03-08 00:44:20.000000000 -0800
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <malloc.h>
+
+main(int argc, char* argv[])
+{
+	int fd;
+	char *addr;
+
+	fd = open("/dev/raw/raw1", O_RDONLY);
+	if (fd == -1) {
+		perror("error opening\n");
+		exit(0);
+	}
+
+	addr = memalign(4096, 4096);
+	if (addr == 0) {
+		printf("no memory\n");
+		exit(0);
+	}
+
+	while (1) {
+		pread(fd, addr, 4096, 0);
+	}
+
+}
diff -Nur zero/makefile blknull_test/makefile
--- zero/makefile	1969-12-31 16:00:00.000000000 -0800
+++ blknull_test/makefile	2005-03-08 17:10:39.000000000 -0800
@@ -0,0 +1,10 @@
+all:	pread_null aio_null
+
+pread_null: pread_null.c
+	gcc -O3 -o $@ pread_null.c
+
+aio_null: aio_null.c
+	gcc -O3 -o $@ aio_null.c -laio
+
+clean:
+	rm -f pread_null aio_null




             reply	other threads:[~2005-03-09  1:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-09  1:53 Chen, Kenneth W [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-03-10  2:04 Direct io on block device has performance regression on 2.6.x kernel Chen, Kenneth W
2005-03-10  1:24 Chen, Kenneth W
2005-03-09 22:18 Chen, Kenneth W
2005-03-09 23:23 ` Andi Kleen
2005-03-09 23:52   ` Jesse Barnes
2005-03-09 23:52   ` Jesse Barnes
2005-03-10  1:00     ` Chen, Kenneth W
2005-03-10  0:57   ` Chen, Kenneth W
2005-03-09  1:39 Chen, Kenneth W
2005-03-09  6:27 ` Andrew Morton
2005-03-09 17:21   ` Chen, Kenneth W
2005-03-09 20:04     ` Andrew Morton
2005-03-09 21:59       ` Chen, Kenneth W
2005-03-09 22:44         ` Andrew Morton
2005-03-10  1:11           ` Chen, Kenneth W
2005-03-10  1:33             ` Andrew Morton
2005-03-10  1:44               ` Chen, Kenneth W
2005-03-10  2:25     ` Andrew Morton
2005-03-10  3:47       ` Chen, Kenneth W
2005-03-10  4:04         ` David Lang
2005-03-10  4:10           ` Andrew Morton
2005-03-10  4:09         ` Andrew Morton
2005-03-10 18:31           ` Chen, Kenneth W
2005-03-10 20:30             ` Andrew Morton
2005-03-10 21:42               ` Chen, Kenneth W
2005-03-10 22:01                 ` Andrew Morton
2005-03-10  4:28         ` Andrew Vasquez

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=200503090153.j291rbg16445@unix-os.sc.intel.com \
    --to=kenneth.w.chen@intel.com \
    --cc=akpm@osdl.org \
    --cc=axboe@suse.de \
    --cc=linux-kernel@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