Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp449972rdh; Wed, 14 Feb 2024 01:31:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHF/iSsfUxobUTy77Nyy4R78FLlHeOLYLPV4oEoVK+nCD8B+ypr6eL0Z3p1o3AFGbhcmI66lE2u2v3p0YdkGCaCfadFttr0ymfsiTI/g== X-Google-Smtp-Source: AGHT+IHpGGHLyseH8kTDGKMY/0YimLzlpPyjAtfJGUtt6orCP8Vt02h0n69NEGqYydo2pvST+QNP X-Received: by 2002:a05:620a:1584:b0:787:20c9:54ef with SMTP id d4-20020a05620a158400b0078720c954efmr2225582qkk.68.1707903118877; Wed, 14 Feb 2024 01:31:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707903118; cv=pass; d=google.com; s=arc-20160816; b=gldtXslrEN1YXSZd5IYnHlgGLxWaKAs/mGY8NRPH6N8v6pmgwS6AnKXpaSjkCc2xM5 JsBI2oUyZPatT/vlLpo1mTpfEpPWbc+5ZOq0EwEk9fyBLTk+XkV8vfbrlnvFojEhpk/k IhEs9y/bTHVorPZukhVpERdM2eNdU0HDr/B+0NJUoP6wtvro2Wx7DWLaKT69MpDOFpKS uvvvji6goPkPgtDTYG8h+twiSz6cNXi19CuDUt/hT1oATthFeLJ0Vq0CaB7aq2HF3QEd Sn/vhS677oa6EOMW2twHFPhXasANArQWWr74+rQoYA3UcrmaT7W+ja47bK2RleYcJ8I2 xOkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=mma7wfUNF3QcF2/p2Wj8oZ4dYl748XCEjPWFOwBXlAc=; fh=SnUzXGmlgNuLYoQjFh6JIG4fEc1r6VeeJUGrV79gbBM=; b=in8AzgkTQXH171mQxqvKlPMSYMZ1tw9cbI9mRQXe+aCFogx3EQXp5ISHAYauKS4+D6 V0sPpqWdztaBFQHHpNK6UJQHeNCdZdvISk6w0XckyF8l1fsix5Yvo2wCXwx7GrgVSapC 5dZPwITACqu5IPz27hOv2cYO85UirPQwFa8O47UcF7K4piYNY+IyO6pYEdFAgRkB35oA iuDAmMIoC1/MAs9qbhYk5AIC1lcVe9F9Z/1D5IEvr0wzXzRjl/XKhvEuvih6+GRuSbeI ssrojgUWmXrQFdNM5d5JrwuryDlbnvX4gLVQXbtKaXvRHyOqaZT0eF2Dc5GaWGy2XEE2 vllg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VhV9QM6Z; arc=pass (i=1 spf=pass spfdomain=flex--pranavpp.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUaXakS800wHthJg9JLea7LWTDxOPTjsnKjyaIVaiPRC9FDE8VQD0pqZvlB+towee5d2l7xybDxhpEpnGh3BWIOL1UvDxAI6caa7DA80A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u16-20020a05620a455000b00785c299aaadsi11079679qkp.435.2024.02.14.01.31.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 01:31:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=VhV9QM6Z; arc=pass (i=1 spf=pass spfdomain=flex--pranavpp.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64969-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BB1C51C279AD for ; Wed, 14 Feb 2024 09:31:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B114712E6C; Wed, 14 Feb 2024 09:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VhV9QM6Z" Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 764E0171AC for ; Wed, 14 Feb 2024 09:30:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707903015; cv=none; b=jGRtXUL//I+wpKXsK3nJNq109QQYR8OfDsX+CfYfuFPD6/UywY0ASuswQawzZWIJZzOl9Da0agbdHbsw/ar2MRQqVwV2j1ZWsxIVKt9yTfpPlXDbq4Gnq3S2F0ILDWBJTgfHUx02GXAH8YwNMBlVZWwtHaeckqe8VS11eZAMnIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707903015; c=relaxed/simple; bh=MZXc/+oEg/fprLTqq3So8SjUVzpTcPO4Doree43jGjc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=KHcaOgO9SZ7FOBjzh7Csoql/+SnfEZXff0XeENiZDrsN7leQQkB71qPPm2SuHEl59fEfw0vHYZ8AkvcrojuSMKKTm8/bxl8kdbu6TuqHOCtkTJB7F5Usz8uI5rX5U5CyK/gBnn50RLRW1WSV2Kfjd55RI0ssb6PjT7qmkJDWJvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pranavpp.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VhV9QM6Z; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--pranavpp.bounces.google.com Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-296f78bdb40so5374348a91.2 for ; Wed, 14 Feb 2024 01:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707903014; x=1708507814; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=mma7wfUNF3QcF2/p2Wj8oZ4dYl748XCEjPWFOwBXlAc=; b=VhV9QM6ZO8Ts8KYK1gtL1nLchEU2B5loY/O0XscC8dJmHCjANqOx61cHuDyWGggptv Ozgc3Q8juYncUaokDuBtiQgWw1M4s3Tp32eod4vcYlfrXtHwCSVImEyqAK2zLFeDWyf5 0eDkAkgLUr8p+XCaycGFN16KqUVrzGIoT0GyO4qTotUn17A43qEp4NjNo6+Oo55weFNT t85s5mPaeniGNGpTJ1GOljUs+DhXj+01XrRL6GZs3b6buptLMRuCmvJFFPIR0owPy8qz Xn9qQZNJBmhs8y5Ol20NrGRRPE3zXiFGGON+IR6Kwks/9iVtdyWA8qJffO3mAW1vBySy Hv9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707903014; x=1708507814; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mma7wfUNF3QcF2/p2Wj8oZ4dYl748XCEjPWFOwBXlAc=; b=lICZcZE6/gC/mx1Il+TadNjnAh+t40wP9AUmKriiox+zDVEyMkbPBncbk2d4/a0TAR iv/sXW1stvX+lGICnuEyGPUxRQivNptnpB+cD9ameQLlRWYza1c5rF1T44U90b2yxla1 wiVJCvjxcbZKsLjPKmVRBHuw8wi7tdImy/z2EQ6NfhJB/fa1itAGuaog2V3oH7WPrYab wXKr6FUXn9YmG39n55mivGe020MzWWtXW4h68TcazrYPcCX2T+97byeXpckUDuRLMKJG ZrIciA/puNFS+ZbxfV//Nm2+kZAH1qLU3e2hsFIsydOYT7oIIJ+U5Oz7KK771PQAVdGe d1yQ== X-Gm-Message-State: AOJu0YxtglrYrzRZH89NIXM4aPuj9awb17ZITDhfTElDDY3gcpd4r9wV ITaOSA4psg6wNeJQzXNao+M5ETzNCNg/hk7chKLjOQJDetJbTfxG4DSwwYNSaOSUqNngfgf388k cxAF/UlMq3w== X-Received: from pranav-first.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:390b]) (user=pranavpp job=sendgmr) by 2002:a17:90b:5288:b0:295:efdc:6abc with SMTP id si8-20020a17090b528800b00295efdc6abcmr23368pjb.5.1707903013898; Wed, 14 Feb 2024 01:30:13 -0800 (PST) Date: Wed, 14 Feb 2024 09:29:00 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214092902.1908443-1-pranavpp@google.com> Subject: [PATCH v3 0/2] alarmtimer: Rework the suspend flow in alarmtimer From: Pranav Prasad To: tglx@linutronix.de, jstultz@google.com, sboyd@kernel.org Cc: linux-kernel@vger.kernel.org, krossmo@google.com, Pranav Prasad Content-Type: text/plain; charset="UTF-8" Hi! During the driver suspend phase of kernel suspend, alarmtimer's suspend callback is invoked and it identifies the earliest next wakeup alarm and programs that into the HW real time clock (RTC). However, there is an exception to this process. If the next alarm is within the next 2 seconds, the alarmtimer driver fails to suspend. In this case, a non-trivial amount of power is spent to freeze and unfreeze all userspace processes and to suspend and resume a number of devices. In the vast majority of cases, the imminent alarm that caused the failure was likely already scheduled before suspend even started. This provides an opportunity to reduce power consumption if the suspend failure decision is made earlier in the suspend flow, before the unnecessary extra work is done. This patch series aims to achieve a kernel suspend flow in which the check for an imminent alarm is performed early during the suspend prepare phase. Changes in v3 from v2: - Reversed the order of patches - Formatted variable declarations - Moved the RTC device check out of alarmtimer_get_soonest() - Reinstated the check for pending alarm in alarmtimer_suspend() Changes in v2 from v1: - Moved the pm_wakeup_event call to the PM notifier - Added a check for RTC device in the PM notifier Pranav Prasad (2): alarmtimer: Add PM notifier to check early for imminent alarm alarmtimer: Create sysfs to make alarm check window configurable kernel/time/alarmtimer.c | 164 +++++++++++++++++++++++++++++++++------ 1 file changed, 140 insertions(+), 24 deletions(-) -- 2.43.0.687.g38aa6559b0-goog