Skip to content

Commit e4c4bf9

Browse files
cfd-36Linus Torvalds
authored andcommitted
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>
1 parent c439901 commit e4c4bf9

17 files changed

Lines changed: 30 additions & 38 deletions

File tree

‎arch/um/drivers/cow_sys.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
static inline void *cow_malloc(int size)
1010
{
11-
return um_kmalloc(size);
11+
return kmalloc(size, UM_GFP_KERNEL);
1212
}
1313

1414
static inline void cow_free(void *ptr)

‎arch/um/drivers/daemon_user.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static struct sockaddr_un *new_addr(void *name, int len)
3535
{
3636
struct sockaddr_un *sun;
3737

38-
sun = um_kmalloc(sizeof(struct sockaddr_un));
38+
sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
3939
if(sun == NULL){
4040
printk("new_addr: allocation of sockaddr_un failed\n");
4141
return NULL;
@@ -83,7 +83,7 @@ static int connect_to_switch(struct daemon_data *pri)
8383
goto out_close;
8484
}
8585

86-
sun = um_kmalloc(sizeof(struct sockaddr_un));
86+
sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
8787
if(sun == NULL){
8888
printk("new_addr: allocation of sockaddr_un failed\n");
8989
err = -ENOMEM;

‎arch/um/drivers/fd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts)
3737
printk("fd_init : couldn't parse file descriptor '%s'\n", str);
3838
return(NULL);
3939
}
40-
data = um_kmalloc(sizeof(*data));
40+
data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
4141
if(data == NULL) return(NULL);
4242
*data = ((struct fd_chan) { .fd = n,
4343
.raw = opts->raw });

‎arch/um/drivers/mcast_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port)
3030
{
3131
struct sockaddr_in *sin;
3232

33-
sin = um_kmalloc(sizeof(struct sockaddr_in));
33+
sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
3434
if(sin == NULL){
3535
printk("new_addr: allocation of sockaddr_in failed\n");
3636
return NULL;

‎arch/um/drivers/net_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static void change(char *dev, char *what, unsigned char *addr,
217217
netmask[2], netmask[3]);
218218

219219
output_len = UM_KERN_PAGE_SIZE;
220-
output = um_kmalloc(output_len);
220+
output = kmalloc(output_len, UM_GFP_KERNEL);
221221
if(output == NULL)
222222
printk("change : failed to allocate output buffer\n");
223223

‎arch/um/drivers/port_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
5050
if(kern_data == NULL)
5151
return NULL;
5252

53-
data = um_kmalloc(sizeof(*data));
53+
data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
5454
if(data == NULL)
5555
goto err;
5656

‎arch/um/drivers/pty.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static void *pty_chan_init(char *str, int device, const struct chan_opts *opts)
2929
{
3030
struct pty_chan *data;
3131

32-
data = um_kmalloc(sizeof(*data));
32+
data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
3333
if (data == NULL)
3434
return NULL;
3535

‎arch/um/drivers/slip_user.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int slip_tramp(char **argv, int fd)
9191
pid = err;
9292

9393
output_len = UM_KERN_PAGE_SIZE;
94-
output = um_kmalloc(output_len);
94+
output = kmalloc(output_len, UM_GFP_KERNEL);
9595
if(output == NULL){
9696
printk("slip_tramp : failed to allocate output buffer\n");
9797
os_kill_process(pid, 1);

‎arch/um/drivers/tty.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static void *tty_chan_init(char *str, int device, const struct chan_opts *opts)
2929
}
3030
str++;
3131

32-
data = um_kmalloc(sizeof(*data));
32+
data = kmalloc(sizeof(*data), UM_GFP_KERNEL);
3333
if(data == NULL)
3434
return NULL;
3535
*data = ((struct tty_chan) { .dev = str,

‎arch/um/include/common-offsets.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ DEFINE(UM_ELFCLASS64, ELFCLASS64);
2727

2828
DEFINE(UM_NR_CPUS, NR_CPUS);
2929

30+
DEFINE(UM_GFP_KERNEL, GFP_KERNEL);
31+
DEFINE(UM_GFP_ATOMIC, GFP_ATOMIC);
32+
3033
/* For crypto assembler code. */
3134
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
3235

0 commit comments

Comments
 (0)