Skip to contentSkip to conversation

Linearized 2.6.33.7-rt30 patch set available (with free coffee!)

DISCUSSION Frank Rowand 2 participants 6 messages Jan 31, 2011 – Feb 1, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Paul,

Thanks for the patch set! I had started down the path of doing the same work, and truly appreciate the effort you put into this.

One of the patches had a chunk that failed to apply:

genirq-support-forced-threading-of-interrupts.patch

patching file kernel/irq/manage.c
Hunk #2 succeeded at 465 (offset 3 lines).
Hunk #3 succeeded at 633 (offset 3 lines).
Hunk #4 succeeded at 706 (offset 3 lines).
Hunk #5 succeeded at 736 (offset 3 lines).
Hunk #6 succeeded at 804 (offset 3 lines).
Hunk #7 FAILED at 829.
1 out of 7 hunks FAILED -- rejects in file kernel/irq/manage.c

I fixed it up and I am attaching the new version of the patch.

With the fixed patch, the kernel source tree with your patches applied matches the kernel source tree with the monolithic 2.6.33.7-rt30 patch applied.

-Frank Rowand

Quoted 1 line

From b23664db5316f231a75007c9cfc3922e797cee2e Mon Sep 17 00:00:00 2001

From: Thomas Gleixner <[email protected]>
Date: Thu, 16 Jul 2009 12:23:12 +0200
Subject: [PATCH] genirq: support forced threading of interrupts

commit 8baf330d664a262b4e6d42728b40e6161ef02183 in tip.

Based on the mainline infrastructure we force thread all interrupts with per device threads.

[PG: put HARDIRQ directly into PFE extra_flags; flatten some other
irq changes buried in merge commits back into this commit.]

---

 include/linux/interrupt.h |   13 	11 +	2 -	0 !
 include/linux/irq.h       |    1 	1 +	0 -	0 !
 include/linux/sched.h     |    1 	1 +	0 -	0 !
 kernel/irq/chip.c         |    1 	1 +	0 -	0 !
 kernel/irq/handle.c       |   26 	25 +	1 -	0 !
 kernel/irq/manage.c       |   97 	90 +	7 -	0 !
 kernel/irq/migration.c    |    3 	2 +	1 -	0 !
 kernel/sched.c            |    3 	2 +	1 -	0 !
 8 files changed, 133 insertions(+), 12 deletions(-)
