From: Andrew Morton <akpm@linux-foundation.org>
To: Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>
Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso <davidlohr@hp.com>,
Manfred Spraul <manfred@colorfullife.com>,
"J. Bruce Fields" <bfields@redhat.com>,
Doug Ledford <dledford@redhat.com>,
linux-newbie@vger.kernel.org
Subject: Re: [PATCH 1/1] ipc/mqueue.c: Drag unneeded code out of locks
Date: Tue, 11 Nov 2014 16:21:46 -0800 [thread overview]
Message-ID: <20141111162146.6e72c3fb0858df4945096c47@linux-foundation.org> (raw)
In-Reply-To: <fae396b9bc15.545c5b55@langara.bc.ca>
On Fri, 07 Nov 2014 05:40:37 +0000 (GMT) Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca> wrote:
> This shouldn't be too controversial. I simply looked for where there
> was a tiny bit of waste in the message queue code.
>
It's probably better to do this as three or four separate patches.
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -278,16 +278,29 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
> mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
> info->attr.mq_msgsize);
>
> - spin_lock(&mq_lock);
> - if (u->mq_bytes + mq_bytes < u->mq_bytes ||
> - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
> + {
> + bool too_many_open_files;
Well yes, that's what EMFILE means but "too_many_open_files" doesn't
make sense in this context!
> + long msgqueue_lim;
> + unsigned long u_bytes;
> +
> + msgqueue_lim = rlimit(RLIMIT_MSGQUEUE);
> +
> + spin_lock(&mq_lock);
> +
> + u_bytes = u->mq_bytes;
> + too_many_open_files = u_bytes + mq_bytes < u_bytes ||
> + u_bytes + mq_bytes > msgqueue_lim;
> + if (!too_many_open_files)
This test isn't really needed.
> + u->mq_bytes += mq_bytes;
> +
> spin_unlock(&mq_lock);
> +
> /* mqueue_evict_inode() releases info->messages */
> - ret = -EMFILE;
> - goto out_inode;
> + if (too_many_open_files) {
> + ret = -EMFILE;
> + goto out_inode;
> + }
> }
> - u->mq_bytes += mq_bytes;
> - spin_unlock(&mq_lock);
>
> /* all is ok */
> info->user = get_uid(u);
> @@ -423,44 +436,60 @@ static int mqueue_create(struct inode *dir, struct dentry
> *dentry,
> umode_t mode, bool excl)
> {
> struct inode *inode;
> - struct mq_attr *attr = dentry->d_fsdata;
> - int error;
> + struct mq_attr *attr;
> struct ipc_namespace *ipc_ns;
> + int error = 0;
> +
> + if (!capable(CAP_SYS_RESOURCE)) {
> + error = -ENOSPC;
> + goto finish;
> + }
Thatsabug. It only requires CAP_SYS_RESOURCE if we're trying with
queues_count >= queues_max.
next prev parent reply other threads:[~2014-11-12 0:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 5:40 [PATCH 1/1] ipc/mqueue.c: Drag unneeded code out of locks Steven Stewart-Gallus
2014-11-12 0:21 ` Andrew Morton [this message]
2014-11-15 4:42 ` Steven Stewart-Gallus
2014-11-12 8:16 ` Davidlohr Bueso
2014-11-15 4:44 ` Steven Stewart-Gallus
2014-11-15 21:22 ` Davidlohr Bueso
2014-11-16 19:40 ` Steven Stewart-Gallus
2014-11-17 19:08 ` Manfred Spraul
2014-11-17 20:52 ` Davidlohr Bueso
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=20141111162146.6e72c3fb0858df4945096c47@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bfields@redhat.com \
--cc=davidlohr@hp.com \
--cc=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-newbie@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=sstewartgallus00@mylangara.bc.ca \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox