From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Herrmann Subject: Re: [PATCH 11/11] kvm tools: Modify term_putc to write more than one char Date: Mon, 12 May 2014 13:21:11 +0200 Message-ID: <20140512112111.GE15623@alberich> References: <1399391491-5021-1-git-send-email-andreas.herrmann@caviumnetworks.com> <1399391491-5021-12-git-send-email-andreas.herrmann@caviumnetworks.com> <536A5826.6010008@cogentembedded.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: Pekka Enberg , David Daney , , , David Daney To: Sergei Shtylyov Return-path: Content-Disposition: inline In-Reply-To: <536A5826.6010008@cogentembedded.com> Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: List-Id: kvm.vger.kernel.org On Wed, May 07, 2014 at 07:58:30PM +0400, Sergei Shtylyov wrote: > Hello. > > On 06-05-2014 19:51, Andreas Herrmann wrote: > > >From: David Daney > > >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 > >Signed-off-by: Andreas Herrmann > >--- > > 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; > > Perhaps 'return cnt - num_remaining' instead? Although all current callers of this function are not checking the return value I aggree that this change would be nice to have. I wouldn't make this change within this patch though. (I'll add a separate patch to modify the return value.) > >+ num_remaining -= ret; > >+ addr += ret; > > } > > > > return cnt; > > WBR, Sergei Thanks, Andreas