[tip:tools/kvm] kvm tools: Modify term_putc to write more than one char

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  af00d196c3c750ac9724aef41972b2b9d5c97d46
Gitweb:     http://git.kernel.org/tip/af00d196c3c750ac9724aef41972b2b9d5c97d46
Author:     David Daney <david.daney@xxxxxxxxxx>
AuthorDate: Wed, 28 May 2014 22:28:05 +0200
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Fri, 30 May 2014 21:38:17 +0300

kvm tools: Modify term_putc to write more than one char

It is a performance enhancement. When running in a simulator, each
system call to write a character takes a lot of time.  Batching them
up decreases the overhead (in the root kernel) of each virtio console
write.

Signed-off-by: David Daney <david.daney@xxxxxxxxxx>
Signed-off-by: Andreas Herrmann <andreas.herrmann@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/term.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/term.c b/tools/kvm/term.c
index 3de410b..b153eed 100644
--- a/tools/kvm/term.c
+++ b/tools/kvm/term.c
@@ -52,11 +52,14 @@ int term_getc(struct kvm *kvm, int term)
 int term_putc(char *addr, int cnt, int term)
 {
 	int ret;
+	int num_remaining = cnt;
 
-	while (cnt--) {
-		ret = write(term_fds[term][TERM_FD_OUT], addr++, 1);
+	while (num_remaining) {
+		ret = write(term_fds[term][TERM_FD_OUT], addr, num_remaining);
 		if (ret < 0)
 			return 0;
+		num_remaining -= ret;
+		addr += ret;
 	}
 
 	return cnt;
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux