From patchwork Fri Oct 16 11:36:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 531295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2A3C71402BF for ; Fri, 16 Oct 2015 23:29:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=b+yd0Moc; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; q=dns; s=default; b=ucx62INxhciN3LhMxuDQjT11z8NEI dWhc0a30e2LWdJzlooKc9yFaohjBeras4uGcoLLKZS735g1xgSt+RGtV41s8CEJR nSkErZhqk5kmC+0UQxOqncjcy1/090dpJF9pd7Ygrk+I55smdkg/fcMesv4K9a7J /WkXZoFmyDY5ZA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:message-id:date:mime-version :content-type; s=default; bh=MUr8Yyn9HeaCh3yxsb5a4tt7kzg=; b=b+y d0MoccLQ+xMlOa88c71UVE97QRp33AiBvKooxdsxsCPzHrBf97F18qVKa4rLSeEF UdP9tvchTewLIYcz2XK9r7vxGxoEHIlJ0XAG0N57m1QQx7EirRI2pC7jEEoNCRM2 5NQY9oOOGxjKSMH5E6Zq8RTcn/4EQalLrCSW2vpM= Received: (qmail 39021 invoked by alias); 16 Oct 2015 12:29:03 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 39009 invoked by uid 89); 16 Oct 2015 12:29:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com To: GNU C Library From: Florian Weimer X-Enigmail-Draft-Status: N1110 Subject: [PATCH] sunrpc: Rewrite with explicit TLS access using __thread Message-ID: <5620E137.6080005@redhat.com> Date: Fri, 16 Oct 2015 13:36:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 No differences in generated code on x86_64, except for the changed variable name. (GCC already eliminated the redundant assignment I removed.) Florian 2015-10-16 Florian Weimer sunrpc: Rewrite with explicit TLS access using __thread. * sunrpc/rpc_thread.c (thread_rpc_vars): New TLS variable. (__rpc_thread_destroy, rpc_thread_multi): Access thread_rpc_vars directly. (__rpc_thread_variables): Access thread_rpc_vars directly. Eliminate redundant assignment of the tvp variable. diff --git a/sunrpc/rpc_thread.c b/sunrpc/rpc_thread.c index 2b93db4..e5225c5 100644 --- a/sunrpc/rpc_thread.c +++ b/sunrpc/rpc_thread.c @@ -10,7 +10,8 @@ /* Variable used in non-threaded applications or for the first thread. */ static struct rpc_thread_variables __libc_tsd_RPC_VARS_mem; -__libc_tsd_define (, struct rpc_thread_variables *, RPC_VARS) +static __thread struct rpc_thread_variables *thread_rpc_vars + attribute_tls_model_ie; /* * Task-variable destructor @@ -18,8 +19,7 @@ __libc_tsd_define (, struct rpc_thread_variables *, RPC_VARS) void __attribute__ ((section ("__libc_thread_freeres_fn"))) __rpc_thread_destroy (void) { - struct rpc_thread_variables *tvp - = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS); + struct rpc_thread_variables *tvp = thread_rpc_vars; if (tvp != NULL) { __rpc_thread_svc_cleanup (); @@ -34,7 +34,7 @@ __rpc_thread_destroy (void) free (tvp->svc_pollfd_s); if (tvp != &__libc_tsd_RPC_VARS_mem) free (tvp); - __libc_tsd_set (struct rpc_thread_variables *, RPC_VARS, NULL); + thread_rpc_vars = NULL; } } #ifdef _LIBC_REENTRANT @@ -49,8 +49,7 @@ text_set_element (__libc_subfreeres, __rpc_thread_destroy); static void rpc_thread_multi (void) { - __libc_tsd_set (struct rpc_thread_variables *, RPC_VARS, - &__libc_tsd_RPC_VARS_mem); + thread_rpc_vars = &__libc_tsd_RPC_VARS_mem; } @@ -58,20 +57,15 @@ struct rpc_thread_variables * __rpc_thread_variables (void) { __libc_once_define (static, once); - struct rpc_thread_variables *tvp; + struct rpc_thread_variables *tvp = thread_rpc_vars; - tvp = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS); if (tvp == NULL) { __libc_once (once, rpc_thread_multi); - tvp = __libc_tsd_get (struct rpc_thread_variables *, RPC_VARS); + tvp = thread_rpc_vars; if (tvp == NULL) { tvp = calloc (1, sizeof *tvp); if (tvp != NULL) - __libc_tsd_set (struct rpc_thread_variables *, - RPC_VARS, tvp); - else - tvp = __libc_tsd_get (struct rpc_thread_variables *, - RPC_VARS); + thread_rpc_vars = tvp; } } return tvp; -- 2.4.3