IPV4 spinlock_casting
Subsystems (2)
PATCH 1/1 IPV4 spinlock_casting
Fix a compile error in net/ipv4/route.c when RT patch is applied:
LD .tmp_vmlinux1
net/built-in.o(.text+0x19058): In function `rt_check_expire':net/ipv4/route.c:628: undefined reference to __bad_spinlock_type' net/built-in.o(.text+0x1907a):net/ipv4/route.c:661: undefined reference to __bad_spinlock_type' net/built-in.o(.text+0x1918b): In function `rt_run_flush':net/ipv4/route.c:684: undefined reference to __bad_spinlock_type' net/built-in.o(.text+0x191a3):net/ipv4/route.c:688: undefined reference to __bad_spinlock_type' net/built-in.o(.text+0x193b9): In function `rt_garbage_collect':net/ipv4/route.c:821: undefined reference to __bad_spinlock_type' net/built-in.o(.text+0x193e7):net/ipv4/route.c:853: more undefined references to __bad_spinlock_type' follow
make: *** [.tmp_vmlinux1] Error 1
Problem is related to the RT PICK_OP function.
Adds explicit casting to spinlock_t (whatever that happens to be for the given .config)
net/ipv4/route.c +13 -13
@@ -228,7 +228,7 @@ rt_hash_locks =kmalloc (sizeof (spinlock_t) *RT_HASH_LOCK_SZ ,GFP_KERNEL ); \if (!rt_hash_locks)panic ("IP: failed to allocate rt_hash_locks\n" ); \for (i =0 ; i <RT_HASH_LOCK_SZ ; i++) \ - spin_lock_init(&rt_hash_locks[i]); \ + spin_lock_init((spinlock_t *) &rt_hash_locks[i]); \ }#else # define rt_hash_lock_addr (slot) NULL
@@ -625,7 +625,7 @@if (*rthp ==0 )continue ; -spin_lock (rt_hash_lock_addr (i)); +spin_lock ((spinlock_t *)rt_hash_lock_addr (i));while ((rth = *rthp) !=NULL ) {if (rth->u.dst.expires) {/* Entry is expired even if it is in use */
@@ -658,7 +658,7 @@rt_free (rth);#endif /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */ } -spin_unlock (rt_hash_lock_addr (i)); +spin_unlock ((spinlock_t *)rt_hash_lock_addr (i));/* Fallback loop breaker. */ if (time_after (jiffies, now))
@@ -681,11 +681,11 @@get_random_bytes (&rt_hash_rnd,4 );for (i = rt_hash_mask; i >=0 ; i--) { -spin_lock_bh (rt_hash_lock_addr (i)); +spin_lock_bh ((spinlock_t *)rt_hash_lock_addr (i)); rth = rt_hash_table[i].chain;if (rth) rt_hash_table[i].chain =NULL ; -spin_unlock_bh (rt_hash_lock_addr (i)); +spin_unlock_bh ((spinlock_t *)rt_hash_lock_addr (i));for (; rth; rth = next) { next = rth->u.rt_next;
@@ -818,7 +818,7 @@ k = (k +1 ) & rt_hash_mask; rthp = &rt_hash_table[k].chain; -spin_lock_bh (rt_hash_lock_addr (k)); +spin_lock_bh ((spinlock_t *)rt_hash_lock_addr (k));while ((rth = *rthp) !=NULL ) {if (!rt_may_expire (rth, tmo, expire)) { tmo >>=1 ;
@@ -850,7 +850,7 @@ goal--;#endif /* CONFIG_IP_ROUTE_MULTIPATH_CACHED */ } -spin_unlock_bh (rt_hash_lock_addr (k)); +spin_unlock_bh ((spinlock_t *)rt_hash_lock_addr (k));if (goal <=0 )break ; }
@@ -920,7 +920,7 @@ rthp = &rt_hash_table[hash].chain; -spin_lock_bh (rt_hash_lock_addr (hash)); +spin_lock_bh ((spinlock_t *)rt_hash_lock_addr (hash));while ((rth = *rthp) !=NULL ) {#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED if (!(rth->u.dst.flags & DST_BALANCED) &&
@@ -946,7 +946,7 @@ rth->u.dst.__use++;dst_hold (&rth->u.dst); rth->u.dst.lastuse = now; -spin_unlock_bh (rt_hash_lock_addr (hash)); +spin_unlock_bh ((spinlock_t *)rt_hash_lock_addr (hash));rt_drop (rt); *rp = rth;
@@ -987,7 +987,7 @@if (rt->rt_type ==RTN_UNICAST || rt->fl.iif ==0 ) {int err =arp_bind_neighbour (&rt->u.dst);if (err) { -spin_unlock_bh (rt_hash_lock_addr (hash)); +spin_unlock_bh ((spinlock_t *)rt_hash_lock_addr (hash));if (err != -ENOBUFS ) {rt_drop (rt);
@@ -1028,7 +1028,7 @@ }#endif rt_hash_table[hash].chain = rt; -spin_unlock_bh (rt_hash_lock_addr (hash)); +spin_unlock_bh ((spinlock_t *)rt_hash_lock_addr (hash)); *rp = rt;return 0 ; }
@@ -1096,7 +1096,7 @@ {struct rtable **rthp; -spin_lock_bh (rt_hash_lock_addr (hash)); +spin_lock_bh ((spinlock_t *)rt_hash_lock_addr (hash));ip_rt_put (rt);for (rthp = &rt_hash_table[hash].chain; *rthp; rthp = &(*rthp)->u.rt_next)
@@ -1105,7 +1105,7 @@rt_free (rt);break ; } -spin_unlock_bh (rt_hash_lock_addr (hash)); +spin_unlock_bh ((spinlock_t *)rt_hash_lock_addr (hash)); } void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
Quoted 3 lines · Sven-Thorsten Dietrich
Fix a compile error in
net/ipv4/route.cwhen RT patch is applied:Index:
linux-2.6.13-rc4-RT-V0.7.52-14/net/ipv4/route.c
are you sure you are seeing this with the -52-14 patch? If yes then please send me your .config.
the build error showed a more fundamental bug, which had to be solved differently. The problem was the code in route.c, the problem was this:
# define rt_hash_lock_addr(slot) NULL # define rt_hash_lock_init()
where NULL has no type. The solution for the build problem would have been to cast the NULL to spinlock_t *, but we need this spinlock so the correct solution was to add a || defined(PREEMPT_RT) to the #if defined(CONFIG_SMP) line above. Solving the build problem alone only fixes the symptom, not the bug.
Ingo
Quoted 10 lines · Ingo Molnar
Quoted 3 lines
Fix a compile error in
net/ipv4/route.cwhen RT patch is applied:Index:
linux-2.6.13-rc4-RT-V0.7.52-14/net/ipv4/route.care you sure you are seeing this with the -52-14 patch? If yes then please send me your .config.
the build error showed a more fundamental bug, which had to be solved differently. The problem was the code in
route.c, the problem was this:
Quoted 8 lines
# define rt_hash_lock_addr(slot) NULL # define rt_hash_lock_init()where NULL has no type. The solution for the build problem would have been to cast the NULL to
spinlock_t*, but we need this spinlock so the correct solution was to add a ||defined(PREEMPT_RT)to the #ifdefined(CONFIG_SMP)line above. Solving the build problem alone only fixes the symptom, not the bug.
it just occured to me that !PREEMPT_RT builds would be affected by the #else branch, so i committed the build fix below into -52-15.
Ingo
net/ipv4/route.c +1 -1
@@ -231,7 +231,7 @@ static spinlock_t *rt_hash_locks; spin_lock_init(&rt_hash_locks[i]); \ }#else -# define rt_hash_lock_addr (slot) NULL +# define rt_hash_lock_addr (slot) ((spinlock_t *)NULL)# define rt_hash_lock_init ()#endif
Quoted 6 lines · Ingo Molnar
it just occured to me that !PREEMPT_RT builds would be affected by the #else branch, so i committed the build fix below into -52-15.
Ingo
That fixes it. Thanks
Sven
Quoted 14 lines
Index:
linux/net/ipv4/route.c
===================================================================net/ipv4/route.c +1
-1@@ -231,7 +231,7 @@ static spinlock_t *rt_hash_locks; spin_lock_init(&rt_hash_locks[i]); \ }#else -# define rt_hash_lock_addr (slot) NULL +# define rt_hash_lock_addr (slot) ((spinlock_t *)NULL)# define rt_hash_lock_init ()#endif