From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751868AbdFVOda (ORCPT ); Thu, 22 Jun 2017 10:33:30 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55977 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbdFVOd2 (ORCPT ); Thu, 22 Jun 2017 10:33:28 -0400 Date: Thu, 22 Jun 2017 16:32:07 +0200 (CEST) From: Thomas Gleixner To: root cc: mingo@redhat.com, hpa@zytor.com, pbonzini@redhat.com, x86@kernel.org, corbet@lwn.net, tony.luck@intel.com, bp@alien8.de, peterz@infradead.org, mchehab@kernel.org, akpm@linux-foundation.org, krzk@kernel.org, jpoimboe@redhat.com, luto@kernel.org, borntraeger@de.ibm.com, thgarnie@google.com, rgerst@gmail.com, minipli@googlemail.com, douly.fnst@cn.fujitsu.com, nicstange@gmail.com, fweisbec@gmail.com, dvlasenk@redhat.com, bristot@redhat.com, yamada.masahiro@socionext.com, mika.westerberg@linux.intel.com, yu.c.chen@intel.com, aaron.lu@intel.com, rostedt@goodmis.org, me@kylehuey.com, len.brown@intel.com, prarit@redhat.com, hidehiro.kawai.ez@hitachi.com, fengtiantian@huawei.com, pmladek@suse.com, jeyu@redhat.com, Larry.Finger@lwfinger.net, zijun_hu@htc.com, luisbg@osg.samsung.com, johannes.berg@intel.com, niklas.soderlund+renesas@ragnatech.se, zlpnobody@gmail.com, adobriyan@gmail.com, fgao@48lvckh6395k16k5.yundunddos.com, ebiederm@xmission.com, subashab@codeaurora.org, arnd@arndb.de, matt@codeblueprint.co.uk, mgorman@techsingularity.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-edac@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH 2/2] x86/idle: use dynamic halt poll In-Reply-To: <1498130534-26568-3-git-send-email-root@ip-172-31-39-62.us-west-2.compute.internal> Message-ID: References: <1498130534-26568-1-git-send-email-root@ip-172-31-39-62.us-west-2.compute.internal> <1498130534-26568-3-git-send-email-root@ip-172-31-39-62.us-west-2.compute.internal> 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 On Thu, 22 Jun 2017, root wrote: > @@ -962,6 +962,7 @@ __visible void __irq_entry smp_apic_timer_interrupt(struct pt_regs *regs) > * interrupt lock, which is the WrongThing (tm) to do. > */ > entering_ack_irq(); > + check_poll(); No way, that we sprinkle this function into every interrupt hotpath. There are enough genuine ways to do that w/o touching a gazillion of files. > #ifdef CONFIG_HYPERVISOR_GUEST > +static unsigned int grow_poll_ns(unsigned int old, unsigned int grow, > + unsigned int max) > +{ > + unsigned int val; > + > + /* 10us as base poll duration */ > + if (old == 0 && grow) > + return 10000; > + > + val = old * grow; > + if (val > max) > + val = max; > + > + return val; > +} > + > +static unsigned int shrink_poll_ns(unsigned int old, unsigned int shrink) > +{ > + if (shrink == 0) > + return 0; > + > + return old / shrink; > +} > + > +void check_poll(void) > +{ > + unsigned int val, poll_duration; > + unsigned long begin_ns, now_ns; > + > + if (!poll_threshold_ns) > + return; If at all then this needs to be a static key based decision. > + > + begin_ns = this_cpu_read(poll_begin_ns); > + /* Not from halt state */ > + if (!begin_ns) > + return; If you integrate this stuff into the proper place, then the whole mess goes away. We really do not need another facility to track idle state. We have enough already, really. Thanks, tglx From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Subject: [2/2] x86/idle: use dynamic halt poll From: Thomas Gleixner Message-Id: Date: Thu, 22 Jun 2017 16:32:07 +0200 (CEST) To: root Cc: mingo@redhat.com, hpa@zytor.com, pbonzini@redhat.com, x86@kernel.org, corbet@lwn.net, tony.luck@intel.com, bp@alien8.de, peterz@infradead.org, mchehab@kernel.org, akpm@linux-foundation.org, krzk@kernel.org, jpoimboe@redhat.com, luto@kernel.org, borntraeger@de.ibm.com, thgarnie@google.com, rgerst@gmail.com, minipli@googlemail.com, douly.fnst@cn.fujitsu.com, nicstange@gmail.com, fweisbec@gmail.com, dvlasenk@redhat.com, bristot@redhat.com, yamada.masahiro@socionext.com, mika.westerberg@linux.intel.com, yu.c.chen@intel.com, aaron.lu@intel.com, rostedt@goodmis.org, me@kylehuey.com, len.brown@intel.com, prarit@redhat.com, hidehiro.kawai.ez@hitachi.com, fengtiantian@huawei.com, pmladek@suse.com, jeyu@redhat.com, Larry.Finger@lwfinger.net, zijun_hu@htc.com, luisbg@osg.samsung.com, johannes.berg@intel.com, niklas.soderlund+renesas@ragnatech.se, zlpnobody@gmail.com, adobriyan@gmail.com, fgao@ikuai8.com, ebiederm@xmission.com, subashab@codeaurora.org, arnd@arndb.de, matt@codeblueprint.co.uk, mgorman@techsingularity.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-edac@vger.kernel.org, kvm@vger.kernel.org List-ID: T24gVGh1LCAyMiBKdW4gMjAxNywgcm9vdCB3cm90ZToKPiBAQCAtOTYyLDYgKzk2Miw3IEBAIF9f dmlzaWJsZSB2b2lkIF9faXJxX2VudHJ5IHNtcF9hcGljX3RpbWVyX2ludGVycnVwdChzdHJ1Y3Qg cHRfcmVncyAqcmVncykKPiAgCSAqIGludGVycnVwdCBsb2NrLCB3aGljaCBpcyB0aGUgV3JvbmdU aGluZyAodG0pIHRvIGRvLgo+ICAJICovCj4gIAllbnRlcmluZ19hY2tfaXJxKCk7Cj4gKwljaGVj a19wb2xsKCk7CgpObyB3YXksIHRoYXQgd2Ugc3ByaW5rbGUgdGhpcyBmdW5jdGlvbiBpbnRvIGV2 ZXJ5IGludGVycnVwdCBob3RwYXRoLiBUaGVyZQphcmUgZW5vdWdoIGdlbnVpbmUgd2F5cyB0byBk byB0aGF0IHcvbyB0b3VjaGluZyBhIGdhemlsbGlvbiBvZiBmaWxlcy4KCj4g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ucykKPiArCQly ZXR1cm47CgpJZiB5b3UgaW50ZWdyYXRlIHRoaXMgc3R1ZmYgaW50byB0aGUgcHJvcGVyIHBsYWNl LCB0aGVuIHRoZSB3aG9sZSBtZXNzIGdvZXMKYXdheS4gV2UgcmVhbGx5IGRvIG5vdCBuZWVkIGFu b3RoZXIgZmFjaWxpdHkgdG8gdHJhY2sgaWRsZSBzdGF0ZS4gV2UgaGF2ZQplbm91Z2ggYWxyZWFk eSwgcmVhbGx5LgoKVGhhbmtzLAoKCXRnbHgKLS0tClRvIHVuc3Vic2NyaWJlIGZyb20gdGhpcyBs aXN0OiBzZW5kIHRoZSBsaW5lICJ1bnN1YnNjcmliZSBsaW51eC1lZGFjIiBpbgp0aGUgYm9keSBv ZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIua2VybmVsLm9yZwpNb3JlIG1ham9yZG9tbyBp bmZvIGF0ICBodHRwOi8vdmdlci5rZXJuZWwub3JnL21ham9yZG9tby1pbmZvLmh0bWwK From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: [PATCH 2/2] x86/idle: use dynamic halt poll Date: Thu, 22 Jun 2017 16:32:07 +0200 (CEST) Message-ID: References: <1498130534-26568-1-git-send-email-root@ip-172-31-39-62.us-west-2.compute.internal> <1498130534-26568-3-git-send-email-root@ip-172-31-39-62.us-west-2.compute.internal> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Cc: mingo@redhat.com, hpa@zytor.com, pbonzini@redhat.com, x86@kernel.org, corbet@lwn.net, tony.luck@intel.com, bp@alien8.de, peterz@infradead.org, mchehab@kernel.org, akpm@linux-foundation.org, krzk@kernel.org, jpoimboe@redhat.com, luto@kernel.org, borntraeger@de.ibm.com, thgarnie@google.com, rgerst@gmail.com, minipli@googlemail.com, douly.fnst@cn.fujitsu.com, nicstange@gmail.com, fweisbec@gmail.com, dvlasenk@redhat.com, bristot@redhat.com, yamada.masahiro@socionext.com, mika.westerberg@linux.intel.com, yu.c.chen@intel.com, aaron.lu@intel.com, rostedt@goodmis.org, me@kylehuey.com, len.brown@intel.com, prarit@redhat.com, hidehiro.kawai.ez@hitachi.com, fengtiantian@huawei.com, pmladek@suse.com, jeyu@redhat.com, Larry.Finger@lwfinger.net, zijun_hu@htc.com, luisbg@osg.samsung.com, johannes To: root Return-path: In-Reply-To: <1498130534-26568-3-git-send-email-root@ip-172-31-39-62.us-west-2.compute.internal> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Thu, 22 Jun 2017, root wrote: > @@ -962,6 +962,7 @@ __visible void __irq_entry smp_apic_timer_interrupt(struct pt_regs *regs) > * interrupt lock, which is the WrongThing (tm) to do. > */ > entering_ack_irq(); > + check_poll(); No way, that we sprinkle this function into every interrupt hotpath. There are enough genuine ways to do that w/o touching a gazillion of files. > #ifdef CONFIG_HYPERVISOR_GUEST > +static unsigned int grow_poll_ns(unsigned int old, unsigned int grow, > + unsigned int max) > +{ > + unsigned int val; > + > + /* 10us as base poll duration */ > + if (old == 0 && grow) > + return 10000; > + > + val = old * grow; > + if (val > max) > + val = max; > + > + return val; > +} > + > +static unsigned int shrink_poll_ns(unsigned int old, unsigned int shrink) > +{ > + if (shrink == 0) > + return 0; > + > + return old / shrink; > +} > + > +void check_poll(void) > +{ > + unsigned int val, poll_duration; > + unsigned long begin_ns, now_ns; > + > + if (!poll_threshold_ns) > + return; If at all then this needs to be a static key based decision. > + > + begin_ns = this_cpu_read(poll_begin_ns); > + /* Not from halt state */ > + if (!begin_ns) > + return; If you integrate this stuff into the proper place, then the whole mess goes away. We really do not need another facility to track idle state. We have enough already, really. Thanks, tglx