From: Manfred Spraul <manfred@colorfullife.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Re: softirq buggy
Date: Sun, 08 Apr 2001 23:35:36 +0200 [thread overview]
Message-ID: <3AD0D9A8.189AA43C@colorfullife.com> (raw)
In-Reply-To: <200104081758.VAA15670@ms2.inr.ac.ru>
[-- Attachment #1: Type: text/plain, Size: 377 bytes --]
I've attached a new patch:
* cpu_is_idle() moved to <linux/pm.h>
* function uninlined due to header dependencies
* cpu_is_idle() doesn't call do_softirq directly, instead the caller
returns to schedule()
* cpu_is_idle() exported for modules.
* docu updated.
I'd prefer to inline cpu_is_idle(), but optimizing the idle code path is
probably not that important ;-)
--
Manfred
[-- Attachment #2: patch-cpu-idle --]
[-- Type: text/plain, Size: 2940 bytes --]
// $Header$
// Kernel Version:
// VERSION = 2
// PATCHLEVEL = 4
// SUBLEVEL = 3
// EXTRAVERSION = -ac3
--- 2.4/include/linux/pm.h Thu Jan 4 23:50:47 2001
+++ build-2.4/include/linux/pm.h Sun Apr 8 21:02:02 2001
@@ -186,6 +186,8 @@
extern void (*pm_idle)(void);
extern void (*pm_power_off)(void);
+int cpu_is_idle(void);
+
#endif /* __KERNEL__ */
#endif /* _LINUX_PM_H */
--- 2.4/kernel/sched.c Sat Apr 7 22:02:27 2001
+++ build-2.4/kernel/sched.c Sun Apr 8 21:02:37 2001
@@ -1242,6 +1242,28 @@
sched_data->last_schedule = get_cycles();
}
+/**
+ * cpu_is_idle - helper function for idle functions
+ *
+ * pm_idle functions must call this function to verify that
+ * the cpu is really idle.
+ * The return value is valid until local interrupts are
+ * reenabled.
+ * Return values:
+ * 1: go into power saving mode.
+ * 0: cpu is not idle, return to schedule()
+ */
+int cpu_is_idle(void)
+{
+ if (current->need_resched)
+ return 0;
+
+ if (softirq_active(smp_processor_id()) & softirq_mask(smp_processor_id()))
+ return 0;
+
+ return 1;
+}
+
extern void init_timervecs (void);
void __init sched_init(void)
--- 2.4/kernel/ksyms.c Sat Apr 7 22:02:27 2001
+++ build-2.4/kernel/ksyms.c Sun Apr 8 21:42:48 2001
@@ -440,6 +440,7 @@
#endif
EXPORT_SYMBOL(kstat);
EXPORT_SYMBOL(nr_running);
+EXPORT_SYMBOL(cpu_is_idle);
/* misc */
EXPORT_SYMBOL(panic);
--- 2.4/arch/i386/kernel/process.c Thu Feb 22 22:28:52 2001
+++ build-2.4/arch/i386/kernel/process.c Sun Apr 8 21:25:23 2001
@@ -81,7 +81,7 @@
{
if (current_cpu_data.hlt_works_ok && !hlt_counter) {
__cli();
- if (!current->need_resched)
+ if (cpu_is_idle())
safe_halt();
else
__sti();
@@ -105,13 +105,10 @@
*/
oldval = xchg(¤t->need_resched, -1);
- if (!oldval)
- asm volatile(
- "2:"
- "cmpl $-1, %0;"
- "rep; nop;"
- "je 2b;"
- : :"m" (current->need_resched));
+ if (!oldval) {
+ while(cpu_is_idle())
+ rep_nop();
+ }
}
/*
@@ -131,7 +128,7 @@
void (*idle)(void) = pm_idle;
if (!idle)
idle = default_idle;
- while (!current->need_resched)
+ while (cpu_is_idle())
idle();
schedule();
check_pgt_cache();
--- 2.4/drivers/acpi/cpu.c Sat Apr 7 22:02:01 2001
+++ build-2.4/drivers/acpi/cpu.c Sat Apr 7 23:55:17 2001
@@ -148,7 +148,7 @@
unsigned long diff;
__cli();
- if (current->need_resched)
+ if (!cpu_is_idle())
goto out;
if (acpi_bm_activity())
goto sleep2;
@@ -171,7 +171,7 @@
unsigned long diff;
__cli();
- if (current->need_resched)
+ if (!cpu_is_idle())
goto out;
if (acpi_bm_activity())
goto sleep2;
@@ -205,7 +205,7 @@
unsigned long diff;
__cli();
- if (current->need_resched)
+ if (!cpu_is_idle())
goto out;
time = acpi_read_pm_timer();
@@ -235,7 +235,7 @@
unsigned long diff;
__cli();
- if (current->need_resched)
+ if (!cpu_is_idle())
goto out;
time = acpi_read_pm_timer();
acpi_c1_count++;
next prev parent reply other threads:[~2001-04-08 21:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <000401c0b319517fea9@local>
2001-03-25 23:10 ` Serial port latency Pavel Machek
2001-03-29 7:58 ` Manfred Spraul
2001-03-30 22:36 ` Pavel Machek
2001-03-31 22:09 ` Manfred Spraul
2001-04-03 23:07 ` softirq buggy [Re: Serial port latency] Pavel Machek
2001-04-04 21:18 ` Manfred Spraul
2001-04-06 12:00 ` Pavel Machek
2001-04-07 22:28 ` Manfred Spraul
2001-04-08 16:58 ` kuznet
2001-04-08 17:21 ` Manfred Spraul
2001-04-08 17:58 ` kuznet
2001-04-08 18:16 ` Manfred Spraul
2001-04-08 21:35 ` Manfred Spraul [this message]
2001-04-09 8:42 ` [PATCH] Re: softirq buggy Albert D. Cahalan
2001-04-09 13:50 ` Andrea Arcangeli
2001-04-09 15:26 ` Manfred Spraul
2001-04-09 17:31 ` Andrea Arcangeli
2001-04-09 17:48 ` kuznet
2001-04-09 18:26 ` Andrea Arcangeli
2001-04-10 0:37 ` Serial port latency Andrea Arcangeli
2001-04-09 11:37 [PATCH] Re: softirq buggy Studierende der Universitaet des Saarlandes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3AD0D9A8.189AA43C@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox