Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1073768imm; Fri, 15 Jun 2018 10:44:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLBPu1OgzQ+xshYFaM5iGJ/HVZNaXkju2uFwyhAXdiLTEOnp/gMRmYeh9z0W0boR7eF8sQm X-Received: by 2002:a63:6642:: with SMTP id a63-v6mr2432425pgc.408.1529084682165; Fri, 15 Jun 2018 10:44:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529084682; cv=none; d=google.com; s=arc-20160816; b=G82zbKt+LE7P0CcsnhRdvq7fmWIZ2eozL7Jw3NT+hABcRjd9EfvNZx7W2HLA+CPUBr 3lbcr6motEhE0Wf6B+XSMBnRbIwqbLOp7SbB/ni2xgIThiiv03LG489YyP9sz511K5qu azDFU7jyaVinrUUo3tbENzQz7tBnk3uVEqqfrituLgj7/Y6X77zG1OX1hYHMxYZlYPrb DUhNpITz8h49qXSUFdV7DH8+YZV7yDv/gIKNPRsTKklThFfOhd108gIsarA7U2IYzP7i fKAhPA+fGZf+H4BDWKJBDxM/Vne9FFIU0+bTZAxoxSmaOkgIyQT9fRxzq5wr6dstrCzR Cs5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=PhlQovQUtqxvQY7YwG/AEyhHnbXUMSQojHf+J/RT/Wo=; b=cKjxiUd1ChwdaD0M0wZuUWgN430lUKdJpVFrOsW3jC7HuljJ2h4l5y0evGsWkJiKHT ZQtz9ujj5C0Y3z32tgbXRkpyGtxOJFNMXYx+1xggCc4R/blkMhgoq5dlEvTt0iYfhgPM Tq/tY8XIOAq3lCQAsrBip+pehuRKie6cdiYFrT4cl/3PuPxCaCvjoDx9C3uO7IJrsPAE gqmJXPuviSjLRLFw0JxZMCOo1K0PPD9Fl15M2j38p5YmwST0W77bp7AVfi67gf7fpe97 E7EtjLlx8pK/U4pAKBlF5HyqbMAXlyIl7GcyAgSP6JGLfnlx7hRx3h5G4HLF5DNshTkn 09eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jMBthNUC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o61-v6si8328261pld.109.2018.06.15.10.44.28; Fri, 15 Jun 2018 10:44:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=jMBthNUC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966415AbeFORnp (ORCPT + 99 others); Fri, 15 Jun 2018 13:43:45 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:58854 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965916AbeFORnP (ORCPT ); Fri, 15 Jun 2018 13:43:15 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5FHcXrw071369; Fri, 15 Jun 2018 17:42:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=PhlQovQUtqxvQY7YwG/AEyhHnbXUMSQojHf+J/RT/Wo=; b=jMBthNUCUa2BrHBZSqhkE1rTTeOp7mXmnghZ+oJSruRpSbYpa5XiXi2zPNiB7vvKFxD6 YK8cR+iKfmwm0V/bUPjfdLoBrVKNFauG6hnbr4PH8CwH37u/ZNXmi0nMorEw5F9ll7Z3 V6T9PnIs+J9/bGpLTczp7N3AkGQ2bD+Fci7yKOiYWXfvquHYmGLKYQqcEuRPGClD4eWz OCUIjOaWmAQOzOZKTFCmlvwHB9Wzqs33MKQ8SeiwzemPWa8ac4Jgw3pJo6mS9MWZ79Qe Uz87bhp/AmiPXR1QRKUPzCw36aBRqnQ32reaxH9ykf1qb4kcbQwLbEAyd4d4Lu3Df9JO SA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2jk0xrsvpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jun 2018 17:42:20 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5FHgJ7w009868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jun 2018 17:42:19 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5FHgIpe022515; Fri, 15 Jun 2018 17:42:18 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 15 Jun 2018 10:42:18 -0700 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux@armlinux.org.uk, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, john.stultz@linaro.org, sboyd@codeaurora.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, douly.fnst@cn.fujitsu.com, peterz@infradead.org, prarit@redhat.com, feng.tang@intel.com, pmladek@suse.com, gnomes@lxorguk.ukuu.org.uk Subject: [PATCH v10 4/7] sched: early boot clock Date: Fri, 15 Jun 2018 13:42:01 -0400 Message-Id: <20180615174204.30581-5-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615174204.30581-1-pasha.tatashin@oracle.com> References: <20180615174204.30581-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8925 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=979 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806150189 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow sched_clock() to be used before schec_clock_init() and sched_clock_init_late() are called. This provides us with a way to get early boot timestamps on machines with unstable clocks. Signed-off-by: Pavel Tatashin --- kernel/sched/clock.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index 10c83e73837a..f034392b0f6c 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -205,6 +205,11 @@ void clear_sched_clock_stable(void) */ static int __init sched_clock_init_late(void) { + /* Transition to unstable clock from early clock */ + local_irq_disable(); + __gtod_offset = sched_clock() + __sched_clock_offset - ktime_get_ns(); + local_irq_enable(); + sched_clock_running = 2; /* * Ensure that it is impossible to not do a static_key update. @@ -350,8 +355,9 @@ u64 sched_clock_cpu(int cpu) if (sched_clock_stable()) return sched_clock() + __sched_clock_offset; - if (unlikely(!sched_clock_running)) - return 0ull; + /* Use early clock until sched_clock_init_late() */ + if (unlikely(sched_clock_running < 2)) + return sched_clock() + __sched_clock_offset; preempt_disable_notrace(); scd = cpu_sdc(cpu); -- 2.17.1