From: Hugh Dickins <hughd@google.com>
To: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Herrmann <dh.herrmann@gmail.com>,
Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] shm: Fix unlikely() test of info->seals to test only for WRITE and GROW
Date: Sat, 4 Feb 2017 14:51:55 -0800 (PST) [thread overview]
Message-ID: <alpine.LSU.2.11.1702041449400.1865@eggly.anvils> (raw)
In-Reply-To: <20170203105656.7aec6237@gandalf.local.home>
On Fri, 3 Feb 2017, Steven Rostedt (VMware) wrote:
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> Running my likely/unlikely profiler, I discovered that the test in
> shmem_write_begin() that tests for info->seals as unlikely, is
> always incorrect. This is because shmem_get_inode() sets info->seals to
> have F_SEAL_SEAL set by default, and it is unlikely to be cleared when
> shmem_write_begin() is called. Thus, the if statement is very likely.
>
> But as the if statement block only cares about F_SEAL_WRITE and
> F_SEAL_GROW, change the test to only test those two bits.
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Hugh Dickins <hughd@google.com>
> ---
> mm/shmem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index bb53285..ef4cdbb 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2194,7 +2194,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping,
> pgoff_t index = pos >> PAGE_SHIFT;
>
> /* i_mutex is held by caller */
> - if (unlikely(info->seals)) {
> + if (unlikely(info->seals & (F_SEAL_WRITE | F_SEAL_GROW))) {
> if (info->seals & F_SEAL_WRITE)
> return -EPERM;
> if ((info->seals & F_SEAL_GROW) && pos + len > inode->i_size)
> --
> 2.9.3
prev parent reply other threads:[~2017-02-04 22:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 15:56 Steven Rostedt (VMware)
2017-02-04 22:51 ` Hugh Dickins [this message]
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=alpine.LSU.2.11.1702041449400.1865@eggly.anvils \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=dh.herrmann@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/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
all inboxes | Powered by JetHome®