: (2.5 latest) More __builtin_expect() cleanup in
There you are Rusty, i've made the changes as suggested, verified it patches with -p1 . Patch attached.
Quoted 15 lines · Rusty Russell
In message <[email protected]> you write:
Quoted 4 lines
Copying Rusty as well.
Changed files in the
include/asm-ia64directory to get rid of__builtin_expect()in favour of likely/unlikely.Hi Manik,
You got a reject because these patches do not apply with -p1
(diffs should be taken from one level, furthur down as Linux norm).The other issue is:
Quoted 1 line
- if (!__builtin_expect (
current->mm->dumpable, 1)) {\
Quoted 8 lines
Quoted 1 line
+ if (!likely (
current->mm->dumpable)) {if (
unlikely(!current->mm->dumpable)), please!Thanks,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
include/asm-ia64/delay.h +2 -1
@@ -15,6 +15,7 @@#include <linux/config.h> #include <linux/kernel.h> #include <linux/sched.h> +#include <linux/compiler.h> #include <asm/processor.h>
@@ -52,7 +53,7 @@ __asm__ __volatile__("mov %0=ar.itc" :"=r" (result) ::"memory" );#ifdef CONFIG_ITANIUM -while (__builtin_expect ((__s32 ) result ==-1 ,0 )) + while (unlikely((__s32) result == -1) __asm__ __volatile__("mov %0=ar.itc" :"=r" (result) ::"memory" );#endif return result;
include/asm-ia64/pgalloc.h +8 -7
@@ -17,6 +17,7 @@#include <linux/mm.h> #include <linux/threads.h> +#include <linux/compiler.h> #include <asm/mmu_context.h> #include <asm/processor.h>
@@ -37,7 +38,7 @@ {unsigned long *ret = pgd_quicklist; -if (__builtin_expect (ret !=NULL ,1 )) { +if (likely (ret !=NULL )) { pgd_quicklist = (unsigned long *)(*ret); ret[0 ] =0 ; --pgtable_cache_size;
@@ -52,9 +53,9 @@/* the VM system never calls pgd_alloc_one_fast(), so we do it here. */ pgd_t *pgd =pgd_alloc_one_fast (mm); -if (__builtin_expect (pgd ==NULL ,0 )) { +if (unlikely (pgd ==NULL )) { pgd = (pgd_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pgd !=NULL ,1 )) +if (likely (pgd !=NULL ))clear_page (pgd); }return pgd;
@@ -80,7 +81,7 @@ {unsigned long *ret = (unsigned long *)pmd_quicklist; -if (__builtin_expect (ret !=NULL ,1 )) { +if (likely (ret !=NULL )) { pmd_quicklist = (unsigned long *)(*ret); ret[0 ] =0 ; --pgtable_cache_size;
@@ -93,7 +94,7 @@ {pmd_t *pmd = (pmd_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pmd !=NULL ,1 )) +if (likely (pmd !=NULL ))clear_page (pmd);return pmd; }
@@ -125,7 +126,7 @@ {struct page *pte =alloc_pages (GFP_KERNEL ,0 ); -if (__builtin_expect (pte !=NULL ,1 )) +if (likely (pte !=NULL ))clear_page (page_address (pte));return pte; }
@@ -135,7 +136,7 @@ {pte_t *pte = (pte_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pte !=NULL ,1 )) +if (likely (pte !=NULL ))clear_page (pte);return pte; }
include/asm-ia64/processor.h +2 -1
@@ -16,6 +16,7 @@#include <linux/config.h> #include <linux/percpu.h> +#include <linux/compiler.h> #include <asm/ptrace.h> #include <asm/kregs.h>
@@ -283,7 +284,7 @@ regs->loadrs =0 ; \ regs->r8 = current->mm->dumpable;/* set "don't zap registers" flag */ \ regs->r12 = new_sp -16 ;/* allocate 16 byte scratch area */ \ -if (!__builtin_expect (current->mm->dumpable,1 )) { \ +if (unlikely (!current->mm->dumpable)) { \/* \ * Zap scratch regs to avoid leaking bits between processes with different \ * uid/privileges. \
include/asm-ia64/softirq.h +1 -1
@@ -13,7 +13,7 @@#define local_bh_enable () \ do { \ __local_bh_enable(); \ - if (__builtin_expect(local_softirq_pending(), 0) && really_local_bh_count() == 0) \ + if (unlikely(local_softirq_pending()) && really_local_bh_count() == 0) \ do_softirq(); \ } while (0)
include/asm-ia64/softirq.h Fri Jun 21 10:44:05 2002 line 19
Quoted 13 lines · Manik Raina
diff -u -r
linux-2.5.22/include/asm-ia64/softirq.hreal/include/asm-ia64/softirq.hinclude/asm-ia64/softirq.h Fri Jun 21 10:44:05 2002 renamed from include/asm-ia64/softirq.h Mon Jun 17 08:01:35 2002 +1
-1@@ -13,7 +13,7 @@ #define local_bh_enable() \ do { \ __local_bh_enable(); \ - if (__builtin_expect(local_softirq_pending(), 0) && really_local_bh_count() = 0) \ + if (unlikely(local_softirq_pending()) && really_local_bh_count() = 0) \ do_softirq(); \ } while (0)
I don't think softirq.h includes linux/compiler.h . Can you please include that ?
Latest diffs attached ...
Quoted 18 lines · Manik Raina
include/asm-ia64/softirq.h Fri Jun 21 10:44:05 2002 line 19
Quoted 13 lines · Manik Raina
diff -u -r
linux-2.5.22/include/asm-ia64/softirq.hreal/include/asm-ia64/softirq.hinclude/asm-ia64/softirq.h Fri Jun 21 10:44:05 2002 renamed from include/asm-ia64/softirq.h Mon Jun 17 08:01:35 2002 +1
-1@@ -13,7 +13,7 @@ #define local_bh_enable() \ do { \ __local_bh_enable(); \ - if (__builtin_expect(local_softirq_pending(), 0) && really_local_bh_count() == 0) \ + if (unlikely(local_softirq_pending()) && really_local_bh_count() == 0) \ do_softirq(); \ } while (0)I don't think
softirq.hincludeslinux/compiler.h. Can you please include that ?
include/asm-ia64/delay.h +2 -1
@@ -15,6 +15,7 @@#include <linux/config.h> #include <linux/kernel.h> #include <linux/sched.h> +#include <linux/compiler.h> #include <asm/processor.h>
@@ -52,7 +53,7 @@ __asm__ __volatile__("mov %0=ar.itc" :"=r" (result) ::"memory" );#ifdef CONFIG_ITANIUM -while (__builtin_expect ((__s32 ) result ==-1 ,0 )) + while (unlikely((__s32) result == -1) __asm__ __volatile__("mov %0=ar.itc" :"=r" (result) ::"memory" );#endif return result;
include/asm-ia64/pgalloc.h +8 -7
@@ -17,6 +17,7 @@#include <linux/mm.h> #include <linux/threads.h> +#include <linux/compiler.h> #include <asm/mmu_context.h> #include <asm/processor.h>
@@ -37,7 +38,7 @@ {unsigned long *ret = pgd_quicklist; -if (__builtin_expect (ret !=NULL ,1 )) { +if (likely (ret !=NULL )) { pgd_quicklist = (unsigned long *)(*ret); ret[0 ] =0 ; --pgtable_cache_size;
@@ -52,9 +53,9 @@/* the VM system never calls pgd_alloc_one_fast(), so we do it here. */ pgd_t *pgd =pgd_alloc_one_fast (mm); -if (__builtin_expect (pgd ==NULL ,0 )) { +if (unlikely (pgd ==NULL )) { pgd = (pgd_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pgd !=NULL ,1 )) +if (likely (pgd !=NULL ))clear_page (pgd); }return pgd;
@@ -80,7 +81,7 @@ {unsigned long *ret = (unsigned long *)pmd_quicklist; -if (__builtin_expect (ret !=NULL ,1 )) { +if (likely (ret !=NULL )) { pmd_quicklist = (unsigned long *)(*ret); ret[0 ] =0 ; --pgtable_cache_size;
@@ -93,7 +94,7 @@ {pmd_t *pmd = (pmd_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pmd !=NULL ,1 )) +if (likely (pmd !=NULL ))clear_page (pmd);return pmd; }
@@ -125,7 +126,7 @@ {struct page *pte =alloc_pages (GFP_KERNEL ,0 ); -if (__builtin_expect (pte !=NULL ,1 )) +if (likely (pte !=NULL ))clear_page (page_address (pte));return pte; }
@@ -135,7 +136,7 @@ {pte_t *pte = (pte_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pte !=NULL ,1 )) +if (likely (pte !=NULL ))clear_page (pte);return pte; }
include/asm-ia64/processor.h +2 -1
@@ -16,6 +16,7 @@#include <linux/config.h> #include <linux/percpu.h> +#include <linux/compiler.h> #include <asm/ptrace.h> #include <asm/kregs.h>
@@ -283,7 +284,7 @@ regs->loadrs =0 ; \ regs->r8 = current->mm->dumpable;/* set "don't zap registers" flag */ \ regs->r12 = new_sp -16 ;/* allocate 16 byte scratch area */ \ -if (!__builtin_expect (current->mm->dumpable,1 )) { \ +if (unlikely (!current->mm->dumpable)) { \/* \ * Zap scratch regs to avoid leaking bits between processes with different \ * uid/privileges. \
include/asm-ia64/softirq.h +2 -1
@@ -6,6 +6,7 @@* David Mosberger-Tang <[email protected]> */ #include <asm/hardirq.h> +#include <linux/compiler.h> #define __local_bh_enable () do { barrier(); really_local_bh_count()--; } while (0)
@@ -13,7 +14,7 @@#define local_bh_enable () \ do { \ __local_bh_enable(); \ - if (__builtin_expect(local_softirq_pending(), 0) && really_local_bh_count() == 0) \ + if (unlikely(local_softirq_pending()) && really_local_bh_count() == 0) \ do_softirq(); \ } while (0)
Re: [Linux-ia64] Re: [Trivial Patch] : (2.5 latest) More
In reply to Manik RainaManik Raina <[email protected]> writes:
|> diff -u -r linux-2.5.22/include/asm-ia64/delay.h linux-likely-patch/include/asm-ia64/delay.h
|> --- linux-2.5.22/include/asm-ia64/delay.h Mon Jun 17 08:01:23 2002
|> +++ linux-likely-patch/include/asm-ia64/delay.h Fri Jun 21 11:18:00 2002
|> @@ -15,6 +15,7 @@
|> #include <linux/config.h>
|> #include <linux/kernel.h>
|> #include <linux/sched.h>
|> +#include <linux/compiler.h>
|>
|> #include <asm/processor.h>
|>
|> @@ -52,7 +53,7 @@
|>
|> __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
|> #ifdef CONFIG_ITANIUM
|> - while (__builtin_expect ((__s32) result = -1, 0))
|> + while (unlikely((__s32) result = -1)This doesn't compile, it lacks a paren.
Andreas.
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [Linux-ia64] Re: [Trivial Patch] : (2.5 latest)
In reply to Manik Rainathanks, new diffs attached
Quoted 23 lines · Andreas Schwab
Manik Raina <[email protected]> writes:
|> diff -u -r linux-2.5.22/include/asm-ia64/delay.h linux-likely-patch/include/asm-ia64/delay.h |> --- linux-2.5.22/include/asm-ia64/delay.h Mon Jun 17 08:01:23 2002 |> +++ linux-likely-patch/include/asm-ia64/delay.h Fri Jun 21 11:18:00 2002 |> @@ -15,6 +15,7 @@ |> #include <linux/config.h> |> #include <linux/kernel.h> |> #include <linux/sched.h> |> +#include <linux/compiler.h> |> |> #include <asm/processor.h> |> |> @@ -52,7 +53,7 @@ |> |> __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); |> #ifdef CONFIG_ITANIUM |> - while (__builtin_expect ((__s32) result == -1, 0)) |> + while (unlikely((__s32) result == -1)This doesn't compile, it lacks a paren.
Quoted 7 lines
Andreas.
--
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
include/asm-ia64/delay.h +2 -1
@@ -15,6 +15,7 @@#include <linux/config.h> #include <linux/kernel.h> #include <linux/sched.h> +#include <linux/compiler.h> #include <asm/processor.h>
@@ -52,7 +53,7 @@ __asm__ __volatile__("mov %0=ar.itc" :"=r" (result) ::"memory" );#ifdef CONFIG_ITANIUM -while (__builtin_expect ((__s32 ) result ==-1 ,0 )) +while (unlikely ((__s32 ) result ==-1 )) __asm__ __volatile__("mov %0=ar.itc" :"=r" (result) ::"memory" );#endif return result;
include/asm-ia64/pgalloc.h +8 -7
@@ -17,6 +17,7 @@#include <linux/mm.h> #include <linux/threads.h> +#include <linux/compiler.h> #include <asm/mmu_context.h> #include <asm/processor.h>
@@ -37,7 +38,7 @@ {unsigned long *ret = pgd_quicklist; -if (__builtin_expect (ret !=NULL ,1 )) { +if (likely (ret !=NULL )) { pgd_quicklist = (unsigned long *)(*ret); ret[0 ] =0 ; --pgtable_cache_size;
@@ -52,9 +53,9 @@/* the VM system never calls pgd_alloc_one_fast(), so we do it here. */ pgd_t *pgd =pgd_alloc_one_fast (mm); -if (__builtin_expect (pgd ==NULL ,0 )) { +if (unlikely (pgd ==NULL )) { pgd = (pgd_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pgd !=NULL ,1 )) +if (likely (pgd !=NULL ))clear_page (pgd); }return pgd;
@@ -80,7 +81,7 @@ {unsigned long *ret = (unsigned long *)pmd_quicklist; -if (__builtin_expect (ret !=NULL ,1 )) { +if (likely (ret !=NULL )) { pmd_quicklist = (unsigned long *)(*ret); ret[0 ] =0 ; --pgtable_cache_size;
@@ -93,7 +94,7 @@ {pmd_t *pmd = (pmd_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pmd !=NULL ,1 )) +if (likely (pmd !=NULL ))clear_page (pmd);return pmd; }
@@ -125,7 +126,7 @@ {struct page *pte =alloc_pages (GFP_KERNEL ,0 ); -if (__builtin_expect (pte !=NULL ,1 )) +if (likely (pte !=NULL ))clear_page (page_address (pte));return pte; }
@@ -135,7 +136,7 @@ {pte_t *pte = (pte_t *)__get_free_page (GFP_KERNEL ); -if (__builtin_expect (pte !=NULL ,1 )) +if (likely (pte !=NULL ))clear_page (pte);return pte; }
include/asm-ia64/processor.h +2 -1
@@ -16,6 +16,7 @@#include <linux/config.h> #include <linux/percpu.h> +#include <linux/compiler.h> #include <asm/ptrace.h> #include <asm/kregs.h>
@@ -283,7 +284,7 @@ regs->loadrs =0 ; \ regs->r8 = current->mm->dumpable;/* set "don't zap registers" flag */ \ regs->r12 = new_sp -16 ;/* allocate 16 byte scratch area */ \ -if (!__builtin_expect (current->mm->dumpable,1 )) { \ +if (unlikely (!current->mm->dumpable)) { \/* \ * Zap scratch regs to avoid leaking bits between processes with different \ * uid/privileges. \
include/asm-ia64/softirq.h +2 -1
@@ -6,6 +6,7 @@* David Mosberger-Tang <[email protected]> */ #include <asm/hardirq.h> +#include <linux/compiler.h> #define __local_bh_enable () do { barrier(); really_local_bh_count()--; } while (0)
@@ -13,7 +14,7 @@#define local_bh_enable () \ do { \ __local_bh_enable(); \ - if (__builtin_expect(local_softirq_pending(), 0) && really_local_bh_count() == 0) \ + if (unlikely(local_softirq_pending()) && really_local_bh_count() == 0) \ do_softirq(); \ } while (0)