lkml.org 
[lkml]   [2012]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch 1/4] ipc/mqueue: improve performance of send/recv
On Tue, May 01, 2012 at 01:50:52PM -0400, Doug Ledford wrote:
> @@ -150,16 +241,25 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
> info->attr.mq_maxmsg = attr->mq_maxmsg;
> info->attr.mq_msgsize = attr->mq_msgsize;
> }
> - mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *);
> - if (mq_msg_tblsz > PAGE_SIZE)
> - info->messages = vmalloc(mq_msg_tblsz);
> - else
> - info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
> - if (!info->messages)
> - goto out_inode;
> + /*
> + * We used to allocate a static array of pointers and account
> + * the size of that array as well as one msg_msg struct per
> + * possible message into the queue size. That's no longer
> + * accurate as the queue is now an rbtree and will grow and
> + * shrink depending on usage patterns. We can, however, still
> + * account one msg_msg struct per message, but the nodes are
> + * allocated depending on priority usage, and most programs
> + * only use one, or a handful, of priorities. However, since
> + * this is pinned memory, we need to assume worst case, so
> + * that means the min(mq_maxmsg, max_priorities) * struct
> + * posix_msg_tree_node.
> + */
> + mq_treesize = info->attr.mq_maxmsg * sizeof(struct msg_msg) +
> + min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) *
> + sizeof(struct posix_msg_tree_node);

"info->attr.mq_maxmsg" is a long, but the min_t() truncates it to an
unsigned int. I'm not familiar with this code so I don't know if
that's a problem...

We do the same thing in mqueue_evict_inode() and mq_attr_ok().

regards,
dan carpenter



\
 
 \ /
  Last update: 2012-05-03 11:41    [W:0.108 / U:0.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site