Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758151AbYGNVCY (ORCPT ); Mon, 14 Jul 2008 17:02:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756632AbYGNVCP (ORCPT ); Mon, 14 Jul 2008 17:02:15 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:43710 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754348AbYGNVCO (ORCPT ); Mon, 14 Jul 2008 17:02:14 -0400 From: "Woodruff, Richard" To: Linux Power Management List CC: Linux Kernel Mailing List Date: Mon, 14 Jul 2008 16:02:00 -0500 Subject: [RFC-PATCH] Improve Menu Governor Prediction of interrupted C states. Thread-Topic: [RFC-PATCH] Improve Menu Governor Prediction of interrupted C states. Thread-Index: Acjl9NwKQ0on4gDvSK+0rYSuOpnIRw== Message-ID: <13B9B4C6EF24D648824FF11BE8967162035BEA0EDF@dlee02.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/mixed; boundary="_002_13B9B4C6EF24D648824FF11BE8967162035BEA0EDFdlee02enttico_" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8109 Lines: 178 --_002_13B9B4C6EF24D648824FF11BE8967162035BEA0EDFdlee02enttico_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, Any comments on the following? I'm finding with high interrupt rates for some USB devices the menu governo= r guesses wrong enough that throughput drops. With the below tweak tests with fixed data sizes which were taking 12s to c= omplete drop back to 9s. Also my standby idle doesn't change before and af= ter activity with our with out the patch. What it does is simply timestamp incoming irqs, then in the menu governor w= ill use current & last irq time delta to refine its guess as to how long sl= eep will happen. Regards, Richard W. Signed-off-by: Richard Woodruff diff -purN img/2.6_kernel/arch/arm/kernel/irq.c 2.6_kernel/arch/arm/kernel/= irq.c --- img/2.6_kernel/arch/arm/kernel/irq.c 2008-04-03 22:43:09.0000000= 00 -0500 +++ 2.6_kernel/arch/arm/kernel/irq.c 2008-07-14 15:09:48.000000000 -0500 @@ -122,6 +131,8 @@ asmlinkage void __exception asm_do_IRQ(u irq_enter(); + kstat_irq_stamp(); + desc_handle_irq(irq, desc); /* AT91 specific workaround */ diff -purN img/2.6_kernel/drivers/cpuidle/governors/menu.c 2.6_kernel/drive= rs/cpuidle/governors/menu.c --- img/2.6_kernel/drivers/cpuidle/governors/menu.c 2008-07-04 15:31:23= .000000000 -0500 +++ 2.6_kernel/drivers/cpuidle/governors/menu.c 2008-07-14 15:22:55.0000000= 00 -0500 @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -70,6 +71,7 @@ static void menu_reflect(struct cpuidle_ unsigned int measured_us =3D cpuidle_get_last_residency(dev) + data->elapsed_us; struct cpuidle_state *target =3D &dev->states[last_idx]; + const unsigned int cpu =3D smp_processor_id(); /* * Ugh, this idle state doesn't support residency measurements, so = we @@ -92,6 +94,10 @@ static void menu_reflect(struct cpuidle_ data->elapsed_us =3D -1; data->predicted_us =3D max(measured_us, data->last_measured= _us); } + + /* Guess & factor in interrupt wake rate */ + data->predicted_us =3D min((s64)data->predicted_us, ktime_to_us( + ktime_sub(kstat_cpu(cpu).irq_now, kstat_cpu(cpu).irq_last))= ); } /** diff -purN img/2.6_kernel/include/linux/kernel_stat.h 2.6_kernel/include/li= nux/kernel_stat.h --- img/2.6_kernel/include/linux/kernel_stat.h 2008-04-03 21:51:50.0000000= 00 -0500 +++ 2.6_kernel/include/linux/kernel_stat.h 2008-07-14 13:11:09.0000000= 00 -0500 @@ -7,6 +7,7 @@ #include #include #include +#include /* * 'kernel_stat.h' contains the definitions needed for doing @@ -29,6 +30,8 @@ struct cpu_usage_stat { struct kernel_stat { struct cpu_usage_stat cpustat; unsigned int irqs[NR_IRQS]; + ktime_t irq_now; + ktime_t irq_last; }; DECLARE_PER_CPU(struct kernel_stat, kstat); @@ -52,6 +55,16 @@ static inline int kstat_irqs(int irq) return sum; } +/* + * Provide hook to try and understand interrupt rate on a processor + */ +static inline void kstat_irq_stamp(void) +{ + const unsigned int cpu =3D smp_processor_id(); + kstat_cpu(cpu).irq_last =3D kstat_cpu(cpu).irq_now; + kstat_cpu(cpu).irq_now =3D ktime_get(); +} + extern void account_user_time(struct task_struct *, cputime_t); extern void account_user_time_scaled(struct task_struct *, cputime_t); extern void account_system_time(struct task_struct *, int, cputime_t); --_002_13B9B4C6EF24D648824FF11BE8967162035BEA0EDFdlee02enttico_ Content-Type: application/octet-stream; name="menu_gov_irq_guess.diff" Content-Description: menu_gov_irq_guess.diff Content-Disposition: attachment; filename="menu_gov_irq_guess.diff"; size=2725; creation-date="Mon, 14 Jul 2008 15:25:31 GMT"; modification-date="Mon, 14 Jul 2008 15:25:31 GMT" Content-Transfer-Encoding: base64 ZGlmZiAtcHVyTiBpbWcvMi42X2tlcm5lbC9hcmNoL2FybS9rZXJuZWwvaXJxLmMgMi42X2tlcm5l bC9hcmNoL2FybS9rZXJuZWwvaXJxLmMKLS0tIGltZy8yLjZfa2VybmVsL2FyY2gvYXJtL2tlcm5l bC9pcnEuYwkyMDA4LTA0LTAzIDIyOjQzOjA5LjAwMDAwMDAwMCAtMDUwMAorKysgMi42X2tlcm5l bC9hcmNoL2FybS9rZXJuZWwvaXJxLmMJMjAwOC0wNy0xNCAxNTowOTo0OC4wMDAwMDAwMDAgLTA1 MDAKQEAgLTEyMiw2ICsxMzEsOCBAQCBhc21saW5rYWdlIHZvaWQgX19leGNlcHRpb24gYXNtX2Rv X0lSUSh1CiAKIAlpcnFfZW50ZXIoKTsKIAorCWtzdGF0X2lycV9zdGFtcCgpOworCiAJZGVzY19o YW5kbGVfaXJxKGlycSwgZGVzYyk7CiAKIAkvKiBBVDkxIHNwZWNpZmljIHdvcmthcm91bmQgKi8K ZGlmZiAtcHVyTiBpbWcvMi42X2tlcm5lbC9kcml2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AJc3RydWN0IGNwdV91c2FnZV9zdGF0CWNwdXN0YXQ7 CiAJdW5zaWduZWQgaW50IGlycXNbTlJfSVJRU107CisJa3RpbWVfdCBpcnFfbm93OworCWt0aW1l X3QgaXJxX2xhc3Q7CiB9OwogCiBERUNMQVJFX1BFUl9DUFUoc3RydWN0IGtlcm5lbF9zdGF0LCBr c3RhdCk7CkBAIC01Miw2ICs1NSwxNiBAQCBzdGF0aWMgaW5saW5lIGludCBrc3RhdF9pcnFzKGlu dCBpcnEpCiAJcmV0dXJuIHN1bTsKIH0KIAorLyoKKyAqIFByb3ZpZGUgaG9vayB0byB0cnkgYW5k IHVuZGVyc3RhbmQgaW50ZXJydXB0IHJhdGUgb24gYSBwcm9jZXNzb3IKKyAqLworc3RhdGljIGlu bGluZSB2b2lkIGtzdGF0X2lycV9zdGFtcCh2b2lkKQoreworCWNvbnN0IHVuc2lnbmVkIGludCBj cHUgPSBzbXBfcHJvY2Vzc29yX2lkKCk7CisJa3N0YXRfY3B1KGNwdSkuaXJxX2xhc3QgPSBrc3Rh dF9jcHUoY3B1KS5pcnFfbm93OworCWtzdGF0X2NwdShjcHUpLmlycV9ub3cgPSBrdGltZV9nZXQo KTsKK30KKwogZXh0ZXJuIHZvaWQgYWNjb3VudF91c2VyX3RpbWUoc3RydWN0IHRhc2tfc3RydWN0 ICosIGNwdXRpbWVfdCk7CiBleHRlcm4gdm9pZCBhY2NvdW50X3VzZXJfdGltZV9zY2FsZWQoc3Ry dWN0IHRhc2tfc3RydWN0ICosIGNwdXRpbWVfdCk7CiBleHRlcm4gdm9pZCBhY2NvdW50X3N5c3Rl bV90aW1lKHN0cnVjdCB0YXNrX3N0cnVjdCAqLCBpbnQsIGNwdXRpbWVfdCk7Cg== --_002_13B9B4C6EF24D648824FF11BE8967162035BEA0EDFdlee02enttico_-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/