From patchwork Mon May 6 23:50:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 2529061 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 789D6DF230 for ; Mon, 6 May 2013 23:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932273Ab3EFXyE (ORCPT ); Mon, 6 May 2013 19:54:04 -0400 Received: from mail-qe0-f74.google.com ([209.85.128.74]:40942 "EHLO mail-qe0-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932393Ab3EFXua (ORCPT ); Mon, 6 May 2013 19:50:30 -0400 Received: by mail-qe0-f74.google.com with SMTP id 1so447692qec.1 for ; Mon, 06 May 2013 16:50:28 -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=DcukGCvjqAtqngysJUqmED7hnlp9GEDBAqGQqbOUHeE=; b=XvbN8KbJL5+6lEfxrO6Zg9uGvnt09SacUnalq9gzkkYIlnUHkn2n9wMwoPT4F6nwDC 7rpyCZ0pcD053lM105iyp9Wpb+r3ErAgCCtEJL5E7NIphHmuqn9Zc/CeFh9TI+Cg8AKk fyASI/LonoKOl3CZMiak0SRjlbQMFvZYEruLOFiWbT58cmnzMLYB0IcTH/6Zx2j5T5DW h9EAxH2RHq4qKnT31v3v/hxrwUlPAfMpeMnM9bUezFvRKOqQJEXvWjjN4oKH89Aj85td R0M+zCZvGQG0wSU8R7e+BKmk4nE/B6BdJiLy4oHMnP6Eccix1FJS4pJsqUXW0e5SuIrV cjTQ== X-Received: by 10.236.183.98 with SMTP id p62mr17666016yhm.3.1367884228023; Mon, 06 May 2013 16:50:28 -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 u42si1443097yhi.0.2013.05.06.16.50.27 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 06 May 2013 16:50:28 -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 D264331C078; Mon, 6 May 2013 16:50:27 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 93A671613E8; Mon, 6 May 2013 16:50:27 -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 07/16] freezer: convert freezable helpers to freezer_do_not_count() Date: Mon, 6 May 2013 16:50:12 -0700 Message-Id: <1367884221-20462-8-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: ALoCoQn8WTpHPBERr16qqS4lwRZe9uMKFyKIgeILo3LIbjyIb8XQUoVm+OAIU+/7Hzryp0aj5j0AZgpo/192rSvoEFPnpFLEerCgpQ5ZYz5rIxZy4V3pS6ihDAemO5ekKmUbM7il05UnYQEsTvCKWlzQnEP+pFucciAGAfen9heah3pkeNgi78o3hvf+2st9NPgSb+xeKKBo Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Freezing tasks will wake up almost every userspace task from where it is blocking and force it to run until it hits a call to try_to_sleep(), generally on the exit path from the syscall it is blocking in. On resume each task will run again, usually restarting the syscall and running until it hits the same blocking call as it was originally blocked in. Convert the existing wait_event_freezable* wrappers to use freezer_do_not_count(). Combined with a previous patch, these tasks will not run during suspend or resume unless they wake up for another reason, in which case they will run until they hit the try_to_freeze() in freezer_count(), and then continue processing the wakeup after tasks are thawed. This results in a small change in behavior, previously a race between freezing and a normal wakeup would be won by the wakeup, now the task will freeze and then handle the wakeup after thawing. Signed-off-by: Colin Cross --- v3: split this out of the patch that adds new freezable helpers include/linux/freezer.h | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/include/linux/freezer.h b/include/linux/freezer.h index bcf9e65..c71337af 100644 --- a/include/linux/freezer.h +++ b/include/linux/freezer.h @@ -228,27 +228,19 @@ static inline bool freezer_should_skip(struct task_struct *p) #define wait_event_freezable(wq, condition) \ ({ \ int __retval; \ - for (;;) { \ - __retval = wait_event_interruptible(wq, \ - (condition) || freezing(current)); \ - if (__retval || (condition)) \ - break; \ - try_to_freeze(); \ - } \ + freezer_do_not_count(); \ + __retval = wait_event_interruptible(wq, (condition)); \ + freezer_count(); \ __retval; \ }) #define wait_event_freezable_timeout(wq, condition, timeout) \ ({ \ long __retval = timeout; \ - for (;;) { \ - __retval = wait_event_interruptible_timeout(wq, \ - (condition) || freezing(current), \ - __retval); \ - if (__retval <= 0 || (condition)) \ - break; \ - try_to_freeze(); \ - } \ + freezer_do_not_count(); \ + __retval = wait_event_interruptible_timeout(wq, (condition), \ + __retval); \ + freezer_count(); \ __retval; \ })