Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752516AbdGCDXz (ORCPT ); Sun, 2 Jul 2017 23:23:55 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:36755 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752292AbdGCDXy (ORCPT ); Sun, 2 Jul 2017 23:23:54 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="20763233" Subject: Re: [PATCH v5 08/12] x86/ioapic: Refactor the delay logic in timer_irq_works() To: Thomas Gleixner References: <3ce38e2076e32d1e323f0ef9d236937c1c251bc1.1498795030.git.douly.fnst@cn.fujitsu.com> CC: , , , , , , , , , From: Dou Liyang Message-ID: Date: Mon, 3 Jul 2017 11:23:46 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.106] X-yoursite-MailScanner-ID: 5419C47E98A6.AA7E7 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: douly.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1427 Lines: 78 Hi Thomas, At 07/03/2017 03:15 AM, Thomas Gleixner wrote: > 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. um, I see. Will use 'end' instead. > >> + 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; > OK, I will. >> + >> + /* >> + * 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/ > Got it! Thanks, dou. >> + } while (band < 12 && time_before_eq(jiffies, ticks + 4)); >> +} > > Thanks, > > tglx > > >