* [PATCH] skbuff: remove old NET_CALLER macro
@ 2005-04-19 7:44 Stephen Hemminger
2005-04-19 8:04 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2005-04-19 7:44 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
Kill NET_CALLER it causes warnings from sparse and is no longer
necessary.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
diff -urNp -X dontdiff ck-2.6.11/include/linux/skbuff.h net-2.6.11/include/linux/skbuff.h
--- ck-2.6.11/include/linux/skbuff.h 2005-03-02 18:38:38.000000000 +1100
+++ net-2.6.11/include/linux/skbuff.h 2005-04-19 16:59:31.000000000 +1000
@@ -83,12 +83,6 @@
* Any questions? No questions, good. --ANK
*/
-#ifdef __i386__
-#define NET_CALLER(arg) (*(((void **)&arg) - 1))
-#else
-#define NET_CALLER(arg) __builtin_return_address(0)
-#endif
-
struct net_device;
#ifdef CONFIG_NETFILTER
diff -urNp -X dontdiff ck-2.6.11/net/core/skbuff.c net-2.6.11/net/core/skbuff.c
--- ck-2.6.11/net/core/skbuff.c 2005-04-19 17:07:13.000000000 +1000
+++ net-2.6.11/net/core/skbuff.c 2005-04-19 17:31:38.000000000 +1000
@@ -275,9 +275,10 @@ void kfree_skbmem(struct sk_buff *skb)
void __kfree_skb(struct sk_buff *skb)
{
- if (skb->list) {
+ if (unlikely(skb->list)) {
printk(KERN_WARNING "Warning: kfree_skb passed an skb still "
- "on a list (from %p).\n", NET_CALLER(skb));
+ "on a list (from %p).\n",
+ __builtin_return_address(0));
BUG();
}
@@ -285,10 +286,11 @@ void __kfree_skb(struct sk_buff *skb)
#ifdef CONFIG_XFRM
secpath_put(skb->sp);
#endif
- if(skb->destructor) {
+ if (unlikely(skb->destructor)) {
if (in_irq())
printk(KERN_WARNING "Warning: kfree_skb on "
- "hard IRQ %p\n", NET_CALLER(skb));
+ "hard IRQ %p\n",
+ __builtin_return_address(0));
skb->destructor(skb);
}
#ifdef CONFIG_NETFILTER
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] skbuff: remove old NET_CALLER macro
2005-04-19 7:44 [PATCH] skbuff: remove old NET_CALLER macro Stephen Hemminger
@ 2005-04-19 8:04 ` Herbert Xu
2005-04-19 18:35 ` David S. Miller
0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2005-04-19 8:04 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: davem, netdev
Stephen Hemminger <shemminger@osdl.org> wrote:
> --- ck-2.6.11/net/core/skbuff.c 2005-04-19 17:07:13.000000000 +1000
> +++ net-2.6.11/net/core/skbuff.c 2005-04-19 17:31:38.000000000 +1000
> @@ -275,9 +275,10 @@ void kfree_skbmem(struct sk_buff *skb)
>
> void __kfree_skb(struct sk_buff *skb)
> {
> - if (skb->list) {
> + if (unlikely(skb->list)) {
> printk(KERN_WARNING "Warning: kfree_skb passed an skb still "
> - "on a list (from %p).\n", NET_CALLER(skb));
> + "on a list (from %p).\n",
> + __builtin_return_address(0));
> BUG();
Why not turn this if block into a BUG_ON? The return address will be
printed by BUG anyway.
> @@ -285,10 +286,11 @@ void __kfree_skb(struct sk_buff *skb)
> #ifdef CONFIG_XFRM
> secpath_put(skb->sp);
> #endif
> - if(skb->destructor) {
> + if (unlikely(skb->destructor)) {
Are you sure that this is the less common case?
> if (in_irq())
> printk(KERN_WARNING "Warning: kfree_skb on "
> - "hard IRQ %p\n", NET_CALLER(skb));
> + "hard IRQ %p\n",
> + __builtin_return_address(0));
Similarly, This can be turned into a WARN_ON.
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] skbuff: remove old NET_CALLER macro
2005-04-19 8:04 ` Herbert Xu
@ 2005-04-19 18:35 ` David S. Miller
[not found] ` <20050420100457.2444512d@localhost.localdomain>
0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2005-04-19 18:35 UTC (permalink / raw)
To: Herbert Xu; +Cc: shemminger, netdev
On Tue, 19 Apr 2005 18:04:43 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> Why not turn this if block into a BUG_ON? The return address will be
> printed by BUG anyway.
Also, __builtin_return_address(0) does not work reliably on some
platforms, notably MIPS. However, you are making a straight
transformation so you're not making things any worse than before.
Eventually, this belongs in linux/compiler.h as "function_caller()"
or something like that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] skbuff: remove old NET_CALLER macro
[not found] ` <20050420100457.2444512d@localhost.localdomain>
@ 2005-04-20 0:15 ` Herbert Xu
0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2005-04-20 0:15 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David S. Miller, netdev
On Wed, Apr 20, 2005 at 10:04:57AM +1000, Stephen Hemminger wrote:
> Here is a revised alternative that uses BUG_ON/WARN_ON to eliminate
> NET_CALLER.
Looks good. Thanks Stephen.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-04-20 0:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-19 7:44 [PATCH] skbuff: remove old NET_CALLER macro Stephen Hemminger
2005-04-19 8:04 ` Herbert Xu
2005-04-19 18:35 ` David S. Miller
[not found] ` <20050420100457.2444512d@localhost.localdomain>
2005-04-20 0:15 ` Herbert Xu
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).