From: Dan Carpenter <dan.carpenter@oracle.com>
To: Doug Ledford <dledford@redhat.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
sfr@canb.auug.org.au
Subject: Re: [Patch 1/4] ipc/mqueue: improve performance of send/recv
Date: Thu, 3 May 2012 12:21:05 +0300 [thread overview]
Message-ID: <20120503092105.GA6603@mwanda> (raw)
In-Reply-To: <5b62749cb9227016ed5965fa57b96c0dccce37a8.1335894230.git.dledford@redhat.com>
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
next prev parent reply other threads:[~2012-05-03 9:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-01 17:50 [Patch 0/4] ipc/mqueue improvements Doug Ledford
2012-05-01 17:50 ` [Patch 1/4] ipc/mqueue: improve performance of send/recv Doug Ledford
2012-05-01 17:50 ` [Patch 2/4] ipc/mqueue: correct mq_attr_ok test Doug Ledford
2012-05-01 19:34 ` Andrew Morton
2012-05-01 19:38 ` Doug Ledford
2012-05-01 17:50 ` [Patch 3/4] ipc/mqueue: strengthen checks on mqueue creation Doug Ledford
2012-05-01 20:01 ` KOSAKI Motohiro
2012-05-01 20:11 ` Doug Ledford
2012-05-01 20:18 ` KOSAKI Motohiro
2012-05-01 23:02 ` Doug Ledford
2012-05-01 23:04 ` KOSAKI Motohiro
2012-05-01 23:11 ` Andrew Morton
2012-05-01 17:50 ` [Patch 4/4] tools/selftests: add mq_perf_tests Doug Ledford
2012-05-01 19:53 ` Andrew Morton
2012-05-01 20:14 ` Doug Ledford
2012-05-03 9:21 ` Dan Carpenter [this message]
2012-05-03 13:03 ` [Patch 1/4] ipc/mqueue: improve performance of send/recv Doug Ledford
2012-05-03 10:05 ` Nick Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120503092105.GA6603@mwanda \
--to=dan.carpenter@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.