Skip to content

Commit

Permalink
mqueue: don't use kmalloc with KMALLOC_MAX_SIZE
Browse files Browse the repository at this point in the history
KMALLOC_MAX_SIZE is not a good threshold.  It is extremely high and
problematic.  Unfortunately, some silly drivers depend on this and we
can't change it.  But any new code needn't use such extreme ugly high
order allocations.  It brings us awful fragmentation issues and system
slowdown.

Signed-off-by: KOSAKI Motohiro <[email protected]>
Acked-by: Doug Ledford <[email protected]>
Acked-by: Joe Korty <[email protected]>
Cc: Amerigo Wang <[email protected]>
Cc: Serge E. Hallyn <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: Joe Korty <[email protected]>
Cc: Manfred Spraul <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kosaki authored and torvalds committed Jun 1, 2012
1 parent e6315bb commit fd1f87d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ipc/mqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
info->attr.mq_msgsize = attr->mq_msgsize;
}
mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *);
if (mq_msg_tblsz > KMALLOC_MAX_SIZE)
if (mq_msg_tblsz > PAGE_SIZE)
info->messages = vmalloc(mq_msg_tblsz);
else
info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
Expand Down Expand Up @@ -266,7 +266,7 @@ static void mqueue_evict_inode(struct inode *inode)
spin_lock(&info->lock);
for (i = 0; i < info->attr.mq_curmsgs; i++)
free_msg(info->messages[i]);
if (info->attr.mq_maxmsg * sizeof(struct msg_msg *) > KMALLOC_MAX_SIZE)
if (is_vmalloc_addr(info->messages))
vfree(info->messages);
else
kfree(info->messages);
Expand Down

0 comments on commit fd1f87d

Please sign in to comment.