1 |
From 2770d15e7e880821fc586619c59eb45180628e16 Mon Sep 17 00:00:00 2001 |
2 |
From: Siddhesh Poyarekar <siddhesh@redhat.com> |
3 |
Date: Thu, 3 Oct 2013 08:26:21 +0530 |
4 |
Subject: [PATCH] Fix PI mutex check in pthread_cond_broadcast and pthread_cond_signal |
5 |
|
6 |
Fixes BZ #15996. |
7 |
|
8 |
The check had a typo - it checked for PTHREAD_MUTEX_ROBUST_NP instead |
9 |
of PTHREAD_MUTEX_ROBUST_NORMAL_NP. It has now been replaced by the |
10 |
already existing convenience macro USE_REQUEUE_PI. |
11 |
--- |
12 |
NEWS | 2 +- |
13 |
nptl/ChangeLog | 9 +++++++++ |
14 |
nptl/pthread_cond_broadcast.c | 5 +---- |
15 |
nptl/pthread_cond_signal.c | 7 +------ |
16 |
4 files changed, 12 insertions(+), 11 deletions(-) |
17 |
|
18 |
#diff --git a/NEWS b/NEWS |
19 |
#index f64fb82..fb6069d 100644 |
20 |
#--- a/NEWS |
21 |
#+++ b/NEWS |
22 |
#@@ -9,7 +9,7 @@ Version 2.18.1 |
23 |
# |
24 |
# * The following bugs are resolved with this release: |
25 |
# |
26 |
#- 15909. |
27 |
#+ 15909, 15996. |
28 |
# |
29 |
# Version 2.18 |
30 |
# |
31 |
#diff --git a/nptl/ChangeLog b/nptl/ChangeLog |
32 |
#index eae5079..2d78490 100644 |
33 |
#--- a/nptl/ChangeLog |
34 |
#+++ b/nptl/ChangeLog |
35 |
#@@ -1,3 +1,12 @@ |
36 |
#+2013-10-03 Siddhesh Poyarekar <siddhesh@redhat.com> |
37 |
#+ |
38 |
#+ [BZ #15996] |
39 |
#+ * pthread_cond_broadcast.c (__pthread_cond_broadcast) |
40 |
#+ [lll_futex_cmp_requeue_pi && __ASSUME_REQUEUE_PI]: Use |
41 |
#+ USE_REQUEUE_PI. |
42 |
#+ * pthread_cond_signal.c (__pthread_cond_signal) |
43 |
#+ [lll_futex_cmd_requeue_pi && __ASSUME_REQUEUE_PI]: Likewise. |
44 |
#+ |
45 |
# 2013-07-23 David S. Miller <davem@davemloft.net> |
46 |
# |
47 |
# * tst-cancel4.c (WRITE_BUFFER_SIZE): Adjust comment. |
48 |
diff --git a/nptl/pthread_cond_broadcast.c b/nptl/pthread_cond_broadcast.c |
49 |
index 0702ec0..7ba9efa 100644 |
50 |
--- a/nptl/pthread_cond_broadcast.c |
51 |
+++ b/nptl/pthread_cond_broadcast.c |
52 |
@@ -63,10 +63,7 @@ __pthread_cond_broadcast (cond) |
53 |
|
54 |
#if (defined lll_futex_cmp_requeue_pi \ |
55 |
&& defined __ASSUME_REQUEUE_PI) |
56 |
- int pi_flag = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NP; |
57 |
- pi_flag &= mut->__data.__kind; |
58 |
- |
59 |
- if (pi_flag == PTHREAD_MUTEX_PRIO_INHERIT_NP) |
60 |
+ if (USE_REQUEUE_PI (mut)) |
61 |
{ |
62 |
if (lll_futex_cmp_requeue_pi (&cond->__data.__futex, 1, INT_MAX, |
63 |
&mut->__data.__lock, futex_val, |
64 |
diff --git a/nptl/pthread_cond_signal.c b/nptl/pthread_cond_signal.c |
65 |
index 102d0b3..ffc35dc 100644 |
66 |
--- a/nptl/pthread_cond_signal.c |
67 |
+++ b/nptl/pthread_cond_signal.c |
68 |
@@ -49,14 +49,9 @@ __pthread_cond_signal (cond) |
69 |
|
70 |
#if (defined lll_futex_cmp_requeue_pi \ |
71 |
&& defined __ASSUME_REQUEUE_PI) |
72 |
- int pi_flag = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NP; |
73 |
pthread_mutex_t *mut = cond->__data.__mutex; |
74 |
|
75 |
- /* Do not use requeue for pshared condvars. */ |
76 |
- if (mut != (void *) ~0l) |
77 |
- pi_flag &= mut->__data.__kind; |
78 |
- |
79 |
- if (__builtin_expect (pi_flag == PTHREAD_MUTEX_PRIO_INHERIT_NP, 0) |
80 |
+ if (USE_REQUEUE_PI (mut) |
81 |
/* This can only really fail with a ENOSYS, since nobody can modify |
82 |
futex while we have the cond_lock. */ |
83 |
&& lll_futex_cmp_requeue_pi (&cond->__data.__futex, 1, 0, |
84 |
-- |
85 |
1.7.1 |
86 |
|