Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932217AbWAILLw (ORCPT ); Mon, 9 Jan 2006 06:11:52 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932221AbWAILLw (ORCPT ); Mon, 9 Jan 2006 06:11:52 -0500 Received: from mail.gmx.de ([213.165.64.21]:56285 "HELO mail.gmx.net") by vger.kernel.org with SMTP id S932217AbWAILLv (ORCPT ); Mon, 9 Jan 2006 06:11:51 -0500 X-Authenticated: #14349625 Message-Id: <5.2.1.1.2.20060109112238.00be96f8@pop.gmx.net> X-Mailer: QUALCOMM Windows Eudora Version 5.2.1 Date: Mon, 09 Jan 2006 12:11:31 +0100 To: Paolo Ornati From: Mike Galbraith Subject: Re: [SCHED] wrong priority calc - SIMPLE test case Cc: Linux Kernel Mailing List , Con Kolivas , Ingo Molnar , Nick Piggin , Peter Williams In-Reply-To: <5.2.1.1.2.20060102092903.00bde090@pop.gmx.net> References: <20060101123902.27a10798@localhost> <5.2.1.1.2.20051231162352.00bda610@pop.gmx.net> <5.2.1.1.2.20051231090255.00bede00@pop.gmx.net> <200512281027.00252.kernel@kolivas.org> <20051227190918.65c2abac@localhost> <20051227224846.6edcff88@localhost> <200512281027.00252.kernel@kolivas.org> <5.2.1.1.2.20051231090255.00bede00@pop.gmx.net> <5.2.1.1.2.20051231162352.00bda610@pop.gmx.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=====================_17772421==_" X-Antivirus: avast! (VPS 0601-0, 01/02/2006), Outbound message X-Antivirus-Status: Clean X-Y-GMX-Trusted: 0 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7767 Lines: 134 --=====================_17772421==_ Content-Type: text/plain; charset="us-ascii"; format=flowed At 10:15 AM 1/2/2006 +0100, Mike Galbraith wrote: >At 12:39 PM 1/1/2006 +0100, Paolo Ornati wrote: >>On Sat, 31 Dec 2005 17:37:11 +0100 >>Mike Galbraith wrote: >> >> > Strange. Using the exact same arguments, I do see some odd bouncing up to >> > high priorities, but they spend the vast majority of their time down >> at 25. >> >>Mmmm... to make it more easly reproducible I've enlarged the sleep time >>(1 microsecond is likely to be rounded too much and give different >>results on different hardware/kernel/config...). >> >>Compile this _without_ optimizations and try again: > > > >>Try different values: 1000, 2000, 3000 ... are you able to reproduce it >>now? > >Yeah. One instance running has to sustain roughly _95%_ cpu before it's >classified as a cpu piggy. Not good. > >>If yes, try to start 2 of them with something like this: >> >>"./a.out 3000 & ./a.out 3161" >> >>so they are NOT syncronized and they use almost all the CPU time: >> >> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND >> 5582 paolo 16 0 2396 320 252 S 45.7 0.1 0:05.52 a.out >> 5583 paolo 15 0 2392 320 252 S 45.7 0.1 0:05.49 a.out >> >>This is the bad situation I hate: some cpu-eaters that eat all the CPU >>time BUT have a really good priority only because they sleeps a bit. > >Yup, your proggy fools the interactivity estimator quite well. This >problem was addressed a long time ago, and thought to be more or less >cured. Guess not. Care to try an experiment? I'd be very interested in knowing if the attached patch cures the real-life problem you were investigating. It attempts to catch tasks which the interactivity logic has misidentified, and "pull their plug". It maintains a running plausibility check (slice_avg) against sleep_avg, and if a sustained disparity appears, cuts off a cpu burning task's supply of bonus points such that it has to "run on battery" until the disparity decreases to within acceptable limits. Obviously, anything that affects fairness _will_ affect interactivity to some degree. This simple bolt-on throttle has delayed initiation and accelerated release in the hopes of keeping it's impact acceptable. After some initial testing, It doesn't _seem_ to suck. -Mike --=====================_17772421==_ Content-Type: application/octet-stream; name="sched_throttle" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="sched_throttle" LS0tIGluY2x1ZGUvbGludXgvc2NoZWQuaC5vcmcJVHVlIEphbiAgMyAwOToyNjo1MCAyMDA2Cisr KyBpbmNsdWRlL2xpbnV4L3NjaGVkLmgJU2F0IEphbiAgNyAxNDo0NTozNyAyMDA2CkBAIC03MDEs OCArNzAxLDggQEAKIAogCXVuc2lnbmVkIHNob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c2xpY2VfYXZnICsgKE5TX01BWF9TTEVFUF9BVkcvMTApICYmCisJCQkhcnRfdGFzayhwcmV2 KSkKKwkJcHJldi0+c3RhdGUgfD0gVEFTS19OT05JTlRFUkFDVElWRTsKKwlpZiAoIXJ0X3Rhc2so bmV4dCkgJiYgIShuZXh0LT50aW1lX3NsaWNlICUgREVGX1RJTUVTTElDRSkpCisJCW5leHQtPmxh c3Rfc2xpY2UgPSBub3c7CisKIAlwcmV2LT50aW1lc3RhbXAgPSBwcmV2LT5sYXN0X3JhbiA9IG5v dzsKIAogCXNjaGVkX2luZm9fc3dpdGNoKHByZXYsIG5leHQpOwo= --=====================_17772421==_-- - 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/