Received: by 10.223.164.221 with SMTP id h29csp331940wrb; Fri, 3 Nov 2017 15:32:11 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SqKrRKwG7erxn3mEUOohRO0b8e6DF5Tj21Qm2G+Eel7l6YfALZBkQIbjLXPrT8xgJlAwdz X-Received: by 10.84.169.3 with SMTP id g3mr7939081plb.438.1509748331186; Fri, 03 Nov 2017 15:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509748331; cv=none; d=google.com; s=arc-20160816; b=EpG8PtNyg6HO3NBWHrlbwk2pOBCHmhCUVHEIboBIoXXhNCLXj/ZEEeBWVjKCKqa/4p 6G/zlq7vlo5hvZnZe7SxQ46CgFoMJyFygXzZNAw0CnkcVElH3U+D/CrGn9bFbxEl5NlR wbUcVx9Yu7ks1O9h7TdT1DmEdsBmrtXsK/Ap5LEctclIiJeKMJ3SBneRo+ViONctkdY8 6xzOEDEkGqhRG0MoBw8viFDzxvftnmseBUXtCKf6/a1H3aAkzkMYES7HPQy57Od4qA25 3qSPQ7jg7L1ncAwdAOplyVLZA0tMOd/MjyTBtxjwBblLHwfO+bh1AzzWVG/cbxYmrQDf q+1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=qGxn021LTBD4mjAR5If9JOE/YIhp9YYxBAupPlb3Axs=; b=uhs1DpxdlWi2FWYyqu0cGE3v3Nci7kqTiwTB6vLf+xfP0bSqQIJ1W2U6Fy6NWEq4aS 6SepivCp39bZM/gMSD9tPj/YoYz1zinlaqPOm9e58IP1iALp0Si/AjTo9/y1N2WX9o0i addwjnYLOHps3G08Y86pq0yLCedsGHJ9mT7iBRK1gDV/XtM0BVAZiEJTSkEGyfq2ZSWV ZdBW2dYq4P0BPnsBkaw6Rofh8Dm5Htw31/6GTv4YldVCW7khtpKfxmx3WneLjXxe16uU XZayXbERVQm3Vxr6lp6IwslrBDwDANNCFKXVkj/BoGNQ8YDdkAHhWtZHST6u/zqTJZ5L IbvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si6947955pgn.773.2017.11.03.15.31.58; Fri, 03 Nov 2017 15:32:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755859AbdKCWbJ (ORCPT + 92 others); Fri, 3 Nov 2017 18:31:09 -0400 Received: from mx0a-00010702.pphosted.com ([148.163.156.75]:37092 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755189AbdKCWbI (ORCPT ); Fri, 3 Nov 2017 18:31:08 -0400 Received: from pps.filterd (m0098781.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA3MQR2c002859; Fri, 3 Nov 2017 17:30:29 -0500 Received: from ni.com (skprod3.natinst.com [130.164.80.24]) by mx0a-00010702.pphosted.com with ESMTP id 2dvtn4gstj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Nov 2017 17:30:29 -0500 Received: from us-aus-exch2.ni.corp.natinst.com (us-aus-exch2.ni.corp.natinst.com [130.164.68.12]) by us-aus-skprod3.natinst.com (8.16.0.21/8.16.0.21) with ESMTPS id vA3MUSYa024136 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 3 Nov 2017 17:30:28 -0500 Received: from us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) by us-aus-exch2.ni.corp.natinst.com (130.164.68.12) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Fri, 3 Nov 2017 17:30:28 -0500 Received: from jcartwri.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Fri, 3 Nov 2017 17:30:28 -0500 Received: by jcartwri.amer.corp.natinst.com (Postfix, from userid 1000) id 1DAB230185B; Fri, 3 Nov 2017 17:30:28 -0500 (CDT) From: Julia Cartwright To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner CC: , Gratian Crisan , Darren Hart Subject: [PATCH] futex: Drop now unnecessary check in exit_pi_state() Date: Fri, 3 Nov 2017 17:30:28 -0500 Message-ID: <20171103223028.31984-1-julia@ni.com> X-Mailer: git-send-email 2.14.2 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-03_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_policy_notspam policy=outbound_policy score=30 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=30 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711030269 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This check was an attempt to protect against a race with put_pi_state() by ensuring that the pi_state_list was consistent across the unlock/lock of pi_lock. However, as of commit 153fbd1226fb3 ("futex: Fix more put_pi_state() vs. exit_pi_state_list() races"), this check is no longer necessary because we now hold a reference to the pi_state object across the unlock/lock of pi_lock. This reference guarantees that a put_pi_state() on another CPU won't rip the pi_state object from the list when we drop pi_lock. Cc: Gratian Crisan Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Peter Zijlstra Cc: Darren Hart Signed-off-by: Julia Cartwright --- I'm not sure my analysis is 100% correct here, so please carefully think through it, as I'm sure you all always do when futex patches hit your mailbox :). Julia kernel/futex.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/kernel/futex.c b/kernel/futex.c index ca5bb9cba5cf..e127ec0555b6 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -889,7 +889,7 @@ static struct task_struct *futex_find_get_task(pid_t pid) */ void exit_pi_state_list(struct task_struct *curr) { - struct list_head *next, *head = &curr->pi_state_list; + struct list_head *head = &curr->pi_state_list; struct futex_pi_state *pi_state; struct futex_hash_bucket *hb; union futex_key key = FUTEX_KEY_INIT; @@ -903,8 +903,7 @@ void exit_pi_state_list(struct task_struct *curr) */ raw_spin_lock_irq(&curr->pi_lock); while (!list_empty(head)) { - next = head->next; - pi_state = list_entry(next, struct futex_pi_state, list); + pi_state = list_first_entry(head, struct futex_pi_state, list); key = pi_state->key; hb = hash_futex(&key); @@ -929,17 +928,6 @@ void exit_pi_state_list(struct task_struct *curr) spin_lock(&hb->lock); raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock); raw_spin_lock(&curr->pi_lock); - /* - * We dropped the pi-lock, so re-check whether this - * task still owns the PI-state: - */ - if (head->next != next) { - /* retain curr->pi_lock for the loop invariant */ - raw_spin_unlock(&pi_state->pi_mutex.wait_lock); - spin_unlock(&hb->lock); - put_pi_state(pi_state); - continue; - } WARN_ON(pi_state->owner != curr); WARN_ON(list_empty(&pi_state->list)); -- 2.14.2 From 1583326670412375841@xxx Mon Nov 06 14:19:40 +0000 2017 X-GM-THRID: 1577823759598431641 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread