Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78791
b: refs/heads/master
c: 8d96544
h: refs/heads/master
i:
  78789: a8319c6
  78787: e5cc69e
  78783: 4f15116
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jan 28, 2008
1 parent 74826f5 commit ac17cec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 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: f16f3026db6fa63cbb0f4a37833562aa999c93e5
refs/heads/master: 8d96544475b236a0f319e492f4828aa8c0801c7f
25 changes: 12 additions & 13 deletions trunk/net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ typedef unsigned int t_key;
#define IS_LEAF(n) (n->parent & T_LEAF)

struct node {
t_key key;
unsigned long parent;
t_key key;
};

struct leaf {
t_key key;
unsigned long parent;
t_key key;
struct hlist_head list;
struct rcu_head rcu;
};
Expand All @@ -116,12 +116,12 @@ struct leaf_info {
};

struct tnode {
t_key key;
unsigned long parent;
t_key key;
unsigned char pos; /* 2log(KEYLENGTH) bits needed */
unsigned char bits; /* 2log(KEYLENGTH) bits needed */
unsigned short full_children; /* KEYLENGTH bits needed */
unsigned short empty_children; /* KEYLENGTH bits needed */
unsigned int full_children; /* KEYLENGTH bits needed */
unsigned int empty_children; /* KEYLENGTH bits needed */
struct rcu_head rcu;
struct node *child[0];
};
Expand Down Expand Up @@ -329,12 +329,12 @@ static inline void free_leaf_info(struct leaf_info *leaf)
call_rcu(&leaf->rcu, __leaf_info_free_rcu);
}

static struct tnode *tnode_alloc(unsigned int size)
static struct tnode *tnode_alloc(size_t size)
{
struct page *pages;

if (size <= PAGE_SIZE)
return kcalloc(size, 1, GFP_KERNEL);
return kzalloc(size, GFP_KERNEL);

pages = alloc_pages(GFP_KERNEL|__GFP_ZERO, get_order(size));
if (!pages)
Expand All @@ -346,8 +346,8 @@ static struct tnode *tnode_alloc(unsigned int size)
static void __tnode_free_rcu(struct rcu_head *head)
{
struct tnode *tn = container_of(head, struct tnode, rcu);
unsigned int size = sizeof(struct tnode) +
(1 << tn->bits) * sizeof(struct node *);
size_t size = sizeof(struct tnode) +
(sizeof(struct node *) << tn->bits);

if (size <= PAGE_SIZE)
kfree(tn);
Expand Down Expand Up @@ -386,8 +386,7 @@ static struct leaf_info *leaf_info_new(int plen)

static struct tnode* tnode_new(t_key key, int pos, int bits)
{
int nchildren = 1<<bits;
int sz = sizeof(struct tnode) + nchildren * sizeof(struct node *);
size_t sz = sizeof(struct tnode) + (sizeof(struct node *) << bits);
struct tnode *tn = tnode_alloc(sz);

if (tn) {
Expand All @@ -399,8 +398,8 @@ static struct tnode* tnode_new(t_key key, int pos, int bits)
tn->empty_children = 1<<bits;
}

pr_debug("AT %p s=%u %u\n", tn, (unsigned int) sizeof(struct tnode),
(unsigned int) (sizeof(struct node) * 1<<bits));
pr_debug("AT %p s=%u %lu\n", tn, (unsigned int) sizeof(struct tnode),
(unsigned long) (sizeof(struct node) << bits));
return tn;
}

Expand Down

0 comments on commit ac17cec

Please sign in to comment.