Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Mon, 9 Apr 2001 11:57:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Mon, 9 Apr 2001 11:57:31 -0400 Received: from d12lmsgate.de.ibm.com ([195.212.91.199]:53934 "EHLO d12lmsgate.de.ibm.com") by vger.kernel.org with ESMTP id ; Mon, 9 Apr 2001 11:57:08 -0400 From: schwidefsky@de.ibm.com X-Lotus-FromDomain: IBMDE To: linux-kernel@vger.kernel.org Message-ID: Date: Mon, 9 Apr 2001 17:54:37 +0200 Subject: No 100 HZ timer ! Mime-Version: 1.0 Content-type: multipart/mixed; Boundary="0__=AxUwewK46NPW3l78cMfeqzg27zDccjV0SOMwunyt3i8B0oHhABq1qiLy" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org --0__=AxUwewK46NPW3l78cMfeqzg27zDccjV0SOMwunyt3i8B0oHhABq1qiLy Content-type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-transfer-encoding: quoted-printable Hi, seems like my first try with the complete patch hasn't made it through to the mailing list. This is the second try with only the common part o= f the patch. Here we go (again): --- I have a suggestion that might seem unusual at first but it is importan= t for Linux on S/390. We are facing the problem that we want to start man= y (> 1000) Linux images on a big S/390 machine. Every image has its own 100 HZ timer on every processor the images uses (normally 1). On a sing= le image system the processor use of the 100 HZ timer is not a big deal bu= t with > 1000 images you need a lot of processing power just to execute t= he 100 HZ timers. You quickly end up with 100% CPU only for the timer interrupts of otherwise idle images. Therefore I had a go at the timer stuff and now I have a system running without the 100 HZ timer. Unluckl= y I need to make changes to common code and I want you opinion on it. The first problem was how to get rid of the jiffies. The solution is simple. I simply defined a macro that calculates the jiffies value from= the TOD clock: #define jiffies ({ \ uint64_t __ticks; \ asm ("STCK %0" : "=3Dm" (__ticks) ); \ __ticks =3D (__ticks - init_timer_cc) >> 12; \ do_div(__ticks, (1000000/HZ)); \ ((unsigned long) __ticks); \ }) With this define you are independent of the jiffies variable which is n= o longer needed so I ifdef'ed the definition. There are some places where= a local variable is named jiffies. You may not replace these so I renamed= them to _jiffies. A kernel compiled with only this change works as alwa= ys. The second problem is that you need to be able to find out when the nex= t timer event is due to happen. You'll find a new function "next_timer_ev= ent" in the patch which traverses tv1-tv5 and returns the timer_list of the = next timer event. It is used in timer_bh to indicate to the backend when the= next interrupt should happen. This leads us to the notifier functions. Each time a new timer is added, a timer is modified, or a timer expires= the architecture backend needs to reset its timeout value. That is what= the "timer_notify" callback is used for. The implementation on S/390 uses t= he clock comparator and looks like this: static void s390_timer_notify(unsigned long expires) { S390_lowcore.timer_event =3D ((__u64) expires*CLK_TICKS_PER_JIFFY) + init_timer_cc= ; asm volatile ("SCKC %0" : : "m" (S390_lowcore.timer_event)); } This causes an interrupt on the cpu which executed s390_timer_notify af= ter "expires" has passed. That means that timer events are spread over the = cpus in the system. Modified or deleted timer events do not cause a deletion= notification. A cpu might be errornously interrupted to early because o= f a timer event that has been modified or deleted. But that doesn't do any harm, it is just unnecessary work. There is a second callback "itimer_notify" that is used to get the per process timers right. We use the cpu timer for this purpose: void set_cpu_timer(void) { unsigned long min_ticks; __u64 time_slice; if (current->pid !=3D 0 && current->need_resched =3D=3D 0) { min_ticks =3D current->counter; if (current->it_prof_value !=3D 0 && current->it_prof_value < min_ticks) min_ticks =3D current->it_prof_value; if (current->it_virt_value !=3D 0 && current->it_virt_value < min_ticks) min_ticks =3D current->it_virt_value; time_slice =3D (__u64) min_ticks*CLK_TICKS_PER_JIFFY;= asm volatile ("spt %0" : : "m" (time_slice)); } } The cpu timer is a one shot timer that interrupts after the specified amount of time has passed. Not a 100% accurate because VM can schedule the vir= tual processor before the "spt" has been done but good enough for per proces= s timers. The remaining changes to common code parts deal with the problem that m= any ticks may be accounted at once. For example without the 100 HZ timer it= is possible that a process runs for half a second in user space. With the = next interrupt all the ticks between the last update and the interrupt have = to be added to the tick counters. This is why update_wall_time and do_it_p= rof have changed and update_process_times2 has been introduced. That leaves three problems: 1) you need to check on every system entry = if a tick or more has passed and do the update if necessary, 2) you need t= o keep track of the elapsed time in user space and in kernel space and 3)= you need to check tq_timer every time the system is left and setup a timer event for the next timer tick if there is work to do on the timer queue= . These three problems are related and have to be implemented architectur= e dependent. A nice thing we get for free is that the user/kernel elapsed= time measurement gets much more accurate. The number of interrupts in an idle system due to timer activity drops = from from 100 per second on every cpu to about 5-6 on all (!) cpus if this p= atch is used. Exactly what we want to have. All this new timer code is only used if the config option CONFIG_NO_HZ_TIMER is set. Without it everything works as always, especially for architect= ures that will not use it. Now what do you think? (See attached file: timer_common) blue skies, Martin Linux/390 Design & Development, IBM Deutschland Entwicklung GmbH Sch=F6naicherstr. 220, D-71032 B=F6blingen, Telefon: 49 - (0)7031 - 16-= 2247 E-Mail: schwidefsky@de.ibm.com = --0__=AxUwewK46NPW3l78cMfeqzg27zDccjV0SOMwunyt3i8B0oHhABq1qiLy Content-type: application/octet-stream; name="timer_common" Content-Disposition: attachment; filename="timer_common" Content-transfer-encoding: base64 ZGlmZiAtdXJOIGxpbnV4LTIuNC4zL2luY2x1ZGUvbGludXgvc2NoZWQuaCBsaW51eC0yLjQuMy1z MzkwL2luY2x1ZGUvbGludXgvc2NoZWQuaAotLS0gbGludXgtMi40LjMvaW5jbHVkZS9saW51eC9z Y2hlZC5oCVR1ZSBNYXIgMjcgMDE6NDg6MTEgMjAwMQorKysgbGludXgtMi40LjMtczM5MC9pbmNs dWRlL2xpbnV4L3NjaGVkLmgJVGh1IEFwciAgNSAxMDoyMzo0OCAyMDAxCkBAIC0xNDQsNiArMTQ0 LDcgQEAKIGV4dGVybiB2b2lkIGNwdV9pbml0ICh2b2lkKTsKIGV4dGVybiB2b2lkIHRyYXBfaW5p dCh2b2lkKTsKIGV4dGVybiB2b2lkIHVwZGF0ZV9wcm9jZXNzX3RpbWVzKGludCB1c2VyKTsKK2V4 dGVybiB2b2lkIHVwZGF0ZV9wcm9jZXNzX3RpbWVzMihpbnQgdXNlciw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WVyX2xpc3QoKTsKKyNpZmRlZiBDT05GSUdfTk9fSFpf VElNRVIKKwlpZiAodGltZXJfbm90aWZ5ICE9IE5VTEwpIHsKKwkJc3RydWN0IHRpbWVyX2xpc3Qg KnRpbWVyOworCQl1bnNpZ25lZCBsb25nIGZsYWdzOworCisJCXNwaW5fbG9ja19pcnFzYXZlKCZ0 aW1lcmxpc3RfbG9jaywgZmxhZ3MpOworCQl0aW1lciA9IG5leHRfdGltZXJfZXZlbnQoKTsKKwkJ aWYgKHRpbWVyICE9IE5VTEwpIHsKKwkJCSgqdGltZXJfbm90aWZ5KSh0aW1lci0+ZXhwaXJlcyk7 CisJCQlub3RpZnlfamlmZnkgPSB0aW1lci0+ZXhwaXJlczsKKwkJfSBlbHNlCisJCQlub3RpZnlf amlmZnkgPSAwOworCQlzcGluX3VubG9ja19pcnFyZXN0b3JlKCZ0aW1lcmxpc3RfbG9jaywgZmxh Z3MpOworCX0KKyNlbmRpZgogfQogCisjaWZuZGVmIENPTkZJR19OT19IWl9USU1FUgogdm9pZCBk b190aW1lcihzdHJ1Y3QgcHRfcmVncyAqcmVncykKIHsKIAkoKih1bnNpZ25lZCBsb25nICopJmpp ZmZpZXMpKys7CkBAIC02ODMsNiArODQ0LDcgQEAKIAlpZiAoVFFfQUNUSVZFKHRxX3RpbWVyKSkK IAkJbWFya19iaChUUVVFVUVfQkgpOwogfQorI2VuZGlmCiAKICNpZiAhZGVmaW5lZChfX2FscGhh X18pICYmICFkZWZpbmVkKF9faWE2NF9fKQogCg== --0__=AxUwewK46NPW3l78cMfeqzg27zDccjV0SOMwunyt3i8B0oHhABq1qiLy-- - 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/