From patchwork Thu May 2 01:35:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 2509681 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 24AC33FC5A for ; Thu, 2 May 2013 01:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758906Ab3EBBfT (ORCPT ); Wed, 1 May 2013 21:35:19 -0400 Received: from mail-qc0-f202.google.com ([209.85.216.202]:45882 "EHLO mail-qc0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758527Ab3EBBfQ (ORCPT ); Wed, 1 May 2013 21:35:16 -0400 Received: by mail-qc0-f202.google.com with SMTP id n41so14413qco.5 for ; Wed, 01 May 2013 18:35:15 -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=xIBp/C1uvZlqYUJtbfzeqec+6FAR2cGh43sphlb9bJc=; b=g8YncQ7Ti9Sn7YEh1k3HEogkTs/KvoItK+bzHdZLyHs7P7iSRSulHnpNSyRcLIHNpI fdTFbNdMG7JaptHjJ7lBJxW9ek8BnOscTht2+GwPW6Dflz6cylW+MC+cozkFfKmmydcH ofFElTcl3XjvxEi1EDGTS+hbNMxDxoXldiXQ2P8j8u/3Zr/ktqJzNbC0eChoTU09LTVL r2hHjm5mLEH5uM3r2jflmxavCQLd1Hfkt1FszyA/SbOoI9xVyRTkBINjWV8Vh+J1oU4/ KfsXgIdZNLqBpwMQvY+zmchHgI35QemHCzu81amBG7QoQWnv3qTthQZ7tsOSdui7IkrZ fHeQ== X-Received: by 10.236.19.198 with SMTP id n46mr3639042yhn.8.1367458515385; Wed, 01 May 2013 18:35:15 -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 q46si398746yhh.4.2013.05.01.18.35.15 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Wed, 01 May 2013 18:35:15 -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 3C8B95A4174; Wed, 1 May 2013 18:35:15 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id E4E5D160F41; Wed, 1 May 2013 18:35:14 -0700 (PDT) From: Colin Cross To: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , arve@android.com, Tejun Heo , Oleg Nesterov , Colin Cross , Pavel Machek Subject: [PATCH v2 02/10] freezer: skip waking up tasks with PF_FREEZER_SKIP set Date: Wed, 1 May 2013 18:35:00 -0700 Message-Id: <1367458508-9133-3-git-send-email-ccross@android.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1367458508-9133-1-git-send-email-ccross@android.com> References: <1367458508-9133-1-git-send-email-ccross@android.com> X-Gm-Message-State: ALoCoQkuD7sFeNa/Jb7Ktn+/6QKDDQajbjXIK9gwhxH2fepNoOSMYjWIa3YcYo9b9t3FZLtLhKRXVe+ktJLHWF+HuLSbqCCNA0FtPJjKHig4XdJCMBEXIojRfFtaNG28eSH30gPQBk/nQIW8H9oQO9j6DkV6fcOZ/G8yyBscKtn6RxedU0RceVCD9WbXRQB0UzwRqVzqV/mh Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Android goes through suspend/resume very often (every few seconds when on a busy wifi network with the screen off), and a significant portion of the energy used to go in and out of suspend is spent in the freezer. If a task has called freezer_do_not_count(), don't bother waking it up. If it happens to wake up later it will call freezer_count() and immediately enter the refrigerator. Combined with patches to convert freezable helpers to use freezer_do_not_count() and convert common sites where idle userspace tasks are blocked to use the freezable helpers, this reduces the time and energy required to suspend and resume. Signed-off-by: Colin Cross Acked-by: Tejun Heo Acked-by: Pavel Machek --- v2: move check to freeze_task() kernel/freezer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/freezer.c b/kernel/freezer.c index c38893b..8b2afc1 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c @@ -110,6 +110,18 @@ bool freeze_task(struct task_struct *p) { unsigned long flags; + /* + * This check can race with freezer_do_not_count, but worst case that + * will result in an extra wakeup being sent to the task. It does not + * race with freezer_count(), the barriers in freezer_count() and + * freezer_should_skip() ensure that either freezer_count() sees + * freezing == true in try_to_freeze() and freezes, or + * freezer_should_skip() sees !PF_FREEZE_SKIP and freezes the task + * normally. + */ + if (freezer_should_skip(p)) + return false; + spin_lock_irqsave(&freezer_lock, flags); if (!freezing(p) || frozen(p)) { spin_unlock_irqrestore(&freezer_lock, flags);