* [uml-devel] [PATCH 2/4] UML - Send pointers instead of structures to I/O thread
@ 2007-04-11 16:01 ` Jeff Dike
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2007-04-11 16:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML, uml-devel
Instead of writing entire structures between UML and the I/O thread,
we send pointers. This cuts down on the amount of data being copied
and possibly allows more requests to be pending between the two.
This requires that the requests be kmalloced and freed instead of
living on the stack.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
--
arch/um/drivers/ubd_kern.c | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-04-10 10:59:03.000000000 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c 2007-04-10 10:59:17.000000000 -0400
@@ -503,7 +503,7 @@ static struct list_head restart = LIST_H
/* Called without dev->lock held, and only in interrupt context. */
static void ubd_handler(void)
{
- struct io_thread_req req;
+ struct io_thread_req *req;
struct request *rq;
struct ubd *ubd;
struct list_head *list, *next_ele;
@@ -511,7 +511,8 @@ static void ubd_handler(void)
int n;
while(1){
- n = os_read_file_k(thread_fd, &req, sizeof(req));
+ n = os_read_file_k(thread_fd, &req,
+ sizeof(struct io_thread_req *));
if(n != sizeof(req)){
if(n == -EAGAIN)
break;
@@ -520,10 +521,11 @@ static void ubd_handler(void)
return;
}
- rq = req.req;
- rq->nr_sectors -= req.length >> 9;
+ rq = req->req;
+ rq->nr_sectors -= req->length >> 9;
if(rq->nr_sectors == 0)
ubd_finish(rq, rq->hard_nr_sectors << 9);
+ kfree(req);
}
reactivate_fd(thread_fd, UBD_IRQ);
@@ -1078,7 +1080,7 @@ static void prepare_request(struct reque
/* Called with dev->lock held */
static void do_ubd_request(request_queue_t *q)
{
- struct io_thread_req io_req;
+ struct io_thread_req *io_req;
struct request *req;
int n;
@@ -1099,13 +1101,20 @@ static void do_ubd_request(request_queue
while(dev->start_sg < dev->end_sg){
struct scatterlist *sg = &dev->sg[dev->start_sg];
- prepare_request(req, &io_req,
+ io_req = kmalloc(sizeof(struct io_thread_req),
+ GFP_KERNEL | GFP_ATOMIC);
+ if(io_req == NULL){
+ if(list_empty(&dev->restart))
+ list_add(&dev->restart, &restart);
+ return;
+ }
+ prepare_request(req, io_req,
(unsigned long long) req->sector << 9,
sg->offset, sg->length, sg->page);
- n = os_write_file_k(thread_fd, (char *) &io_req,
- sizeof(io_req));
- if(n != sizeof(io_req)){
+ n = os_write_file_k(thread_fd, &io_req,
+ sizeof(struct io_thread_req *));
+ if(n != sizeof(struct io_thread_req *)){
if(n != -EAGAIN)
printk("write to io thread failed, "
"errno = %d\n", -n);
@@ -1437,13 +1446,14 @@ static int io_count = 0;
int io_thread(void *arg)
{
- struct io_thread_req req;
+ struct io_thread_req *req;
int n;
ignore_sigwinch_sig();
while(1){
- n = os_read_file_k(kernel_fd, &req, sizeof(req));
- if(n != sizeof(req)){
+ n = os_read_file_k(kernel_fd, &req,
+ sizeof(struct io_thread_req *));
+ if(n != sizeof(struct io_thread_req *)){
if(n < 0)
printk("io_thread - read failed, fd = %d, "
"err = %d\n", kernel_fd, -n);
@@ -1454,9 +1464,10 @@ int io_thread(void *arg)
continue;
}
io_count++;
- do_io(&req);
- n = os_write_file_k(kernel_fd, &req, sizeof(req));
- if(n != sizeof(req))
+ do_io(req);
+ n = os_write_file_k(kernel_fd, &req,
+ sizeof(struct io_thread_req *));
+ if(n != sizeof(struct io_thread_req *))
printk("io_thread - write failed, fd = %d, err = %d\n",
kernel_fd, -n);
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] UML - Send pointers instead of structures to I/O thread
@ 2007-04-11 16:01 ` Jeff Dike
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2007-04-11 16:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: LKML, uml-devel
Instead of writing entire structures between UML and the I/O thread,
we send pointers. This cuts down on the amount of data being copied
and possibly allows more requests to be pending between the two.
This requires that the requests be kmalloced and freed instead of
living on the stack.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
--
arch/um/drivers/ubd_kern.c | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
Index: linux-2.6.21-mm/arch/um/drivers/ubd_kern.c
===================================================================
--- linux-2.6.21-mm.orig/arch/um/drivers/ubd_kern.c 2007-04-10 10:59:03.000000000 -0400
+++ linux-2.6.21-mm/arch/um/drivers/ubd_kern.c 2007-04-10 10:59:17.000000000 -0400
@@ -503,7 +503,7 @@ static struct list_head restart = LIST_H
/* Called without dev->lock held, and only in interrupt context. */
static void ubd_handler(void)
{
- struct io_thread_req req;
+ struct io_thread_req *req;
struct request *rq;
struct ubd *ubd;
struct list_head *list, *next_ele;
@@ -511,7 +511,8 @@ static void ubd_handler(void)
int n;
while(1){
- n = os_read_file_k(thread_fd, &req, sizeof(req));
+ n = os_read_file_k(thread_fd, &req,
+ sizeof(struct io_thread_req *));
if(n != sizeof(req)){
if(n == -EAGAIN)
break;
@@ -520,10 +521,11 @@ static void ubd_handler(void)
return;
}
- rq = req.req;
- rq->nr_sectors -= req.length >> 9;
+ rq = req->req;
+ rq->nr_sectors -= req->length >> 9;
if(rq->nr_sectors == 0)
ubd_finish(rq, rq->hard_nr_sectors << 9);
+ kfree(req);
}
reactivate_fd(thread_fd, UBD_IRQ);
@@ -1078,7 +1080,7 @@ static void prepare_request(struct reque
/* Called with dev->lock held */
static void do_ubd_request(request_queue_t *q)
{
- struct io_thread_req io_req;
+ struct io_thread_req *io_req;
struct request *req;
int n;
@@ -1099,13 +1101,20 @@ static void do_ubd_request(request_queue
while(dev->start_sg < dev->end_sg){
struct scatterlist *sg = &dev->sg[dev->start_sg];
- prepare_request(req, &io_req,
+ io_req = kmalloc(sizeof(struct io_thread_req),
+ GFP_KERNEL | GFP_ATOMIC);
+ if(io_req == NULL){
+ if(list_empty(&dev->restart))
+ list_add(&dev->restart, &restart);
+ return;
+ }
+ prepare_request(req, io_req,
(unsigned long long) req->sector << 9,
sg->offset, sg->length, sg->page);
- n = os_write_file_k(thread_fd, (char *) &io_req,
- sizeof(io_req));
- if(n != sizeof(io_req)){
+ n = os_write_file_k(thread_fd, &io_req,
+ sizeof(struct io_thread_req *));
+ if(n != sizeof(struct io_thread_req *)){
if(n != -EAGAIN)
printk("write to io thread failed, "
"errno = %d\n", -n);
@@ -1437,13 +1446,14 @@ static int io_count = 0;
int io_thread(void *arg)
{
- struct io_thread_req req;
+ struct io_thread_req *req;
int n;
ignore_sigwinch_sig();
while(1){
- n = os_read_file_k(kernel_fd, &req, sizeof(req));
- if(n != sizeof(req)){
+ n = os_read_file_k(kernel_fd, &req,
+ sizeof(struct io_thread_req *));
+ if(n != sizeof(struct io_thread_req *)){
if(n < 0)
printk("io_thread - read failed, fd = %d, "
"err = %d\n", kernel_fd, -n);
@@ -1454,9 +1464,10 @@ int io_thread(void *arg)
continue;
}
io_count++;
- do_io(&req);
- n = os_write_file_k(kernel_fd, &req, sizeof(req));
- if(n != sizeof(req))
+ do_io(req);
+ n = os_write_file_k(kernel_fd, &req,
+ sizeof(struct io_thread_req *));
+ if(n != sizeof(struct io_thread_req *))
printk("io_thread - write failed, fd = %d, err = %d\n",
kernel_fd, -n);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [uml-devel] [PATCH 2/4] UML - Send pointers instead of structures to I/O thread
2007-04-11 16:01 ` Jeff Dike
(?)
@ 2007-04-11 17:05 ` Gerb Stralko
2007-04-11 18:17 ` Jeff Dike
-1 siblings, 1 reply; 4+ messages in thread
From: Gerb Stralko @ 2007-04-11 17:05 UTC (permalink / raw)
To: Jeff Dike; +Cc: uml-devel
On 4/11/07, Jeff Dike <jdike@addtoit.com> wrote:
> Instead of writing entire structures between UML and the I/O thread,
> we send pointers. This cuts down on the amount of data being copied
> and possibly allows more requests to be pending between the two.
<snip>
>
> - n = os_write_file_k(thread_fd, (char *) &io_req,
> - sizeof(io_req));
> - if(n != sizeof(io_req)){
> + n = os_write_file_k(thread_fd, &io_req,
> + sizeof(struct io_thread_req *));
> + if(n != sizeof(struct io_thread_req *)){
Is this wrong? you declare io_reg as a pointer but then you pass him
to os_write_file_k by reference of a pointer? Should you just do this
instead:
> + n = os_write_file_k(thread_fd, io_req,
> + sizeof(struct io_thread_req *));
Was this intentional, or am I just an idiot. :)
-Jerry
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [uml-devel] [PATCH 2/4] UML - Send pointers instead of structures to I/O thread
2007-04-11 17:05 ` [uml-devel] " Gerb Stralko
@ 2007-04-11 18:17 ` Jeff Dike
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2007-04-11 18:17 UTC (permalink / raw)
To: Gerb Stralko; +Cc: uml-devel
On Wed, Apr 11, 2007 at 01:05:16PM -0400, Gerb Stralko wrote:
> Is this wrong? you declare io_reg as a pointer but then you pass him
> to os_write_file_k by reference of a pointer? Should you just do this
> instead:
Intentional, I'm writing pointers, not structures, down the pipe.
Tx for the review, BTW.
Jeff
--
Work email - jdike at linux dot intel dot com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-11 18:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-11 16:01 [uml-devel] [PATCH 2/4] UML - Send pointers instead of structures to I/O thread Jeff Dike
2007-04-11 16:01 ` Jeff Dike
2007-04-11 17:05 ` [uml-devel] " Gerb Stralko
2007-04-11 18:17 ` Jeff Dike
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.