From patchwork Thu Feb 8 19:56:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranav Prasad X-Patchwork-Id: 20129 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp435541dyd; Thu, 8 Feb 2024 12:31:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX3uVbG7UIQ7Fq3BVdme6ulWLepZlx+8aCxMPALeTxZyCZUCcYdoXgFxTHnZ1VzUWj5fnWkUna/xT3nhX5RQ7roYuzByA== X-Google-Smtp-Source: AGHT+IFnBAL0e6pwG3zmXghYxm1yXiD3BjsG+4TXZDZL19BCpzp9KRUhHxc14hJdjFOYjUKcs3HG X-Received: by 2002:a17:902:ce8f:b0:1d9:bc11:66e with SMTP id f15-20020a170902ce8f00b001d9bc11066emr301555plg.37.1707424314157; Thu, 08 Feb 2024 12:31:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707424314; cv=pass; d=google.com; s=arc-20160816; b=hqNUYGHFsLM9uA3DyBcv+W3xBkS8/YwrohYDbRhQHElBKCdeyx6YufUGpqx+jncTT7 iO8i3RYNUAB1OTWWfCcDqgHqiLgwp7pJ8jHMl0ycP2ymQ9XkOSqGJWfm6iEVmdWEHVY8 2UdMJ9OawcKaNnlZaNPzWV3C4eLXXZmZ5JdZHNLqiodlXoMtkBg5m+mj3zCZwkYM+Ol9 uDoRVDwNEoD8bYgDgvEj3NBM5sVZPdUi8co2YyrS3+yBqvFUMjRLd990Ww0yNb8GnUty lHAr+JGJlzXST01mUCimiO8qUMRpx3V1fH55Ded6vA7dDlRss/jhLT/BscID4wi9xG0/ 9rhw== 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=OOleo//MfjGDgS1GOiwnSqETbwNldE5AFFRWOVg3YKQ=; fh=iQUqR+Q4Lj2YrIdQ/cYFMk/WkIohfAErV0tRoii/NW0=; b=A0btQ7kEYos4Ze4PfI4pTwhmbL9/9/mDMuZsd7zXVIDwVILlopvr9hdr7EhDFM4ZFU 5v2zXHyc0IsPlkViOiCgXAkV2INfVQg0lzZOunmXbGZlGnlRjsMnInsqVdmU4UjwZRiF +sGjF5hxOhu1gU7JTJv4kR45+gQ/1kpngpX1b4c7yzZGGgLoKeAjzz1x+x5Nx2QTo24U 8Vd+1z6k22GOFxkrcYv4M6CHWNDQ0T+gfjKjchYq65fdv4PQwe94YpL4el9yaFAJPZUb beDBw1fyo885cZhA0mKpMZtwjY/vjqIp0pBAGjFZl4autV/7oTSgsw31tTUxXtMnkrB2 PDEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lY5zrXFe; 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-58637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58637-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXDXgaUWj9GjKwpp1F3YKAcM5jkcU9vNuLaURiHbWGDO/5TuPAnYFLp6veAjkCAzvmVHp0tR4E3rZs59dN7mypGd7Ctgg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p6-20020a170902ebc600b001d985910a7esi323198plg.260.2024.02.08.12.31.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:31:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lY5zrXFe; 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-58637-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58637-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 034A4B29559 for ; Thu, 8 Feb 2024 19:56:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DC383839D; Thu, 8 Feb 2024 19:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lY5zrXFe" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 15911381C8 for ; Thu, 8 Feb 2024 19:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707422195; cv=none; b=nx3axjQ6zHHZ76mipcEknkG4LFojMqiVUs347YOW8bT5Ak4kRjb7/N8cS2PxBgbhQIZd0bo1Fhau2DM9O328Or6aEr5gm7tltJdVMSkI4nOcarIllZctQa+/Ql58eZMiiUmFM6gIoAhfheaNfiq+HAkexIlxD+MqC7tUQ3obZF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707422195; c=relaxed/simple; bh=S+nef6BW4eUAN+y4fvovGg6BjjxT7V8KN4eL+oI6qoE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Oh3saGiv09dKEKP6wHORDktOuH4x+DXpob3Xor1Se1PIxAqHQPM8qxLkAln0yP3OIlBNsdi0HhEyJgI9JzS3pplRX+L3Wb+Rl+QwNfSjHNqMZKseVsVVYIcFuO4QLm4zCF1WWRVXjTRd8A+k+C2BKtUykeOflIUOZPRa4bl0Mkg= 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=lY5zrXFe; arc=none smtp.client-ip=209.85.128.202 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-f202.google.com with SMTP id 00721157ae682-603cbb4f06dso4950307b3.3 for ; Thu, 08 Feb 2024 11:56:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707422193; x=1708026993; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=OOleo//MfjGDgS1GOiwnSqETbwNldE5AFFRWOVg3YKQ=; b=lY5zrXFeuGzoS1mERCmWRyIqxSaP4DezPfh5HgWKtHpQpoHD5tqINSsdMUX7pFNUWc XIeY/4SK043WYoN+rNneAgu2HoUvZLK9CLsCG2Q7CN9OxzsmXSn92wkIU8dFqG/QOjdA UXu89R2ftFTp7m5P5MvQMshQ7mGGGyooR13ZEe+4qFWxHIlN13lZm5QIf5o2rh1pvmMd eRhZHHdrpyF870DX5KjW1AWi262EmVwA6Iz1NNBKJSFEmYBq0ewiybhux6e8NPBo12kD EKscB+E2Yn+0mBZi/oasJBY3hOQlRGL4kcSURyOc/y5FaqfwaeWOwySUtSsxPzkwofX8 B2zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707422193; x=1708026993; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OOleo//MfjGDgS1GOiwnSqETbwNldE5AFFRWOVg3YKQ=; b=TTcR9RggOO7N8n2e49icBYC5u4oii3Wg0EZ/PhI14KII1386O7C9tDxZgsZeXe3buJ bUiSN/dr6k2YB666t/weimqiwsLzpwSCiWJlyfjLg0EJ6bzeEjNP8xptzdqEpemmrI5Y n1bCG8B5QTCkaKG/hDkfZQAZf0X5J9MS7z79uLSG372heOD4RRvYqsqBbE0EGAAgxV0F /oIPjjCrlt8IFuePz3alQzILCzABZNnsAh5CVMOSkUssUrfvW+6qdhK0e32JGUTt61Gj BNP9YPKXvzDOvgUV5RgN345QrP53NkUI1JkdK5H0FAOrE7eYFqwFnrHwXOVrzBCDz1xU XChQ== X-Gm-Message-State: AOJu0YyFJWA9TCByPzHrekqM20U2aj0qVEvKM7TvqVqJabWNGMLC/ZK9 8oB4DJ7RbeYE9f+fDdwBC4ebKTZReVpfoDp/BP326HCeUQZzIH5Wr3TDrksQXGi292agONCXTOu pM6Ksa3SYug== X-Received: from pranav-first.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:390b]) (user=pranavpp job=sendgmr) by 2002:a05:690c:e1e:b0:602:d398:5176 with SMTP id cp30-20020a05690c0e1e00b00602d3985176mr90276ywb.4.1707422192989; Thu, 08 Feb 2024 11:56:32 -0800 (PST) Date: Thu, 8 Feb 2024 19:56:20 +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: <20240208195622.758765-1-pranavpp@google.com> Subject: [PATCH v2 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790364157491309885 X-GMAIL-MSGID: 1790364157491309885 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 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: 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 | 183 ++++++++++++++++++++++++++++++--------- 1 file changed, 143 insertions(+), 40 deletions(-)