include/linux/interrupt.h +11 -2
Index: b/include/linux/interrupt.h
===================================================================
@@ -95,6 +95,7 @@ typedef irqreturn_t (*irq_handler_t)(int
  * @thread_fn:	interupt handler function for threaded interrupts
  * @thread:	thread pointer for threaded interrupts
  * @thread_flags:	flags related to @thread
+ * @thread_mask:	bit mask to account for forced threads
  */
 struct irqaction {
 	irq_handler_t handler;
@@ -107,6 +108,7 @@ struct irqaction {
 	irq_handler_t thread_fn;
 	struct task_struct *thread;
 	unsigned long thread_flags;
+	unsigned long thread_mask;
 };
 
 extern irqreturn_t no_action(int cpl, void *dev_id);
@@ -323,6 +325,7 @@ static inline int disable_irq_wake(unsig
 
 #ifndef __ARCH_SET_SOFTIRQ_PENDING
 #define set_softirq_pending(x) (local_softirq_pending() = (x))
+// FIXME: PREEMPT_RT: set_bit()?
 #define or_softirq_pending(x)  (local_softirq_pending() |= (x))
 #endif
 
@@ -371,9 +374,15 @@ struct softirq_action
 	void	(*action)(struct softirq_action *);
 };
 
-#define __raise_softirq_irqoff(nr) \
+#ifdef CONFIG_PREEMPT_HARDIRQS
+# define __raise_softirq_irqoff(nr) raise_softirq_irqoff(nr)
+# define __do_raise_softirq_irqoff(nr) \
 	do { or_softirq_pending(1UL << (nr)); } while (0)
-#define __do_raise_softirq_irqoff(nr) __raise_softirq_irqoff(nr)
+#else
+# define __raise_softirq_irqoff(nr) \
+	do { or_softirq_pending(1UL << (nr)); } while (0)
+# define __do_raise_softirq_irqoff(nr) __raise_softirq_irqoff(nr)
+#endif
 
 asmlinkage void do_softirq(void);
 asmlinkage void __do_softirq(void);
include/linux/irq.h +1 -0
Index: b/include/linux/irq.h
===================================================================
@@ -201,6 +201,7 @@ struct irq_desc {
 #endif
 #endif
 	atomic_t		threads_active;
+	unsigned long		forced_threads_active;
 	wait_queue_head_t       wait_for_threads;
 #ifdef CONFIG_PROC_FS
 	struct proc_dir_entry	*dir;
include/linux/sched.h +1 -0
Index: b/include/linux/sched.h
===================================================================
@@ -1799,6 +1799,7 @@ extern void thread_group_times(struct ta
 
 /* Flags in the extra_flags field */
 #define PFE_SOFTIRQ	0x00000001	/* softirq context */
+#define PFE_HARDIRQ	0x00000002	/* hardirq thread */
 
 /*
  * Only the _current_ task can read/write to tsk->flags, but other
kernel/irq/chip.c +1 -0
Index: b/kernel/irq/chip.c
===================================================================
@@ -309,6 +309,7 @@ static unsigned int default_startup(unsi
 {
 	struct irq_desc *desc = irq_to_desc(irq);
 
+	desc->status &= ~IRQ_MASKED;
 	desc->chip->enable(irq);
 	return 0;
 }
kernel/irq/handle.c +25 -1
Index: b/kernel/irq/handle.c
===================================================================
@@ -360,6 +360,25 @@ static void warn_no_thread(unsigned int 
 	       "but no thread function available.", irq, action->name);
 }
 
+/*
+ * Momentary workaround until I have a brighter idea how to handle the
+ * accounting of forced threaded (shared) handlers.
+ */
+irqreturn_t handle_irq_action(unsigned int irq, struct irqaction *action)
+{
+	struct irq_desc *desc = irq_to_desc(irq);
+
+	if (desc->status & IRQ_ONESHOT) {
+		unsigned long flags;
+
+		raw_spin_lock_irqsave(&desc->lock, flags);
+		desc->forced_threads_active |= action->thread_mask;
+		raw_spin_unlock_irqrestore(&desc->lock, flags);
+		return IRQ_WAKE_THREAD;
+	}
+	return action->handler(irq, action->dev_id);
+}
+
 /**
  * handle_IRQ_event - irq action chain handler
  * @irq:	the interrupt number
@@ -377,7 +396,7 @@ irqreturn_t handle_IRQ_event(unsigned in
 
 	do {
 		trace_irq_handler_entry(irq, action);
-		ret = action->handler(irq, action->dev_id);
+		ret = handle_irq_action(irq, action);
 		trace_irq_handler_exit(irq, action, ret);
 
 		switch (ret) {
@@ -454,6 +473,11 @@ unsigned int __do_IRQ(unsigned int irq)
 	struct irqaction *action;
 	unsigned int status;
 
+#ifdef CONFIG_PREEMPT_RT
+	printk(KERN_WARNING "__do_IRQ called for irq %d. "
+	       "PREEMPT_RT will crash your system soon\n", irq);
+	printk(KERN_WARNING "I hope you have a fire-extinguisher handy!\n");
+#endif
 	kstat_incr_irqs_this_cpu(irq, desc);
 
 	if (CHECK_IRQ_PER_CPU(desc->status)) {
kernel/irq/manage.c +90 -7

141 lines not on this page · raw message

kernel/irq/migration.c +2 -1
Index: b/kernel/irq/migration.c
===================================================================
@@ -66,7 +66,8 @@ void move_native_irq(int irq)
 	 * If the irq is already in progress, it should be masked.
 	 * If we unmask it, we might cause an interrupt storm on RT.
 	 */
-	if (unlikely(desc->status & IRQ_INPROGRESS))
+	if (unlikely((desc->status & IRQ_INPROGRESS) ||
+		     desc->forced_threads_active))
 		mask = 0;
 
 	if (mask)
kernel/sched.c +2 -1
Index: b/kernel/sched.c
===================================================================
@@ -5147,7 +5147,8 @@ void account_system_time(struct task_str
 
 	/* Add system time to cpustat. */
 	tmp = cputime_to_cputime64(cputime);
-	if (hardirq_count() - hardirq_offset)
+	if ((hardirq_count() - hardirq_offset) ||
+	    (p->extra_flags & PFE_HARDIRQ))
 		cpustat->irq = cputime64_add(cpustat->irq, tmp);
 	else if (softirq_count() || (p->extra_flags & PFE_SOFTIRQ))
 		cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
#1 lore raw
Quoted 8 lines · Frank Rowand

Hi Paul,

Thanks for the patch set! I had started down the path of doing the same work, and truly appreciate the effort you put into this.

One of the patches had a chunk that failed to apply:

genirq-support-forced-threading-of-interrupts.patch

Interesting. I was using "git am" to apply them, and I can assure you that they all applied with that (which is quite strict in its checking.)

What were you applying them with?

I'll go re-export the patch and look at the diff of the patch later when I get a chance, but I suspect something else.

Were you using master branch of the patch repo, or the v2.6.33-rt
branch? I've already started moving the master branch ahead towards
2.6.34, so you will definitely get patch failures if you are trying it against a v2.6.33.7 baseline.

Paul.

Quoted 18 lines

patching file kernel/irq/manage.c
Hunk #2 succeeded at 465 (offset 3 lines).
Hunk #3 succeeded at 633 (offset 3 lines).
Hunk #4 succeeded at 706 (offset 3 lines).
Hunk #5 succeeded at 736 (offset 3 lines).
Hunk #6 succeeded at 804 (offset 3 lines).
Hunk #7 FAILED at 829.
1 out of 7 hunks FAILED -- rejects in file kernel/irq/manage.c

I fixed it up and I am attaching the new version of the patch.

With the fixed patch, the kernel source tree with your patches applied matches the kernel source tree with the monolithic 2.6.33.7-rt30 patch applied.

-Frank Rowand

#2 lore raw
Quoted 8 lines · Paul Gortmaker
Quoted 7 lines · Frank Rowand

Hi Paul,

Thanks for the patch set! I had started down the path of doing the same work, and truly appreciate the effort you put into this.

One of the patches had a chunk that failed to apply:

Quoted 7 lines
Quoted 1 line

genirq-support-forced-threading-of-interrupts.patch

Interesting. I was using "git am" to apply them, and I can assure you that they all applied with that (which is quite strict in its checking.)

What were you applying them with?

quilt push -a

Quoted 3 lines

I'll go re-export the patch and look at the diff of the patch later when I get a chance, but I suspect something else.

Here is the hunk:

@@ -742,10 +743,6 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)

                rand_initialize_irq(irq);
        }

- /* Oneshot interrupts are not allowed with shared */
- if ((new->flags & IRQF_ONESHOT) && (new->flags & IRQF_SHARED))
- return -EINVAL;
-

        /* Preempt-RT setup for forced threading */
        preempt_hardirq_setup(new);

The problem is that the text after the deleted lines did not exist:

        /* Preempt-RT setup for forced threading */
        preempt_hardirq_setup(new);

The text that did exist is:

        /*
         * Check whether the interrupt nests into another interrupt
         * thread.
         */
        nested = desc->status & IRQ_NESTED_THREAD;
Quoted 2 lines

Were you using master branch of the patch repo, or the v2.6.33-rt

I used the master branch, as of:
commit 9638db087a2b51cccb7dd73d29bced849c7c5765
Mon Jan 24 00:12:32 2011 -0500

Quoted 26 lines

branch? I've already started moving the master branch ahead towards
2.6.34, so you will definitely get patch failures if you are trying it against a v2.6.33.7 baseline.

Paul.

Quoted 18 lines

patching file kernel/irq/manage.c
Hunk #2 succeeded at 465 (offset 3 lines).
Hunk #3 succeeded at 633 (offset 3 lines).
Hunk #4 succeeded at 706 (offset 3 lines).
Hunk #5 succeeded at 736 (offset 3 lines).
Hunk #6 succeeded at 804 (offset 3 lines).
Hunk #7 FAILED at 829.
1 out of 7 hunks FAILED -- rejects in file kernel/irq/manage.c

I fixed it up and I am attaching the new version of the patch.

With the fixed patch, the kernel source tree with your patches applied matches the kernel source tree with the monolithic 2.6.33.7-rt30 patch applied.

-Frank Rowand

#3 lore raw
Quoted 11 lines · Frank Rowand
Quoted 10 lines · Paul Gortmaker
Quoted 8 lines · Frank Rowand

Hi Paul,

Thanks for the patch set! I had started down the path of doing the same work, and truly appreciate the effort you put into this.

One of the patches had a chunk that failed to apply:

genirq-support-forced-threading-of-interrupts.patch

Quoted 7 lines
Quoted 5 lines

Interesting. I was using "git am" to apply them, and I can assure you that they all applied with that (which is quite strict in its checking.)

What were you applying them with?

quilt push -a

OK, so it is simply a matter of quilt dying while git am is capable of doing the right thing (see below for evidence). I'll re-export all the patches on the v2.6.33-rt branch, which will fix you up. Should be able to do that shortly -- check the gitweb page for activity on the v2.6.33-rt branch, which is what you want to use.

You do realize that by using quilt though, that you are throwing away all the commit headers and the history, which is the whole point of
this tree existing? You are just building up the original RT giant
diff one chunk at a time. Unless you are thinking or intending to insert some other SCM into the quilt processing at each step, I don't see the point of using quilt and doing a "push -a"

Assuming you aren't doing this for integration with another SCM, if you simply replace quilt with something as simple as this $0.02 script, you will keep the history intact:

----------------------------------------
#!/bin/bash
SERIES=$1

if [ -z "$SERIES" ]; then
echo need a series file
exit 1
fi

DIR=dirname $SERIES

for i in cat $SERIES | grep '^[a-zA-Z0-9_]'
do
git am $DIR/$i
if [ $? != 0 ];then
echo git am of $i failed. STBU.
exit 1
fi
done
----------------------------------------------------

The above is essentially a dumbed-down version of git quiltimport (i.e. no possibility of author or subject munging.)

There is also "guilt", which is essentially quilt, but with a git commit for each changeset -- something you might want to evaluate for your own needs.

Paul.

---

tip-debare$git checkout quilt-junk
Switched to branch 'quilt-junk'
tip-debare$git am patches/genirq-support-forced-threading-of-interrupts.patch
Applying: genirq: support forced threading of interrupts

(git am is happy, now rewind/pop that commit and retry with quilt)

tip-debare$git reset --hard HEAD^
HEAD is now at fd659fd7 quilt-junk
tip-debare$quilt push
Applying patch genirq-support-forced-threading-of-interrupts.patch
patching file include/linux/interrupt.h
patching file include/linux/irq.h
patching file include/linux/sched.h
patching file kernel/irq/chip.c
patching file kernel/irq/handle.c
patching file kernel/irq/manage.c
Hunk #2 succeeded at 465 (offset 3 lines).
Hunk #3 succeeded at 633 (offset 3 lines).
Hunk #4 succeeded at 706 (offset 3 lines).
Hunk #5 succeeded at 736 (offset 3 lines).
Hunk #6 succeeded at 804 (offset 3 lines).
Hunk #7 FAILED at 829.
1 out of 7 hunks FAILED -- rejects in file kernel/irq/manage.c
patching file kernel/irq/migration.c
patching file kernel/sched.c
Hunk #1 succeeded at 5147 (offset 3 lines).
Patch genirq-support-forced-threading-of-interrupts.patch does not apply (enforce with -f) tip-debare$

#4 lore raw
Quoted 18 lines · Paul Gortmaker
Quoted 17 lines · Frank Rowand
Quoted 15 lines · Paul Gortmaker
Quoted 8 lines · Frank Rowand

Hi Paul,

Thanks for the patch set! I had started down the path of doing the same work, and truly appreciate the effort you put into this.

One of the patches had a chunk that failed to apply:

genirq-support-forced-threading-of-interrupts.patch

Interesting. I was using "git am" to apply them, and I can assure you that they all applied with that (which is quite strict in its checking.)

What were you applying them with?

Quoted 7 lines
Quoted 1 line

quilt push -a

OK, so it is simply a matter of quilt dying while git am is capable of doing the right thing (see below for evidence). I'll re-export all the patches on the v2.6.33-rt branch, which will fix you up. Should be able to do that shortly -- check the gitweb page for activity on the v2.6.33-rt branch, which is what you want to use.

I'll watch for that and check it again.

Quoted 4 lines

You do realize that by using quilt though, that you are throwing away all the commit headers and the history, which is the whole point of this tree existing?

Yes. I do find great value in the history -- it is very informative.

Quoted 4 lines

You are just building up the original RT giant
diff one chunk at a time. Unless you are thinking or intending to insert some other SCM into the quilt processing at each step, I don't see the point of using quilt and doing a "push -a"

I wasn't to the point yet of importing the patches into an SCM. I was just checking that the patches applied and that they are equivalent to the patch set you started with. Think of it as a simple consistency and paranoia check that a reviewer would do.

I used quilt because it is a trivial manual method of applying all the patches, since they are nicely listed in the proper order in the series file.

-Frank

#5 lore raw
In reply to Paul Gortmaker

On 01/31/11 15:35, Paul Gortmaker wrote:

< snip >

Quoted 2 lines

OK, so it is simply a matter of quilt dying while git am is capable of doing the right thing (see below for evidence).

< snip >

Yes, when I use git am I get the same result that you show here:

Quoted 6 lines

tip-debare$git checkout quilt-junk
Switched to branch 'quilt-junk'
tip-debare$git am patches/genirq-support-forced-threading-of-interrupts.patch
Applying: genirq: support forced threading of interrupts

(git am is happy,

Yes, git am somehow managed to apply the patch cleanly.

If at this point you do

git show >junk
diff junk patches/genirq-support-forced-threading-of-interrupts.patch

you will see that the patch as applied by git am has cleaned up the problem with the original patch. Pretty cool magic...

Quoted 16 lines

now rewind/pop that commit and retry with quilt)

tip-debare$git reset --hard HEAD^
HEAD is now at fd659fd7 quilt-junk
tip-debare$quilt push
Applying patch genirq-support-forced-threading-of-interrupts.patch patching file include/linux/interrupt.h
patching file include/linux/irq.h
patching file include/linux/sched.h
patching file kernel/irq/chip.c
patching file kernel/irq/handle.c
patching file kernel/irq/manage.c
Hunk #2 succeeded at 465 (offset 3 lines).
Hunk #3 succeeded at 633 (offset 3 lines).
Hunk #4 succeeded at 706 (offset 3 lines).
Hunk #5 succeeded at 736 (offset 3 lines).

Quoted 8 lines

Hunk #6 succeeded at 804 (offset 3 lines).
Hunk #7 FAILED at 829.
1 out of 7 hunks FAILED -- rejects in file kernel/irq/manage.c
patching file kernel/irq/migration.c
patching file kernel/sched.c
Hunk #1 succeeded at 5147 (offset 3 lines).
Patch genirq-support-forced-threading-of-interrupts.patch does not apply (enforce with -f) tip-debare$

Again, I get the same result. And I get the same "Hunk #7 FAILED" with

  patch --dry-run -p1 < patches/genirq-support-forced-threading-of-interrupts.patch

-Frank