From patchwork Mon May 6 23:50:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Cross X-Patchwork-Id: 2529211 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 2A2673FD85 for ; Mon, 6 May 2013 23:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758487Ab3EFX4x (ORCPT ); Mon, 6 May 2013 19:56:53 -0400 Received: from mail-ye0-f202.google.com ([209.85.213.202]:59852 "EHLO mail-ye0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756966Ab3EFX4w (ORCPT ); Mon, 6 May 2013 19:56:52 -0400 Received: by mail-ye0-f202.google.com with SMTP id r13so448445yen.1 for ; Mon, 06 May 2013 16:56: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=p7TQ2mY2lmr2pWT6dguomeNcWBDKyFnxRxqXqQc1Kkc=; b=kcwF//4lYG74Lk9j3lY6n7tI0Lb0UrwGtu4X+0JHNL+MQoSIFiNI+jlBlmHaWsu53y l1Om+1RHULBL6wznKlWb6GgrURgyQoXC7kbsasapbd/018xhosZuMccebq3BIxtv3N38 NU9N9KMerhT7ljEcstgyn1hjscfH/3OqOhvGw/Acf6i8hD/X4J174sJKrcF/u3B7xsI+ x298awF0HeKu7mx1OYZjww8NiROY8ddiSVdgYGb3jxQTBEBC+N49cxl4vjGEjODObv/A duT5oeaRIhj73lYL150tdypSK1+9f5m5ZvwYiWFA9Gi8IHMqeNBTj17wvzkSXmZlupA5 nWsg== X-Received: by 10.236.181.234 with SMTP id l70mr16971063yhm.53.1367884227867; Mon, 06 May 2013 16:50:27 -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 n78si2644886yhh.1.2013.05.06.16.50.27 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Mon, 06 May 2013 16:50:27 -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 A8AB05A4005; Mon, 6 May 2013 16:50:27 -0700 (PDT) Received: by walnut.mtv.corp.google.com (Postfix, from userid 99897) id 686FB16078C; 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 Subject: [PATCH v3 06/16] freezer: skip waking up tasks with PF_FREEZER_SKIP set Date: Mon, 6 May 2013 16:50:11 -0700 Message-Id: <1367884221-20462-7-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: ALoCoQmhldbnKFbUBdfL44n8Irz+21kadNAUw8jO4kzPDjkz3hYNxkDspSfpBBzrp8LGz42d723IAlIJkiUf2mzwFFXqsBt6nH9kftVmCVspsIu4xQE+pK8kUvXbLbsu+8KJVj4wTucADC1Oclr+97mQ4OTqIVy+aAGesZjAlKP+eQpzv7p/U3WPnfleLyf6TgEGj/1bG+DZ 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. Acked-by: Tejun Heo Acked-by: Pavel Machek Signed-off-by: Colin Cross --- 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);