netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
To: Matt Mackall <mpm@selenic.com>
Cc: Linux Networking Development Mailing List <netdev@oss.sgi.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH-2.6.0-tiny] "uninline" {lock,release}_sock
Date: Sun, 28 Dec 2003 05:54:27 -0200	[thread overview]
Message-ID: <20031228075426.GB24351@conectiva.com.br> (raw)

Hi Matt,

	Please apply on top of your 2.6.0-tiny1 tree, CC to netdev for
eventual comments.

	With this patch we save more 3.321 bytes. At a first compilation
on top of plain 2.6.0 I thought I had seen it save more, will perhaps check
this later... if you optimized some of the kernel primitives that are called
by the current lock_sock/release_sock... Nah, too sleepy now :)

	Will test too with lock_sock/release_sock as an inline (or not if
CONFIG_NET_SMALL is selected) and not as a macro as it is today, does anybody
knows why it isn't already inline? Dave? /me must be missing something here...

   text    data     bss     dec     hex filename  patch        savings
 858052  163460   65068 1086580  109474 vmlinux   2.6.0-tiny1
 854697  163494   65068 1083259  10877b vmlinux   lock_sock       3321

Best Regards,

- Arnaldo

diff -urp linux-2.6.0.tiny.orig/include/net/sock.h linux-2.6.0.tiny.acme/include/net/sock.h
--- linux-2.6.0.tiny.orig/include/net/sock.h	2003-12-18 00:59:15.000000000 -0200
+++ linux-2.6.0.tiny.acme/include/net/sock.h	2003-12-28 01:32:50.000000000 -0200
@@ -542,7 +542,7 @@ static inline struct inode *SOCK_INODE(s
 extern void __lock_sock(struct sock *sk);
 extern void __release_sock(struct sock *sk);
 #define sock_owned_by_user(sk)	((sk)->sk_lock.owner)
-#define lock_sock(__sk) \
+#define _lock_sock(__sk) \
 do {	might_sleep(); \
 	spin_lock_bh(&((__sk)->sk_lock.slock)); \
 	if ((__sk)->sk_lock.owner) \
@@ -551,7 +551,7 @@ do {	might_sleep(); \
 	spin_unlock_bh(&((__sk)->sk_lock.slock)); \
 } while(0)
 
-#define release_sock(__sk) \
+#define _release_sock(__sk) \
 do {	spin_lock_bh(&((__sk)->sk_lock.slock)); \
 	if ((__sk)->sk_backlog.tail) \
 		__release_sock(__sk); \
@@ -561,6 +561,14 @@ do {	spin_lock_bh(&((__sk)->sk_lock.sloc
 	spin_unlock_bh(&((__sk)->sk_lock.slock)); \
 } while(0)
 
+#ifdef CONFIG_NET_SMALL
+extern void lock_sock(struct sock *sk);
+extern void release_sock(struct sock *sk);
+#else
+#define lock_sock(__sk) _lock_sock(__sk)
+#define release_sock(__sk) _release_sock(__sk)
+#endif
+
 /* BH context may only use the following locking interface. */
 #define bh_lock_sock(__sk)	spin_lock(&((__sk)->sk_lock.slock))
 #define bh_unlock_sock(__sk)	spin_unlock(&((__sk)->sk_lock.slock))
diff -urp linux-2.6.0.tiny.orig/net/core/sock.c linux-2.6.0.tiny.acme/net/core/sock.c
--- linux-2.6.0.tiny.orig/net/core/sock.c	2003-12-18 00:59:15.000000000 -0200
+++ linux-2.6.0.tiny.acme/net/core/sock.c	2003-12-28 01:32:50.000000000 -0200
@@ -1119,6 +1119,22 @@ void sock_init_data(struct socket *sock,
 	atomic_set(&sk->sk_refcnt, 1);
 }
 
+#ifdef CONFIG_NET_SMALL
+void lock_sock(struct sock *sk)
+{
+	_lock_sock(sk);
+}
+
+EXPORT_SYMBOL(lock_sock);
+
+void release_sock(struct sock *sk)
+{
+	_release_sock(sk);
+}
+
+EXPORT_SYMBOL(release_sock);
+#endif
+
 EXPORT_SYMBOL(__lock_sock);
 EXPORT_SYMBOL(__release_sock);
 EXPORT_SYMBOL(sk_alloc);

             reply	other threads:[~2003-12-28  7:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-28  7:54 Arnaldo Carvalho de Melo [this message]
2003-12-28  8:23 ` [PATCH-2.6.0-tiny] "uninline" {lock,release}_sock Linus Torvalds
2003-12-28  9:23   ` David S. Miller
2003-12-28 18:42     ` Matt Mackall

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=20031228075426.GB24351@conectiva.com.br \
    --to=acme@conectiva.com.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --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 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).