* [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
@ 2016-11-23 9:23 Kirill A. Shutemov
2016-11-23 9:30 ` Kirill A. Shutemov
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Kirill A. Shutemov @ 2016-11-23 9:23 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, Naoya Horiguchi, Doug Nelson, Kirill A. Shutemov, [4.8+]
Hugetlb pages have ->index in size of the huge pages (PMD_SIZE or
PUD_SIZE), not in PAGE_SIZE as other types of pages. This means we
cannot user page_to_pgoff() to check whether we've got the right page
for the radix-tree index.
Let's introduce page_to_index() which would return radix-tree index for
given page.
We will be able to get rid of this once hugetlb will be switched to
multi-order entries.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-and-tested-by: Doug Nelson <doug.nelson@intel.com>
Fixes: fc127da085c2 ("truncate: handle file thp")
Cc: <stable@vger.kernel.org> [4.8+]
---
include/linux/pagemap.h | 23 +++++++++++++++++------
mm/truncate.c | 8 ++++----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index dd15d39e1985..7e68545d58d8 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -374,16 +374,13 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
}
/*
- * Get the offset in PAGE_SIZE.
- * (TODO: hugepage should have ->index in PAGE_SIZE)
+ * Index of the page with in radix-tree
+ * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
*/
-static inline pgoff_t page_to_pgoff(struct page *page)
+static inline pgoff_t page_to_index(struct page *page)
{
pgoff_t pgoff;
- if (unlikely(PageHeadHuge(page)))
- return page->index << compound_order(page);
-
if (likely(!PageTransTail(page)))
return page->index;
@@ -397,6 +394,20 @@ static inline pgoff_t page_to_pgoff(struct page *page)
}
/*
+ * Get the offset in PAGE_SIZE.
+ * (TODO: hugepage should have ->index in PAGE_SIZE)
+ */
+static inline pgoff_t page_to_pgoff(struct page *page)
+{
+ pgoff_t pgoff;
+
+ if (unlikely(PageHeadHuge(page)))
+ return page->index << compound_order(page);
+
+ return page_to_index(page);
+}
+
+/*
* Return byte-offset into filesystem object for page.
*/
static inline loff_t page_offset(struct page *page)
diff --git a/mm/truncate.c b/mm/truncate.c
index a01cce450a26..8d8c62d89e6d 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -283,7 +283,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
if (!trylock_page(page))
continue;
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
if (PageWriteback(page)) {
unlock_page(page);
continue;
@@ -371,7 +371,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
}
lock_page(page);
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
wait_on_page_writeback(page);
truncate_inode_page(mapping, page);
unlock_page(page);
@@ -492,7 +492,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
if (!trylock_page(page))
continue;
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
/* Middle of THP: skip */
if (PageTransTail(page)) {
@@ -612,7 +612,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
}
lock_page(page);
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
if (page->mapping != mapping) {
unlock_page(page);
continue;
--
2.10.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
2016-11-23 9:23 [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb Kirill A. Shutemov
@ 2016-11-23 9:30 ` Kirill A. Shutemov
2016-11-23 11:52 ` kbuild test robot
2016-11-23 12:07 ` kbuild test robot
2 siblings, 0 replies; 8+ messages in thread
From: Kirill A. Shutemov @ 2016-11-23 9:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, Naoya Horiguchi, Doug Nelson, [4.8+]
Sorry, forgot to commit local changes.
----8<----
>From 321379738fa2359385a38dfac838a83c261a382d Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date: Wed, 23 Nov 2016 12:05:30 +0300
Subject: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for
hugetlb
Hugetlb pages have ->index in size of the huge pages (PMD_SIZE or
PUD_SIZE), not in PAGE_SIZE as other types of pages. This means we
cannot user page_to_pgoff() to check whether we've got the right page
for the radix-tree index.
Let's introduce page_to_index() which would return radix-tree index for
given page.
We will be able to get rid of this once hugetlb will be switched to
multi-order entries.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-and-tested-by: Doug Nelson <doug.nelson@intel.com>
Fixes: fc127da085c2 ("truncate: handle file thp")
Cc: <stable@vger.kernel.org> [4.8+]
---
include/linux/pagemap.h | 21 +++++++++++++++------
mm/truncate.c | 8 ++++----
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index dd15d39e1985..7dbe9148b2f8 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -374,16 +374,13 @@ static inline struct page *read_mapping_page(struct address_space *mapping,
}
/*
- * Get the offset in PAGE_SIZE.
- * (TODO: hugepage should have ->index in PAGE_SIZE)
+ * Get index of the page with in radix-tree
+ * (TODO: remove once hugetlb pages will have ->index in PAGE_SIZE)
*/
-static inline pgoff_t page_to_pgoff(struct page *page)
+static inline pgoff_t page_to_index(struct page *page)
{
pgoff_t pgoff;
- if (unlikely(PageHeadHuge(page)))
- return page->index << compound_order(page);
-
if (likely(!PageTransTail(page)))
return page->index;
@@ -397,6 +394,18 @@ static inline pgoff_t page_to_pgoff(struct page *page)
}
/*
+ * Get the offset in PAGE_SIZE.
+ * (TODO: hugepage should have ->index in PAGE_SIZE)
+ */
+static inline pgoff_t page_to_pgoff(struct page *page)
+{
+ if (unlikely(PageHeadHuge(page)))
+ return page->index << compound_order(page);
+
+ return page_to_index(page);
+}
+
+/*
* Return byte-offset into filesystem object for page.
*/
static inline loff_t page_offset(struct page *page)
diff --git a/mm/truncate.c b/mm/truncate.c
index a01cce450a26..8d8c62d89e6d 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -283,7 +283,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
if (!trylock_page(page))
continue;
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
if (PageWriteback(page)) {
unlock_page(page);
continue;
@@ -371,7 +371,7 @@ void truncate_inode_pages_range(struct address_space *mapping,
}
lock_page(page);
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
wait_on_page_writeback(page);
truncate_inode_page(mapping, page);
unlock_page(page);
@@ -492,7 +492,7 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
if (!trylock_page(page))
continue;
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
/* Middle of THP: skip */
if (PageTransTail(page)) {
@@ -612,7 +612,7 @@ int invalidate_inode_pages2_range(struct address_space *mapping,
}
lock_page(page);
- WARN_ON(page_to_pgoff(page) != index);
+ WARN_ON(page_to_index(page) != index);
if (page->mapping != mapping) {
unlock_page(page);
continue;
--
Kirill A. Shutemov
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
@ 2016-11-23 9:30 ` Kirill A. Shutemov
0 siblings, 0 replies; 8+ messages in thread
From: Kirill A. Shutemov @ 2016-11-23 9:30 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, Naoya Horiguchi, Doug Nelson, [4.8+]
Sorry, forgot to commit local changes.
----8<----
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
2016-11-23 9:23 [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb Kirill A. Shutemov
@ 2016-11-23 11:52 ` kbuild test robot
2016-11-23 11:52 ` kbuild test robot
2016-11-23 12:07 ` kbuild test robot
2 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2016-11-23 11:52 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild-all, Andrew Morton, linux-mm, Naoya Horiguchi,
Doug Nelson, Kirill A. Shutemov, [4.8+]
[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]
Hi Kirill,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.9-rc6 next-20161123]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/mm-fix-false-positive-WARN_ON-in-truncate-invalidate-for-hugetlb/20161123-185641
config: alpha-defconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha
All errors (new ones prefixed by >>):
In file included from arch/alpha/mm/init.c:9:0:
include/linux/pagemap.h: In function 'page_to_pgoff':
>> include/linux/pagemap.h:402:10: error: unused variable 'pgoff' [-Werror=unused-variable]
pgoff_t pgoff;
^~~~~
cc1: all warnings being treated as errors
vim +/pgoff +402 include/linux/pagemap.h
396 /*
397 * Get the offset in PAGE_SIZE.
398 * (TODO: hugepage should have ->index in PAGE_SIZE)
399 */
400 static inline pgoff_t page_to_pgoff(struct page *page)
401 {
> 402 pgoff_t pgoff;
403
404 if (unlikely(PageHeadHuge(page)))
405 return page->index << compound_order(page);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 12066 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
@ 2016-11-23 11:52 ` kbuild test robot
0 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2016-11-23 11:52 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild-all, Andrew Morton, linux-mm, Naoya Horiguchi,
Doug Nelson, [4.8+]
[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]
Hi Kirill,
[auto build test ERROR on linus/master]
[also build test ERROR on v4.9-rc6 next-20161123]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/mm-fix-false-positive-WARN_ON-in-truncate-invalidate-for-hugetlb/20161123-185641
config: alpha-defconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha
All errors (new ones prefixed by >>):
In file included from arch/alpha/mm/init.c:9:0:
include/linux/pagemap.h: In function 'page_to_pgoff':
>> include/linux/pagemap.h:402:10: error: unused variable 'pgoff' [-Werror=unused-variable]
pgoff_t pgoff;
^~~~~
cc1: all warnings being treated as errors
vim +/pgoff +402 include/linux/pagemap.h
396 /*
397 * Get the offset in PAGE_SIZE.
398 * (TODO: hugepage should have ->index in PAGE_SIZE)
399 */
400 static inline pgoff_t page_to_pgoff(struct page *page)
401 {
> 402 pgoff_t pgoff;
403
404 if (unlikely(PageHeadHuge(page)))
405 return page->index << compound_order(page);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 12066 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
2016-11-23 9:23 [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb Kirill A. Shutemov
@ 2016-11-23 12:07 ` kbuild test robot
2016-11-23 11:52 ` kbuild test robot
2016-11-23 12:07 ` kbuild test robot
2 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2016-11-23 12:07 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild-all, Andrew Morton, linux-mm, Naoya Horiguchi,
Doug Nelson, Kirill A. Shutemov, [4.8+]
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
Hi Kirill,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.9-rc6 next-20161123]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/mm-fix-false-positive-WARN_ON-in-truncate-invalidate-for-hugetlb/20161123-185641
config: x86_64-randconfig-a0-11231631 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from fs/hfsplus/super.c:12:
include/linux/pagemap.h: In function 'page_to_pgoff':
>> include/linux/pagemap.h:402: warning: unused variable 'pgoff'
vim +/pgoff +402 include/linux/pagemap.h
386
387 /*
388 * We don't initialize ->index for tail pages: calculate based on
389 * head page
390 */
391 pgoff = compound_head(page)->index;
392 pgoff += page - compound_head(page);
393 return pgoff;
394 }
395
396 /*
397 * Get the offset in PAGE_SIZE.
398 * (TODO: hugepage should have ->index in PAGE_SIZE)
399 */
400 static inline pgoff_t page_to_pgoff(struct page *page)
401 {
> 402 pgoff_t pgoff;
403
404 if (unlikely(PageHeadHuge(page)))
405 return page->index << compound_order(page);
406
407 return page_to_index(page);
408 }
409
410 /*
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28158 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
@ 2016-11-23 12:07 ` kbuild test robot
0 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2016-11-23 12:07 UTC (permalink / raw)
To: Kirill A. Shutemov
Cc: kbuild-all, Andrew Morton, linux-mm, Naoya Horiguchi,
Doug Nelson, [4.8+]
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
Hi Kirill,
[auto build test WARNING on linus/master]
[also build test WARNING on v4.9-rc6 next-20161123]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kirill-A-Shutemov/mm-fix-false-positive-WARN_ON-in-truncate-invalidate-for-hugetlb/20161123-185641
config: x86_64-randconfig-a0-11231631 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from fs/hfsplus/super.c:12:
include/linux/pagemap.h: In function 'page_to_pgoff':
>> include/linux/pagemap.h:402: warning: unused variable 'pgoff'
vim +/pgoff +402 include/linux/pagemap.h
386
387 /*
388 * We don't initialize ->index for tail pages: calculate based on
389 * head page
390 */
391 pgoff = compound_head(page)->index;
392 pgoff += page - compound_head(page);
393 return pgoff;
394 }
395
396 /*
397 * Get the offset in PAGE_SIZE.
398 * (TODO: hugepage should have ->index in PAGE_SIZE)
399 */
400 static inline pgoff_t page_to_pgoff(struct page *page)
401 {
> 402 pgoff_t pgoff;
403
404 if (unlikely(PageHeadHuge(page)))
405 return page->index << compound_order(page);
406
407 return page_to_index(page);
408 }
409
410 /*
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28158 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb
2016-11-23 9:30 ` Kirill A. Shutemov
(?)
@ 2016-11-24 1:37 ` Naoya Horiguchi
-1 siblings, 0 replies; 8+ messages in thread
From: Naoya Horiguchi @ 2016-11-24 1:37 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: Andrew Morton, linux-mm, Doug Nelson, [4.8+]
On Wed, Nov 23, 2016 at 12:30:53PM +0300, Kirill A. Shutemov wrote:
> Sorry, forgot to commit local changes.
>
> ----8<----
>
> From 321379738fa2359385a38dfac838a83c261a382d Mon Sep 17 00:00:00 2001
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
> Date: Wed, 23 Nov 2016 12:05:30 +0300
> Subject: [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for
> hugetlb
>
> Hugetlb pages have ->index in size of the huge pages (PMD_SIZE or
> PUD_SIZE), not in PAGE_SIZE as other types of pages. This means we
> cannot user page_to_pgoff() to check whether we've got the right page
> for the radix-tree index.
>
> Let's introduce page_to_index() which would return radix-tree index for
> given page.
>
> We will be able to get rid of this once hugetlb will be switched to
> multi-order entries.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reported-and-tested-by: Doug Nelson <doug.nelson@intel.com>
> Fixes: fc127da085c2 ("truncate: handle file thp")
> Cc: <stable@vger.kernel.org> [4.8+]
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-11-24 1:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-23 9:23 [PATCH] mm: fix false-positive WARN_ON() in truncate/invalidate for hugetlb Kirill A. Shutemov
2016-11-23 9:30 ` Kirill A. Shutemov
2016-11-23 9:30 ` Kirill A. Shutemov
2016-11-24 1:37 ` Naoya Horiguchi
2016-11-23 11:52 ` kbuild test robot
2016-11-23 11:52 ` kbuild test robot
2016-11-23 12:07 ` kbuild test robot
2016-11-23 12:07 ` kbuild test robot
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.