From patchwork Mon Dec 12 15:23:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 61801 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA171385C67B for ; Mon, 12 Dec 2022 15:26:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA171385C67B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670858776; bh=5bFxdF/bnDDGT4uGWVs0E2dB6ltJSRQXzc6X4DCMQVw=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G6dJFm/p6nkmuzc4j8MICC1RXGiAg2kC+CNZPczPCwRn29S+ZHw5zeDAPp4++DFrU Ebm0eMIjr0DTGh+x9sQA5yltSIkgv9xzSx+33ntcj6Oit3iP2n4ao9g4o53qZUeHET IacOfo2aqwY+uBNaH3yJTFV/S/N6ZMXPsq9Zfq1o= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 869E63856B41 for ; Mon, 12 Dec 2022 15:23:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 869E63856B41 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-muojklysMo2Db68cSRzPFw-1; Mon, 12 Dec 2022 10:23:29 -0500 X-MC-Unique: muojklysMo2Db68cSRzPFw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9932629AA2E7 for ; Mon, 12 Dec 2022 15:23:29 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3C42492B00 for ; Mon, 12 Dec 2022 15:23:28 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v5 06/11] stdio-common: Add lock optimization to vfprintf and vfwprintf In-Reply-To: References: X-From-Line: a407f0532feffbc31a3fa89754dc2313bd56eb89 Mon Sep 17 00:00:00 2001 Message-Id: Date: Mon, 12 Dec 2022 16:23:25 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" After the rewrite and the implicit unbuffered streams handling, this is very straightforward to add. Reviewed-by: Adhemerval Zanella --- stdio-common/vfprintf-internal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c index 83a6aea510..23ada8d0ff 100644 --- a/stdio-common/vfprintf-internal.c +++ b/stdio-common/vfprintf-internal.c @@ -1452,6 +1452,14 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags) return EOF; #endif + if (!_IO_need_lock (s)) + { + struct Xprintf (buffer_to_file) wrap; + Xprintf (buffer_to_file_init) (&wrap, s); + Xprintf_buffer (&wrap.base, format, ap, mode_flags); + return Xprintf (buffer_to_file_done) (&wrap); + } + int done; /* Lock stream. */