From patchwork Tue May 7 17:52:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 2536201 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 30BE8DF215 for ; Tue, 7 May 2013 17:52:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759583Ab3EGRwX (ORCPT ); Tue, 7 May 2013 13:52:23 -0400 Received: from mail-yh0-f73.google.com ([209.85.213.73]:65002 "EHLO mail-yh0-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759569Ab3EGRwV (ORCPT ); Tue, 7 May 2013 13:52:21 -0400 X-Greylist: delayed 64913 seconds by postgrey-1.27 at vger.kernel.org; Tue, 07 May 2013 13:52:21 EDT Received: by mail-yh0-f73.google.com with SMTP id a41so86521yho.4 for ; Tue, 07 May 2013 10:52:21 -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=xuHLTRU97r9CajkJbcwCRkitx7kHHGhZ4m8Ypz/NZoE=; b=pe9tTjcJE7g1nPeDlXAWH/xHC1zvC/+CYyPTBm+b6wSGlm2LfkiRH1KxTzikeUu/tf 47AHYdyh43alkjwCMVI6jM8F2mtg3t4T5tU6CGrQxnG1Hp4i8aiOD0K5jPAK/DbJxEnw KoNb0CmYNSduIrF33e5YffmD+Fc1fY0zJL5CZ3d2w/geghy/6fWlzdiQcFcYy0S0FouU S5WMTw0ohLue4LKGVUb/FgI9X1xyb0GhFk7D1Kc5/BcNFP93mEtFWowRmCoTX8hRzMCg DGq9UW3GgAuCNbpLLrwdSMHSuh7eJKV0TeXmaf0SuTQ48N50v7hPsuuRbY53MT6jL4hV 38dw== X-Received: by 10.236.203.134 with SMTP id f6mr1865624yho.46.1367949140897; Tue, 07 May 2013 10:52:20 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id o42si3052115yhe.5.2013.05.07.10.52.20 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 07 May 2013 10:52:20 -0700 (PDT) Received: from walnut.mtv.corp.google.com (walnut.mtv.corp.google.com [172.18.105.48]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id B1DD15A4111; Tue, 7 May 2013 10:52:20 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 522E3160DAD; Tue, 7 May 2013 10:52:20 -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 , Steve French , Len Brown , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: Re: [PATCH v4 02/16] freezer: add unsafe versions of freezable helpers for CIFS Date: Tue, 7 May 2013 10:52:05 -0700 Message-Id: <1367949125-21809-1-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: References: X-Gm-Message-State: ALoCoQnS42wZy4nHR2+ARvDewi4niienqs0lO5jubtl23Xa9fQfrHQJU3UCgGZWXEKUzbzzlbx7Hbe6y2tn/P0k/mOC9uG/EAj+12EVv7gMUyk1qaQNRWQNIl4TUK1Y7c7mUptUDz2nFk8QnHSDWAtNb3lGJWOLK6v/K6Ys9JRsqhilTHBxnnokpRPIH5WUBLLQ0QmKCmebM 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. Acked-by: Pavel Machek Signed-off-by: Colin Cross Reviewed-by: Jeff Layton --- v4: Corrected to include CIFS wait_for_response hunk. The rest of this series is still at v3. fs/cifs/transport.c | 2 +- include/linux/freezer.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 1a52868..e7f22f8 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -452,7 +452,7 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ) { int error; - error = wait_event_freezekillable(server->response_q, + error = wait_event_freezekillable_unsafe(server->response_q, midQ->mid_state != MID_REQUEST_SUBMITTED); if (error < 0) return -ERESTARTSYS; 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 */