* [PATCH] [NET] Save space for sk_alloc_slab() failure message.
@ 2005-03-17 18:30 YOSHIFUJI Hideaki / 吉藤英明
2005-03-17 18:31 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2005-03-17 18:30 UTC (permalink / raw)
To: davem; +Cc: yoshfuji, netdev
Hello.
(Almost) all callers of sk_alloc_slab() handle its failure like this:
if (sk_alloc_slab(&prot, "sock")) {
sk_alloc_slab_error(&prot); /* except for sctp */
goto out;
}
So, why don't we move sk_alloc_slab_error() into sk_alloc_slab()
for simplification and save text segment?
Signed-off-by: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
===== include/net/sock.h 1.99 vs edited =====
--- 1.99/include/net/sock.h 2005-03-16 08:24:42 +09:00
+++ edited/include/net/sock.h 2005-03-18 03:00:59 +09:00
@@ -561,11 +561,6 @@
extern int sk_alloc_slab(struct proto *prot, char *name);
extern void sk_free_slab(struct proto *prot);
-static inline void sk_alloc_slab_error(struct proto *proto)
-{
- printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n", proto->name);
-}
-
static __inline__ void sk_set_owner(struct sock *sk, struct module *owner)
{
/*
===== net/core/sock.c 1.65 vs edited =====
--- 1.65/net/core/sock.c 2005-03-16 08:20:37 +09:00
+++ edited/net/core/sock.c 2005-03-18 03:05:04 +09:00
@@ -1374,7 +1374,13 @@
prot->slab_obj_size, 0,
SLAB_HWCACHE_ALIGN, NULL, NULL);
- return prot->slab != NULL ? 0 : -ENOBUFS;
+ if (prot->slab == NULL) {
+ printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n",
+ prot->name);
+ return -ENOBUFS;
+ }
+
+ return 0;
}
EXPORT_SYMBOL(sk_alloc_slab);
===== net/ipv4/af_inet.c 1.84 vs edited =====
--- 1.84/net/ipv4/af_inet.c 2005-01-14 13:41:05 +09:00
+++ edited/net/ipv4/af_inet.c 2005-03-18 03:00:06 +09:00
@@ -1027,20 +1027,16 @@
}
rc = sk_alloc_slab(&tcp_prot, "tcp_sock");
- if (rc) {
- sk_alloc_slab_error(&tcp_prot);
+ if (rc)
goto out;
- }
+
rc = sk_alloc_slab(&udp_prot, "udp_sock");
- if (rc) {
- sk_alloc_slab_error(&udp_prot);
+ if (rc)
goto out_tcp_free_slab;
- }
+
rc = sk_alloc_slab(&raw_prot, "raw_sock");
- if (rc) {
- sk_alloc_slab_error(&raw_prot);
+ if (rc)
goto out_udp_free_slab;
- }
/*
* Tell SOCKET that we are alive...
===== net/ipv6/af_inet6.c 1.90 vs edited =====
--- 1.90/net/ipv6/af_inet6.c 2005-03-10 13:39:44 +09:00
+++ edited/net/ipv6/af_inet6.c 2005-03-18 03:00:29 +09:00
@@ -711,20 +711,17 @@
}
err = sk_alloc_slab(&tcpv6_prot, "tcpv6_sock");
- if (err) {
- sk_alloc_slab_error(&tcpv6_prot);
+ if (err)
goto out;
- }
+
err = sk_alloc_slab(&udpv6_prot, "udpv6_sock");
- if (err) {
- sk_alloc_slab_error(&udpv6_prot);
+ if (err)
goto out_tcp_free_slab;
- }
+
err = sk_alloc_slab(&rawv6_prot, "rawv6_sock");
- if (err) {
- sk_alloc_slab_error(&rawv6_prot);
+ if (err)
goto out_udp_free_slab;
- }
+
/* Register the socket-side information for inet6_create. */
for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@linux-ipv6.org>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [NET] Save space for sk_alloc_slab() failure message.
2005-03-17 18:30 [PATCH] [NET] Save space for sk_alloc_slab() failure message YOSHIFUJI Hideaki / 吉藤英明
@ 2005-03-17 18:31 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2005-03-17 18:31 UTC (permalink / raw)
To: yoshfuji; +Cc: netdev
On Fri, 18 Mar 2005 03:30:39 +0900 (JST)
YOSHIFUJI Hideaki / ^[$B5HF#1QL@^[(B <yoshfuji@linux-ipv6.org> wrote:
> (Almost) all callers of sk_alloc_slab() handle its failure like this:
>
> if (sk_alloc_slab(&prot, "sock")) {
> sk_alloc_slab_error(&prot); /* except for sctp */
> goto out;
> }
>
> So, why don't we move sk_alloc_slab_error() into sk_alloc_slab()
> for simplification and save text segment?
>
> Signed-off-by: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Looks great, patch applied.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-17 18:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-17 18:30 [PATCH] [NET] Save space for sk_alloc_slab() failure message YOSHIFUJI Hideaki / 吉藤英明
2005-03-17 18:31 ` David S. Miller
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).