Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1228479 > unrolled thread
| Started by | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| First post | 2015-09-19 19:20 +0200 |
| Last post | 2015-09-24 22:30 +0200 |
| Articles | 20 on this page of 33 — 7 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] fix allmodconfig failure of avr32 Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-19 19:20 +0200
[PATCH 3/3] page-flags: rectify forward declaration Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-19 19:20 +0200
Re: [PATCH 3/3] page-flags: rectify forward declaration Andrew Morton <akpm@linux-foundation.org> - 2015-09-22 00:40 +0200
Re: [PATCH 3/3] page-flags: rectify forward declaration Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-22 11:00 +0200
Re: [PATCH 3/3] page-flags: rectify forward declaration Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-24 17:30 +0200
[PATCH 14/16] page-flags: define PG_uptodate behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 11/16] page-flags: define PG_swapcache behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 02/16] page-flags: move code around "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 05/16] page-flags: define behavior of FS/IO-related flags on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 01/16] page-flags: trivial cleanup for PageTrans* helpers "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
Re: [PATCH 01/16] page-flags: trivial cleanup for PageTrans* helpers Christoph Lameter <cl@linux.com> - 2015-09-24 17:50 +0200
[PATCH 09/16] page-flags: define PG_reserved behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 06/16] page-flags: define behavior of LRU-related flags on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 13/16] page-flags: define PG_uncached behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 10/16] page-flags: define PG_swapbacked behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 15/16] page-flags: look at head page if the flag is encoded in page->mapping "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 08/16] page-flags: define behavior of Xen-related flags on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 16/16] mm: sanitize page->mapping for tail pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
Re: [PATCH 16/16] mm: sanitize page->mapping for tail pages Jerome Glisse <j.glisse@gmail.com> - 2015-09-25 04:30 +0200
[PATCH 07/16] page-flags: define behavior SL*B-related flags on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 00/16] Refreshed page-flags patchset "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 12/16] page-flags: define PG_mlocked behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
[PATCH 03/16] page-flags: introduce page flags policies wrt compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
Re: [PATCH 03/16] page-flags: introduce page flags policies wrt compound pages Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-25 14:30 +0200
Re: [PATCH 03/16] page-flags: introduce page flags policies wrt compound pages "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-09-25 21:20 +0200
Re: [PATCH 03/16] page-flags: introduce page flags policies wrt compound pages "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-09-28 13:10 +0200
Re: [PATCH 03/16] page-flags: introduce page flags policies wrt compound pages Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-09-28 13:50 +0200
Re: [PATCH 03/16] page-flags: introduce page flags policies wrt compound pages "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-09-28 20:00 +0200
[PATCH 04/16] page-flags: define PG_locked behavior on compound pages "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-09-24 17:00 +0200
Re: [PATCH 04/16] page-flags: define PG_locked behavior on compound pages Christoph Lameter <cl@linux.com> - 2015-09-24 18:10 +0200
Re: [PATCH 04/16] page-flags: define PG_locked behavior on compound pages "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-09-24 22:30 +0200
Re: [PATCH 00/16] Refreshed page-flags patchset Christoph Lameter <cl@linux.com> - 2015-09-24 18:20 +0200
Re: [PATCH 00/16] Refreshed page-flags patchset "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-09-24 22:30 +0200
Page 1 of 2 [1] 2 Next page →
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-19 19:20 +0200 |
| Subject | [PATCH 0/3] fix allmodconfig failure of avr32 |
| Message-ID | <qatXQ-7P2-7@gated-at.bofh.it> |
Build of allmodconfig with avr32 used to fail with the errors: error: implicit declaration of function 'pci_iomap' error: implicit declaration of function 'pci_iounmap' and "at91_pmc_base" [drivers/usb/gadget/udc/atmel_usba_udc.ko] undefined! First two patches fixes these two problems. Third patch is related to a build warning: warning: 'compound_head' declared inline after being called. warning: previous declaration of 'compound_head' was here. regards sudip Sudip Mukherjee (3): avr32: fix build failure usb: gadget: at91_udc: mention proper dependency page-flags: rectify forward declaration arch/avr32/include/asm/io.h | 13 +++++++++++++ drivers/usb/gadget/udc/Kconfig | 2 +- include/linux/page-flags.h | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-19 19:20 +0200 |
| Subject | [PATCH 3/3] page-flags: rectify forward declaration |
| Message-ID | <qatXQ-7P2-17@gated-at.bofh.it> |
| In reply to | #1228479 |
compound_head is defined as inline in page-flags.h but in the forward
declaration of compound_head in the same file missed "inline". As a result
we got plenty of build warnings while building for some architecture
like avr32. The warning showed as:
warning: 'compound_head' declared inline after being called.
warning: previous declaration of 'compound_head' was here
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
tested build with avr32 and also with x86_64 allmodconfig to verify that
nothing breaks due to this change.
include/linux/page-flags.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index ab1a0e9..2a2391c 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -227,7 +227,7 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
struct page;
static inline int PageCompound(struct page *page);
static inline int PageTail(struct page *page);
-static struct page *compound_head(struct page *page);
+static inline struct page *compound_head(struct page *page);
__PAGEFLAG(Locked, locked, PF_NO_TAIL)
PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2015-09-22 00:40 +0200 |
| Subject | Re: [PATCH 3/3] page-flags: rectify forward declaration |
| Message-ID | <qbhUB-3qy-7@gated-at.bofh.it> |
| In reply to | #1228481 |
On Sat, 19 Sep 2015 22:42:59 +0530 Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
> compound_head is defined as inline in page-flags.h but in the forward
> declaration of compound_head in the same file missed "inline". As a result
> we got plenty of build warnings while building for some architecture
> like avr32. The warning showed as:
> warning: 'compound_head' declared inline after being called.
> warning: previous declaration of 'compound_head' was here
>
> ...
>
> --- a/include/linux/page-flags.h
> +++ b/include/linux/page-flags.h
> @@ -227,7 +227,7 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
> struct page;
> static inline int PageCompound(struct page *page);
> static inline int PageTail(struct page *page);
> -static struct page *compound_head(struct page *page);
> +static inline struct page *compound_head(struct page *page);
>
> __PAGEFLAG(Locked, locked, PF_NO_TAIL)
> PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
Yes, that's an error, in -mm due to Kirill's page-flags patches.
The code is effectively doing
static inline XXX foo(...);
static inline YYY bar(...)
{
foo(...);
}
inline XXX foo(...)
{
...
}
ie: asking gcc to inline a forward-defined function. That does work,
but it's unusual and unexpected, and it's a bit unwise to expect the
compiler to do unusual and more difficult things.
Is it fixable? Can we use the traditional define-before-using structure?
Also, I'm finding that the patch series introduces a pretty large
bisection hole:
include/linux/page-flags.h: In function 'PageYoung':
include/linux/page-flags.h:327: error: implicit declaration of function 'PF_ANY'
include/linux/page-flags.h:327: error: invalid type argument of '->' (have 'int')
include/linux/page-flags.h:327: error: invalid type argument of '->' (have 'int')
which later gets fixed up by
page-flags-rectify-forward-declaration.patch.
Maybe it's time to do a wholesale refactoring of the patchset?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-22 11:00 +0200 |
| Subject | Re: [PATCH 3/3] page-flags: rectify forward declaration |
| Message-ID | <qbrAC-qV-19@gated-at.bofh.it> |
| In reply to | #1229798 |
On Mon, Sep 21, 2015 at 03:35:09PM -0700, Andrew Morton wrote:
> On Sat, 19 Sep 2015 22:42:59 +0530 Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
>
<snip>
>
> Is it fixable? Can we use the traditional define-before-using structure?
How about this:
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index ab1a0e9..d7a1055 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -133,6 +133,19 @@ enum pageflags {
#ifndef __GENERATING_BOUNDS_H
+/* Forward declarations */
+struct page;
+static inline int PageCompound(struct page *page);
+static inline int PageTail(struct page *page);
+static inline struct page *compound_head(struct page *page)
+{
+ unsigned long head = READ_ONCE(page->compound_head);
+
+ if (unlikely(head & 1))
+ return (struct page *) (head - 1);
+ return page;
+}
+
/* Page flags policies wrt compound pages */
#define PF_ANY(page, enforce) page
#define PF_HEAD(page, enforce) compound_head(page)
@@ -223,12 +236,6 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
#define TESTSCFLAG_FALSE(uname) \
TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
-/* Forward declarations */
-struct page;
-static inline int PageCompound(struct page *page);
-static inline int PageTail(struct page *page);
-static struct page *compound_head(struct page *page);
-
__PAGEFLAG(Locked, locked, PF_NO_TAIL)
PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
PAGEFLAG(Referenced, referenced, PF_HEAD)
@@ -450,15 +457,6 @@ static inline void clear_compound_head(struct page *page)
WRITE_ONCE(page->compound_head, 0);
}
-static inline struct page *compound_head(struct page *page)
-{
- unsigned long head = READ_ONCE(page->compound_head);
-
- if (unlikely(head & 1))
- return (struct page *) (head - 1);
- return page;
-}
-
static inline int PageCompound(struct page *page)
{
return PageHead(page) || PageTail(page);
---
It builds properly. Tested with allmodconfig of x86_64 and avr32.
>
> Also, I'm finding that the patch series introduces a pretty large
> bisection hole:
>
> include/linux/page-flags.h: In function 'PageYoung':
> include/linux/page-flags.h:327: error: implicit declaration of function 'PF_ANY'
> include/linux/page-flags.h:327: error: invalid type argument of '->' (have 'int')
> include/linux/page-flags.h:327: error: invalid type argument of '->' (have 'int')
>
> which later gets fixed up by
> page-flags-rectify-forward-declaration.patch.
How to test this? Should I apply them on top of v4.2 and bisect? And I
don't see any relation between the first two patches and this patch of
the series, then how does it fail in bisect? Am I missing something?
Confused.. :(
>
> Maybe it's time to do a wholesale refactoring of the patchset?
If this patch is the first in the series will that help?
And besides I got the auto mail from you that the patch is applied.
Now totally confused.. :(
regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Date | 2015-09-24 17:30 +0200 |
| Subject | Re: [PATCH 3/3] page-flags: rectify forward declaration |
| Message-ID | <qcgD7-70f-7@gated-at.bofh.it> |
| In reply to | #1229988 |
> > > > Also, I'm finding that the patch series introduces a pretty large > > bisection hole: > > > > include/linux/page-flags.h: In function 'PageYoung': > > include/linux/page-flags.h:327: error: implicit declaration of function 'PF_ANY' > > include/linux/page-flags.h:327: error: invalid type argument of '->' (have 'int') > > include/linux/page-flags.h:327: error: invalid type argument of '->' (have 'int') > > > > which later gets fixed up by > > page-flags-rectify-forward-declaration.patch. > How to test this? Should I apply them on top of v4.2 and bisect? And I > don't see any relation between the first two patches and this patch of > the series, then how does it fail in bisect? Am I missing something? > Confused.. :( > > > > Maybe it's time to do a wholesale refactoring of the patchset? > If this patch is the first in the series will that help? > And besides I got the auto mail from you that the patch is applied. > Now totally confused.. :( Ohhh ..all the time you were talking about Kirill's patch set and I kept thinking you are mentioning about this patchset. :) regards sudip -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 14/16] page-flags: define PG_uptodate behavior on compound pages |
| Message-ID | <qcga6-6cP-3@gated-at.bofh.it> |
| In reply to | #1229798 |
We use PG_uptodate on head pages on transparent huge page.
Let's use PF_NO_TAIL.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/page-flags.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 5e52cc6a27c3..e3ccd95de660 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -392,8 +392,9 @@ u64 stable_page_flags(struct page *page);
static inline int PageUptodate(struct page *page)
{
- int ret = test_bit(PG_uptodate, &(page)->flags);
-
+ int ret;
+ page = compound_head(page);
+ ret = test_bit(PG_uptodate, &(page)->flags);
/*
* Must ensure that the data we read out of the page is loaded
* _after_ we've loaded page->flags to check for PageUptodate.
@@ -410,12 +411,14 @@ static inline int PageUptodate(struct page *page)
static inline void __SetPageUptodate(struct page *page)
{
+ VM_BUG_ON_PAGE(PageTail(page), page);
smp_wmb();
__set_bit(PG_uptodate, &page->flags);
}
static inline void SetPageUptodate(struct page *page)
{
+ VM_BUG_ON_PAGE(PageTail(page), page);
/*
* Memory barrier must be issued before setting the PG_uptodate bit,
* so that all previous stores issued in order to bring the page
@@ -425,7 +428,7 @@ static inline void SetPageUptodate(struct page *page)
set_bit(PG_uptodate, &page->flags);
}
-CLEARPAGEFLAG(Uptodate, uptodate, PF_ANY)
+CLEARPAGEFLAG(Uptodate, uptodate, PF_NO_TAIL)
int test_clear_page_writeback(struct page *page);
int __test_set_page_writeback(struct page *page, bool keep_write);
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 11/16] page-flags: define PG_swapcache behavior on compound pages |
| Message-ID | <qcga7-6cP-23@gated-at.bofh.it> |
| In reply to | #1229798 |
Swap cannot handle compound pages so far. Transparent huge pages are split on the way to swap. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- include/linux/page-flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index a31d682caeb2..c933416b2f92 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -306,7 +306,7 @@ PAGEFLAG_FALSE(HighMem) #endif #ifdef CONFIG_SWAP -PAGEFLAG(SwapCache, swapcache, PF_ANY) +PAGEFLAG(SwapCache, swapcache, PF_NO_COMPOUND) #else PAGEFLAG_FALSE(SwapCache) #endif -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 02/16] page-flags: move code around |
| Message-ID | <qcga6-6cP-15@gated-at.bofh.it> |
| In reply to | #1229798 |
The preparation patch: we are going to use compound_head(), PageTail()
and PageCompound() to define page-flags helpers.
Let's define them before macros.
We cannot user PageHead() helper in PageCompound() as it's not yet
defined -- use test_bit(PG_head, &page->flags) instead.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/page-flags.h | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 815246a80e2d..713d3f2c2468 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -133,6 +133,27 @@ enum pageflags {
#ifndef __GENERATING_BOUNDS_H
+struct page; /* forward declaration */
+
+static inline struct page *compound_head(struct page *page)
+{
+ unsigned long head = READ_ONCE(page->compound_head);
+
+ if (unlikely(head & 1))
+ return (struct page *) (head - 1);
+ return page;
+}
+
+static inline int PageTail(struct page *page)
+{
+ return READ_ONCE(page->compound_head) & 1;
+}
+
+static inline int PageCompound(struct page *page)
+{
+ return test_bit(PG_head, &page->flags) || PageTail(page);
+}
+
/*
* Macros to create function definitions for page flags
*/
@@ -204,7 +225,6 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
#define TESTSCFLAG_FALSE(uname) \
TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
-struct page; /* forward declaration */
TESTPAGEFLAG(Locked, locked)
PAGEFLAG(Error, error) TESTCLEARFLAG(Error, error)
@@ -395,11 +415,6 @@ static inline void set_page_writeback_keepwrite(struct page *page)
__PAGEFLAG(Head, head) CLEARPAGEFLAG(Head, head)
-static inline int PageTail(struct page *page)
-{
- return READ_ONCE(page->compound_head) & 1;
-}
-
static inline void set_compound_head(struct page *page, struct page *head)
{
WRITE_ONCE(page->compound_head, (unsigned long)head + 1);
@@ -410,20 +425,6 @@ static inline void clear_compound_head(struct page *page)
WRITE_ONCE(page->compound_head, 0);
}
-static inline struct page *compound_head(struct page *page)
-{
- unsigned long head = READ_ONCE(page->compound_head);
-
- if (unlikely(head & 1))
- return (struct page *) (head - 1);
- return page;
-}
-
-static inline int PageCompound(struct page *page)
-{
- return PageHead(page) || PageTail(page);
-
-}
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
static inline void ClearPageCompound(struct page *page)
{
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 05/16] page-flags: define behavior of FS/IO-related flags on compound pages |
| Message-ID | <qcga7-6cP-19@gated-at.bofh.it> |
| In reply to | #1229798 |
It seems we don't have compound page on FS/IO path currently.
Use PF_NO_COMPOUND to catch if we have.
The odd exception is PG_dirty: sound uses compound pages and maps them
with PTEs. PF_NO_COMPOUND triggers VM_BUG_ON() in set_page_dirty() on
handling shared fault. Let's use PF_HEAD for PG_dirty.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/page-flags.h | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 26102813f0ac..63db7483c264 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -245,16 +245,16 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname)
__PAGEFLAG(Locked, locked, PF_NO_TAIL)
-PAGEFLAG(Error, error, PF_ANY) TESTCLEARFLAG(Error, error, PF_ANY)
+PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
PAGEFLAG(Referenced, referenced, PF_ANY) TESTCLEARFLAG(Referenced, referenced, PF_ANY)
__SETPAGEFLAG(Referenced, referenced, PF_ANY)
-PAGEFLAG(Dirty, dirty, PF_ANY) TESTSCFLAG(Dirty, dirty, PF_ANY)
- __CLEARPAGEFLAG(Dirty, dirty, PF_ANY)
+PAGEFLAG(Dirty, dirty, PF_HEAD) TESTSCFLAG(Dirty, dirty, PF_HEAD)
+ __CLEARPAGEFLAG(Dirty, dirty, PF_HEAD)
PAGEFLAG(LRU, lru, PF_ANY) __CLEARPAGEFLAG(LRU, lru, PF_ANY)
PAGEFLAG(Active, active, PF_ANY) __CLEARPAGEFLAG(Active, active, PF_ANY)
TESTCLEARFLAG(Active, active, PF_ANY)
__PAGEFLAG(Slab, slab, PF_ANY)
-PAGEFLAG(Checked, checked, PF_ANY) /* Used by some filesystems */
+PAGEFLAG(Checked, checked, PF_NO_COMPOUND) /* Used by some filesystems */
PAGEFLAG(Pinned, pinned, PF_ANY) TESTSCFLAG(Pinned, pinned, PF_ANY) /* Xen */
PAGEFLAG(SavePinned, savepinned, PF_ANY); /* Xen */
PAGEFLAG(Foreign, foreign, PF_ANY); /* Xen */
@@ -280,12 +280,15 @@ PAGEFLAG(OwnerPriv1, owner_priv_1, PF_ANY)
* Only test-and-set exist for PG_writeback. The unconditional operators are
* risky: they bypass page accounting.
*/
-TESTPAGEFLAG(Writeback, writeback, PF_ANY) TESTSCFLAG(Writeback, writeback, PF_ANY)
-PAGEFLAG(MappedToDisk, mappedtodisk, PF_ANY)
+TESTPAGEFLAG(Writeback, writeback, PF_NO_COMPOUND)
+ TESTSCFLAG(Writeback, writeback, PF_NO_COMPOUND)
+PAGEFLAG(MappedToDisk, mappedtodisk, PF_NO_COMPOUND)
/* PG_readahead is only used for reads; PG_reclaim is only for writes */
-PAGEFLAG(Reclaim, reclaim, PF_ANY) TESTCLEARFLAG(Reclaim, reclaim, PF_ANY)
-PAGEFLAG(Readahead, reclaim, PF_ANY) TESTCLEARFLAG(Readahead, reclaim, PF_ANY)
+PAGEFLAG(Reclaim, reclaim, PF_NO_COMPOUND)
+ TESTCLEARFLAG(Reclaim, reclaim, PF_NO_COMPOUND)
+PAGEFLAG(Readahead, reclaim, PF_NO_COMPOUND)
+ TESTCLEARFLAG(Readahead, reclaim, PF_NO_COMPOUND)
#ifdef CONFIG_HIGHMEM
/*
@@ -401,7 +404,7 @@ static inline int PageUptodate(struct page *page)
static inline void __SetPageUptodate(struct page *page)
{
smp_wmb();
- __set_bit(PG_uptodate, &(page)->flags);
+ __set_bit(PG_uptodate, &page->flags);
}
static inline void SetPageUptodate(struct page *page)
@@ -412,7 +415,7 @@ static inline void SetPageUptodate(struct page *page)
* uptodate are actually visible before PageUptodate becomes true.
*/
smp_wmb();
- set_bit(PG_uptodate, &(page)->flags);
+ set_bit(PG_uptodate, &page->flags);
}
CLEARPAGEFLAG(Uptodate, uptodate, PF_ANY)
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 01/16] page-flags: trivial cleanup for PageTrans* helpers |
| Message-ID | <qcga7-6cP-21@gated-at.bofh.it> |
| In reply to | #1229798 |
Use TESTPAGEFLAG_FALSE() to get it a bit cleaner.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/page-flags.h | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 4fdfb5ed4b43..815246a80e2d 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -485,21 +485,9 @@ static inline int PageTransTail(struct page *page)
}
#else
-
-static inline int PageTransHuge(struct page *page)
-{
- return 0;
-}
-
-static inline int PageTransCompound(struct page *page)
-{
- return 0;
-}
-
-static inline int PageTransTail(struct page *page)
-{
- return 0;
-}
+TESTPAGEFLAG_FALSE(TransHuge)
+TESTPAGEFLAG_FALSE(TransCompound)
+TESTPAGEFLAG_FALSE(TransTail)
#endif
/*
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Christoph Lameter <cl@linux.com> |
|---|---|
| Date | 2015-09-24 17:50 +0200 |
| Subject | Re: [PATCH 01/16] page-flags: trivial cleanup for PageTrans* helpers |
| Message-ID | <qcgWv-7mP-31@gated-at.bofh.it> |
| In reply to | #1232148 |
On Thu, 24 Sep 2015, Kirill A. Shutemov wrote: > Use TESTPAGEFLAG_FALSE() to get it a bit cleaner. Acked-by: Christoph Lameter <cl@linux.com> -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 09/16] page-flags: define PG_reserved behavior on compound pages |
| Message-ID | <qcga7-6cP-29@gated-at.bofh.it> |
| In reply to | #1229798 |
As far as I can see there's no users of PG_reserved on compound pages. Let's use PF_NO_COMPOUND here. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- include/linux/page-flags.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index adaa2b39f471..5ba8130fffb5 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -264,7 +264,8 @@ PAGEFLAG(Pinned, pinned, PF_NO_COMPOUND) PAGEFLAG(SavePinned, savepinned, PF_NO_COMPOUND); PAGEFLAG(Foreign, foreign, PF_NO_COMPOUND); -PAGEFLAG(Reserved, reserved, PF_ANY) __CLEARPAGEFLAG(Reserved, reserved, PF_ANY) +PAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) + __CLEARPAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) PAGEFLAG(SwapBacked, swapbacked, PF_ANY) __CLEARPAGEFLAG(SwapBacked, swapbacked, PF_ANY) __SETPAGEFLAG(SwapBacked, swapbacked, PF_ANY) -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 06/16] page-flags: define behavior of LRU-related flags on compound pages |
| Message-ID | <qcga7-6cP-37@gated-at.bofh.it> |
| In reply to | #1229798 |
Only head pages are ever on LRU. Let's use PF_HEAD policy to avoid any
confusion for all LRU-related flags.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/page-flags.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 63db7483c264..10b75615ddf2 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -246,13 +246,14 @@ static inline int __TestClearPage##uname(struct page *page) { return 0; }
__PAGEFLAG(Locked, locked, PF_NO_TAIL)
PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND)
-PAGEFLAG(Referenced, referenced, PF_ANY) TESTCLEARFLAG(Referenced, referenced, PF_ANY)
- __SETPAGEFLAG(Referenced, referenced, PF_ANY)
+PAGEFLAG(Referenced, referenced, PF_HEAD)
+ TESTCLEARFLAG(Referenced, referenced, PF_HEAD)
+ __SETPAGEFLAG(Referenced, referenced, PF_HEAD)
PAGEFLAG(Dirty, dirty, PF_HEAD) TESTSCFLAG(Dirty, dirty, PF_HEAD)
__CLEARPAGEFLAG(Dirty, dirty, PF_HEAD)
-PAGEFLAG(LRU, lru, PF_ANY) __CLEARPAGEFLAG(LRU, lru, PF_ANY)
-PAGEFLAG(Active, active, PF_ANY) __CLEARPAGEFLAG(Active, active, PF_ANY)
- TESTCLEARFLAG(Active, active, PF_ANY)
+PAGEFLAG(LRU, lru, PF_HEAD) __CLEARPAGEFLAG(LRU, lru, PF_HEAD)
+PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Active, active, PF_HEAD)
+ TESTCLEARFLAG(Active, active, PF_HEAD)
__PAGEFLAG(Slab, slab, PF_ANY)
PAGEFLAG(Checked, checked, PF_NO_COMPOUND) /* Used by some filesystems */
PAGEFLAG(Pinned, pinned, PF_ANY) TESTSCFLAG(Pinned, pinned, PF_ANY) /* Xen */
@@ -306,9 +307,9 @@ PAGEFLAG(SwapCache, swapcache, PF_ANY)
PAGEFLAG_FALSE(SwapCache)
#endif
-PAGEFLAG(Unevictable, unevictable, PF_ANY)
- __CLEARPAGEFLAG(Unevictable, unevictable, PF_ANY)
- TESTCLEARFLAG(Unevictable, unevictable, PF_ANY)
+PAGEFLAG(Unevictable, unevictable, PF_HEAD)
+ __CLEARPAGEFLAG(Unevictable, unevictable, PF_HEAD)
+ TESTCLEARFLAG(Unevictable, unevictable, PF_HEAD)
#ifdef CONFIG_MMU
PAGEFLAG(Mlocked, mlocked, PF_ANY) __CLEARPAGEFLAG(Mlocked, mlocked, PF_ANY)
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 13/16] page-flags: define PG_uncached behavior on compound pages |
| Message-ID | <qcga8-6cP-45@gated-at.bofh.it> |
| In reply to | #1229798 |
So far, only IA64 uses PG_uncached and only on non-compound pages. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- include/linux/page-flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 31e68a8c2777..5e52cc6a27c3 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -326,7 +326,7 @@ PAGEFLAG_FALSE(Mlocked) __CLEARPAGEFLAG_NOOP(Mlocked) #endif #ifdef CONFIG_ARCH_USES_PG_UNCACHED -PAGEFLAG(Uncached, uncached, PF_ANY) +PAGEFLAG(Uncached, uncached, PF_NO_COMPOUND) #else PAGEFLAG_FALSE(Uncached) #endif -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 10/16] page-flags: define PG_swapbacked behavior on compound pages |
| Message-ID | <qcga8-6cP-51@gated-at.bofh.it> |
| In reply to | #1229798 |
PG_swapbacked is used for transparent huge pages. For head pages only. Let's use PF_NO_TAIL policy. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- include/linux/page-flags.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 5ba8130fffb5..a31d682caeb2 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -266,9 +266,9 @@ PAGEFLAG(Foreign, foreign, PF_NO_COMPOUND); PAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) __CLEARPAGEFLAG(Reserved, reserved, PF_NO_COMPOUND) -PAGEFLAG(SwapBacked, swapbacked, PF_ANY) - __CLEARPAGEFLAG(SwapBacked, swapbacked, PF_ANY) - __SETPAGEFLAG(SwapBacked, swapbacked, PF_ANY) +PAGEFLAG(SwapBacked, swapbacked, PF_NO_TAIL) + __CLEARPAGEFLAG(SwapBacked, swapbacked, PF_NO_TAIL) + __SETPAGEFLAG(SwapBacked, swapbacked, PF_NO_TAIL) /* * Private page markings that may be used by the filesystem that owns the page -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 15/16] page-flags: look at head page if the flag is encoded in page->mapping |
| Message-ID | <qcga8-6cP-53@gated-at.bofh.it> |
| In reply to | #1229798 |
PageAnon() and PageKsm() look at lower bits of page->mapping to check if
the page is Anon or KSM. page->mapping can be overloaded in tail pages.
Let's always look at head page to avoid false-positives.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/page-flags.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index e3ccd95de660..6f5df65d1038 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -369,6 +369,7 @@ PAGEFLAG(Idle, idle, PF_ANY)
static inline int PageAnon(struct page *page)
{
+ page = compound_head(page);
return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
}
@@ -381,6 +382,7 @@ static inline int PageAnon(struct page *page)
*/
static inline int PageKsm(struct page *page)
{
+ page = compound_head(page);
return ((unsigned long)page->mapping & PAGE_MAPPING_FLAGS) ==
(PAGE_MAPPING_ANON | PAGE_MAPPING_KSM);
}
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 08/16] page-flags: define behavior of Xen-related flags on compound pages |
| Message-ID | <qcga8-6cP-55@gated-at.bofh.it> |
| In reply to | #1229798 |
PG_pinned and PG_savepinned are about page table's pages which are never compound. I'm not so sure about PG_foreign, but it seems we shouldn't see compound pages there too. Let's use PF_NO_COMPOUND for all of them. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- include/linux/page-flags.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index c9cd82310e2d..adaa2b39f471 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -257,9 +257,13 @@ PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Active, active, PF_HEAD) __PAGEFLAG(Slab, slab, PF_NO_TAIL) __PAGEFLAG(SlobFree, slob_free, PF_NO_TAIL) PAGEFLAG(Checked, checked, PF_NO_COMPOUND) /* Used by some filesystems */ -PAGEFLAG(Pinned, pinned, PF_ANY) TESTSCFLAG(Pinned, pinned, PF_ANY) /* Xen */ -PAGEFLAG(SavePinned, savepinned, PF_ANY); /* Xen */ -PAGEFLAG(Foreign, foreign, PF_ANY); /* Xen */ + +/* Xen */ +PAGEFLAG(Pinned, pinned, PF_NO_COMPOUND) + TESTSCFLAG(Pinned, pinned, PF_NO_COMPOUND) +PAGEFLAG(SavePinned, savepinned, PF_NO_COMPOUND); +PAGEFLAG(Foreign, foreign, PF_NO_COMPOUND); + PAGEFLAG(Reserved, reserved, PF_ANY) __CLEARPAGEFLAG(Reserved, reserved, PF_ANY) PAGEFLAG(SwapBacked, swapbacked, PF_ANY) __CLEARPAGEFLAG(SwapBacked, swapbacked, PF_ANY) -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 16/16] mm: sanitize page->mapping for tail pages |
| Message-ID | <qcga8-6cP-47@gated-at.bofh.it> |
| In reply to | #1229798 |
We don't define meaning of page->mapping for tail pages. Currently it's
always NULL, which can be inconsistent with head page and potentially lead
to problems.
Let's poison the pointer to catch all illigal uses.
page_rmapping(), page_mapping() and page_anon_vma() are changed to look on
head page.
The only illegal use I've caught so far is __GPF_COMP pages from sound
subsystem, mapped with PTEs. do_shared_fault() is changed to use
page_rmapping() instead of direct access to fault_page->mapping.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
---
include/linux/poison.h | 4 ++++
mm/huge_memory.c | 2 +-
mm/memory.c | 2 +-
mm/page_alloc.c | 6 ++++++
mm/util.c | 10 ++++++----
5 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/include/linux/poison.h b/include/linux/poison.h
index 317e16de09e5..76c3b6c38c16 100644
--- a/include/linux/poison.h
+++ b/include/linux/poison.h
@@ -32,6 +32,10 @@
/********** mm/debug-pagealloc.c **********/
#define PAGE_POISON 0xaa
+/********** mm/page_alloc.c ************/
+
+#define TAIL_MAPPING ((void *) 0x01014A11 + POISON_POINTER_DELTA)
+
/********** mm/slab.c **********/
/*
* Magic nums for obj red zoning.
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 244c852d565c..65ab7858bbcc 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1836,7 +1836,7 @@ static void __split_huge_page_refcount(struct page *page,
*/
page_tail->_mapcount = page->_mapcount;
- BUG_ON(page_tail->mapping);
+ BUG_ON(page_tail->mapping != TAIL_MAPPING);
page_tail->mapping = page->mapping;
page_tail->index = page->index + i;
diff --git a/mm/memory.c b/mm/memory.c
index caecc64301e9..3bd465a6fa0d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3087,7 +3087,7 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
* pinned by vma->vm_file's reference. We rely on unlock_page()'s
* release semantics to prevent the compiler from undoing this copying.
*/
- mapping = fault_page->mapping;
+ mapping = page_rmapping(fault_page);
unlock_page(fault_page);
if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) {
/*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 321a91747949..9bcfd70b1eb8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -473,6 +473,7 @@ void prep_compound_page(struct page *page, unsigned int order)
for (i = 1; i < nr_pages; i++) {
struct page *p = page + i;
set_page_count(p, 0);
+ p->mapping = TAIL_MAPPING;
set_compound_head(p, page);
}
}
@@ -864,6 +865,10 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
ret = 0;
goto out;
}
+ if (page->mapping != TAIL_MAPPING) {
+ bad_page(page, "corrupted mapping in tail page", 0);
+ goto out;
+ }
if (unlikely(!PageTail(page))) {
bad_page(page, "PageTail not set", 0);
goto out;
@@ -874,6 +879,7 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
}
ret = 0;
out:
+ page->mapping = NULL;
clear_compound_head(page);
return ret;
}
diff --git a/mm/util.c b/mm/util.c
index 9af1c12b310c..902b65a43899 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -355,7 +355,9 @@ struct anon_vma *page_anon_vma(struct page *page)
struct address_space *page_mapping(struct page *page)
{
- unsigned long mapping;
+ struct address_space *mapping;
+
+ page = compound_head(page);
/* This happens if someone calls flush_dcache_page on slab page */
if (unlikely(PageSlab(page)))
@@ -368,10 +370,10 @@ struct address_space *page_mapping(struct page *page)
return swap_address_space(entry);
}
- mapping = (unsigned long)page->mapping;
- if (mapping & PAGE_MAPPING_FLAGS)
+ mapping = page->mapping;
+ if ((unsigned long)mapping & PAGE_MAPPING_FLAGS)
return NULL;
- return page->mapping;
+ return mapping;
}
int overcommit_ratio_handler(struct ctl_table *table, int write,
--
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jerome Glisse <j.glisse@gmail.com> |
|---|---|
| Date | 2015-09-25 04:30 +0200 |
| Subject | Re: [PATCH 16/16] mm: sanitize page->mapping for tail pages |
| Message-ID | <qcqVP-4UA-1@gated-at.bofh.it> |
| In reply to | #1232160 |
On Thu, Sep 24, 2015 at 05:51:04PM +0300, Kirill A. Shutemov wrote:
> We don't define meaning of page->mapping for tail pages. Currently it's
> always NULL, which can be inconsistent with head page and potentially lead
> to problems.
>
> Let's poison the pointer to catch all illigal uses.
>
> page_rmapping(), page_mapping() and page_anon_vma() are changed to look on
> head page.
>
> The only illegal use I've caught so far is __GPF_COMP pages from sound
> subsystem, mapped with PTEs. do_shared_fault() is changed to use
> page_rmapping() instead of direct access to fault_page->mapping.
>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Just a nitpick but page_rmapping() is already using compound_head() and
thus commit message is missleading. I was expecting to see some changes
to page_rmapping(). Anyway:
Reviewed-by: Jérôme Glisse <jglisse@redhat.com>
> ---
> include/linux/poison.h | 4 ++++
> mm/huge_memory.c | 2 +-
> mm/memory.c | 2 +-
> mm/page_alloc.c | 6 ++++++
> mm/util.c | 10 ++++++----
> 5 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/poison.h b/include/linux/poison.h
> index 317e16de09e5..76c3b6c38c16 100644
> --- a/include/linux/poison.h
> +++ b/include/linux/poison.h
> @@ -32,6 +32,10 @@
> /********** mm/debug-pagealloc.c **********/
> #define PAGE_POISON 0xaa
>
> +/********** mm/page_alloc.c ************/
> +
> +#define TAIL_MAPPING ((void *) 0x01014A11 + POISON_POINTER_DELTA)
> +
> /********** mm/slab.c **********/
> /*
> * Magic nums for obj red zoning.
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 244c852d565c..65ab7858bbcc 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1836,7 +1836,7 @@ static void __split_huge_page_refcount(struct page *page,
> */
> page_tail->_mapcount = page->_mapcount;
>
> - BUG_ON(page_tail->mapping);
> + BUG_ON(page_tail->mapping != TAIL_MAPPING);
> page_tail->mapping = page->mapping;
>
> page_tail->index = page->index + i;
> diff --git a/mm/memory.c b/mm/memory.c
> index caecc64301e9..3bd465a6fa0d 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3087,7 +3087,7 @@ static int do_shared_fault(struct mm_struct *mm, struct vm_area_struct *vma,
> * pinned by vma->vm_file's reference. We rely on unlock_page()'s
> * release semantics to prevent the compiler from undoing this copying.
> */
> - mapping = fault_page->mapping;
> + mapping = page_rmapping(fault_page);
> unlock_page(fault_page);
> if ((dirtied || vma->vm_ops->page_mkwrite) && mapping) {
> /*
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 321a91747949..9bcfd70b1eb8 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -473,6 +473,7 @@ void prep_compound_page(struct page *page, unsigned int order)
> for (i = 1; i < nr_pages; i++) {
> struct page *p = page + i;
> set_page_count(p, 0);
> + p->mapping = TAIL_MAPPING;
> set_compound_head(p, page);
> }
> }
> @@ -864,6 +865,10 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
> ret = 0;
> goto out;
> }
> + if (page->mapping != TAIL_MAPPING) {
> + bad_page(page, "corrupted mapping in tail page", 0);
> + goto out;
> + }
> if (unlikely(!PageTail(page))) {
> bad_page(page, "PageTail not set", 0);
> goto out;
> @@ -874,6 +879,7 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
> }
> ret = 0;
> out:
> + page->mapping = NULL;
> clear_compound_head(page);
> return ret;
> }
> diff --git a/mm/util.c b/mm/util.c
> index 9af1c12b310c..902b65a43899 100644
> --- a/mm/util.c
> +++ b/mm/util.c
> @@ -355,7 +355,9 @@ struct anon_vma *page_anon_vma(struct page *page)
>
> struct address_space *page_mapping(struct page *page)
> {
> - unsigned long mapping;
> + struct address_space *mapping;
> +
> + page = compound_head(page);
>
> /* This happens if someone calls flush_dcache_page on slab page */
> if (unlikely(PageSlab(page)))
> @@ -368,10 +370,10 @@ struct address_space *page_mapping(struct page *page)
> return swap_address_space(entry);
> }
>
> - mapping = (unsigned long)page->mapping;
> - if (mapping & PAGE_MAPPING_FLAGS)
> + mapping = page->mapping;
> + if ((unsigned long)mapping & PAGE_MAPPING_FLAGS)
> return NULL;
> - return page->mapping;
> + return mapping;
> }
>
> int overcommit_ratio_handler(struct ctl_table *table, int write,
> --
> 2.5.1
>
> --
> 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>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> |
|---|---|
| Date | 2015-09-24 17:00 +0200 |
| Subject | [PATCH 07/16] page-flags: define behavior SL*B-related flags on compound pages |
| Message-ID | <qcga8-6cP-59@gated-at.bofh.it> |
| In reply to | #1229798 |
SL*B uses compound pages and marks head pages with PG_slab. __SetPageSlab() and __ClearPageSlab() are never called for tail pages. The same situation with PG_slob_free in SLOB allocator. PF_NO_TAIL is appropriate for these flags. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> --- include/linux/page-flags.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 10b75615ddf2..c9cd82310e2d 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -254,7 +254,8 @@ PAGEFLAG(Dirty, dirty, PF_HEAD) TESTSCFLAG(Dirty, dirty, PF_HEAD) PAGEFLAG(LRU, lru, PF_HEAD) __CLEARPAGEFLAG(LRU, lru, PF_HEAD) PAGEFLAG(Active, active, PF_HEAD) __CLEARPAGEFLAG(Active, active, PF_HEAD) TESTCLEARFLAG(Active, active, PF_HEAD) -__PAGEFLAG(Slab, slab, PF_ANY) +__PAGEFLAG(Slab, slab, PF_NO_TAIL) +__PAGEFLAG(SlobFree, slob_free, PF_NO_TAIL) PAGEFLAG(Checked, checked, PF_NO_COMPOUND) /* Used by some filesystems */ PAGEFLAG(Pinned, pinned, PF_ANY) TESTSCFLAG(Pinned, pinned, PF_ANY) /* Xen */ PAGEFLAG(SavePinned, savepinned, PF_ANY); /* Xen */ @@ -264,8 +265,6 @@ PAGEFLAG(SwapBacked, swapbacked, PF_ANY) __CLEARPAGEFLAG(SwapBacked, swapbacked, PF_ANY) __SETPAGEFLAG(SwapBacked, swapbacked, PF_ANY) -__PAGEFLAG(SlobFree, slob_free, PF_ANY) - /* * Private page markings that may be used by the filesystem that owns the page * for its own purposes. -- 2.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web