* [PATCH 5/7] net: use simple_free()
@ 2008-11-16 4:34 Lai Jiangshan
2008-11-16 4:54 ` Alexey Dobriyan
0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2008-11-16 4:34 UTC (permalink / raw)
To: David S. Miller, Andrew Morton; +Cc: Linux Kernel Mailing List
simple_free() free the memory by kfree(), or vfree() if it is vmalloc addr.
simple_free() is simpler than current codes.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/net/core/request_sock.c b/net/core/request_sock.c
index 7552495..53fd8a7 100644
--- a/net/core/request_sock.c
+++ b/net/core/request_sock.c
@@ -16,6 +16,7 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
+#include <linux/mm.h>
#include <net/request_sock.h>
@@ -71,22 +72,11 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
void __reqsk_queue_destroy(struct request_sock_queue *queue)
{
- struct listen_sock *lopt;
- size_t lopt_size;
-
/*
* this is an error recovery path only
* no locking needed and the lopt is not NULL
*/
-
- lopt = queue->listen_opt;
- lopt_size = sizeof(struct listen_sock) +
- lopt->nr_table_entries * sizeof(struct request_sock *);
-
- if (lopt_size > PAGE_SIZE)
- vfree(lopt);
- else
- kfree(lopt);
+ simple_free(queue->listen_opt);
}
static inline struct listen_sock *reqsk_queue_yank_listen_sk(
@@ -106,8 +96,6 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
{
/* make all the listen_opt local to us */
struct listen_sock *lopt = reqsk_queue_yank_listen_sk(queue);
- size_t lopt_size = sizeof(struct listen_sock) +
- lopt->nr_table_entries * sizeof(struct request_sock *);
if (lopt->qlen != 0) {
unsigned int i;
@@ -124,9 +112,6 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
}
WARN_ON(lopt->qlen != 0);
- if (lopt_size > PAGE_SIZE)
- vfree(lopt);
- else
- kfree(lopt);
+ simple_free(lopt);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 5/7] net: use simple_free()
2008-11-16 4:34 [PATCH 5/7] net: use simple_free() Lai Jiangshan
@ 2008-11-16 4:54 ` Alexey Dobriyan
0 siblings, 0 replies; 2+ messages in thread
From: Alexey Dobriyan @ 2008-11-16 4:54 UTC (permalink / raw)
To: Lai Jiangshan; +Cc: David S. Miller, Andrew Morton, Linux Kernel Mailing List
On Sun, Nov 16, 2008 at 12:34:04PM +0800, Lai Jiangshan wrote:
> simple_free() free the memory by kfree(), or vfree() if it is vmalloc addr.
> simple_free() is simpler than current codes.
Where is corresponding alloc chunk?
> --- a/net/core/request_sock.c
> +++ b/net/core/request_sock.c
> @@ -71,22 +72,11 @@ int reqsk_queue_alloc(struct request_sock_queue *queue,
>
> void __reqsk_queue_destroy(struct request_sock_queue *queue)
> {
> - struct listen_sock *lopt;
> - size_t lopt_size;
> -
> /*
> * this is an error recovery path only
> * no locking needed and the lopt is not NULL
> */
> -
> - lopt = queue->listen_opt;
> - lopt_size = sizeof(struct listen_sock) +
> - lopt->nr_table_entries * sizeof(struct request_sock *);
> -
> - if (lopt_size > PAGE_SIZE)
> - vfree(lopt);
> - else
> - kfree(lopt);
> + simple_free(queue->listen_opt);
> }
>
> static inline struct listen_sock *reqsk_queue_yank_listen_sk(
> @@ -106,8 +96,6 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
> {
> /* make all the listen_opt local to us */
> struct listen_sock *lopt = reqsk_queue_yank_listen_sk(queue);
> - size_t lopt_size = sizeof(struct listen_sock) +
> - lopt->nr_table_entries * sizeof(struct request_sock *);
>
> if (lopt->qlen != 0) {
> unsigned int i;
> @@ -124,9 +112,6 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
> }
>
> WARN_ON(lopt->qlen != 0);
> - if (lopt_size > PAGE_SIZE)
> - vfree(lopt);
> - else
> - kfree(lopt);
> + simple_free(lopt);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-16 4:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-16 4:34 [PATCH 5/7] net: use simple_free() Lai Jiangshan
2008-11-16 4:54 ` Alexey Dobriyan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox