Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751973AbdGBTPG (ORCPT ); Sun, 2 Jul 2017 15:15:06 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:40327 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751806AbdGBTPF (ORCPT ); Sun, 2 Jul 2017 15:15:05 -0400 Date: Sun, 2 Jul 2017 21:15:00 +0200 (CEST) From: Thomas Gleixner To: Dou Liyang cc: x86@kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, mingo@kernel.org, hpa@zytor.com, ebiederm@xmission.com, bhe@redhat.com, boris.ostrovsky@oracle.com, peterz@infradead.org, izumi.taku@jp.fujitsu.com Subject: Re: [PATCH v5 08/12] x86/ioapic: Refactor the delay logic in timer_irq_works() In-Reply-To: <3ce38e2076e32d1e323f0ef9d236937c1c251bc1.1498795030.git.douly.fnst@cn.fujitsu.com> Message-ID: References: <3ce38e2076e32d1e323f0ef9d236937c1c251bc1.1498795030.git.douly.fnst@cn.fujitsu.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1215 Lines: 57 On Fri, 30 Jun 2017, Dou Liyang wrote: > +static void __init delay_with_tsc(void) > +{ > + unsigned long long start, now; > + unsigned long ticks = jiffies; Please make that unsigned long end = jiffies + 4; ticks really means: number of ticks. But that variable is doing something different. > + start = rdtsc(); > + > + /* > + * We don't know the TSC frequency yet, but waiting for > + * 40000000000/HZ TSC cycles is safe: > + * 4 GHz == 10 jiffies > + * 1 GHz == 40 jiffies > + */ > + do { > + rep_nop(); > + now = rdtsc(); > + } while ((now - start) < 40000000000UL / HZ && > + time_before_eq(jiffies, ticks + 4)); > +} > + > +static void __init delay_without_tsc(void) > +{ > + int band = 1; > + unsigned long ticks = jiffies; Please sort variables in reverse fir tree order unsigned long end = jiffies + 4; int band = 1; > + > + /* > + * We don't know any frequency yet, but waiting for > + * 40940000000/HZ cycles is safe: > + * 4 GHz == 10 jiffies > + * 1 GHz == 40 jiffies > + * 1 << 1 + 1 << 2 +...+ 1 << 11 = 4094 > + */ > + do { > + __delay(((1 << band++) * 10000000UL) / HZ); s/1/1U/ > + } while (band < 12 && time_before_eq(jiffies, ticks + 4)); > +} Thanks, tglx