From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 06 May 2014 17:56:07 +0200 (CEST) Received: from mail-by2lp0238.outbound.protection.outlook.com ([207.46.163.238]:46398 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S6837949AbaEFPxLT8aN1 (ORCPT ); Tue, 6 May 2014 17:53:11 +0200 Received: from CO1PR07MB396.namprd07.prod.outlook.com (10.141.74.19) by CO1PR07MB111.namprd07.prod.outlook.com (10.242.167.17) with Microsoft SMTP Server (TLS) id 15.0.929.12; Tue, 6 May 2014 15:53:04 +0000 Received: from alberich.caveonetworks.com (2.171.87.122) by CO1PR07MB396.namprd07.prod.outlook.com (10.141.74.19) with Microsoft SMTP Server (TLS) id 15.0.929.12; Tue, 6 May 2014 15:53:03 +0000 From: Andreas Herrmann To: Pekka Enberg CC: David Daney , Andreas Herrmann , , , David Daney Subject: [PATCH 11/11] kvm tools: Modify term_putc to write more than one char Date: Tue, 6 May 2014 17:51:31 +0200 Message-ID: <1399391491-5021-12-git-send-email-andreas.herrmann@caviumnetworks.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1399391491-5021-1-git-send-email-andreas.herrmann@caviumnetworks.com> References: <1399391491-5021-1-git-send-email-andreas.herrmann@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2.171.87.122] X-ClientProxiedBy: DBXPR07CA010.eurprd07.prod.outlook.com (10.255.191.168) To CO1PR07MB396.namprd07.prod.outlook.com (10.141.74.19) X-Forefront-PRVS: 0203C93D51 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019001)(979002)(6009001)(428001)(199002)(189002)(77982001)(83072002)(85852003)(89996001)(92566001)(31966008)(77156001)(99396002)(20776003)(47776003)(83322001)(19580405001)(74662001)(74502001)(19580395003)(92726001)(80022001)(33646001)(53416003)(66066001)(2009001)(4396001)(36756003)(88136002)(81542001)(101416001)(50226001)(42186004)(93916002)(86362001)(81342001)(46102001)(79102001)(62966002)(50466002)(76482001)(87976001)(87286001)(37156001)(50986999)(48376002)(76176999)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:CO1PR07MB396;H:alberich.caveonetworks.com;FPR:9B3EF851.2C96C5A9.73D4ABBB.80E98A4B.20184;MLV:ovrnspm;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (: caviumnetworks.com does not designate permitted sender hosts) X-OriginatorOrg: caviumnetworks.com Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 40035 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: andreas.herrmann@caviumnetworks.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips 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; + num_remaining -= ret; + addr += ret; } return cnt; -- 1.7.9.5 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-by2lp0238.outbound.protection.outlook.com ([207.46.163.238]:46398 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by eddie.linux-mips.org with ESMTP id S6837949AbaEFPxLT8aN1 (ORCPT ); Tue, 6 May 2014 17:53:11 +0200 From: Andreas Herrmann Subject: [PATCH 11/11] kvm tools: Modify term_putc to write more than one char Date: Tue, 6 May 2014 17:51:31 +0200 Message-ID: <1399391491-5021-12-git-send-email-andreas.herrmann@caviumnetworks.com> In-Reply-To: <1399391491-5021-1-git-send-email-andreas.herrmann@caviumnetworks.com> References: <1399391491-5021-1-git-send-email-andreas.herrmann@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain Return-Path: 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: To: Pekka Enberg Cc: David Daney , Andreas Herrmann , kvm@vger.kernel.org, linux-mips@linux-mips.org, David Daney Message-ID: <20140506155131.qilPGt6st5LvPnRk0KOgEWs3xGLfpMTIJ0IBoCflliE@z> 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; + num_remaining -= ret; + addr += ret; } return cnt; -- 1.7.9.5