Skip to content

Commit e2c789c

Browse files
Mikulas PatockaMike Snitzer
authored andcommitted
dm: get rid of GFP_NOIO workarounds for __vmalloc and kvmalloc
In the past, the function __vmalloc didn't respect the GFP flags - it allocated memory with the provided gfp flags, but it allocated page tables with GFP_KERNEL. This was fixed in commit 451769e ("mm/vmalloc: alloc GFP_NO{FS,IO} for vmalloc") so the memalloc_noio_{save,restore} workaround is no longer needed. The function kvmalloc didn't like flags different from GFP_KERNEL. This was fixed in commit a421ef3 ("mm: allow !GFP_KERNEL allocations for kvmalloc"), so kvmalloc can now be called with GFP_NOIO. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@kernel.org>
1 parent 3be1622 commit e2c789c

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

drivers/md/dm-bufio.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,23 +1157,6 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
11571157

11581158
*data_mode = DATA_MODE_VMALLOC;
11591159

1160-
/*
1161-
* __vmalloc allocates the data pages and auxiliary structures with
1162-
* gfp_flags that were specified, but pagetables are always allocated
1163-
* with GFP_KERNEL, no matter what was specified as gfp_mask.
1164-
*
1165-
* Consequently, we must set per-process flag PF_MEMALLOC_NOIO so that
1166-
* all allocations done by this process (including pagetables) are done
1167-
* as if GFP_NOIO was specified.
1168-
*/
1169-
if (gfp_mask & __GFP_NORETRY) {
1170-
unsigned int noio_flag = memalloc_noio_save();
1171-
void *ptr = __vmalloc(c->block_size, gfp_mask);
1172-
1173-
memalloc_noio_restore(noio_flag);
1174-
return ptr;
1175-
}
1176-
11771160
return __vmalloc(c->block_size, gfp_mask);
11781161
}
11791162

drivers/md/dm-ioctl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,6 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
19321932
struct dm_ioctl *dmi;
19331933
int secure_data;
19341934
const size_t minimum_data_size = offsetof(struct dm_ioctl, data);
1935-
unsigned int noio_flag;
19361935

19371936
/* check_version() already copied version from userspace, avoid TOCTOU */
19381937
if (copy_from_user((char *)param_kernel + sizeof(param_kernel->version),
@@ -1962,9 +1961,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
19621961
* Use kmalloc() rather than vmalloc() when we can.
19631962
*/
19641963
dmi = NULL;
1965-
noio_flag = memalloc_noio_save();
1966-
dmi = kvmalloc(param_kernel->data_size, GFP_KERNEL | __GFP_HIGH);
1967-
memalloc_noio_restore(noio_flag);
1964+
dmi = kvmalloc(param_kernel->data_size, GFP_NOIO | __GFP_HIGH);
19681965

19691966
if (!dmi) {
19701967
if (secure_data && clear_user(user, param_kernel->data_size))

0 commit comments

Comments
 (0)