From patchwork Tue Jan 10 16:11:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Torvald Riegel X-Patchwork-Id: 90732 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp693405qgi; Tue, 10 Jan 2017 08:11:57 -0800 (PST) X-Received: by 10.84.174.129 with SMTP id r1mr6124179plb.19.1484064717794; Tue, 10 Jan 2017 08:11:57 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h74si2574214pfj.182.2017.01.10.08.11.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2017 08:11:57 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-76658-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-76658-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-76658-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:subject:from:to:cc:date :content-type:mime-version; q=dns; s=default; b=liUiIlHRVBwcnmcq j0v3fB3L3W234PfUdUBuA99Mek4U9qBNIwZeHkzbbWcACMfIjnE9W8P85hHuyMEH FHzoxadwRfNp8onYQ6D+CEwErD/KwyFmaz8HOndsbV1O+FK5QJ4DUwNuqqey/Kh4 rwsO8BW1mD8Wevg1e8GbohN0bXA= 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:message-id:subject:from:to:cc:date :content-type:mime-version; s=default; bh=QgO6YVxiM5Cxr10TGSylHi d++LA=; b=O5c6xBsnWyhqKnjb8/tswhVVXSG+X6snqjcIxGeANYHmhUg/gZYOOf YlK5LvxmqJDfp1nuLS2WNT40+dN6QlxIrHQNArvvXuZ8uhGyGXKNoRzgulljsZ3K 7K7HHkmN+08NbT+kASX1IWyPehOMJOV9IJpO1aFvvBm7IGlYVtF64= Received: (qmail 29660 invoked by alias); 10 Jan 2017 16:11:46 -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 29651 invoked by uid 89); 10 Jan 2017 16:11:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*M:208, H*MI:208, waiters, states X-HELO: mx1.redhat.com Message-ID: <1484064691.5606.208.camel@redhat.com> Subject: [PATCH] Fix mutex pretty printer test and pretty printer output. From: Torvald Riegel To: GLIBC Devel Cc: Martin Galvan Date: Tue, 10 Jan 2017 17:11:31 +0100 Mime-Version: 1.0 This fixes the test for the mutex pretty printers in that it does not assume that the owner field is set even though the mutex is acquired; this is not guaranteed under the current lock elision implementation. Also, it improves the wording of some of the pretty printer output (eg, changing 'Locked' to 'Acquired'). Tested on x86_64 with --enable-lock-elision. commit 661a8a8d766747367314f848733804f22cef825e Author: Torvald Riegel Date: Mon Jan 9 20:40:57 2017 +0100 Fix mutex pretty printer test and pretty printer output. This fixes the test for the mutex pretty printers in that it does not assume that the owner field is set even though the mutex is acquired; this is not guaranteed under the current lock elision implementation. Also, it improves the wording of some of the pretty printer output (eg, changing 'Locked' to 'Acquired'). * nptl/nptl-printers.py (MutexPrinter): Change output. * nptl/test-mutex-printers.py: Fix test and adapt to changed output. diff --git a/nptl/nptl-printers.py b/nptl/nptl-printers.py index 9d67865..54d4c84 100644 --- a/nptl/nptl-printers.py +++ b/nptl/nptl-printers.py @@ -124,18 +124,21 @@ class MutexPrinter(object): """ if self.lock == PTHREAD_MUTEX_UNLOCKED: - self.values.append(('Status', 'Unlocked')) + self.values.append(('Status', 'Not acquired')) else: if self.lock & FUTEX_WAITERS: - self.values.append(('Status', 'Locked, possibly with waiters')) + self.values.append(('Status', + 'Acquired, possibly with waiters')) else: self.values.append(('Status', - 'Locked, possibly with no waiters')) + 'Acquired, possibly with no waiters')) if self.lock & FUTEX_OWNER_DIED: - self.values.append(('Owner ID', '%d (dead)' % self.owner)) + self.values.append(('Owner ID (if known)', + '%d (dead)' % self.owner)) else: - self.values.append(('Owner ID', self.lock & FUTEX_TID_MASK)) + self.values.append(('Owner ID (if known)', + self.lock & FUTEX_TID_MASK)) if self.owner == PTHREAD_MUTEX_INCONSISTENT: self.values.append(('State protected by this mutex', @@ -157,7 +160,7 @@ class MutexPrinter(object): lock_value &= ~(PTHREAD_MUTEX_PRIO_CEILING_MASK) if lock_value == PTHREAD_MUTEX_UNLOCKED: - self.values.append(('Status', 'Unlocked')) + self.values.append(('Status', 'Not acquired')) else: if self.kind & PTHREAD_MUTEX_PRIO_INHERIT_NP: waiters = self.lock & FUTEX_WAITERS @@ -168,12 +171,13 @@ class MutexPrinter(object): owner = self.owner if waiters: - self.values.append(('Status', 'Locked, possibly with waiters')) + self.values.append(('Status', + 'Acquired, possibly with waiters')) else: self.values.append(('Status', - 'Locked, possibly with no waiters')) + 'Acquired, possibly with no waiters')) - self.values.append(('Owner ID', owner)) + self.values.append(('Owner ID (if known)', owner)) def read_attributes(self): """Read the mutex's attributes.""" @@ -215,7 +219,7 @@ class MutexPrinter(object): mutex_type = self.kind & PTHREAD_MUTEX_KIND_MASK if mutex_type == PTHREAD_MUTEX_RECURSIVE and self.count > 1: - self.values.append(('Times locked recursively', self.count)) + self.values.append(('Times acquired by the owner', self.count)) class MutexAttributesPrinter(object): """Pretty printer for pthread_mutexattr_t. diff --git a/nptl/test-mutex-printers.py b/nptl/test-mutex-printers.py index 23f16b0..d0600b7 100644 --- a/nptl/test-mutex-printers.py +++ b/nptl/test-mutex-printers.py @@ -39,15 +39,17 @@ try: break_at(test_source, 'Test status (non-robust)') continue_cmd() # Go to test_status_no_robust - test_printer(var, to_string, {'Status': 'Unlocked'}) + test_printer(var, to_string, {'Status': 'Not acquired'}) next_cmd() thread_id = get_current_thread_lwpid() - test_printer(var, to_string, {'Status': 'Locked, possibly with no waiters', - 'Owner ID': thread_id}) + # Don't check Owner ID here because the owner may not always be set + # (e.g., if using lock elision). + test_printer(var, to_string, + {'Status': 'Acquired, possibly with no waiters'}) break_at(test_source, 'Test status (robust)') continue_cmd() # Go to test_status_robust - test_printer(var, to_string, {'Status': 'Unlocked'}) + test_printer(var, to_string, {'Status': 'Not acquired'}) # We'll now test the robust mutex locking states. We'll create a new # thread that will lock a robust mutex and exit without unlocking it. @@ -69,21 +71,22 @@ try: # The new thread should be dead by now. break_at(test_source, 'Test locking (robust)') continue_cmd() - test_printer(var, to_string, {'Owner ID': r'{0} \(dead\)'.format(child_id)}) + test_printer(var, to_string, + {'Owner ID \(if known\)': r'{0} \(dead\)'.format(child_id)}) # Try to lock and unlock the mutex. next_cmd() - test_printer(var, to_string, {'Owner ID': thread_id, + test_printer(var, to_string, {'Owner ID \(if known\)': thread_id, 'State protected by this mutex': 'Inconsistent'}) next_cmd() - test_printer(var, to_string, {'Status': 'Unlocked', + test_printer(var, to_string, {'Status': 'Not acquired', 'State protected by this mutex': 'Not recoverable'}) set_scheduler_locking(False) break_at(test_source, 'Test recursive locks') continue_cmd() # Go to test_recursive_locks - test_printer(var, to_string, {'Times locked recursively': '2'}) + test_printer(var, to_string, {'Times acquired by the owner': '2'}) next_cmd() - test_printer(var, to_string, {'Times locked recursively': '3'}) + test_printer(var, to_string, {'Times acquired by the owner': '3'}) continue_cmd() # Exit except (NoLineError, pexpect.TIMEOUT) as exception: