From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 2ABAB389EC46 for ; Mon, 16 May 2022 16:23:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2ABAB389EC46 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-332-A3Katuu7NvenAtoMS1aMrg-1; Mon, 16 May 2022 12:23:43 -0400 X-MC-Unique: A3Katuu7NvenAtoMS1aMrg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D5C5185A794; Mon, 16 May 2022 16:23:43 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78ADD2026D64; Mon, 16 May 2022 16:23:42 +0000 (UTC) From: Florian Weimer To: Wilco Dijkstra Cc: Adhemerval Zanella , 'GNU C Library' Subject: Re: [PATCH v2 3/4] Move libio lock single-thread optimization to generic libc-lock (BZ #27842) References: <970c59ff-f004-22ad-5132-c3137e63c87c@linaro.org> Date: Mon, 16 May 2022 18:23:40 +0200 In-Reply-To: (Wilco Dijkstra's message of "Mon, 16 May 2022 16:17:11 +0000") Message-ID: <871qwtqwdv.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Mon, 16 May 2022 16:23:50 -0000 * Wilco Dijkstra: > Hi Adhemerval, > >> The main problem is _IO_enable_locks is a clunky interface because it re= quires >> flockfile to set _flags2 outside a lock region leading a possible racy i= ssue=20 >> (BZ #27842).=C2=A0 Moving to lock itself it will pretty much: > > It should be fine if we use a boolean instead of a flag. IIRC the IO > structure was externally exposed in Emacs, but if that is no longer > the case then we could change the structure safely. gnulib has code that directly _flags (not _flags2). gnulib is statically linked, which makes for a long transition time. >> I think ideally we would like to model all internal locks to a futex-lik= e >> so we can use the congestion optimization as described by Jens Gustedt >> paper [1] which would allows us to move the counter and the lock to >> same word.=C2=A0 I don't think we can improve recursive locks without a = 64-bit >> futex operation.=20 > > How much lock recursion exists in GLIBC? An 8-bit counter is likely > sufficient... One of the loader logs is recursive, and dlopen calls can be nested basically arbitrarily deeply in ELF constructors. Thanks, Florian