From patchwork Wed Feb 7 10:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranav Prasad X-Patchwork-Id: 20048 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2124385dyb; Wed, 7 Feb 2024 02:06:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6x2mw/0gx2rieUHg4G3/D0/pbe3u00ZZbiIxvcqR+kgHwXLvpLDbqxM7VUAhzPjyjR9PL X-Received: by 2002:ac8:7747:0:b0:42c:3892:a7a7 with SMTP id g7-20020ac87747000000b0042c3892a7a7mr3231931qtu.29.1707300400720; Wed, 07 Feb 2024 02:06:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707300400; cv=pass; d=google.com; s=arc-20160816; b=fO38IXBExyrKcxedHn6+X2hgPxrK6DxioSD7y+yKZzNHCRp/8Wt/ZuEq0jfiqRGWqV hfs2KWQw2w9YtHVP0qekn8XQPVg86WmRCl+nnJSLtCCmmh8yjJkU8bXCdEXgJ8wu7+KJ qGuIFbqMwJDNWwHgsQMsONeAYD9VLU/RLnTyrQFBR6WV9ALlXv76CPV7B2INlB7seIKw FyO9G2HfUMXY4vpWsKUIwGe2DmA5bHbaOxBaW9w4+Z6Qush1sGraX8If1kqU2ECMKM+U xXbcruwj39urclfR9RTOLtw+7GRhSKnlwUOtl9kGRDcQhkjvn6Ts6iidKZKuUrRr/eD6 WgKg== 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=NhsgtWrjN5DTrTIswAcbtbIxanspnt64Vbtpc0B5slc=; fh=LmxaA72YYAxFoQh6/5cI/MRsVhq8MqkBHzT5sknZjt0=; b=Tvanb5/1l6mgrhrPlTYL7ZRtOEvpZQ3GBUXDhhL3/bUs8KX+WPiti1P5jxfFWR1zq9 oXumXIYS0ZxjJKohiCKHp2mYeowu7VRi9KBDHLg0GcLk7bgF+HN5RWr1bPlteQOUsN0X YVxvVCz6MoAa+oFTd9WI3RZuGmPqSV6bEClRLrB8jWJMgwai/Tq1mwFp3Tjku9x6KRb/ isPqd0LRzIVxHIzLaa0GYcbcB3cFcCsim0Ooy1AAOdBwZa6L+lBn4iMk+lWb5ZICNwJc c2K0TB6GTf7RccsCjwv1WBZTs7xqV+lh77eKxOX27r/OE7WP/4fFgm2GdM5ozNz+A+ul cL2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lNHzpgng; 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-56278-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56278-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCVElS6v2R25QVYOF4KkoBJimt9WOxSTeVLNj9khnILgAQwmDAk0+I8qVxsQg07Rqd7O+0QaxCWbiPiQkS0q7deE3TVfDQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j17-20020a05622a039100b0042c189b36c8si825203qtx.599.2024.02.07.02.06.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 02:06:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56278-ouuuleilei=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=lNHzpgng; 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-56278-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56278-ouuuleilei=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 832961C2385A for ; Wed, 7 Feb 2024 10:06:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5FD925603; Wed, 7 Feb 2024 10:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lNHzpgng" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 7D957250F2 for ; Wed, 7 Feb 2024 10:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707300386; cv=none; b=dAYz2XMYLja1uNZiHU0+ycRfA+hEOOnV+VvKZoQLjASx92krZ8KM5yqmS1WWwoqEBjElJZj2AJcd8VH+JG/6zu65DAJOUO1vCiSsogUe3uvydXbrd7KT2EOrltSKvnTFjvZ8Xv0fbpZcFYywYnuq8Mk6FSm2ndwDRX+CTL3jm2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707300386; c=relaxed/simple; bh=Jik8leFC0KlwrVebA3uRhtiGLFsrbgU9Zi7josFPrDs=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=X5E7PcppJxljY/+SYaJWjxX8DJ+KguPq6fWQ7WgKlZV/bZkqZDxVJx782q+A1JQCCoXo0nj0xaWMXuXz+Ysordt6ArbvziCe6CrYW8BEaJTblXdmuZNgjDLaZtXjQ8gYBnfPhfJVKGh7rs8n6XmjwaS2waLfJG2n3UGsYkZBskI= 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=lNHzpgng; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-6041c45ce1cso7273667b3.1 for ; Wed, 07 Feb 2024 02:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707300384; x=1707905184; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=NhsgtWrjN5DTrTIswAcbtbIxanspnt64Vbtpc0B5slc=; b=lNHzpgngfBWpmu2bevk+ehYkQsRBKv7vyT9gHbs2+YUVY2xLiiTy8G+QKmS85kkHJb C/ObbD2SBNfvFdPw9qgYkF8nQjA+Gzny7qcBlQcT6iRWezSffJC4JafbWBnirBoFgxeO TMWly3nGsX6yWaCrQ0Cnm7IzWXw5NLCTewrNGBKWC4nXxDLH40a7+sMm9K2/DQy4vM7v cxIcGGdgzHyR8MqUtUpITa8qx1ZpGFw/3wfWtRS5WhskHr2yCDcbIK8Jh8HuZzolYAq/ kN/buGKu6d13G3UDfAkVLkOAaBBrRyVG6j2cVyj8lPDYvd0SHksMW/OGZYvSIqrXZSyW n0fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707300384; x=1707905184; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NhsgtWrjN5DTrTIswAcbtbIxanspnt64Vbtpc0B5slc=; b=CGMpTJWF6xJLP2lhF2GsdVJGU1phKlDANZAhhfvwLHCUSKMFi4nLqZf0oPuZIv7E4Z DTzairdPljIa+tEB+10PTRVmZORTIauluimwpdFPJbao+dGAPg7tPGS9lHCBDMc6C6Ej lRbAjTpk7/Yb54mNDx5Xr30gLkJzRf/R0ET6yvbvcDSBaLR9kwJ9ecCGi1Il65meLhAD rojFxyxqakSOzx+9eCgI7SyPpJlI6P6VV2j5P4CPvqPZsG/buNDBT/7PjFSmNC25AWM8 y3a7ayVnwsZpIuU75o+yRzVD1qMO3yvp71WPafA44rPVGskUc13JC2r8WhXIGyq4oo7A yO9w== X-Gm-Message-State: AOJu0Yx+CdvpfvH33NrlY+U+U0Lht2/49PQdQJmVpWgDlKW/s9SNowcw LpuZ6lluJQqBz2U4ukEFf82idx1SvofVEoEQNniFAyu0xIKk0BEVjiFwV3S68dFf3wZY790+34o sNhzOoS0f4A== X-Received: from pranav-first.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:390b]) (user=pranavpp job=sendgmr) by 2002:a81:9a8f:0:b0:602:cb41:99ad with SMTP id r137-20020a819a8f000000b00602cb4199admr748759ywg.7.1707300384433; Wed, 07 Feb 2024 02:06:24 -0800 (PST) Date: Wed, 7 Feb 2024 10:06:17 +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.594.gd9cf4e227d-goog Message-ID: <20240207100619.3947442-1-pranavpp@google.com> Subject: [PATCH 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, Pranav Prasad X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790234225434038097 X-GMAIL-MSGID: 1790234225434038097 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. Pranav Prasad (2): alarmtimer: Create alarmtimer sysfs to make duration of kernel suspend check configurable alarmtimer: Modify alarmtimer suspend callback to check for imminent alarm using PM notifier kernel/time/alarmtimer.c | 178 +++++++++++++++++++++++++++++++-------- 1 file changed, 144 insertions(+), 34 deletions(-)