Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1206482imm; Wed, 11 Jul 2018 20:08:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpco8UN+1eb7MTFJfRQJ2gKqE4u+EFxpZaByVDh1bxdp83jI/jEWWtu0yO907YG+Kje2gG3U X-Received: by 2002:a62:21c3:: with SMTP id o64-v6mr501510pfj.21.1531364894902; Wed, 11 Jul 2018 20:08:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531364894; cv=none; d=google.com; s=arc-20160816; b=eNCfPMPCV5L1mfSI7rvptmvfyFPK1jZ5EG6jfzyReFSFeaDLg6Ehh76+ubFOijgS/B nvaGGzyvC/NmuVEyOaTAIAFyHXD9YluBtEjAZdknppXNmPurkVqe54z9vfKlu0Zjm6eL aVjSJORDgZkOjQh0x2Y5pi9DjQEGmFySgFIckznmbZCksfh4CQDsXXKqlOsoPZwBAvBb WbgNjJTWD267ve1k6xcgyuDJorZ1lbVKB/0bIyFX+xCTnw8koBj9S6iXsZKs1mMTwwPW 4VnbmGzZ2m7DCzUYnE+dGzsmOU8fOvOGPbVgc67080xGbt4A35g7GS3q5w/NPrdvAG76 411g== 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=RiGhTN6g///YxNlAnsuvWKTlhs2d21Xsjt/HDHC/SIs=; b=fHc3VDy3wkvCOGtP1qwQV1AsmcLtjiKZUHYppHr7aHrr9LkB+SX2dw7Vw4rfOMbcHT SKPRFXiCxQt8sT5VGcV+rTdZaw7iO0qsZQBl9IbKFxBeGNXfimhsmD/Jb/rIfc/boGz6 XSGpVV9bhOntyeBxsh24BJxcVESjRpe+fCiV9dhnNQp/iW2y32UaV7UIIy5XDPqN8rYz opNjy3pTCjZt7BtEfk1PVNS+DNhQYhHEN0lwl5umpO9GWY0ooVpN2fYbBAiMdJSKLUZl kmwJg/GBHlGuAUlZiH7DwUhFqbrSJQYjV+WRrV+pntS16Y77DIahJWuRKy4KV8/urZ6W cZWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=xb9+kqqX; 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 d41-v6si20038348pla.162.2018.07.11.20.07.59; Wed, 11 Jul 2018 20:08:14 -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-2018-07-02 header.b=xb9+kqqX; 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 S2391049AbeGLANw (ORCPT + 99 others); Wed, 11 Jul 2018 20:13:52 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:39522 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388774AbeGLANv (ORCPT ); Wed, 11 Jul 2018 20:13:51 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6C04kZt178248; Thu, 12 Jul 2018 00:04:46 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-2018-07-02; bh=RiGhTN6g///YxNlAnsuvWKTlhs2d21Xsjt/HDHC/SIs=; b=xb9+kqqXpu8CTCnBlEkFShV463SWHkFLNk1KQ71+s/Th3XAxZ75UogYMIbHBHJlpwaFy J5Zj7GBkdiC3QBD0X0iilUobPIojLwrPr0lOnLIyoeJk8zYF16F2ThXTZRs5Vr6rf8SF Y4KCNN9nqYOtI3xrvYX8mPuZhsAh9Ej3LS2E5DBd9kMTS/ricppdcb5aOVhfXcC9lTqC PiwJE0f1eWyiAGNtDCz6b4bW0fR5hPLaOVwQfYl2W+Q/bjIJwZ6SLwTrRItoncZAUPLU I3XCliia2ampikgL8T/Y/r/kD1yJXk61QiCYihS95jAx5AM38CHbleYKQdRRciI6jQQr Rg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2k2p760972-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jul 2018 00:04:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w6C04jPk029475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 12 Jul 2018 00:04:45 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w6C04iQI011296; Thu, 12 Jul 2018 00:04:44 GMT Received: from localhost.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 11 Jul 2018 17:04:44 -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, linux-s390@vger.kernel.org, pasha.tatashin@oracle.com, boris.ostrovsky@oracle.com, jgross@suse.com Subject: [PATCH v13 10/18] time: default boot time offset to local_clock() Date: Wed, 11 Jul 2018 20:04:11 -0400 Message-Id: <20180712000419.5165-11-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180712000419.5165-1-pasha.tatashin@oracle.com> References: <20180712000419.5165-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8951 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=781 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807110252 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org read_persistent_wall_and_boot_offset() is called during boot to read both the persistent clock and also return the offset between the boot time and the value of persistent clock. Change the default boot_offset from zero to local_clock() so architectures, that do not have a dedicated boot_clock but have early sched_clock(), such as SPARCv9, x86, and possibly more will benefit from this change by getting a better and more consistent estimate of the boot time without need for an arch specific implementation. Signed-off-by: Pavel Tatashin --- kernel/time/timekeeping.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index cb738f825c12..30d7f64ffc87 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1503,14 +1503,17 @@ void __weak read_persistent_clock64(struct timespec64 *ts64) * Weak dummy function for arches that do not yet support it. * wall_time - current time as returned by persistent clock * boot_offset - offset that is defined as wall_time - boot_time - * default to 0. + * The default function calculates offset based on the current value of + * local_clock(). This way architectures that support sched_clock() but don't + * support dedicated boot time clock will provide the best estimate of the + * boot time. */ void __weak __init read_persistent_wall_and_boot_offset(struct timespec64 *wall_time, struct timespec64 *boot_offset) { read_persistent_clock64(wall_time); - *boot_offset = (struct timespec64){0}; + *boot_offset = ns_to_timespec64(local_clock()); } /* Flag for if timekeeping_resume() has injected sleeptime */ -- 2.18.0