From patchwork Sun Jun 19 14:54:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 100968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A782DB7032 for ; Mon, 20 Jun 2011 00:56:55 +1000 (EST) Received: from localhost ([::1]:47521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJQh-0001Nz-FQ for incoming@patchwork.ozlabs.org; Sun, 19 Jun 2011 10:56:51 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJOa-0001Ne-5D for qemu-devel@nongnu.org; Sun, 19 Jun 2011 10:54:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYJOY-0006vc-U4 for qemu-devel@nongnu.org; Sun, 19 Jun 2011 10:54:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYJOY-0006vL-Ma for qemu-devel@nongnu.org; Sun, 19 Jun 2011 10:54:38 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5JEsbFV013697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 19 Jun 2011 10:54:37 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5JEsam6020304 for ; Sun, 19 Jun 2011 10:54:36 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id BF3D9250B25; Sun, 19 Jun 2011 17:54:35 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Date: Sun, 19 Jun 2011 17:54:33 +0300 Message-Id: <1308495273-23383-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] Optimize screendump X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When running kvm-autotest, fputc() is often the second highest (sometimes #1) function showing up in a profile. This is due to fputc() locking the file for every byte written. Optimize by using fputc_unlocked(). Since the file is local to the caller, clearly no locking is needed. According to the manual, _GNU_SOURCE is all that's needed for the function to be present. Signed-off-by: Avi Kivity --- hw/vga.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index d5bc582..8b63358 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -2369,9 +2369,9 @@ int ppm_save(const char *filename, struct DisplaySurface *ds) (ds->pf.gmax + 1); b = ((v >> ds->pf.bshift) & ds->pf.bmax) * 256 / (ds->pf.bmax + 1); - fputc(r, f); - fputc(g, f); - fputc(b, f); + fputc_unlocked(r, f); + fputc_unlocked(g, f); + fputc_unlocked(b, f); d += ds->pf.bytes_per_pixel; } d1 += ds->linesize;