path: root/ipc/shm.c
diff options
authorVasily Averin <>2021-06-30 18:57:12 -0700
committerLinus Torvalds <>2021-07-01 11:06:07 -0700
commitbc8136a543aa839a848b49af5e101ac6de5f6b27 (patch)
tree15cb33e272fc047763557e7a82710e576d632853 /ipc/shm.c
parentfc37a3b8b4388e73e8e3525556d9f1feeb232bb9 (diff)
ipc: use kmalloc for msg_queue and shmid_kernel
msg_queue and shmid_kernel are quite small objects, no need to use kvmalloc for them. mhocko@: "Both of them are 256B on most 64b systems." Previously these objects was allocated via ipc_alloc/ipc_rcu_alloc(), common function for several ipc objects. It had kvmalloc call inside(). Later, this function went away and was finally replaced by direct kvmalloc call, and now we can use more suitable kmalloc/kfree for them. Link: Reported-by: Alexey Dobriyan <> Signed-off-by: Vasily Averin <> Acked-by: Michal Hocko <> Reviewed-by: Shakeel Butt <> Acked-by: Roman Gushchin <> Cc: Johannes Weiner <> Cc: Vladimir Davydov <> Cc: Dmitry Safonov <> Cc: Davidlohr Bueso <> Cc: Manfred Spraul <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'ipc/shm.c')
1 files changed, 3 insertions, 3 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index febd88daba8c..a66b2664558b 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -222,7 +222,7 @@ static void shm_rcu_free(struct rcu_head *head)
struct shmid_kernel *shp = container_of(ptr, struct shmid_kernel,
- kvfree(shp);
+ kfree(shp);
static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s)
@@ -619,7 +619,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
ns->shm_tot + numpages > ns->shm_ctlall)
return -ENOSPC;
- shp = kvmalloc(sizeof(*shp), GFP_KERNEL);
+ shp = kmalloc(sizeof(*shp), GFP_KERNEL);
if (unlikely(!shp))
return -ENOMEM;
@@ -630,7 +630,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
shp-> = NULL;
error = security_shm_alloc(&shp->shm_perm);
if (error) {
- kvfree(shp);
+ kfree(shp);
return error;