Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1302122rdb; Fri, 19 Jan 2024 15:09:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMXmhcnN/eNhBBYhmYcyPLhe3NVFgBZJTezwMyiotXtr+0HPB9Dxy0PK/2rN1LUB1/huvv X-Received: by 2002:a05:6a20:47e4:b0:19b:624c:c7bc with SMTP id ey36-20020a056a2047e400b0019b624cc7bcmr483271pzb.118.1705705785266; Fri, 19 Jan 2024 15:09:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705705785; cv=pass; d=google.com; s=arc-20160816; b=YSVNmpoieFxQmVGmkIRo1IzSqsLlkzsHN5XCkP1s/93EW8Yi8WffqDQHX5Cj4W01j7 Ru1/KtZEtmY9YWlLJrGStT4i7skat0cgt2jOoGvrzVkSn8CT1aYOOO/Apg/ucGQMUXrR kL2MPbUohwZuilL7fd5BVh5AxKfZPMoG5KAivlCndB03Ow/QHJPcJ+rXuD0Hs9ONMGMO XHs95GI7muSI/+Q94ZWIPmZfr2OBu6esBApqqFUarX25b2NDdqxD12P5b0gMXF1Aq3Bo kBo6+Vyi3oCL3a7Fozs5nxB97R8+IvO/5diSdI2BB/lD7fNdEa0o6XK7uyQIuu32lA8g QoUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/GDVdXd1TBpHX2j7H0xPhMwXFKbgX32ui9QuTscsOz8=; fh=DJCF5ovW5QzCqlWsv4kfRWoWavsxz0mMiLBF3ADuRCA=; b=fQRkaYnU3M/6t1p5SbbkVRN7z+XsDrZcSml4+CcoISCfOcJNcz1MTVHXUZ79q8Eld6 0/LsTMHACFlgGrYwjycSYtD5V5V2C3i0q81v4kcwrn3zU4HWtn8C5S5JmRsoCwbhoHsg ynwXzQVGIxKJPqlDn7JZ0jCP/AUVFp0BQH7h2/OOJOvwhc2seUS2eVjNrGwmLK40Jt8D 7kogEQnfyZZRywg2wCcLDTCsJua1/BxFCDtGQayhJZ/IwBGK/NMrfufABzJTIJAvseWY lkLINl+8+8x40Yk8fYRjyn0nJDriqJV5mHXbDjzZfFk1xnXMdJPVXnDWqzIjeLdKVXvs 45vQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1HSI3xgy; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-31622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31622-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l7-20020a635707000000b005cecc6097f2si4047624pgb.895.2024.01.19.15.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 15:09:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1HSI3xgy; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-31622-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31622-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DD6C2284A82 for ; Fri, 19 Jan 2024 23:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E3B0558AC2; Fri, 19 Jan 2024 23:09:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1HSI3xgy" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 8875138E for ; Fri, 19 Jan 2024 23:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705705777; cv=none; b=dMAsioTv7MgJp0tcHfg8x4XBi+kJ9oCjyjDW52FFCUzJUkkmr1QcGyApSRrYVAbmsxglK801XzX56gfeaMpIfYYv4IvDz3U0TPVgn1sdvFRdDGaZ/8iHLQlMkcJus6scc+euPfV0urqOCvT13x38cURjLCNaXctfb1R8Zh5CW7k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705705777; c=relaxed/simple; bh=F8dckIwZyijHfQTYznmnx0TKzYnWRTbezWzuYQEA1tY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=EawMoz1ftQ08XGk3oD7H638+j+LhYiVMvB7/H6V08u2FLSohAbulSLf6pjJ0gjx8MSvoUvtkauTHC4IpdvkubFBZ1xkEQOFg6XE3kpAGtzLhUU6pYLj7Txfqb855hsUU18vFt35rDxwP4JCKQ0k3QfBdCvhgu4ssIub6GLVhCh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=1HSI3xgy; arc=none smtp.client-ip=209.85.218.45 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=google.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a27733ae1dfso124356566b.3 for ; Fri, 19 Jan 2024 15:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705705774; x=1706310574; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/GDVdXd1TBpHX2j7H0xPhMwXFKbgX32ui9QuTscsOz8=; b=1HSI3xgyaKkTNF1p4ztrXpr0yNZ1YMv7xaE2ir0Pkaa+os4PtPwa5m8HkbhCEl5t5h AErPmUztSTruGynddzpZu6r3LQvYQGl/WHaFzJCsypXSki6T4AsO4TMjfnCi+EN8b8zn Otqm2E0hzEjkCK1L2js3JIyvGbWITT+bybClGfCefeCViAZPM4PETqZjdS2tvC0HYbpS WPf8NkZvBpP3JHaT3RUsM4/5ijGE3fu5TRgvpU5cqTTYozUuEUXfH7A4vwoINUH71T5O FOeI3Cge6rvP4vZ8BNdpHBP9xBVZkTODs9DJgNijB9/7u7zhtbZYcRUEUPNkB/KbWpVw LDng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705705774; x=1706310574; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/GDVdXd1TBpHX2j7H0xPhMwXFKbgX32ui9QuTscsOz8=; b=DFTYjtiRvpNCyXgUx3t8uH+WEn8EGvfoJg5kPpaZS55hJhpKrWjF1eWxJv46Up5F05 0LEAoqA3/VDniQcwp4X0yorzFA//t/JeDuSzoor5kdFZx750NWj68ZX1HgzgpZ1XDWpK Df/vyW1bJLs0JlbviPMHPfJ2dUQfJbDHLKDn0KT4xf1C3jtbZNs6jVKlnNFPKO5OGwr9 LSqQVC0wwUnB+H9KFAx5Qyrt3GcmA0FptVWt7yFuTY0YEEFfvvsCzxD8BScxs0bBOWV4 1ac4h74YX0rG0g/RYvLCSArmxxUpmcDC2rsmcO6B8l2lvS3zj60boxyJUZzKAosVVvDp XDrg== X-Gm-Message-State: AOJu0Yzf0Kt8lrosFZXrGSP2DSvofGrSeNbLPAAxI3e5s7fmMEyir3E7 Ua6fhiiN7Edq+58k7bXs0SW2VAZ58AzbwuIXY7E1U+Zydx5478/x6lh5NuGOXrC+GqI0cMcno5H 1F4eiwtLp3rce5KTdQzexgjpJyUe/oOYgGi1cq4BQUn1RufcgTliQ6Jw= X-Received: by 2002:a17:907:c086:b0:a2f:bb33:915f with SMTP id st6-20020a170907c08600b00a2fbb33915fmr89840ejc.261.1705705773643; Fri, 19 Jan 2024 15:09:33 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240118181459.1663313-1-pranavpp@google.com> <87y1cldsgq.ffs@tglx> In-Reply-To: <87y1cldsgq.ffs@tglx> From: Pranav Prasad Date: Fri, 19 Jan 2024 15:09:22 -0800 Message-ID: Subject: Re: [PATCH] alarmtimer: Expose information about next alarm to userspace via sysfs To: Thomas Gleixner Cc: John Stultz , sboyd@kernel.org, linux-kernel@vger.kernel.org, Kelly Rossmoyer Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 19, 2024 at 11:38=E2=80=AFAM Thomas Gleixner wrote: > > On Thu, Jan 18 2024 at 14:11, John Stultz wrote: > > I'm always a bit cautious when exposing stuff to userland, > > particularly if it's potentially racy as you mentioned in your > > description. One thought I had was might adding a similar check > > earlier in the suspend path on the kernel side provide similar benefit > > (without requiring userland changes)? > > > > Basically, if I understand the problem: > > echo mem > /sys/power/state > > > > alarmtimer_suspend() > > if (next_alarm < TWO_SECONDS) > > return -EBUSY; > > > > > > So if instead we did: > > echo mem > /sys/power/state > > enter_state() > > if (alarmtimer_immenent()) > > retrun -EBUSY > > > > So the kernel would come back much faster if the suspend was going to a= bort. > > > > I suspect you all have considered this already but wanted to > > understand what issues that approach has. > > It has the same race issues as the user space readout has as far as I > understand and it's much simpler. > > Thanks, > > tglx Thanks John and Thomas for the suggestions! The reason I did not go ahead with this approach previously was that I wanted to contain the changes to the alarmtimer subsystem. I see the benefit in eliminating the dependency on userspace reading from sysfs, hence I shall work on v2 for this patch with an alternate solution where I expose a function from alarmtimer to be used by the suspend prepare flow in kernel/power. Regards, Pranav