Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3638541imm; Mon, 25 Jun 2018 01:57:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL+KziiRQcBaxEUnGERiDDEUQbfSn/QlBHCvxs5wsmlRWdr5yVWASZjZ9HXkDMzYWAfuj1g X-Received: by 2002:a17:902:28a6:: with SMTP id f35-v6mr11510575plb.110.1529917033933; Mon, 25 Jun 2018 01:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529917033; cv=none; d=google.com; s=arc-20160816; b=g6zNRyjRbO9Zc/W5QW192pVEa+w+AnY7w87I2+B5jwzx1ip2LQ75lM1GsrSmBHytsL BKs3pf4XRykSRB7J+6FBGxfBD7gscDng6OrCuGHkPJWYoJQOBvdSEFNfmj5TkISlQarM csCA7PImq5/TLue/Tk0m2Xuse3ZwvdZjy5fvmf9E43PhUi/ApDDn8aWfw/NOkBB53aHS IWVTk873FL8qt5nBFL7kF5ve7X4ba5frg8A4s2Lo6cbouOuLscUgq1O21YVHmbA48S3b 1UXxTCKQCWx0XB6YEwDZuIHn5i/CUx5wIC9OdCH6NdqsCxPKZY82RQo7fpuXBXlQxjJN 1Fww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=N3lf4SlXfq0ZO0vCyrEw6Gaua8j5NFntXtt8b9BlZeE=; b=TL9gpD/Gw/EiQ+bP92488gajSu3fQ5MBuafNHcNHAZ53v/1SUIS2/iFKhs9QF83tL7 cafW0vADIiRjOGd6ponRnbwNXG2jOMCqrnuSLJ71qCUbwFNao0CLJlX+QUiPUC+bgHGq VMUk1w5uORZV5/MwUMAQeB17NIsS/AzgKolAnkT4sNiJIDxGqpBr5yzoxCR17+jjdABh CuH/gYwSpdPV1VRgFXJ7AxlDK9iAo5JjMB4LCsZJhnZ0axxihEEovicUz0vbTzy0sBAw n0+HJGZT4MXnIslpQZ3nIfEi0C6gVnYXqigmVlItwbsY6rWfKywNk6ihcWYEAlWnt+oU tlxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=MUPm1eHY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23-v6si13616099plk.487.2018.06.25.01.56.59; Mon, 25 Jun 2018 01:57:13 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=MUPm1eHY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754565AbeFYI4U (ORCPT + 99 others); Mon, 25 Jun 2018 04:56:20 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46386 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750919AbeFYI4S (ORCPT ); Mon, 25 Jun 2018 04:56:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=N3lf4SlXfq0ZO0vCyrEw6Gaua8j5NFntXtt8b9BlZeE=; b=MUPm1eHYUvgDgrKiC2+oelLXl +4mpoZO5X+7tQSDqKPXiv70JZ45ReVFEbvddVRyaoFcB3NV1Z5FQZoVqm+GA/78ivTBwg2PLFEwvA tpJfRR7i1O+OEgFxqUtPzz0Y/YIVxXrBmroYcLopBDWiXSsy6RNBqZqZNhyNUqEvoigwU0jSQ1R2u vsAn36wDar1pSJzKpEE/CZxzNzH/2DIZZRAGqwnb7brDDMn51JRa7Rw7MkhlHEQ4M9rjOYgR/mJpL xzmnBtxWgzEPpdE2SGfmhHaFM+SQZsDnyPsG/RK0paJfU2NHnorryNgxEvafRtQBJoZhUNIGXW3E3 XdG6hQnng==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXNHn-0006Ye-8K; Mon, 25 Jun 2018 08:55:48 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E2BCB2029F1DB; Mon, 25 Jun 2018 10:55:43 +0200 (CEST) Date: Mon, 25 Jun 2018 10:55:43 +0200 From: Peter Zijlstra To: Pavel Tatashin Cc: 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, prarit@redhat.com, feng.tang@intel.com, pmladek@suse.com, gnomes@lxorguk.ukuu.org.uk, linux-s390@vger.kernel.org Subject: Re: [PATCH v12 10/11] sched: early boot clock Message-ID: <20180625085543.GT2494@hirez.programming.kicks-ass.net> References: <20180621212518.19914-1-pasha.tatashin@oracle.com> <20180621212518.19914-11-pasha.tatashin@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180621212518.19914-11-pasha.tatashin@oracle.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 21, 2018 at 05:25:17PM -0400, Pavel Tatashin wrote: > 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. There are !x86 architectures that use this code and might not expect to have their sched_clock() called quite that early. Please verify. > 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 */ This is wrong... or at least it smells horribly. This is not the point where we transition from early to unstable, that is in fact in sched_clock_init. This function, sched_clock_init_late(), is where we attempt to transition from unstable to stable. And this is _waaaay_ after SMP init. > + local_irq_disable(); > + __gtod_offset = sched_clock() + __sched_clock_offset - ktime_get_ns(); > + local_irq_enable(); This might work in sched_clock_init(), which is pre-SMP. > 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; And then this remains !sched_clock_running, except instead of 0, you then return sched_clock() + __sched_clock_offset; > preempt_disable_notrace(); > scd = cpu_sdc(cpu);