All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira <pablo@eurodev.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@redhat.com>, netdev@oss.sgi.com
Subject: Re: [PATCH] Improve behaviour of Netlink Sockets
Date: Sun, 19 Sep 2004 22:47:26 +0200	[thread overview]
Message-ID: <414DF05E.7020601@eurodev.net> (raw)
In-Reply-To: <E1C8way-0000aH-00@gondolin.me.apana.org.au>

[-- Attachment #1: Type: text/plain, Size: 2013 bytes --]

Hi Herbert,

Herbert Xu wrote:

>Unfortunately it is still wrong.  You missed the exit path at the
>very top.
>  
>

if netlink_broadcast_deliver returns 0, you decrease sock_put. On the 
other hand if it returns 1, refcount will be decreased by the workqueue 
handler or after calling the callback. I don't see that exit path.

>And I think rather than adding all these new sock_put's, it's much
>better to do what you mean and add a sock_hold on the new path that
>you introduced.
>  
>

yes, it's true that all those sock_put pollutes the source code, I like 
your idea of add a sock_hold, please could you have a look at the patch 
attached? it's basically your patch plus netlink_broadcast_deliver 
revised return value. If you are ok with it, let me know.

>Yes but your patch does a lot more than that wake_up_process.  Have you
>reverted just the wake_up_process and seen a difference?
>  
>

Yes, it works as well so we could remove it, but I got some extra 
throughput with the wake_up_process call if I send something up to 500 
consecutive messages from kernel to user space. For more than 1000 I 
notice that throughput is similar without wake_up_process, I'll study 
the performance without wake_up_process if it's not a good idea using it 
as you think.

>That's not what I meant.  If you have a thread group where everybody's
>got the same pid, your code will probably wake up the wrong thread.
>  
>

no, my patch doesn't wake up the user process with broadcast sockets, 
snipped from broadcast_deliver:

        if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf &&
            !test_bit(0, &nlk->state)) {
             [...]
       }
       return 0;

it returns zero then socket overruns.

>Besides, for any netlink socket but the first for a process, they'll
>all have negative pid's which have nothing to do with the real pid.
>So I really think that the wake_up_process hunk is bogus.
>  
>

same reply as above, we don't wake up the user process with broadcast 
sockets.

regards,
Pablo

[-- Attachment #2: nl-fix-2.6.patch --]
[-- Type: text/x-patch, Size: 969 bytes --]

diff -u -r1.3 af_netlink.c
--- a/net/netlink/af_netlink.c	19 Sep 2004 19:46:20 -0000	1.3
+++ b/net/netlink/af_netlink.c	19 Sep 2004 20:04:44 -0000
@@ -629,8 +629,9 @@
 				kmalloc(sizeof(struct netlink_work), GFP_KERNEL);
 
 			if (!nlwork)
-				return -1;
-		
+				return 0;
+
+			sock_hold(sk);
 			INIT_WORK(&nlwork->work, netlink_wq_handler, nlwork);
 			nlwork->sk = sk;
 			nlwork->len = skb->len;
@@ -638,9 +639,9 @@
 		} else 
 			sk->sk_data_ready(sk, skb->len);
 
-		return 0;
+		return 1;
 	}
-	return -1;
+	return 0;
 }
 
 int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid,
@@ -683,14 +684,13 @@
 			netlink_overrun(sk);
 			/* Clone failed. Notify ALL listeners. */
 			failure = 1;
