Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1573216 > unrolled thread

[PATCH] shm: Fix unlikely() test of info->seals to test only for WRITE and GROW

Started by"Steven Rostedt (VMware)" <rostedt@goodmis.org>
First post2017-02-03 17:00 +0100
Last post2017-02-05 00:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] shm: Fix unlikely() test of info->seals to test only for  WRITE and GROW "Steven Rostedt (VMware)" <rostedt@goodmis.org> - 2017-02-03 17:00 +0100
    Re: [PATCH] shm: Fix unlikely() test of info->seals to test only  for WRITE and GROW Hugh Dickins <hughd@google.com> - 2017-02-05 00:00 +0100

#1573216 — [PATCH] shm: Fix unlikely() test of info->seals to test only for WRITE and GROW

From"Steven Rostedt (VMware)" <rostedt@goodmis.org>
Date2017-02-03 17:00 +0100
Subject[PATCH] shm: Fix unlikely() test of info->seals to test only for WRITE and GROW
Message-ID<t6Orh-3Ei-53@gated-at.bofh.it>
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>
---
 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

[toc] | [next] | [standalone]


#1573770 — Re: [PATCH] shm: Fix unlikely() test of info->seals to test only for WRITE and GROW

FromHugh Dickins <hughd@google.com>
Date2017-02-05 00:00 +0100
SubjectRe: [PATCH] shm: Fix unlikely() test of info->seals to test only for WRITE and GROW
Message-ID<t7htf-7hT-9@gated-at.bofh.it>
In reply to#1573216
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web