From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBF74C636CC for ; Wed, 8 Feb 2023 16:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jr2uYbOAVJFQHLt9PeimisADPpjjzVTVK1inHKJTW2k=; b=1andzndYO4mpe2 c3O5+WG5j6Cr4pEQA1styIYXC2qrVnXcnU0ShsxEVJ1jUXOcgLB8EnknBxQ0vzlXiRzVAbIFmjRds PiyF8W8LkNTMxJIGPlpY8h53wxxLzpfPIsXTzQbZy8DOZv5OSEHtgFthZoPBqBOQqeDqC0XP1Let7 6pyx0asQUrp9a/TKTKsedZekZifJRG+nK0LbV2ddDwb65AG32F+ueUqusFrEBdchEYbC0o3/R2i4p yNY2XdInBIyLf+6/baHEzgCEjHiSFbWAZNA/xh2ueHOWQKDn7UVb5hL9q82e6KC6dC3sF5p4+u7HS lJz+KaH5/YHxPWcZuGuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPn9G-00GENt-EA; Wed, 08 Feb 2023 16:18:18 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPn9C-00GEM3-FH for linux-arm-kernel@lists.infradead.org; Wed, 08 Feb 2023 16:18:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DC26B1477; Wed, 8 Feb 2023 08:18:51 -0800 (PST) Received: from bogus (unknown [10.57.10.143]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9DDEB3F8C6; Wed, 8 Feb 2023 08:18:07 -0800 (PST) Date: Wed, 8 Feb 2023 16:18:05 +0000 From: Sudeep Holla To: Hector Martin Cc: Kazuki , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla , "Rafael J. Wysocki" , Daniel Lezcano , Lorenzo Pieralisi , Sven Peter , Len Brown , Pavel Machek Subject: Re: s2idle breaks on machines without cpuidle support Message-ID: <20230208161805.2dlx66oxphl25p3c@bogus> References: <20230204152747.drte4uitljzngdt6@kazuki-mac> <20230206101239.dret3fv65cnzpken@bogus> <20230207194818.exskn3dhyzqwr32v@kazuki-mac> <20230208103511.w7jzxw6spy6humdn@bogus> <5f741a4f-f37d-079b-d464-59045ebef1ce@marcan.st> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5f741a4f-f37d-079b-d464-59045ebef1ce@marcan.st> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230208_081814_621463_F81FA9D8 X-CRM114-Status: GOOD ( 29.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 09, 2023 at 12:42:17AM +0900, Hector Martin wrote: > On 08/02/2023 19.35, Sudeep Holla wrote: > > On Wed, Feb 08, 2023 at 04:48:18AM +0900, Kazuki wrote: > >> On Mon, Feb 06, 2023 at 10:12:39AM +0000, Sudeep Holla wrote: > >>> > >>> What do you mean by break ? More details on the observation would be helpful. > >> For example, CLOCK_MONOTONIC doesn't stop even after suspend since > >> these chain of commands don't get called. > >> > >> call_cpuidle_s2idle->cpuidle_enter_s2idle->enter_s2idle_proper->tick_freeze->sched_clock_suspend (Function that pauses CLOCK_MONOTONIC) > >> > >> Which in turn causes programs like systemd to crash since it doesn't > >> expect this. > > > > Yes expected IIUC. The per-cpu timers and counters continue to tick in > > WFI and hence CLOCK_MONOTONIC can't stop. > > The hardware counters would also keep ticking in "real" s2idle (with > hypothetical PSCI idle support) and often in full suspend. There is a > flag for this (CLOCK_SOURCE_SUSPEND_NONSTOP) that is set by default for > ARM. So this isn't why CLOCK_MONOTONIC isn't stopping; there is > machinery to make the kernel's view of time stop anyway, it's just not > being invoked here. > Indeed, and I assumed s2idle was designed with those requirements but I think I may be wrong especially looking at few points you have raised provide my understanding is aligned with yours. > This is somewhat orthogonal to the issue of PSCI. These machines can't > physically support PSCI and KVM at the same time (they do not have EL3), > so PSCI is not an option. We will be starting a conversation about how > to provide something "like" PSCI over some other sort of transport to > solve this soon. So that will "fix" this issue once it's all implemented. > All the best for the efforts. > However, these machines aren't the only ones without PSCI (search for > "spin-table" in arch/arm64/boot/dts, this isn't new and these aren't the > first). Yes I am aware of it and if you see arch/arm64/kernel/smp_spin_table.c we don't support CPU hotplug or suspend for such a system. > It seems broken that Linux currently implements s2idle in such a > way that it violates the userspace clock behavior contract on systems > without a cpuidle driver (and does so silently, to make it worse). Just to check if I understand this correctly, are you referring to: cpuidle_idle_call()->default_idle_call() if cpuidle_not_available() And the problem is it idles there in wfi but CLOCK_MONOTONIC isn't stopping as expected by the userspace ? If so, fair enough. If not, I may be missing to understand something. > So that should be fixed regardless of whether we end up coming up with a > PSCI alternative or not for these platforms. If above understanding is correct, I agree. But not sure what was the motivation behind the current behaviour. > There's no fundamental reason why s2idle can't work properly with plain WFI. > Fair enough. I hadn't thought much of it before as most of the platforms I have seen or used have at-least one deeper than WFI state these days. On arm32, this was common but each platform managed suspend_set_ops on its own and probably can do the same s2idle_set_ops. -- Regards, Sudeep _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel