Commit 43f5b3085fdd27c4edf535d938b2cb0ccead4f75

Authored by Jeff Dike
Committed by Linus Torvalds
1 parent 484f1e2c1e

uml: fix build when SLOB is enabled

Reintroduce uml_kmalloc for the benefit of UML libc code.  The
previous tactic of declaring __kmalloc so it could be called directly
from the libc side of the house turned out to be getting too intimate
with slab, and it doesn't work with slob.

So, the uml_kmalloc wrapper is back.  It calls kmalloc or whatever
that translates into, and libc code calls it.

kfree is left alone since that still works, leaving a somewhat
inconsistent API.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Cc: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 17 changed files with 28 additions and 24 deletions Side-by-side Diff

arch/um/drivers/chan_user.c
... ... @@ -11,6 +11,7 @@
11 11 #include <termios.h>
12 12 #include <sys/ioctl.h>
13 13 #include "chan_user.h"
  14 +#include "kern_constants.h"
14 15 #include "os.h"
15 16 #include "um_malloc.h"
16 17 #include "user.h"
arch/um/drivers/cow_sys.h
... ... @@ -8,7 +8,7 @@
8 8  
9 9 static inline void *cow_malloc(int size)
10 10 {
11   - return kmalloc(size, UM_GFP_KERNEL);
  11 + return uml_kmalloc(size, UM_GFP_KERNEL);
12 12 }
13 13  
14 14 static inline void cow_free(void *ptr)
arch/um/drivers/daemon_user.c
... ... @@ -34,7 +34,7 @@
34 34 {
35 35 struct sockaddr_un *sun;
36 36  
37   - sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
  37 + sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
38 38 if (sun == NULL) {
39 39 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
40 40 "failed\n");
... ... @@ -83,7 +83,7 @@
83 83 goto out_close;
84 84 }
85 85  
86   - sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
  86 + sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
87 87 if (sun == NULL) {
88 88 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
89 89 "failed\n");
arch/um/drivers/fd.c
... ... @@ -40,7 +40,7 @@
40 40 return NULL;
41 41 }
42 42  
43   - data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
  43 + data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
44 44 if (data == NULL)
45 45 return NULL;
46 46  
arch/um/drivers/mcast_user.c
... ... @@ -15,6 +15,7 @@
15 15 #include <unistd.h>
16 16 #include <errno.h>
17 17 #include <netinet/in.h>
  18 +#include "kern_constants.h"
18 19 #include "mcast.h"
19 20 #include "net_user.h"
20 21 #include "um_malloc.h"
... ... @@ -24,7 +25,7 @@
24 25 {
25 26 struct sockaddr_in *sin;
26 27  
27   - sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
  28 + sin = uml_kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
28 29 if (sin == NULL) {
29 30 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in "
30 31 "failed\n");
arch/um/drivers/net_user.c
... ... @@ -222,7 +222,7 @@
222 222 netmask[2], netmask[3]);
223 223  
224 224 output_len = UM_KERN_PAGE_SIZE;
225   - output = kmalloc(output_len, UM_GFP_KERNEL);
  225 + output = uml_kmalloc(output_len, UM_GFP_KERNEL);
226 226 if (output == NULL)
227 227 printk(UM_KERN_ERR "change : failed to allocate output "
228 228 "buffer\n");
arch/um/drivers/port_user.c
... ... @@ -47,7 +47,7 @@
47 47 if (kern_data == NULL)
48 48 return NULL;
49 49  
50   - data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
  50 + data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
