From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752329AbbKQJdV (ORCPT ); Tue, 17 Nov 2015 04:33:21 -0500 Received: from mail.skyhub.de ([78.46.96.112]:57842 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbbKQJdS (ORCPT ); Tue, 17 Nov 2015 04:33:18 -0500 Date: Tue, 17 Nov 2015 10:33:09 +0100 From: Borislav Petkov To: Thomas Gleixner Cc: "H. Peter Anvin" , Peter Zijlstra , x86-ml , Andy Lutomirski , Steven Rostedt , lkml Subject: Re: [RFC PATCH -v2.1] x86: Kill notsc Message-ID: <20151117093309.GD8819@pd.tnic> References: <20151021175803.GF3575@pd.tnic> <20151021190109.GC2508@worktop.programming.kicks-ass.net> <20151022185122.GC3442@pd.tnic> <20151104102941.GA1235@pd.tnic> <20151116184548.GA20137@pd.tnic> <564AB4D7.20606@zytor.com> <20151117085345.GB8819@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 17, 2015 at 10:11:03AM +0100, Thomas Gleixner wrote: > There is an interesting problem: > > tsc_init() > { > tsc_khz = x86_platform.calibrate_tsc(); > if (!tsc_khz) { > mark_tsc_unstable("could not calculate TSC khz"); > ... > } > > In the current code we do NOT use TSC for sched_clock() and that's > correct as we have no idea what the TSC frequency is. > > With your changes that is not longer the case, so you end up with a > completely wreckaged sched clock. Hmm, I see it. Well, I had a related splat which bombed because cyc2ns_init() had to run before we do sched_init()->idle_init() which called sched_clock() and there we did the cycles_2_ns() thing and the percpu vars weren't initialized yet. That's why I did this: +void __init early_tsc_init(void) +{ + int cpu; + + /* + * We need to init the cycles to ns conversion machinery because + * init_idle() below will call sched_clock() which needs it. + */ + for_each_possible_cpu(cpu) + cyc2ns_init(cpu); +} Maybe I should move tsc_init() before sched_init() so that the calibration happens before we use the TSC in sched_clock() for the first time...? -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.