From patchwork Fri Dec 16 20:15:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 62026 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 A2EDB38308D5 for ; Fri, 16 Dec 2022 20:18:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2EDB38308D5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671221929; bh=laFV419Pusksi3ejwvxOSMvhlEVQDyn9tj8WWkHWmnw=; 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=HRkDDIW1kU2DLnr5R1LiVi80W3IJZfvlCg/jFXqxkRaM6AN5rP+33JdxZJ0y8NFjr I3EmOeK3FHv7nZk0xj/jSUnkyVZFf5/oN6W/P4ArhRfjGbLxj4OCVNxh66iiKCMb9C nUu24M2Z7yqtfjPYDfePapRUr8GkafOqAVvDw3gA= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id C3BB1384469F for ; Fri, 16 Dec 2022 20:15:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C3BB1384469F Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-aMUGNJOzNqGTnBc15ggmAw-1; Fri, 16 Dec 2022 15:15:35 -0500 X-MC-Unique: aMUGNJOzNqGTnBc15ggmAw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D92B380D180 for ; Fri, 16 Dec 2022 20:15:34 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.61]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8628840C2064 for ; Fri, 16 Dec 2022 20:15:34 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH v6 06/11] stdio-common: Add lock optimization to vfprintf and vfwprintf In-Reply-To: References: X-From-Line: 565edabd34f32bce1d8f90eeaa6360cabe96ba84 Mon Sep 17 00:00:00 2001 Message-Id: <565edabd34f32bce1d8f90eeaa6360cabe96ba84.1671221440.git.fweimer@redhat.com> Date: Fri, 16 Dec 2022 21:15:33 +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.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.6 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. */