From: Steven Rostedt (VMware) Date: Fri, 24 Feb 2017 22:59:10 +0000 (-0800) Subject: mm/shmem.c: fix unlikely() test of info->seals to test only for WRITE and GROW X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=931225a2c76bb00cdf1041318447d53c318bf55c;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git mm/shmem.c: fix unlikely() test of info->seals to test only for WRITE and GROW 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. Link: http://lkml.kernel.org/r/20170203105656.7aec6237@gandalf.local.home Signed-off-by: Steven Rostedt (VMware) Acked-by: Hugh Dickins Cc: David Herrmann Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Change-Id: I83b8fc6ebae581486df16842713ba83a37e3b858 --- diff --git a/mm/shmem.c b/mm/shmem.c index 28da0348982..a7cf8c0371a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1528,7 +1528,7 @@ shmem_write_begin(struct file *file, struct address_space *mapping, pgoff_t index = pos >> PAGE_CACHE_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)