-			sock_put(sk);
 		} else if (netlink_broadcast_deliver(sk, skb2)) {
-			netlink_overrun(sk);
-			sock_put(sk);
-		} else {
 			delivered = 1;
 			skb2 = NULL;
-		}
+		} else 
+			netlink_overrun(sk);
+
+		sock_put(sk);
 	}
 
 	netlink_unlock_table();

  parent reply	other threads:[~2004-09-19 20:47 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <412DF807.2040703@eurodev.net>
     [not found] ` <20040826141407.38b56729.davem@redhat.com>
     [not found]   ` <412EB40A.6010100@eurodev.net>
     [not found]     ` <20040826214710.5e322f1a.davem@redhat.com>
     [not found]       ` <412F1269.8090303@eurodev.net>
     [not found]         ` <20040827172736.543dbd54.davem@redhat.com>
2004-08-30  0:37           ` [PATCH] Improve behaviour of Netlink Sockets Pablo Neira
2004-08-31  0:20             ` David S. Miller
2004-08-31 16:37               ` Pablo Neira
2004-08-31 20:16                 ` David S. Miller
2004-09-18 10:25         ` Herbert Xu
2004-09-19  4:36           ` Pablo Neira
2004-09-19  5:18             ` Pablo Neira
2004-09-19  7:58             ` Herbert Xu
2004-09-19 12:02               ` Herbert Xu
2004-09-19 12:07                 ` Herbert Xu
2004-09-19 20:50                   ` Pablo Neira
2004-09-19 21:53                     ` Herbert Xu
2004-09-19 22:49                       ` Pablo Neira
2004-09-19 23:44                         ` Herbert Xu
2004-09-20  0:31                           ` Pablo Neira
2004-09-20  1:00                             ` Herbert Xu
2004-09-19 20:50                 ` Pablo Neira
2004-09-19 21:59                   ` Herbert Xu
2004-09-19 22:39                     ` jamal
2004-09-19 22:55                       ` Pablo Neira
2004-09-19 23:04                         ` jamal
2004-09-19 23:10                           ` Herbert Xu
2004-09-19 23:17                       ` Herbert Xu
2004-09-20  2:39                         ` jamal
2004-09-20  2:58                           ` Herbert Xu
2004-09-20 12:34                             ` jamal
2004-09-20 18:14                               ` Pablo Neira
2004-09-20 21:59                                 ` Herbert Xu
2004-09-21 11:47                                   ` jamal
2004-09-21 12:09                                     ` Herbert Xu
2004-09-22  0:05                                 ` Herbert Xu
2004-09-22  0:24                                   ` Pablo Neira
2004-09-22  2:48                                   ` Pablo Neira
2004-09-22  2:50                                     ` David S. Miller
2004-09-22  2:53                                     ` jamal
2004-09-22  3:46                                       ` Herbert Xu
2004-09-22 11:35                                         ` jamal
2004-09-23 12:05                                           ` Herbert Xu
2004-09-24  2:56                                             ` jamal
2004-09-24  3:20                                               ` Herbert Xu
2004-09-27 12:41                                                 ` jamal
2004-09-22  4:52                                     ` Herbert Xu
2004-09-22 12:08                                       ` jamal
2004-09-22 17:52                                         ` David S. Miller
2004-09-23 15:40                                           ` Pablo Neira
2004-09-23 19:16                                             ` David S. Miller
2004-09-24  3:28                                               ` Herbert Xu
2004-09-24  5:39                                                 ` David S. Miller
2004-09-24  6:26                                                   ` Herbert Xu
2004-09-24 17:58                                                     ` David S. Miller
2004-09-24 22:06                                                       ` Herbert Xu
2004-09-24 22:28                                                         ` Herbert Xu
2004-09-27 12:59                                                         ` jamal
2004-09-27 12:53                                                 ` jamal
2004-09-23 12:07                                         ` Herbert Xu
2004-09-24  1:19                                           ` Pablo Neira
2004-09-24  3:04                                           ` jamal
2004-09-24  3:24                                             ` Herbert Xu
2004-09-27 12:46                                               ` jamal
2004-09-27 21:36                                                 ` Herbert Xu
2004-09-28  2:43                                                   ` jamal
2004-09-28  2:46                                                     ` Herbert Xu
2004-09-28  3:06                                                       ` jamal
2004-09-28  3:23                                                         ` Herbert Xu
2004-09-28  3:45                                                           ` jamal
2004-09-28  3:59                                                             ` Herbert Xu
2004-09-28 10:36                                                               ` jamal
2004-09-28 11:11                                                                 ` Herbert Xu
2004-09-28 12:16                                                                   ` Herbert Xu
2004-09-28 12:39                                                                     ` On DaveMs congestion control algorithm WAS(Re: " jamal
2004-09-28 18:24                                                                       ` David S. Miller
2004-09-29  2:23                                                                         ` jamal
2004-09-28 12:32                                                                   ` jamal
2004-09-29  0:13                                                                     ` Herbert Xu
2004-09-29  2:52                                                                       ` jamal
2004-09-29  3:27                                                                         ` Herbert Xu
2004-09-29  4:02                                                                           ` David S. Miller
2004-09-29 10:50                                                                           ` jamal
2004-09-29 11:42                                                                             ` Herbert Xu
2004-09-29 13:55                                                                               ` jamal
2004-09-28 21:07                                                                 ` Pablo Neira
2004-09-28 23:19                                                                   ` Herbert Xu
2004-09-28 23:20                                                                     ` David S. Miller
2004-09-29  2:28                                                                   ` jamal
2004-09-29  2:30                                                                     ` Herbert Xu
2004-09-29  2:59                                                                       ` jamal
2004-09-22  2:57                                   ` jamal
2004-09-22  3:39                                     ` Herbert Xu
2004-09-19 20:47               ` Pablo Neira [this message]
2004-09-19 21:20                 ` Herbert Xu
2004-09-19 22:14                   ` Pablo Neira
2004-09-19 23:31                     ` Herbert Xu
     [not found] ` <E1C90Da-0001V7-00@gondolin.me.apana.org.au>
2004-09-19 12:00   ` Herbert Xu
2004-09-29  9:53 James Chapman
2004-09-29  9:59 ` Herbert Xu
  -- strict thread matches above, loose matches on Subject: below --
2004-09-30  9:50 James Chapman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=414DF05E.7020601@eurodev.net \
    --to=pablo@eurodev.net \
    --cc=davem@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.