From patchwork Tue Oct 23 15:48:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torvald Riegel X-Patchwork-Id: 193518 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]) by ozlabs.org (Postfix) with SMTP id 2FC9F2C0109 for ; Wed, 24 Oct 2012 02:48:51 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1351612131; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Subject:From:To:Cc:Content-Type:Date:Message-ID:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=6cLM0/yWi1f2imvYEJI7 pSSlwZU=; b=RwkeHz4DqgRs89/ARf+ogBIZAs/Q1zFnMjCm7/u72YcX+9r7tsMu v9oCSbvAU+fjwgcTKjmKXOYYxOmIKYWBYJ7VwiGweAl7KpX76ckzESkiBx5IEJcn X4DASeTqffIOTC8y+ERT+PGxvqkg0q1XqWYqIzSrgSm2m+hzzoQ16/s= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Subject:From:To:Cc:Content-Type:Date:Message-ID:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=qFHIXWFqjDyDFF2c8OThx0an5dHCCY73Ai/E20cSqsQsSWrja0KmmqmtYvrjon 89DdbzPMN4Tus1rO8B49nSSPiYqLC0wl/lEhEgR5jWFrMWDCMcwWT/k058CIFM9c qwEMzRhEHz1KZRgeosP0ktvMKbfkVA6MES0hwQ759yYz0=; Received: (qmail 7539 invoked by alias); 23 Oct 2012 15:48:43 -0000 Received: (qmail 7518 invoked by uid 22791); 23 Oct 2012 15:48:40 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Oct 2012 15:48:29 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9NFmScw028665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Oct 2012 11:48:28 -0400 Received: from [10.36.5.149] (vpn1-5-149.ams2.redhat.com [10.36.5.149]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9NFmR3s018917; Tue, 23 Oct 2012 11:48:27 -0400 Subject: [Patch] libitm: Ask dispatch whether it requires serial mode. From: Torvald Riegel To: GCC Patches Cc: Richard Henderson Date: Tue, 23 Oct 2012 17:48:26 +0200 Message-ID: <1351007306.3374.10907.camel@triegel.csb> Mime-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch cleans up an implicit assumption about which TM methods actually need to be run in serial mode. Instead, the transaction begin code now asks a TM method's dispatch what it needs. OK for trunk? Torvald commit 12170ba5013e855bf4ea784823961f63e3e2de4c Author: Torvald Riegel Date: Tue Oct 23 14:09:22 2012 +0200 Ask dispatch whether it requires serial mode. * retry.cc (gtm_thread::decide_begin_dispatch): Ask dispatch whether it requires serial mode instead of assuming that for certain dispatchs. * dispatch.h (abi_dispatch::requires_serial): New. (abi_dispatch::abi_dispatch): Adapt. * method-gl.cc (gl_wt_dispatch::gl_wt_dispatch): Adapt. * method-ml.cc (ml_wt_dispatch::ml_wt_dispatch): Same. * method-serial.cc (serialirr_dispatch::serialirr_dispatch, serial_dispatch::serial_dispatch, serialirr_onwrite_dispatch::serialirr_onwrite_dispatch): Same. diff --git a/libitm/dispatch.h b/libitm/dispatch.h index 6a9e62e..200138b 100644 --- a/libitm/dispatch.h +++ b/libitm/dispatch.h @@ -311,6 +311,9 @@ public: } // Returns true iff this TM method supports closed nesting. bool closed_nesting() const { return m_closed_nesting; } + // Returns STATE_SERIAL or STATE_SERIAL | STATE_IRREVOCABLE iff the TM + // method only works for serial-mode transactions. + uint32_t requires_serial() const { return m_requires_serial; } method_group* get_method_group() const { return m_method_group; } static void *operator new(size_t s) { return xmalloc (s); } @@ -332,12 +335,14 @@ protected: const bool m_write_through; const bool m_can_run_uninstrumented_code; const bool m_closed_nesting; + const uint32_t m_requires_serial; method_group* const m_method_group; abi_dispatch(bool ro, bool wt, bool uninstrumented, bool closed_nesting, - method_group* mg) : + uint32_t requires_serial, method_group* mg) : m_read_only(ro), m_write_through(wt), m_can_run_uninstrumented_code(uninstrumented), - m_closed_nesting(closed_nesting), m_method_group(mg) + m_closed_nesting(closed_nesting), m_requires_serial(requires_serial), + m_method_group(mg) { } }; diff --git a/libitm/method-gl.cc b/libitm/method-gl.cc index 4b6769b..be8f36c 100644 --- a/libitm/method-gl.cc +++ b/libitm/method-gl.cc @@ -341,7 +341,7 @@ public: CREATE_DISPATCH_METHODS(virtual, ) CREATE_DISPATCH_METHODS_MEM() - gl_wt_dispatch() : abi_dispatch(false, true, false, false, &o_gl_mg) + gl_wt_dispatch() : abi_dispatch(false, true, false, false, 0, &o_gl_mg) { } }; diff --git a/libitm/method-ml.cc b/libitm/method-ml.cc index 88455e8..80278f5 100644 --- a/libitm/method-ml.cc +++ b/libitm/method-ml.cc @@ -590,7 +590,7 @@ public: CREATE_DISPATCH_METHODS(virtual, ) CREATE_DISPATCH_METHODS_MEM() - ml_wt_dispatch() : abi_dispatch(false, true, false, false, &o_ml_mg) + ml_wt_dispatch() : abi_dispatch(false, true, false, false, 0, &o_ml_mg) { } }; diff --git a/libitm/method-serial.cc b/libitm/method-serial.cc index bdecd7b..09cfdd4 100644 --- a/libitm/method-serial.cc +++ b/libitm/method-serial.cc @@ -50,13 +50,15 @@ static serial_mg o_serial_mg; class serialirr_dispatch : public abi_dispatch { public: - serialirr_dispatch() : abi_dispatch(false, true, true, false, &o_serial_mg) + serialirr_dispatch() : abi_dispatch(false, true, true, false, + gtm_thread::STATE_SERIAL | gtm_thread::STATE_IRREVOCABLE, &o_serial_mg) { } protected: serialirr_dispatch(bool ro, bool wt, bool uninstrumented, - bool closed_nesting, method_group* mg) : - abi_dispatch(ro, wt, uninstrumented, closed_nesting, mg) { } + bool closed_nesting, uint32_t requires_serial, method_group* mg) : + abi_dispatch(ro, wt, uninstrumented, closed_nesting, requires_serial, mg) + { } // Transactional loads and stores simply access memory directly. // These methods are static to avoid indirect calls, and will be used by the @@ -151,7 +153,9 @@ public: CREATE_DISPATCH_METHODS(virtual, ) CREATE_DISPATCH_METHODS_MEM() - serial_dispatch() : abi_dispatch(false, true, false, true, &o_serial_mg) { } + serial_dispatch() : abi_dispatch(false, true, false, true, + gtm_thread::STATE_SERIAL, &o_serial_mg) + { } }; @@ -162,7 +166,7 @@ class serialirr_onwrite_dispatch : public serialirr_dispatch { public: serialirr_onwrite_dispatch() : - serialirr_dispatch(false, true, false, false, &o_serial_mg) { } + serialirr_dispatch(false, true, false, false, 0, &o_serial_mg) { } protected: static void pre_write() diff --git a/libitm/retry.cc b/libitm/retry.cc index 660bf52..172419b 100644 --- a/libitm/retry.cc +++ b/libitm/retry.cc @@ -173,7 +173,7 @@ GTM::gtm_thread::decide_begin_dispatch (uint32_t prop) && dd->closed_nesting_alternative()) dd = dd->closed_nesting_alternative(); - if (dd != dispatch_serial() && dd != dispatch_serialirr()) + if (!(dd->requires_serial() & STATE_SERIAL)) { // The current dispatch is supposedly a non-serial one. Become an // active transaction and verify this. Relaxed memory order is fine @@ -193,10 +193,7 @@ GTM::gtm_thread::decide_begin_dispatch (uint32_t prop) // We are some kind of serial transaction. serial_lock.write_lock(); - if (dd == dispatch_serialirr()) - state = STATE_SERIAL | STATE_IRREVOCABLE; - else - state = STATE_SERIAL; + state = dd->requires_serial(); return dd; }