51 51 if (data == NULL)
52 52 goto err;
53 53  
arch/um/drivers/pty.c
... ... @@ -29,7 +29,7 @@
29 29 {
30 30 struct pty_chan *data;
31 31  
32   - data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
  32 + data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
33 33 if (data == NULL)
34 34 return NULL;
35 35  
arch/um/drivers/slip_user.c
... ... @@ -96,7 +96,7 @@
96 96 pid = err;
97 97  
98 98 output_len = UM_KERN_PAGE_SIZE;
99   - output = kmalloc(output_len, UM_GFP_KERNEL);
  99 + output = uml_kmalloc(output_len, UM_GFP_KERNEL);
100 100 if (output == NULL) {
101 101 printk(UM_KERN_ERR "slip_tramp : failed to allocate output "
102 102 "buffer\n");
arch/um/drivers/tty.c
... ... @@ -29,7 +29,7 @@
29 29 }
30 30 str++;
31 31  
32   - data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
  32 + data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
33 33 if (data == NULL)
34 34 return NULL;
35 35 *data = ((struct tty_chan) { .dev = str,
arch/um/drivers/xterm.c
... ... @@ -30,7 +30,7 @@
30 30 {
31 31 struct xterm_chan *data;
32 32  
33   - data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
  33 + data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
34 34 if (data == NULL)
35 35 return NULL;
36 36 *data = ((struct xterm_chan) { .pid = -1,
arch/um/include/um_malloc.h
... ... @@ -8,12 +8,7 @@
8 8  
9 9 #include "kern_constants.h"
10 10  
11   -extern void *__kmalloc(int size, int flags);
12   -static inline void *kmalloc(int size, int flags)
13   -{
14   - return __kmalloc(size, flags);
15   -}
16   -
  11 +extern void *uml_kmalloc(int size, int flags);
17 12 extern void kfree(const void *ptr);
18 13  
19 14 extern void *vmalloc(unsigned long size);
arch/um/kernel/mem.c
... ... @@ -375,4 +375,9 @@
375 375 return pmd;
376 376 }
377 377 #endif
  378 +
  379 +void *uml_kmalloc(int size, int flags)
  380 +{
  381 + return kmalloc(size, flags);
  382 +}
arch/um/os-Linux/drivers/ethertap_user.c
... ... @@ -52,7 +52,7 @@
52 52 return;
53 53 }
54 54  
55   - output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
  55 + output = uml_kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
56 56 if (output == NULL)
57 57 printk(UM_KERN_ERR "etap_change : Failed to allocate output "
58 58 "buffer\n");
... ... @@ -165,7 +165,7 @@
165 165 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
166 166 control_fds[1], data_fds[0], data_fds[1]);
167 167 output_len = UM_KERN_PAGE_SIZE;
168   - output = kmalloc(output_len, UM_GFP_KERNEL);
  168 + output = uml_kmalloc(output_len, UM_GFP_KERNEL);
169 169 read_output(control_fds[0], output, output_len);
170 170  
171 171 if (output == NULL)
arch/um/os-Linux/helper.c
... ... @@ -71,8 +71,8 @@
71 71 data.pre_data = pre_data;
72 72 data.argv = argv;
73 73 data.fd = fds[1];
74   - data.buf = __cant_sleep() ? kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
75   - kmalloc(PATH_MAX, UM_GFP_KERNEL);
  74 + data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
  75 + uml_kmalloc(PATH_MAX, UM_GFP_KERNEL);
76 76 pid = clone(helper_child, (void *) sp, CLONE_VM, &data);
77 77 if (pid < 0) {
78 78 ret = -errno;
arch/um/os-Linux/main.c
... ... @@ -199,7 +199,7 @@
199 199 return __real_malloc(size);
200 200 else if (size <= UM_KERN_PAGE_SIZE)
201 201 /* finding contiguous pages can be hard*/
202   - ret = kmalloc(size, UM_GFP_KERNEL);
  202 + ret = uml_kmalloc(size, UM_GFP_KERNEL);
203 203 else ret = vmalloc(size);
204 204  
205 205 /*
arch/um/os-Linux/sigio.c
... ... @@ -109,7 +109,7 @@
109 109 if (n <= polls->size)
110 110 return 0;
111 111  
112   - new = kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC);
  112 + new = uml_kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC);
113 113 if (new == NULL) {
114 114 printk(UM_KERN_ERR "need_poll : failed to allocate new "
115 115 "pollfds\n");
... ... @@ -243,7 +243,7 @@
243 243 {
244 244 struct pollfd *p;
245 245  
246   - p = kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL);
  246 + p = uml_kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL);
247 247 if (p == NULL) {
248 248 printk(UM_KERN_ERR "setup_initial_poll : failed to allocate "
249 249 "poll\n");