From: James Cleverdon <jamesclv@us.ibm.com>
To: William Lee Irwin III <wli@holomorphy.com>,
Gerrit Huizenga <gh@us.ibm.com>
Cc: "Nakajima, Jun" <jun.nakajima@intel.com>,
haveblue@us.ibm.com, pbadari@us.ibm.com,
linux-kernel@vger.kernel.org, johnstul@us.ibm.com,
mannthey@us.ibm.com
Subject: Re: userspace irq balancer
Date: Thu, 22 May 2003 07:18:06 -0700 [thread overview]
Message-ID: <200305220718.06982.jamesclv@us.ibm.com> (raw)
In-Reply-To: <20030522020443.GN2444@holomorphy.com>
[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]
On Wednesday 21 May 2003 07:04 pm, William Lee Irwin III wrote:
[ Snip! ]
> ...
> IMHO Linux on Pentium IV should use the TPR in conjunction with _very_
> simplistic interrupt load accounting by default and all more
> sophisticated logic should be punted straight to userspace as an
> administrative API.
>
[ Snip! ]
>
> i.e. frob the fscking TPR as recommended by the APIC docs every once in
> a while by default, punt anything (and everything) fancier up to
> userspace, and get the code that doesn't even understand what the fsck
> DESTMOD means the Hell out of the kernel and the Hell away from my
> IO-APIC RTE's.
>
>
> -- wli
Here's my old very stupid TPR patch . It lacks TPRing soft ints for kernel
preemption, etc. Because the xTPR logic only compares the top nibble of the
TPR and I don't want to mask out IRQs unnecessarily, it only tracks busy/idle
and IRQ/no-IRQ.
Simple enough for you, Bill? 8^)
--
James Cleverdon
IBM xSeries Linux Solutions
{jamesclv(Unix, preferred), cleverdj(Notes)} at us dot ibm dot com
[-- Attachment #2: tpr_dyn-2003-01-10_2.5.55 --]
[-- Type: text/x-diff, Size: 3480 bytes --]
diff -pru j55/arch/i386/kernel/irq.c t55/arch/i386/kernel/irq.c
--- j55/arch/i386/kernel/irq.c Wed Jan 8 20:03:51 2003
+++ t55/arch/i386/kernel/irq.c Fri Jan 10 18:01:03 2003
@@ -329,6 +329,7 @@ asmlinkage unsigned int do_IRQ(struct pt
struct irqaction * action;
unsigned int status;
+ apic_adj_tpr(TPR_IRQ);
irq_enter();
#ifdef CONFIG_DEBUG_STACKOVERFLOW
@@ -406,6 +407,7 @@ out:
spin_unlock(&desc->lock);
irq_exit();
+ apic_adj_tpr(-TPR_IRQ);
return 1;
}
diff -pru j55/arch/i386/kernel/process.c t55/arch/i386/kernel/process.c
--- j55/arch/i386/kernel/process.c Wed Jan 8 20:03:48 2003
+++ t55/arch/i386/kernel/process.c Fri Jan 10 17:59:13 2003
@@ -143,7 +143,9 @@ void cpu_idle (void)
irq_stat[smp_processor_id()].idle_timestamp = jiffies;
while (!need_resched())
idle();
+ apic_set_tpr(TPR_TASK);
schedule();
+ apic_set_tpr(TPR_IDLE);
}
}
diff -pru j55/include/asm-i386/apic.h t55/include/asm-i386/apic.h
--- j55/include/asm-i386/apic.h Wed Jan 8 20:04:27 2003
+++ t55/include/asm-i386/apic.h Fri Jan 10 17:59:13 2003
@@ -64,6 +64,22 @@ static inline void ack_APIC_irq(void)
apic_write_around(APIC_EOI, 0);
}
+static inline void apic_set_tpr(unsigned long val)
+{
+ unsigned long value;
+
+ value = apic_read(APIC_TASKPRI);
+ apic_write_around(APIC_TASKPRI, (value & ~APIC_TPRI_MASK) + val);
+}
+
+static inline void apic_adj_tpr(long adj)
+{
+ unsigned long value;
+
+ value = apic_read(APIC_TASKPRI);
+ apic_write_around(APIC_TASKPRI, value + adj);
+}
+
extern int get_maxlvt(void);
extern void clear_local_APIC(void);
extern void connect_bsp_APIC (void);
@@ -96,6 +112,15 @@ extern unsigned int nmi_watchdog;
#define NMI_LOCAL_APIC 2
#define NMI_INVALID 3
+#else /* CONFIG_X86_LOCAL_APIC */
+#define apic_set_tpr(val)
+#define apic_adj_tpr(adj)
#endif /* CONFIG_X86_LOCAL_APIC */
+/* Priority values for apic_adj_tpr() and apic_set_tpr() */
+/* xAPICs only do priority comparisons on the upper nibble. */
+#define TPR_IDLE (0x00L)
+#define TPR_TASK (0x10L)
+#define TPR_IRQ (0x10L)
+
#endif /* __ASM_APIC_H */
diff -pru j55/include/asm-i386/mach-summit/mach_apic.h t55/include/asm-i386/mach-summit/mach_apic.h
--- j55/include/asm-i386/mach-summit/mach_apic.h Fri Jan 10 16:16:44 2003
+++ t55/include/asm-i386/mach-summit/mach_apic.h Fri Jan 10 19:24:52 2003
@@ -4,7 +4,7 @@
extern int x86_summit;
#define esr_disable (1)
-#define no_balance_irq (0)
+#define no_balance_irq (1)
#define XAPIC_DEST_CPUS_MASK 0x0Fu
#define XAPIC_DEST_CLUSTER_MASK 0xF0u
@@ -13,7 +13,7 @@ extern int x86_summit;
((phys_apic) & XAPIC_DEST_CLUSTER_MASK) )
#define APIC_DFR_VALUE (x86_summit ? APIC_DFR_CLUSTER : APIC_DFR_FLAT)
-#define TARGET_CPUS (x86_summit ? XAPIC_DEST_CPUS_MASK : cpu_online_map)
+#define TARGET_CPUS (x86_summit ? xapic_round_robin_cpu_apic_id() : cpu_online_map)
#define APIC_BROADCAST_ID (x86_summit ? 0xFF : 0x0F)
#define check_apicid_used(bitmap, apicid) (0)
@@ -106,4 +106,20 @@ static inline int check_phys_apicid_pres
return (1);
}
+/*
+ * xapic_round_robin_cpu_apic_id -- Distribute the interrupts using a simple
+ * round robin scheme.
+ */
+static inline int xapic_round_robin_cpu_apic_id(void)
+{
+ int val;
+ static unsigned next_cpu = 0;
+
+ if (next_cpu >= NR_CPUS || cpu_2_logical_apicid[next_cpu] == BAD_APICID)
+ next_cpu = 0;
+ val = cpu_to_logical_apicid(next_cpu) | XAPIC_DEST_CPUS_MASK;
+ ++next_cpu;
+ return (val);
+}
+
#endif /* __ASM_MACH_APIC_H */
next prev parent reply other threads:[~2003-05-22 14:05 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-21 21:43 userspace irq balancer Nakajima, Jun
2003-05-22 0:29 ` Gerrit Huizenga
2003-05-22 1:28 ` Martin J. Bligh
2003-05-22 1:44 ` Gerrit Huizenga
2003-05-22 2:03 ` William Lee Irwin III
2003-05-22 2:04 ` William Lee Irwin III
2003-05-22 2:12 ` Zwane Mwaikambo
2003-05-22 3:57 ` Martin J. Bligh
2003-05-22 17:24 ` Bill Davidsen
2003-05-22 22:44 ` David S. Miller
2003-05-26 22:24 ` Andrea Arcangeli
2003-05-26 23:26 ` Andrew Morton
2003-05-26 23:34 ` Andrea Arcangeli
2003-05-26 23:43 ` David S. Miller
[not found] ` <20030527000639.GA3767@dualathlon.random>
2003-05-27 0:15 ` David S. Miller
2003-05-27 0:41 ` Andrea Arcangeli
2003-05-27 0:48 ` David S. Miller
2003-05-27 1:09 ` Andrea Arcangeli
2003-05-27 1:13 ` David S. Miller
2003-05-27 1:26 ` Andrea Arcangeli
2003-05-27 6:11 ` David S. Miller
2003-05-27 11:53 ` Andrea Arcangeli
2003-05-27 22:04 ` David S. Miller
2003-05-27 22:27 ` Andrea Arcangeli
2003-05-27 23:55 ` David S. Miller
2003-06-13 6:22 ` David S. Miller
2003-06-13 18:23 ` Andrea Arcangeli
2003-05-27 1:16 ` Dave Jones
2003-05-27 1:17 ` David S. Miller
2003-05-27 9:07 ` Arjan van de Ven
2003-05-27 9:10 ` David S. Miller
2003-05-27 1:28 ` Andrea Arcangeli
2003-05-27 1:53 ` William Lee Irwin III
2003-05-27 1:59 ` Andrew Morton
2003-05-27 2:10 ` William Lee Irwin III
2003-05-27 2:15 ` Zwane Mwaikambo
2003-05-27 2:44 ` William Lee Irwin III
2003-05-27 2:45 ` Zwane Mwaikambo
2003-05-27 4:22 ` William Lee Irwin III
2003-05-27 2:15 ` Andrea Arcangeli
2003-05-27 2:14 ` Andrea Arcangeli
2003-05-27 2:26 ` William Lee Irwin III
2003-05-27 1:17 ` Andrea Arcangeli
2003-05-27 1:20 ` David S. Miller
2003-05-27 1:33 ` Andrea Arcangeli
2003-05-22 14:18 ` James Cleverdon [this message]
2003-05-22 14:43 ` William Lee Irwin III
2003-05-22 15:30 ` James Cleverdon
2003-05-22 15:45 ` William Lee Irwin III
-- strict thread matches above, loose matches on Subject: below --
2003-05-24 1:10 Nakajima, Jun
2003-05-21 16:31 James Bottomley
2003-05-21 20:16 ` Arjan van de Ven
2003-05-20 15:41 Nakajima, Jun
2003-05-21 13:54 ` James Cleverdon
2003-05-21 22:56 ` Zwane Mwaikambo
[not found] <200305191314.06216.pbadari@us.ibm.com>
2003-05-19 22:07 ` Dave Hansen
2003-05-19 22:11 ` Arjan van de Ven
2003-05-19 22:22 ` Dave Hansen
2003-05-20 3:25 ` David S. Miller
2003-05-20 3:46 ` William Lee Irwin III
2003-05-20 5:03 ` Dave Hansen
2003-05-20 5:53 ` Martin J. Bligh
2003-05-20 6:13 ` David S. Miller
2003-05-20 6:36 ` Dave Hansen
2003-05-20 6:40 ` David S. Miller
2003-05-20 14:07 ` Andrew Theurer
2003-05-20 14:21 ` Jeff Garzik
2003-05-20 14:35 ` Andrew Theurer
[not found] ` <20030520.163833.104040023.davem@redhat.com>
2003-05-21 14:58 ` Martin J. Bligh
2003-05-21 22:55 ` David S. Miller
2003-05-21 11:00 ` Kai Bankett
2003-05-20 14:01 ` Martin J. Bligh
2003-05-20 9:00 ` Arjan van de Ven
2003-05-20 9:14 ` William Lee Irwin III
2003-05-20 9:17 ` Andrew Morton
[not found] ` <20030520.172230.102567463.davem@redhat.com>
2003-05-21 14:27 ` James Cleverdon
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=200305220718.06982.jamesclv@us.ibm.com \
--to=jamesclv@us.ibm.com \
--cc=gh@us.ibm.com \
--cc=haveblue@us.ibm.com \
--cc=johnstul@us.ibm.com \
--cc=jun.nakajima@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mannthey@us.ibm.com \
--cc=pbadari@us.ibm.com \
--cc=wli@holomorphy.com \
/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;
as well as URLs for NNTP newsgroup(s).