From patchwork Mon Jul 22 10:33:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 11052115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 293BA112C for ; Mon, 22 Jul 2019 10:33:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15C2A28475 for ; Mon, 22 Jul 2019 10:33:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09DE428524; Mon, 22 Jul 2019 10:33:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8958828511 for ; Mon, 22 Jul 2019 10:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=o/Lq8rVun8U1urt97eJ6nJBOTLJSq4fAssB3TH2Nig4=; b=EN8yvN54c9WTTQ HPm+u/LxqAr+a4ADr3qEvI2lVHu/Ru8k8ToF3vYE9MzINyrlElS5ud5tbUP2qcNcTW618jLneeqHA ucLz7QF2Cybt5AaygP2YzDWWOdpG2w+7WbZ3AzpFQkG9SMSajVNrpTna5xOoO1GVwd06mMPNtW3qb ebzVHm388zbfxOoZ7TLUChdGxGlRspUXoCheahWfJNUmPd9lnYfoV8DqOcXczHk6AqN5YsXSm54pB 5lAr/DaTdb8EB2VYEEmojqYkV8/YFwMfBOw+qyI8Eij91WMdrt8kRPPvPYJnNolpDBfSSJWVyh55K QN1JVbGlxrYDbccuAHOA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpVdZ-000399-U5; Mon, 22 Jul 2019 10:33:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hpVdW-00037n-0x for linux-arm-kernel@lists.infradead.org; Mon, 22 Jul 2019 10:33:43 +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 8E54728; Mon, 22 Jul 2019 03:33:40 -0700 (PDT) Received: from filthy-habits.cambridge.arm.com (filthy-habits.cambridge.arm.com [10.1.197.61]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1E90F3F71A; Mon, 22 Jul 2019 03:33:39 -0700 (PDT) From: Marc Zyngier To: Thomas Gleixner , John Stultz , Pavel Tatashin , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Will Deacon , Catalin Marinas , Mark Rutland Subject: [PATCH 0/3] arm64: Allow early timestamping of kernel log Date: Mon, 22 Jul 2019 11:33:27 +0100 Message-Id: <20190722103330.255312-1-marc.zyngier@arm.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190722_033342_115298_733DAD2A X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP So far, we've let the arm64 kernel start its meaningful time stamping of the kernel log pretty late, which is caused by sched_clock() being initialised rather late compared to other architectures. Pavel Tatashin proposed[1] to move the initialisation of sched_clock much earlier, which I had objections to. The reason for initialising sched_clock late is that a number of systems have broken counters, and we need to apply all kind of terrifying workarounds to avoid time going backward on the affected platforms. Being able to identify the right workaround comes pretty late in the kernel boot, and providing an unreliable sched_clock, even for a short period of time, isn't an appealing prospect. To address this, I'm proposing that we allow an architecture to chose to (1) divorce time stamping and sched_clock during the early phase of booting, and (2) inherit the time stamping clock as the new epoch the first time a sched_sched clock gets registered. (1) would allow arm64 to provide a time stamping clock, however unreliable it might be, while (2) would allow sched_clock to provide time stamps that are continuous with the time-stamping clock. The last patch in the series adds the necessary logic to arm64, allowing the (potentially unreliable) time stamping of early kernel messages. Tested on a bunch of arm64 systems, both bare-metal and in VMs. Boot tested on a x86 guest. [1] https://lore.kernel.org/patchwork/patch/1015110/ Marc Zyngier (3): printk: Allow architecture-specific timestamping function sched/clock: Allow sched_clock to inherit timestamp_clock epoch arm64: Allow early time stamping arch/arm64/Kconfig | 3 +++ arch/arm64/kernel/setup.c | 44 +++++++++++++++++++++++++++++++++++++ include/linux/sched/clock.h | 13 +++++++++++ kernel/printk/printk.c | 4 ++-- kernel/time/sched_clock.c | 10 +++++++++ 5 files changed, 72 insertions(+), 2 deletions(-) Tested-by: Hanjun Guo