Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3310375imu; Sun, 11 Nov 2018 12:06:34 -0800 (PST) X-Google-Smtp-Source: AJdET5eXMzgjy7ABIRmhai1i9T41DKLO4cEzx3Ef/JOQb1dAZedrbgBzAPepBk1XauLUEBsVNyhg X-Received: by 2002:a63:4b18:: with SMTP id y24-v6mr15371637pga.181.1541966794716; Sun, 11 Nov 2018 12:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966794; cv=none; d=google.com; s=arc-20160816; b=lXulKDa1Z03jP5nDHyVmM83LRcJEs2ou0HDZ91M3XDxNzvdoPxv6Hhq70sG6yuKFIF 1JIuhp+WZecu6aEG1edOW0CcltchMl19ssDGBbi0KmtFiA7IHQO8fW3OaR+e1PPbiAMa mzuOh+QKFE3AOnpHMI1G9N0j6/Ci/S59mARdsWMKz6qfmOVEOMzUieP51MB3jyjvSCDF Lbxj1hby4izdj/fVAprMnY+CSgXDX3fTHMN73RGJuH3RpaHnLYnJigjtwO9qExZ9sL7f KxkrdJrw//5uGJqS7iEC6L1afJovxXHzhN0SgK+iwiLRmjwelk53MdMB3wHS8fgabDHa 0gVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=6sOFu0j1h/i4mooxACLJXPaQlXo4RWPdkGLzDdsOuGI=; b=TIBv66N0PylV0H/f2KzTBNc6CfTcAIcNh+Hr9i+KT10y3BQzbnluipVgKhPIkXvJlW f6V8Ivl0AAhoUCWwa8xzwtTIbUrh4jvroIawKBYz2ozL4A32vvcGUWpsGTKdQ2/8RyiO b8CjdgaAG8+mc2B1JHGNz3nwYJzz/5gcQE8V+JR25P/9k4gmGk81Mzc8Se4H9qrL+gLz BU9h6R2iUx5k84DeZxB1FQn/If/R09COFxx4gWgXKYxg2tpzaYqywMbu0ykoVCvwFasG oPuUeOpoWn7HR1Kqj4NqqS16dDbbrOSz9RtnIauvQ8QHNLeExLfbkv4Wgfk8cNqgooaS 439g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si14345422pgl.209.2018.11.11.12.06.19; Sun, 11 Nov 2018 12:06:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731025AbeKLFxd (ORCPT + 99 others); Mon, 12 Nov 2018 00:53:33 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51608 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726637AbeKLFxd (ORCPT ); Mon, 12 Nov 2018 00:53:33 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvtC-0000oP-L2; Sun, 11 Nov 2018 19:59:22 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsO-0001P5-GL; Sun, 11 Nov 2018 19:58:32 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Rafael J. Wysocki" , "Doug Berger" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 038/366] PM / wakeup: Only update last time for active wakeup sources In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Doug Berger commit 2ef7c01c0cdb170142058c6d8fe0697aee4e4d7d upstream. When wakelock support was added, the wakeup_source_add() function was updated to set the last_time value of the wakeup source. This has the unintended side effect of producing confusing output from pm_print_active_wakeup_sources() when a wakeup source is added prior to a sleep that is blocked by a different wakeup source. The function pm_print_active_wakeup_sources() will search for the most recently active wakeup source when no active source is found. If a wakeup source is added after a different wakeup source blocks the system from going to sleep it may have a later last_time value than the blocking source and be output as the last active wakeup source even if it has never actually been active. It looks to me like the change to wakeup_source_add() was made to prevent the wakelock garbage collection from accidentally dropping a wakelock during the narrow window between adding the wakelock to the wakelock list in wakelock_lookup_add() and the activation of the wakeup source in pm_wake_lock(). This commit changes the behavior so that only the last_time of the wakeup source used by a wakelock is initialized prior to adding it to the wakeup source list. This preserves the meaning of the last_time value as the last time the wakeup source was active and allows a wakeup source that has never been active to have a last_time value of 0. Fixes: b86ff9820fd5 (PM / Sleep: Add user space interface for manipulating wakeup sources, v3) Signed-off-by: Doug Berger Signed-off-by: Rafael J. Wysocki Signed-off-by: Ben Hutchings --- drivers/base/power/wakeup.c | 1 - kernel/power/wakelock.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -135,7 +135,6 @@ void wakeup_source_add(struct wakeup_sou spin_lock_init(&ws->lock); setup_timer(&ws->timer, pm_wakeup_timer_fn, (unsigned long)ws); ws->active = false; - ws->last_time = ktime_get(); spin_lock_irqsave(&events_lock, flags); list_add_rcu(&ws->entry, &wakeup_sources); --- a/kernel/power/wakelock.c +++ b/kernel/power/wakelock.c @@ -175,6 +175,7 @@ static struct wakelock *wakelock_lookup_ return ERR_PTR(-ENOMEM); } wl->ws.name = wl->name; + wl->ws.last_time = ktime_get(); wakeup_source_add(&wl->ws); rb_link_node(&wl->node, parent, node); rb_insert_color(&wl->node, &wakelocks_tree);