Skip to contentSkip to conversation

Preemption patch for 2.4 Kernels

BUG Gerhard Jaeger 3 participants 4 messages Oct 7, 2004

lore
Share & tools
lore
#0 lore raw

Hi Robert,

maybe the 2.4 series is somewhat outdatet, but nevertheless used in several embedded systems and also with your preemption patches. During some investigations, we found out that the patches found on
http://www.kernel.org/pub/linux/kernel/people/rml/preempt-kernel/
contain a severe bug, when using the patches on PPC systems. The affected function is get_pgd_fast() which is buried in include/asm-ppc/pgalloc.h

While the original function looks like:
extern __inline__ pgd_t *get_pgd_fast(void)

{
        unsigned long *ret;

        if ((ret = pgd_quicklist) != NULL) {
                pgd_quicklist = (unsigned long *)(*ret);
                ret[0] = 0;
                pgtable_cache_size--;
        } else
                ret = (unsigned long *)get_pgd_slow();
        return (pgd_t *)ret;
}

the patched one is:
extern __inline__ pgd_t *get_pgd_fast(void)

{
        unsigned long *ret;

        preempt_disable();
        if ((ret = pgd_quicklist) != NULL) {
                pgd_quicklist = (unsigned long *)(*ret);
                ret[0] = 0;
                pgtable_cache_size--;
                preempt_enable();
        } else 
                preempt_enable();
                ret = (unsigned long *)get_pgd_slow();
        return (pgd_t *)ret;
}

And exactly the "else" path causes the problems ;) I guess it should be

       } else {
                preempt_enable();
                ret = (unsigned long *)get_pgd_slow();
       }

The attached patch will do it the right way, and you might want to correct the patches on your web-space.

Best regards,
Gerhard Jaeger

Signature · 3 lines
Gerhard Jaeger <[email protected]>            
SYSGO AG                      Embedded and Real-Time Software
www.sysgo.com | www.elinos.com | www.osek.de | www.imerva.com
pgalloc.h renamed from pgalloc.h.orig +11 -1
@@ -72,20 +72,26 @@ extern __inline__ pgd_t *get_pgd_fast(vo
 {
         unsigned long *ret;
 
+	preempt_disable();
         if ((ret = pgd_quicklist) != NULL) {
                 pgd_quicklist = (unsigned long *)(*ret);
                 ret[0] = 0;
                 pgtable_cache_size--;
-        } else
+		preempt_enable();
+        } else {
+		preempt_enable();
                 ret = (unsigned long *)get_pgd_slow();
+        }
         return (pgd_t *)ret;
 }
 
 extern __inline__ void free_pgd_fast(pgd_t *pgd)
 {
+	preempt_disable();
         *(unsigned long **)pgd = pgd_quicklist;
         pgd_quicklist = (unsigned long *) pgd;
         pgtable_cache_size++;
+	preempt_enable();
 }
 
 extern __inline__ void free_pgd_slow(pgd_t *pgd)
@@ -124,19 +130,23 @@ static inline pte_t *pte_alloc_one_fast(
 {
         unsigned long *ret;
 
+	preempt_disable();
         if ((ret = pte_quicklist) != NULL) {
                 pte_quicklist = (unsigned long *)(*ret);
                 ret[0] = 0;
                 pgtable_cache_size--;
 	}
+	preempt_enable();
         return (pte_t *)ret;
 }
 
 extern __inline__ void pte_free_fast(pte_t *pte)
 {
+	preempt_disable();
         *(unsigned long **)pte = pte_quicklist;
         pte_quicklist = (unsigned long *) pte;
         pgtable_cache_size++;
+	preempt_enable();
 }
 
 extern __inline__ void pte_free_slow(pte_t *pte)
#1 lore raw
Quoted 5 lines · Gerhard Jaeger

maybe the 2.4 series is somewhat outdatet, but nevertheless used in several embedded systems and also with your preemption patches. During some investigations, we found out that the patches found on
http://www.kernel.org/pub/linux/kernel/people/rml/preempt-kernel/
contain a severe bug, when using the patches on PPC systems.

Yes, it's a known problem with rml preempt patches - DON'T USE THEM on PPC. I sent him similar patch _two_ years ago - nothing happened. MVL tree is IMHO better place to get preempt stuff for 2.4 - it's actually tested and works.

Also, I wish -embedded archives were online, this problem was discussed there around a year ago as well.

--
Eugene

#3 lore raw
In reply to Jaap-Jan Boor
Quoted 10 lines · Jaap-Jan Boor
Quoted 7 lines · Eugene Surovegin
Quoted 5 lines · Gerhard Jaeger

maybe the 2.4 series is somewhat outdatet, but nevertheless used in several embedded systems and also with your preemption patches. During some investigations, we found out that the patches found on
http://www.kernel.org/pub/linux/kernel/people/rml/preempt-kernel/
contain a severe bug, when using the patches on PPC systems.

Quoted 7 lines
Quoted 4 lines

Yes, it's a known problem with rml preempt patches - DON'T USE THEM on PPC. I sent him similar patch _two_ years ago - nothing happened. MVL tree is IMHO better place to get preempt stuff for 2.4 - it's actually tested and works.

yes, because there are more changes then only the forgotten '{'

You're right, there were other (not so obvious) problems which rml patch (like preempt_enable_no_resched() in irq.c::preempt_intercept()), maybe others I don't remember now)...

--
Eugene

#2 lore raw
In reply to Eugene Surovegin
Quoted 11 lines · Eugene Surovegin
Quoted 5 lines · Gerhard Jaeger

maybe the 2.4 series is somewhat outdatet, but nevertheless used in several embedded systems and also with your preemption patches. During some investigations, we found out that the patches found on
http://www.kernel.org/pub/linux/kernel/people/rml/preempt-kernel/
contain a severe bug, when using the patches on PPC systems.

Yes, it's a known problem with rml preempt patches - DON'T USE THEM on PPC. I sent him similar patch _two_ years ago - nothing happened. MVL tree is IMHO better place to get preempt stuff for 2.4 - it's actually tested and works.

yes, because there are more changes then only the forgotten '{'

Jaap-Jan

Quoted 10 lines

Also, I wish -embedded archives were online, this problem was discussed there around a year ago as well.

--
Eugene
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev