diff options
author | Changli Gao <xiaosuo@gmail.com> | 2010-11-30 21:52:57 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-06 15:59:07 -0500 |
commit | c56b4d90123b77e29a91b9b96bb791f929139d8e (patch) | |
tree | 1bf543b3c47c20f26eb4378ceb9fc3a1edd0f3f4 /net/packet | |
parent | 0af55bb58f8fa7865004ac48d16affe125ac1b7f (diff) |
af_packet: remove pgv.flags
As we can check if an address is vmalloc address with is_vmalloc_addr(),
we remove pgv.flags. Then we may get more pg_vecs.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet')
-rw-r--r-- | net/packet/af_packet.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 26fbeb140a6a..a11c731d2ee4 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -167,7 +167,6 @@ static int packet_set_ring(struct sock *sk, struct tpacket_req *req, | |||
167 | #define PGV_FROM_VMALLOC 1 | 167 | #define PGV_FROM_VMALLOC 1 |
168 | struct pgv { | 168 | struct pgv { |
169 | char *buffer; | 169 | char *buffer; |
170 | unsigned char flags; | ||
171 | }; | 170 | }; |
172 | 171 | ||
173 | struct packet_ring_buffer { | 172 | struct packet_ring_buffer { |
@@ -2342,7 +2341,7 @@ static void free_pg_vec(struct pgv *pg_vec, unsigned int order, | |||
2342 | 2341 | ||
2343 | for (i = 0; i < len; i++) { | 2342 | for (i = 0; i < len; i++) { |
2344 | if (likely(pg_vec[i].buffer)) { | 2343 | if (likely(pg_vec[i].buffer)) { |
2345 | if (pg_vec[i].flags & PGV_FROM_VMALLOC) | 2344 | if (is_vmalloc_addr(pg_vec[i].buffer)) |
2346 | vfree(pg_vec[i].buffer); | 2345 | vfree(pg_vec[i].buffer); |
2347 | else | 2346 | else |
2348 | free_pages((unsigned long)pg_vec[i].buffer, | 2347 | free_pages((unsigned long)pg_vec[i].buffer, |
@@ -2353,8 +2352,7 @@ static void free_pg_vec(struct pgv *pg_vec, unsigned int order, | |||
2353 | kfree(pg_vec); | 2352 | kfree(pg_vec); |
2354 | } | 2353 | } |
2355 | 2354 | ||
2356 | static inline char *alloc_one_pg_vec_page(unsigned long order, | 2355 | static inline char *alloc_one_pg_vec_page(unsigned long order) |
2357 | unsigned char *flags) | ||
2358 | { | 2356 | { |
2359 | char *buffer = NULL; | 2357 | char *buffer = NULL; |
2360 | gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP | | 2358 | gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP | |
@@ -2368,7 +2366,6 @@ static inline char *alloc_one_pg_vec_page(unsigned long order, | |||
2368 | /* | 2366 | /* |
2369 | * __get_free_pages failed, fall back to vmalloc | 2367 | * __get_free_pages failed, fall back to vmalloc |
2370 | */ | 2368 | */ |
2371 | *flags |= PGV_FROM_VMALLOC; | ||
2372 | buffer = vzalloc((1 << order) * PAGE_SIZE); | 2369 | buffer = vzalloc((1 << order) * PAGE_SIZE); |
2373 | 2370 | ||
2374 | if (buffer) | 2371 | if (buffer) |
@@ -2377,7 +2374,6 @@ static inline char *alloc_one_pg_vec_page(unsigned long order, | |||
2377 | /* | 2374 | /* |
2378 | * vmalloc failed, lets dig into swap here | 2375 | * vmalloc failed, lets dig into swap here |
2379 | */ | 2376 | */ |
2380 | *flags = 0; | ||
2381 | gfp_flags &= ~__GFP_NORETRY; | 2377 | gfp_flags &= ~__GFP_NORETRY; |
2382 | buffer = (char *)__get_free_pages(gfp_flags, order); | 2378 | buffer = (char *)__get_free_pages(gfp_flags, order); |
2383 | if (buffer) | 2379 | if (buffer) |
@@ -2400,8 +2396,7 @@ static struct pgv *alloc_pg_vec(struct tpacket_req *req, int order) | |||
2400 | goto out; | 2396 | goto out; |
2401 | 2397 | ||
2402 | for (i = 0; i < block_nr; i++) { | 2398 | for (i = 0; i < block_nr; i++) { |
2403 | pg_vec[i].buffer = alloc_one_pg_vec_page(order, | 2399 | pg_vec[i].buffer = alloc_one_pg_vec_page(order); |
2404 | &pg_vec[i].flags); | ||
2405 | if (unlikely(!pg_vec[i].buffer)) | 2400 | if (unlikely(!pg_vec[i].buffer)) |
2406 | goto out_free_pgvec; | 2401 | goto out_free_pgvec; |
2407 | } | 2402 | } |
@@ -2585,13 +2580,8 @@ static int packet_mmap(struct file *file, struct socket *sock, | |||
2585 | void *kaddr = rb->pg_vec[i].buffer; | 2580 | void *kaddr = rb->pg_vec[i].buffer; |
2586 | int pg_num; | 2581 | int pg_num; |
2587 | 2582 | ||
2588 | for (pg_num = 0; pg_num < rb->pg_vec_pages; | 2583 | for (pg_num = 0; pg_num < rb->pg_vec_pages; pg_num++) { |
2589 | pg_num++) { | 2584 | page = pgv_to_page(kaddr); |
2590 | if (rb->pg_vec[i].flags & PGV_FROM_VMALLOC) | ||
2591 | page = vmalloc_to_page(kaddr); | ||
2592 | else | ||
2593 | page = virt_to_page(kaddr); | ||
2594 | |||
2595 | err = vm_insert_page(vma, start, page); | 2585 | err = vm_insert_page(vma, start, page); |
2596 | if (unlikely(err)) | 2586 | if (unlikely(err)) |
2597 | goto out; | 2587 | goto out; |