Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73279
b: refs/heads/master
c: b733c00
h: refs/heads/master
i:
  73277: cf1f309
  73275: 8f1d0c5
  73271: 1ed5c9f
  73263: 4eb7c01
  73247: 65a8567
  73215: aaeed48
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Nov 7, 2007
1 parent c1ebc78 commit b86e4a2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4999f3621f4da622e77931b3d33ada6c7083c705
refs/heads/master: b733c007edad6f3e05109951bacc6f87dd807917
67 changes: 39 additions & 28 deletions trunk/net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,23 +1819,48 @@ static int inuse_get(const struct proto *prot)
res += per_cpu_ptr(prot->inuse_ptr, cpu)[0];
return res;
}
#endif

int proto_register(struct proto *prot, int alloc_slab)
static int inuse_init(struct proto *prot)
{
char *request_sock_slab_name = NULL;
char *timewait_sock_slab_name;
int rc = -ENOBUFS;

#ifdef CONFIG_SMP
if (!prot->inuse_getval || !prot->inuse_add) {
prot->inuse_ptr = alloc_percpu(int);
if (prot->inuse_ptr == NULL)
goto out;
return -ENOBUFS;

prot->inuse_getval = inuse_get;
prot->inuse_add = inuse_add;
}
return 0;
}

static void inuse_fini(struct proto *prot)
{
if (prot->inuse_ptr != NULL) {
free_percpu(prot->inuse_ptr);
prot->inuse_ptr = NULL;
prot->inuse_getval = NULL;
prot->inuse_add = NULL;
}
}
#else
static inline int inuse_init(struct proto *prot)
{
return 0;
}

static inline void inuse_fini(struct proto *prot)
{
}
#endif

int proto_register(struct proto *prot, int alloc_slab)
{
char *request_sock_slab_name = NULL;
char *timewait_sock_slab_name;

if (inuse_init(prot))
goto out;

if (alloc_slab) {
prot->slab = kmem_cache_create(prot->name, prot->obj_size, 0,
SLAB_HWCACHE_ALIGN, NULL);
Expand Down Expand Up @@ -1887,9 +1912,8 @@ int proto_register(struct proto *prot, int alloc_slab)
write_lock(&proto_list_lock);
list_add(&prot->node, &proto_list);
write_unlock(&proto_list_lock);
rc = 0;
out:
return rc;
return 0;

out_free_timewait_sock_slab_name:
kfree(timewait_sock_slab_name);
out_free_request_sock_slab:
Expand All @@ -1903,15 +1927,9 @@ int proto_register(struct proto *prot, int alloc_slab)
kmem_cache_destroy(prot->slab);
prot->slab = NULL;
out_free_inuse:
#ifdef CONFIG_SMP
if (prot->inuse_ptr != NULL) {
free_percpu(prot->inuse_ptr);
prot->inuse_ptr = NULL;
prot->inuse_getval = NULL;
prot->inuse_add = NULL;
}
#endif
goto out;
inuse_fini(prot);
out:
return -ENOBUFS;
}

EXPORT_SYMBOL(proto_register);
Expand All @@ -1922,14 +1940,7 @@ void proto_unregister(struct proto *prot)
list_del(&prot->node);
write_unlock(&proto_list_lock);

#ifdef CONFIG_SMP
if (prot->inuse_ptr != NULL) {
free_percpu(prot->inuse_ptr);
prot->inuse_ptr = NULL;
prot->inuse_getval = NULL;
prot->inuse_add = NULL;
}
#endif
inuse_fini(prot);
if (prot->slab != NULL) {
kmem_cache_destroy(prot->slab);
prot->slab = NULL;
Expand Down

0 comments on commit b86e4a2

Please sign in to comment.