aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-07-16 02:38:56 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:38 -0400
commite4c4bf9968cb4f0fceb1b8fb54790ccae73caf4e (patch)
treefe9892123214821c37a7b615fe52db7f6d46e148 /arch
parentc43990162fc7f9d2f15a12797fdc6f9c0905f704 (diff)
uml: Eliminate kernel allocator wrappers
UML had two wrapper procedures for kmalloc, um_kmalloc and um_kmalloc_atomic because the flag constants weren't available in userspace code. kern_constants.h had made kernel constants available for a long time, so there is no need for these wrappers any more. Rather, userspace code calls kmalloc directly with the userspace versions of the gfp flags. kmalloc isn't a real procedure, so I had to essentially copy the inline wrapper around __kmalloc. vmalloc also had its own wrapper for no good reason. This is now gone. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/um/drivers/cow_sys.h2
-rw-r--r--arch/um/drivers/daemon_user.c4
-rw-r--r--arch/um/drivers/fd.c2
-rw-r--r--arch/um/drivers/mcast_user.c2
-rw-r--r--arch/um/drivers/net_user.c2
-rw-r--r--arch/um/drivers/port_user.c2
-rw-r--r--arch/um/drivers/pty.c2
-rw-r--r--arch/um/drivers/slip_user.c2
-rw-r--r--arch/um/drivers/tty.c2
-rw-r--r--arch/um/include/common-offsets.h3
-rw-r--r--arch/um/include/um_malloc.h12
-rw-r--r--arch/um/kernel/irq.c1
-rw-r--r--arch/um/kernel/process.c16
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c4
-rw-r--r--arch/um/os-Linux/helper.c4
-rw-r--r--arch/um/os-Linux/main.c4
-rw-r--r--arch/um/os-Linux/sigio.c4
17 files changed, 30 insertions, 38 deletions
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h
index 15453845d2ba..ca8c9e11a39b 100644
--- a/arch/um/drivers/cow_sys.h
+++ b/arch/um/drivers/cow_sys.h
@@ -8,7 +8,7 @@
8 8
9static inline void *cow_malloc(int size) 9static inline void *cow_malloc(int size)
10{ 10{
11 return um_kmalloc(size); 11 return kmalloc(size, UM_GFP_KERNEL);
12} 12}
13 13
14static inline void cow_free(void *ptr) 14static inline void cow_free(void *ptr)
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c
index b869e3899683..8d2008f06682 100644
--- a/arch/um/drivers/daemon_user.c
+++ b/arch/um/drivers/daemon_user.c
@@ -35,7 +35,7 @@ static struct sockaddr_un *new_addr(void *name, int len)
35{ 35{
36 struct sockaddr_un *sun; 36 struct sockaddr_un *sun;
37 37
38 sun = um_kmalloc(sizeof(struct sockaddr_un)); 38 sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
39 if(sun == NULL){ 39 if(sun == NULL){
40 printk("new_addr: allocation of sockaddr_un failed\n"); 40 printk("new_addr: allocation of sockaddr_un failed\n");
41 return NULL; 41 return NULL;
@@ -83,7 +83,7 @@ static int connect_to_switch(struct daemon_data *pri)
83 goto out_close; 83 goto out_close;
84 } 84 }
85 85
86 sun = um_kmalloc(sizeof(struct sockaddr_un)); 86 sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
87 if(sun == NULL){ 87 if(sun == NULL){
88 printk("new_addr: allocation of sockaddr_un failed\n"); 88 printk("new_addr: allocation of sockaddr_un failed\n");
89 err = -ENOMEM; 89 err = -ENOMEM;
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c
index 7f083ec47a4f..39c01ffd45c9 100644
--- a/arch/um/drivers/fd.c
+++ b/arch/um/drivers/fd.c
@@ -37,7 +37,7 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts)
37 printk("fd_init : couldn't parse file descriptor '%s'\n", str); 37 printk("fd_init : couldn't parse file descriptor '%s'\n", str);
38 return(NULL); 38 return(NULL);
39 } 39 }
40 data = um_kmalloc(sizeof(*data)); 40 data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
41 if(data == NULL) return(NULL); 41 if(data == NULL) return(NULL);
42 *data = ((struct fd_chan) { .fd = n, 42 *data = ((struct fd_chan) { .fd = n,
43 .raw = opts->raw }); 43 .raw = opts->raw });
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index d319db16d4ec..236a3dfc297d 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -30,7 +30,7 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port)
30{ 30{
31 struct sockaddr_in *sin; 31 struct sockaddr_in *sin;
32 32
33 sin = um_kmalloc(sizeof(struct sockaddr_in)); 33 sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
34 if(sin == NULL){ 34 if(sin == NULL){
35 printk("new_addr: allocation of sockaddr_in failed\n"); 35 printk("new_addr: allocation of sockaddr_in failed\n");
36 return NULL; 36 return NULL;
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 6fa948ba969d..da946e3e1bf2 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -217,7 +217,7 @@ static void change(char *dev, char *what, unsigned char *addr,
217 netmask[2], netmask[3]); 217 netmask[2], netmask[3]);
218 218
219 output_len = UM_KERN_PAGE_SIZE; 219 output_len = UM_KERN_PAGE_SIZE;
220 output = um_kmalloc(output_len); 220 output = kmalloc(output_len, UM_GFP_KERNEL);
221 if(output == NULL) 221 if(output == NULL)
222 printk("change : failed to allocate output buffer\n"); 222 printk("change : failed to allocate output buffer\n");
223 223
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index 29250beba429..c799b00012c7 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -50,7 +50,7 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
50 if(kern_data == NULL) 50 if(kern_data == NULL)
51 return NULL; 51 return NULL;
52 52
53 data = um_kmalloc(sizeof(*data)); 53 data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
54 if(data == NULL) 54 if(data == NULL)
55 goto err; 55 goto err;
56 56
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c
index 640bcdaad9f4..1e3fd619a837 100644
--- a/arch/um/drivers/pty.c
+++ b/arch/um/drivers/pty.c
@@ -29,7 +29,7 @@ static void *pty_chan_init(char *str, int device, const struct chan_opts *opts)
29{ 29{
30 struct pty_chan *data; 30 struct pty_chan *data;
31 31
32 data = um_kmalloc(sizeof(*data)); 32 data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
33 if (data == NULL) 33 if (data == NULL)
34 return NULL; 34 return NULL;
35 35
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
index edc2de3ee2f4..c0b73c28cff0 100644
--- a/arch/um/drivers/slip_user.c
+++ b/arch/um/drivers/slip_user.c
@@ -91,7 +91,7 @@ static int slip_tramp(char **argv, int fd)
91 pid = err; 91 pid = err;
92 92
93 output_len = UM_KERN_PAGE_SIZE; 93 output_len = UM_KERN_PAGE_SIZE;
94 output = um_kmalloc(output_len); 94 output = kmalloc(output_len, UM_GFP_KERNEL);
95 if(output == NULL){ 95 if(output == NULL){
96 printk("slip_tramp : failed to allocate output buffer\n"); 96 printk("slip_tramp : failed to allocate output buffer\n");
97 os_kill_process(pid, 1); 97 os_kill_process(pid, 1);
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c
index c07d0d562780..a9f87e19c5bf 100644
--- a/arch/um/drivers/tty.c
+++ b/arch/um/drivers/tty.c
@@ -29,7 +29,7 @@ static void *tty_chan_init(char *str, int device, const struct chan_opts *opts)
29 } 29 }
30 str++; 30 str++;
31 31
32 data = um_kmalloc(sizeof(*data)); 32 data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
33 if(data == NULL) 33 if(data == NULL)
34 return NULL; 34 return NULL;
35 *data = ((struct tty_chan) { .dev = str, 35 *data = ((struct tty_chan) { .dev = str,
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h
index 7376ee44e330..6eee343e53eb 100644
--- a/arch/um/include/common-offsets.h
+++ b/arch/um/include/common-offsets.h
@@ -27,6 +27,9 @@ DEFINE(UM_ELFCLASS64, ELFCLASS64);
27 27
28DEFINE(UM_NR_CPUS, NR_CPUS); 28DEFINE(UM_NR_CPUS, NR_CPUS);
29 29
30DEFINE(UM_GFP_KERNEL, GFP_KERNEL);
31DEFINE(UM_GFP_ATOMIC, GFP_ATOMIC);
32
30/* For crypto assembler code. */ 33/* For crypto assembler code. */
31DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); 34DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
32 35
diff --git a/arch/um/include/um_malloc.h b/arch/um/include/um_malloc.h
index e6d7c5aa3f4e..0ad17cb83d96 100644
--- a/arch/um/include/um_malloc.h
+++ b/arch/um/include/um_malloc.h
@@ -6,11 +6,17 @@
6#ifndef __UM_MALLOC_H__ 6#ifndef __UM_MALLOC_H__
7#define __UM_MALLOC_H__ 7#define __UM_MALLOC_H__
8 8
9extern void *um_kmalloc(int size); 9#include "kern_constants.h"
10extern void *um_kmalloc_atomic(int size); 10
11extern void *__kmalloc(int size, int flags);
12static inline void *kmalloc(int size, int flags)
13{
14 return __kmalloc(size, flags);
15}
16
11extern void kfree(const void *ptr); 17extern void kfree(const void *ptr);
12 18
13extern void *um_vmalloc(int size); 19extern void *vmalloc(unsigned long size);
14extern void vfree(void *ptr); 20extern void vfree(void *ptr);
15 21
16#endif /* __UM_MALLOC_H__ */ 22#endif /* __UM_MALLOC_H__ */
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index dba04d88b432..9870febdbead 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -30,7 +30,6 @@
30#include "irq_kern.h" 30#include "irq_kern.h"
31#include "os.h" 31#include "os.h"
32#include "sigio.h" 32#include "sigio.h"
33#include "um_malloc.h"
34#include "misc_constants.h" 33#include "misc_constants.h"
35#include "as-layout.h" 34#include "as-layout.h"
36 35
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 8d2c5496532b..bfa52f206bb6 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -46,7 +46,6 @@
46#include "mode.h" 46#include "mode.h"
47#include "mode_kern.h" 47#include "mode_kern.h"
48#include "choose-mode.h" 48#include "choose-mode.h"
49#include "um_malloc.h"
50 49
51/* This is a per-cpu array. A processor only modifies its entry and it only 50/* This is a per-cpu array. A processor only modifies its entry and it only
52 * cares about its entry, so it's OK if another processor is modifying its 51 * cares about its entry, so it's OK if another processor is modifying its
@@ -262,21 +261,6 @@ void dump_thread(struct pt_regs *regs, struct user *u)
262{ 261{
263} 262}
264 263
265void *um_kmalloc(int size)
266{
267 return kmalloc(size, GFP_KERNEL);
268}
269
270void *um_kmalloc_atomic(int size)
271{
272 return kmalloc(size, GFP_ATOMIC);
273}
274
275void *um_vmalloc(int size)
276{
277 return vmalloc(size);
278}
279
280int __cant_sleep(void) { 264int __cant_sleep(void) {
281 return in_atomic() || irqs_disabled() || in_interrupt(); 265 return in_atomic() || irqs_disabled() || in_interrupt();
282 /* Is in_interrupt() really needed? */ 266 /* Is in_interrupt() really needed? */
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index cac01b31ea95..61d3953c7ac9 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -54,7 +54,7 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask,
54 return; 54 return;
55 } 55 }
56 56
57 output = um_kmalloc(UM_KERN_PAGE_SIZE); 57 output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
58 if(output == NULL) 58 if(output == NULL)
59 printk("etap_change : Failed to allocate output buffer\n"); 59 printk("etap_change : Failed to allocate output buffer\n");
60 read_output(fd, output, UM_KERN_PAGE_SIZE); 60 read_output(fd, output, UM_KERN_PAGE_SIZE);
@@ -166,7 +166,7 @@ static int etap_open(void *data)
166 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], 166 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
167 control_fds[1], data_fds[0], data_fds[1]); 167 control_fds[1], data_fds[0], data_fds[1]);
168 output_len = UM_KERN_PAGE_SIZE; 168 output_len = UM_KERN_PAGE_SIZE;
169 output = um_kmalloc(output_len); 169 output = kmalloc(output_len, UM_GFP_KERNEL);
170 read_output(control_fds[0], output, output_len); 170 read_output(control_fds[0], output, output_len);
171 171
172 if(output == NULL) 172 if(output == NULL)
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index 9cf48d0577cc..d81af7b8587a 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -72,8 +72,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
72 data.pre_data = pre_data; 72 data.pre_data = pre_data;
73 data.argv = argv; 73 data.argv = argv;
74 data.fd = fds[1]; 74 data.fd = fds[1];
75 data.buf = __cant_sleep() ? um_kmalloc_atomic(PATH_MAX) : 75 data.buf = __cant_sleep() ? kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
76 um_kmalloc(PATH_MAX); 76 kmalloc(PATH_MAX, UM_GFP_KERNEL);
77 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); 77 pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
78 if (pid < 0) { 78 if (pid < 0) {
79 ret = -errno; 79 ret = -errno;
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index fb510d40480c..e85f4995a011 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -235,8 +235,8 @@ void *__wrap_malloc(int size)
235 return __real_malloc(size); 235 return __real_malloc(size);
236 else if(size <= UM_KERN_PAGE_SIZE) 236 else if(size <= UM_KERN_PAGE_SIZE)
237 /* finding contiguous pages can be hard*/ 237 /* finding contiguous pages can be hard*/
238 ret = um_kmalloc(size); 238 ret = kmalloc(size, UM_GFP_KERNEL);
239 else ret = um_vmalloc(size); 239 else ret = vmalloc(size);
240 240
241 /* glibc people insist that if malloc fails, errno should be 241 /* glibc people insist that if malloc fails, errno should be
242 * set by malloc as well. So we do. 242 * set by malloc as well. So we do.
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index 2c23cb261188..dc03e9cccb63 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -105,7 +105,7 @@ static int need_poll(struct pollfds *polls, int n)
105 if(n <= polls->size) 105 if(n <= polls->size)
106 return 0; 106 return 0;
107 107
108 new = um_kmalloc_atomic(n * sizeof(struct pollfd)); 108 new = kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC);
109 if(new == NULL){ 109 if(new == NULL){
110 printk("need_poll : failed to allocate new pollfds\n"); 110 printk("need_poll : failed to allocate new pollfds\n");
111 return -ENOMEM; 111 return -ENOMEM;
@@ -233,7 +233,7 @@ static struct pollfd *setup_initial_poll(int fd)
233{ 233{
234 struct pollfd *p; 234 struct pollfd *p;
235 235
236 p = um_kmalloc(sizeof(struct pollfd)); 236 p = kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL);
237 if (p == NULL) { 237 if (p == NULL) {
238 printk("setup_initial_poll : failed to allocate poll\n"); 238 printk("setup_initial_poll : failed to allocate poll\n");
239 return NULL; 239 return NULL;