Received: by mail.netbsd.org (Postfix, from userid 605) id 0421A84D8E; Sun, 19 Apr 2020 20:47:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 7D5E584D7F for ; Sun, 19 Apr 2020 20:47:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id Fb2-KLpUCicx for ; Sun, 19 Apr 2020 20:47:04 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 1AC0B84D68 for ; Sun, 19 Apr 2020 20:47:04 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 11F59FB27; Sun, 19 Apr 2020 20:47:04 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Sun, 19 Apr 2020 20:47:04 +0000 From: "Joerg Sonnenberger" Subject: CVS commit: src/lib/libpthread To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20200419204704.11F59FB27@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: source-changes.NetBSD.org Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Joerg Sonnenberger" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: joerg Date: Sun Apr 19 20:47:04 UTC 2020 Modified Files: src/lib/libpthread: pthread_tsd.c Log Message: Improve TSD behavior Optimistically check whether the key has been used by this thread already and avoid locking in that case. This avoids the atomic operation in the hot path. When the value is set to non-NULL for the first time, put the entry on the to-be-freed list and keep it their until destruction or thread exit. Setting the key to NULL and back is common enough and updating the list is more expensive than the extra check on the final round. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libpthread/pthread_tsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.