From patchwork Mon May 6 23:50:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 2529281 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F32DEDF230 for ; Mon, 6 May 2013 23:57:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757452Ab3EFX5x (ORCPT ); Mon, 6 May 2013 19:57:53 -0400 Received: from mail-qc0-f201.google.com ([209.85.216.201]:57168 "EHLO mail-qc0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757135Ab3EFX5w (ORCPT ); Mon, 6 May 2013 19:57:52 -0400 Received: by mail-qc0-f201.google.com with SMTP id c10so11212qcz.4 for ; Mon, 06 May 2013 16:57:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=dEZ8DUOdr/lGQvFhYII/LCYZ7W/Ts6DC7HKuFcL8cB8=; b=JSZg4l2TnI1jfvHM5nO9hshYlElA2+OwnvnqXNtjxoeFz3e32Y1LEZFaHPgwA+u5ze lzXAVp2h6JLwKSJPdYwqL8fMAecKl40zBa45dd68yaKGB5Q9YP4nyEtsTnuytbh2e+C4 2I54oC253RX5Ws03sQfT7cfqQUqMJGrju3xXep3G2KMdd/1fXDVkLOWbJCnWIb9vFd4J FBIKp6kBEeHj3xKY7xAueDOQmygqhFocirY4Qu5GSoGASKX8s7LpkdQ9jfkwCcL08NAE Ih3m0A625KDm6CqZjT2pATRxbKh6MBbF7ADsaHnjsLPmT2A5wYZ1g8XfUyxLvsDIeOAK Jflw== X-Received: by 10.236.61.42 with SMTP id v30mr17560440yhc.15.1367884223545; Mon, 06 May 2013 16:50:23 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id q46si2640373yhh.4.2013.05.06.16.50.23 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 06 May 2013 16:50:23 -0700 (PDT) Received: from walnut.mtv.corp.google.com (walnut.mtv.corp.google.com [172.18.105.48]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 6000F31C1BD; Mon, 6 May 2013 16:50:23 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 1234216078C; Mon, 6 May 2013 16:50:23 -0700 (PDT) From: Colin Cross To: linux-kernel@vger.kernel.org Cc: Pavel Machek , "Rafael J. Wysocki" , Peter Zijlstra , Ingo Molnar , Andrew Morton , Mandeep Singh Baines , Colin Cross , Oleg Nesterov , linux-nfs@vger.kernel.org, linux-pm@vger.kernel.org, netdev@vger.kernel.org, Linus Torvalds , Tejun Heo , Len Brown Subject: [PATCH v3 02/16] freezer: add unsafe versions of freezable helpers for CIFS Date: Mon, 6 May 2013 16:50:07 -0700 Message-Id: <1367884221-20462-3-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1367884221-20462-1-git-send-email-ccross@android.com> References: <1367884221-20462-1-git-send-email-ccross@android.com> X-Gm-Message-State: ALoCoQkmwWEyn+daWtSg5CJ0NnV6Mq2SNdqS5voDB84VuFtZIPYmUYw7ho4V6byYPgzmrwNPl77bo7byw4dIDDGQw9zdx65AE0mSQNhQx+dX1dWj9G5nknlUWJpdTbTDAyDaOgMW2IQRHQWT4vOduSOZElUWHPATIBm2wct7hJJee46W8v8Py4JXF9pLxZgr1vkYQ6xzTgun Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org CIFS calls wait_event_freezekillable_unsafe with a VFS lock held, which is unsafe and will cause lockdep warnings when 6aa9707 "lockdep: check that no locks held at freeze time" is reapplied (it was reverted in dbf520a). CIFS shouldn't be doing this, but it has long-running syscalls that must hold a lock but also shouldn't block suspend. Until CIFS freeze handling is rewritten to use a signal to exit out of the critical section, add a new wait_event_freezekillable_unsafe helper that will not run the lockdep test when 6aa9707 is reapplied, and call it from CIFS. In practice the likley result of holding the lock while freezing is that a second task blocked on the lock will never freeze, aborting suspend, but it is possible to manufacture a case using the cgroup freezer, the lock, and the suspend freezer to create a deadlock. Silencing the lockdep warning here will allow problems to be found in other drivers that may have a more serious deadlock risk, and prevent new problems from being added. Signed-off-by: Colin Cross Acked-by: Pavel Machek --- include/linux/freezer.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index 5b31e21c..d3c038e 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -212,6 +212,16 @@ static inline bool freezer_should_skip(struct task_struct *p) __retval; \ }) +/* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */ +#define wait_event_freezekillable_unsafe(wq, condition) \ +({ \ + int __retval; \ + freezer_do_not_count(); \ + __retval = wait_event_killable(wq, (condition)); \ + freezer_count_unsafe(); \ + __retval; \ +}) + #define wait_event_freezable(wq, condition) \ ({ \ int __retval; \ @@ -277,6 +287,9 @@ static inline void set_freezable(void) {} #define wait_event_freezekillable(wq, condition) \ wait_event_killable(wq, condition) +#define wait_event_freezekillable_unsafe(wq, condition) \ + wait_event_killable(wq, condition) + #endif /* !CONFIG_FREEZER */ #endif /* FREEZER_H_INCLUDED */