linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 0/2] A few simplifications for softdirty memory tracker code
@ 2014-04-25  8:10 Cyrill Gorcunov
  2014-04-25  8:10 ` [patch 1/2] mm: pgtable -- Drop unneeded preprocessor ifdef Cyrill Gorcunov
  2014-04-25  8:10 ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker Cyrill Gorcunov
  0 siblings, 2 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-04-25  8:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, torvalds, mgorman, hpa, mingo, steven, riel,
	david.vrabel, akpm, peterz, xemul, gorcunov

Hi, here are a few simplifications for softdirty memory tracker code, in
particular we dropped off x86-32 support since it seems noone needed it
here on x86 platform.

As Andrew requested I've rebased patches on top of current linux-next repo.

Also at first I wanted to rip off _PAGE_PSE bit which we use in swap ptes
to track dirty status of swapped pages and reuse _PAGE_BIT_SOFT_DIRTY
instead. It's still possible but requires additional shrinking of
maximal swap size and I don't know if it's acceptible or not. Currently
we have

#ifdef CONFIG_NUMA_BALANCING
/* Automatic NUMA balancing needs to be distinguishable from swap entries */
#define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 2)
#else
#define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)
#endif

If I reuse _PAGE_BIT_SOFT_DIRTY I'll have to increase this shift up
to bit 11, which, again, I think is too much, right?

Comments are highly appreciated!

	Cyrill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 1/2] mm: pgtable -- Drop unneeded preprocessor ifdef
  2014-04-25  8:10 [patch 0/2] A few simplifications for softdirty memory tracker code Cyrill Gorcunov
@ 2014-04-25  8:10 ` Cyrill Gorcunov
  2014-04-25  8:10 ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker Cyrill Gorcunov
  1 sibling, 0 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-04-25  8:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, torvalds, mgorman, hpa, mingo, steven, riel,
	david.vrabel, akpm, peterz, xemul, gorcunov

[-- Attachment #1: pgbits-drop-if --]
[-- Type: text/plain, Size: 3021 bytes --]

_PAGE_BIT_FILE (bit 6) is always less than _PAGE_BIT_PROTNONE (bit 8),
so drop redundant #ifdef.

CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Mel Gorman <mgorman@suse.de>
CC: Peter Anvin <hpa@zytor.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: Steven Noonan <steven@uplinklabs.net>
CC: Rik van Riel <riel@redhat.com>
CC: David Vrabel <david.vrabel@citrix.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 arch/x86/include/asm/pgtable-2level.h |   10 ----------
 arch/x86/include/asm/pgtable_64.h     |    8 --------
 2 files changed, 18 deletions(-)

Index: linux-2.6.git/arch/x86/include/asm/pgtable-2level.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/pgtable-2level.h
+++ linux-2.6.git/arch/x86/include/asm/pgtable-2level.h
@@ -115,13 +115,8 @@ static __always_inline pte_t pgoff_to_pt
  */
 #define PTE_FILE_MAX_BITS	29
 #define PTE_FILE_SHIFT1		(_PAGE_BIT_PRESENT + 1)
-#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
 #define PTE_FILE_SHIFT2		(_PAGE_BIT_FILE + 1)
 #define PTE_FILE_SHIFT3		(_PAGE_BIT_PROTNONE + 1)
-#else
-#define PTE_FILE_SHIFT2		(_PAGE_BIT_PROTNONE + 1)
-#define PTE_FILE_SHIFT3		(_PAGE_BIT_FILE + 1)
-#endif
 #define PTE_FILE_BITS1		(PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1)
 #define PTE_FILE_BITS2		(PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1)
 
@@ -153,13 +148,8 @@ static __always_inline pte_t pgoff_to_pt
 #endif /* CONFIG_MEM_SOFT_DIRTY */
 
 /* Encode and de-code a swap entry */
-#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
 #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)
-#else
-#define SWP_TYPE_BITS (_PAGE_BIT_PROTNONE - _PAGE_BIT_PRESENT - 1)
-#define SWP_OFFSET_SHIFT (_PAGE_BIT_FILE + 1)
-#endif
 
 #define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS)
 
Index: linux-2.6.git/arch/x86/include/asm/pgtable_64.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/pgtable_64.h
+++ linux-2.6.git/arch/x86/include/asm/pgtable_64.h
@@ -143,7 +143,6 @@ static inline int pgd_large(pgd_t pgd) {
 #define pte_unmap(pte) ((void)(pte))/* NOP */
 
 /* Encode and de-code a swap entry */
-#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE
 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
 #ifdef CONFIG_NUMA_BALANCING
 /* Automatic NUMA balancing needs to be distinguishable from swap entries */
@@ -151,13 +150,6 @@ static inline int pgd_large(pgd_t pgd) {
 #else
 #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)
 #endif
-#else
-#ifdef CONFIG_NUMA_BALANCING
-#error Incompatible format for automatic NUMA balancing
-#endif
-#define SWP_TYPE_BITS (_PAGE_BIT_PROTNONE - _PAGE_BIT_PRESENT - 1)
-#define SWP_OFFSET_SHIFT (_PAGE_BIT_FILE + 1)
-#endif
 
 #define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS)
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker
  2014-04-25  8:10 [patch 0/2] A few simplifications for softdirty memory tracker code Cyrill Gorcunov
  2014-04-25  8:10 ` [patch 1/2] mm: pgtable -- Drop unneeded preprocessor ifdef Cyrill Gorcunov
@ 2014-04-25  8:10 ` Cyrill Gorcunov
  2014-05-05 23:31   ` Andrew Morton
  2014-05-06 16:28   ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker H. Peter Anvin
  1 sibling, 2 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-04-25  8:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, torvalds, mgorman, hpa, mingo, steven, riel,
	david.vrabel, akpm, peterz, xemul, gorcunov

[-- Attachment #1: pgbits-drop-softdirty-non-x86-64 --]
[-- Type: text/plain, Size: 4344 bytes --]

Tracking dirty status on 2 level pages requires very ugly macros
and taking into account how old the machines who can operate
without PAE mode only are, lets drop soft dirty tracker from
them for code simplicity (note I can't drop all the macros
from 2 level pages by now since _PAGE_BIT_PROTNONE and
_PAGE_BIT_FILE are still used even without tracker).

Linus proposed to completely rip off softdirty support on
x86-32 (even with PAE) and since for CRIU we're not planning
to support native x86-32 mode, lets do that.

(Softdirty tracker is relatively new feature which mostly used
 by CRIU so I don't expect if such API change would cause problems
 on userspace).

CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Mel Gorman <mgorman@suse.de>
CC: Peter Anvin <hpa@zytor.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: Steven Noonan <steven@uplinklabs.net>
CC: Rik van Riel <riel@redhat.com>
CC: David Vrabel <david.vrabel@citrix.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 arch/x86/Kconfig                      |    2 -
 arch/x86/include/asm/pgtable-2level.h |   49 ----------------------------------
 2 files changed, 1 insertion(+), 50 deletions(-)

Index: linux-2.6.git/arch/x86/Kconfig
===================================================================
--- linux-2.6.git.orig/arch/x86/Kconfig
+++ linux-2.6.git/arch/x86/Kconfig
@@ -106,7 +106,7 @@ config X86
 	select HAVE_ARCH_SECCOMP_FILTER
 	select BUILDTIME_EXTABLE_SORT
 	select GENERIC_CMOS_UPDATE
-	select HAVE_ARCH_SOFT_DIRTY
+	select HAVE_ARCH_SOFT_DIRTY if X86_64
 	select CLOCKSOURCE_WATCHDOG
 	select GENERIC_CLOCKEVENTS
 	select ARCH_CLOCKSOURCE_DATA
Index: linux-2.6.git/arch/x86/include/asm/pgtable-2level.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/pgtable-2level.h
+++ linux-2.6.git/arch/x86/include/asm/pgtable-2level.h
@@ -62,53 +62,6 @@ static inline unsigned long pte_bitop(un
 	return ((value >> rightshift) & mask) << leftshift;
 }
 
-#ifdef CONFIG_MEM_SOFT_DIRTY
-
-/*
- * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE, _PAGE_BIT_SOFT_DIRTY and
- * _PAGE_BIT_PROTNONE are taken, split up the 28 bits of offset
- * into this range.
- */
-#define PTE_FILE_MAX_BITS	28
-#define PTE_FILE_SHIFT1		(_PAGE_BIT_PRESENT + 1)
-#define PTE_FILE_SHIFT2		(_PAGE_BIT_FILE + 1)
-#define PTE_FILE_SHIFT3		(_PAGE_BIT_PROTNONE + 1)
-#define PTE_FILE_SHIFT4		(_PAGE_BIT_SOFT_DIRTY + 1)
-#define PTE_FILE_BITS1		(PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1)
-#define PTE_FILE_BITS2		(PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1)
-#define PTE_FILE_BITS3		(PTE_FILE_SHIFT4 - PTE_FILE_SHIFT3 - 1)
-
-#define PTE_FILE_MASK1		((1U << PTE_FILE_BITS1) - 1)
-#define PTE_FILE_MASK2		((1U << PTE_FILE_BITS2) - 1)
-#define PTE_FILE_MASK3		((1U << PTE_FILE_BITS3) - 1)
-
-#define PTE_FILE_LSHIFT2	(PTE_FILE_BITS1)
-#define PTE_FILE_LSHIFT3	(PTE_FILE_BITS1 + PTE_FILE_BITS2)
-#define PTE_FILE_LSHIFT4	(PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3)
-
-static __always_inline pgoff_t pte_to_pgoff(pte_t pte)
-{
-	return (pgoff_t)
-		(pte_bitop(pte.pte_low, PTE_FILE_SHIFT1, PTE_FILE_MASK1,  0)		    +
-		 pte_bitop(pte.pte_low, PTE_FILE_SHIFT2, PTE_FILE_MASK2,  PTE_FILE_LSHIFT2) +
-		 pte_bitop(pte.pte_low, PTE_FILE_SHIFT3, PTE_FILE_MASK3,  PTE_FILE_LSHIFT3) +
-		 pte_bitop(pte.pte_low, PTE_FILE_SHIFT4,           -1UL,  PTE_FILE_LSHIFT4));
-}
-
-static __always_inline pte_t pgoff_to_pte(pgoff_t off)
-{
-	return (pte_t){
-		.pte_low =
-			pte_bitop(off,                0, PTE_FILE_MASK1,  PTE_FILE_SHIFT1) +
-			pte_bitop(off, PTE_FILE_LSHIFT2, PTE_FILE_MASK2,  PTE_FILE_SHIFT2) +
-			pte_bitop(off, PTE_FILE_LSHIFT3, PTE_FILE_MASK3,  PTE_FILE_SHIFT3) +
-			pte_bitop(off, PTE_FILE_LSHIFT4,           -1UL,  PTE_FILE_SHIFT4) +
-			_PAGE_FILE,
-	};
-}
-
-#else /* CONFIG_MEM_SOFT_DIRTY */
-
 /*
  * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken,
  * split up the 29 bits of offset into this range.
@@ -145,8 +98,6 @@ static __always_inline pte_t pgoff_to_pt
 	};
 }
 
-#endif /* CONFIG_MEM_SOFT_DIRTY */
-
 /* Encode and de-code a swap entry */
 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
 #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker
  2014-04-25  8:10 ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker Cyrill Gorcunov
@ 2014-05-05 23:31   ` Andrew Morton
  2014-05-06  8:25     ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker, v2 Cyrill Gorcunov
  2014-05-06 16:28   ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker H. Peter Anvin
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2014-05-05 23:31 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: linux-kernel, linux-mm, torvalds, mgorman, hpa, mingo, steven,
	riel, david.vrabel, peterz, xemul

On Fri, 25 Apr 2014 12:10:32 +0400 Cyrill Gorcunov <gorcunov@openvz.org> wrote:

> Tracking dirty status on 2 level pages requires very ugly macros
> and taking into account how old the machines who can operate
> without PAE mode only are, lets drop soft dirty tracker from
> them for code simplicity (note I can't drop all the macros
> from 2 level pages by now since _PAGE_BIT_PROTNONE and
> _PAGE_BIT_FILE are still used even without tracker).
> 
> Linus proposed to completely rip off softdirty support on
> x86-32 (even with PAE) and since for CRIU we're not planning
> to support native x86-32 mode, lets do that.
> 
> (Softdirty tracker is relatively new feature which mostly used
>  by CRIU so I don't expect if such API change would cause problems
>  on userspace).

i386 allnoconfig:

In file included from /usr/src/25/arch/x86/include/asm/pgtable.h:886,
                 from include/linux/mm.h:51,
                 from include/linux/suspend.h:8,
                 from arch/x86/kernel/asm-offsets.c:12:
include/asm-generic/pgtable.h:414: error: redefinition of 'pte_soft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:300: note: previous definition of 'pte_soft_dirty' was here
include/asm-generic/pgtable.h:419: error: redefinition of 'pmd_soft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:305: note: previous definition of 'pmd_soft_dirty' was here
include/asm-generic/pgtable.h:424: error: redefinition of 'pte_mksoft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:310: note: previous definition of 'pte_mksoft_dirty' was here
include/asm-generic/pgtable.h:429: error: redefinition of 'pmd_mksoft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:315: note: previous definition of 'pmd_mksoft_dirty' was here
include/asm-generic/pgtable.h:434: error: redefinition of 'pte_swp_mksoft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:868: note: previous definition of 'pte_swp_mksoft_dirty' was here
include/asm-generic/pgtable.h:439: error: redefinition of 'pte_swp_soft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:874: note: previous definition of 'pte_swp_soft_dirty' was here
include/asm-generic/pgtable.h:444: error: redefinition of 'pte_swp_clear_soft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:880: note: previous definition of 'pte_swp_clear_soft_dirty' was here
include/asm-generic/pgtable.h:449: error: redefinition of 'pte_file_clear_soft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:320: note: previous definition of 'pte_file_clear_soft_dirty' was here
include/asm-generic/pgtable.h:454: error: redefinition of 'pte_file_mksoft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:325: note: previous definition of 'pte_file_mksoft_dirty' was here
include/asm-generic/pgtable.h:459: error: redefinition of 'pte_file_soft_dirty'
/usr/src/25/arch/x86/include/asm/pgtable.h:330: note: previous definition of 'pte_file_soft_dirty' was here


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker, v2
  2014-05-05 23:31   ` Andrew Morton
@ 2014-05-06  8:25     ` Cyrill Gorcunov
  0 siblings, 0 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-05-06  8:25 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, linux-mm, torvalds, mgorman, hpa, mingo, steven,
	riel, david.vrabel, peterz, xemul

On Mon, May 05, 2014 at 04:31:23PM -0700, Andrew Morton wrote:
> On Fri, 25 Apr 2014 12:10:32 +0400 Cyrill Gorcunov <gorcunov@openvz.org> wrote:
> 
> > Tracking dirty status on 2 level pages requires very ugly macros
> > and taking into account how old the machines who can operate
> > without PAE mode only are, lets drop soft dirty tracker from
> > them for code simplicity (note I can't drop all the macros
> > from 2 level pages by now since _PAGE_BIT_PROTNONE and
> > _PAGE_BIT_FILE are still used even without tracker).
> > 
> > Linus proposed to completely rip off softdirty support on
> > x86-32 (even with PAE) and since for CRIU we're not planning
> > to support native x86-32 mode, lets do that.
> > 
> > (Softdirty tracker is relatively new feature which mostly used
> >  by CRIU so I don't expect if such API change would cause problems
> >  on userspace).
> 
> i386 allnoconfig:
> 
> In file included from /usr/src/25/arch/x86/include/asm/pgtable.h:886,

Thanks! Here is an updated version.
---
From: Cyrill Gorcunov <gorcunov@openvz.org>
Subject: [PATCH -next] mm: pgtable -- Require X86_64 for soft-dirty tracker

Tracking dirty status on 2 level pages requires very ugly macros
and taking into account how old the machines who can operate
without PAE mode only are, lets drop soft dirty tracker from
them for code simplicity (note I can't drop all the macros
from 2 level pages by now since _PAGE_BIT_PROTNONE and
_PAGE_BIT_FILE are still used even without tracker).

Linus proposed to completely rip off softdirty support on
x86-32 (even with PAE) and since for CRIU we're not planning
to support native x86-32 mode, lets do that.

(Softdirty tracker is relatively new feature which mostly used
 by CRIU so I don't expect if such API change would cause problems
 on userspace).

v2 (by akpm@):
 - guard helpers with CONFIG_HAVE_ARCH_SOFT_DIRTY on i386, otherwise
   it fails to build because we've a generic definitions in
   asm-generic/pgtable.h

CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Mel Gorman <mgorman@suse.de>
CC: Peter Anvin <hpa@zytor.com>
CC: Ingo Molnar <mingo@kernel.org>
CC: Steven Noonan <steven@uplinklabs.net>
CC: Rik van Riel <riel@redhat.com>
CC: David Vrabel <david.vrabel@citrix.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Peter Zijlstra <peterz@infradead.org>
CC: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 arch/x86/Kconfig                      |    2 -
 arch/x86/include/asm/pgtable-2level.h |   49 ----------------------------------
 arch/x86/include/asm/pgtable.h        |    5 +++
 3 files changed, 6 insertions(+), 50 deletions(-)

Index: linux-2.6.git/arch/x86/Kconfig
===================================================================
--- linux-2.6.git.orig/arch/x86/Kconfig
+++ linux-2.6.git/arch/x86/Kconfig
@@ -106,7 +106,7 @@ config X86
 	select HAVE_ARCH_SECCOMP_FILTER
 	select BUILDTIME_EXTABLE_SORT
 	select GENERIC_CMOS_UPDATE
-	select HAVE_ARCH_SOFT_DIRTY
+	select HAVE_ARCH_SOFT_DIRTY if X86_64
 	select CLOCKSOURCE_WATCHDOG
 	select GENERIC_CLOCKEVENTS
 	select ARCH_CLOCKSOURCE_DATA
Index: linux-2.6.git/arch/x86/include/asm/pgtable-2level.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/pgtable-2level.h
+++ linux-2.6.git/arch/x86/include/asm/pgtable-2level.h
@@ -62,53 +62,6 @@ static inline unsigned long pte_bitop(un
 	return ((value >> rightshift) & mask) << leftshift;
 }
 
-#ifdef CONFIG_MEM_SOFT_DIRTY
-
-/*
- * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE, _PAGE_BIT_SOFT_DIRTY and
- * _PAGE_BIT_PROTNONE are taken, split up the 28 bits of offset
- * into this range.
- */
-#define PTE_FILE_MAX_BITS	28
-#define PTE_FILE_SHIFT1		(_PAGE_BIT_PRESENT + 1)
-#define PTE_FILE_SHIFT2		(_PAGE_BIT_FILE + 1)
-#define PTE_FILE_SHIFT3		(_PAGE_BIT_PROTNONE + 1)
-#define PTE_FILE_SHIFT4		(_PAGE_BIT_SOFT_DIRTY + 1)
-#define PTE_FILE_BITS1		(PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1)
-#define PTE_FILE_BITS2		(PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1)
-#define PTE_FILE_BITS3		(PTE_FILE_SHIFT4 - PTE_FILE_SHIFT3 - 1)
-
-#define PTE_FILE_MASK1		((1U << PTE_FILE_BITS1) - 1)
-#define PTE_FILE_MASK2		((1U << PTE_FILE_BITS2) - 1)
-#define PTE_FILE_MASK3		((1U << PTE_FILE_BITS3) - 1)
-
-#define PTE_FILE_LSHIFT2	(PTE_FILE_BITS1)
-#define PTE_FILE_LSHIFT3	(PTE_FILE_BITS1 + PTE_FILE_BITS2)
-#define PTE_FILE_LSHIFT4	(PTE_FILE_BITS1 + PTE_FILE_BITS2 + PTE_FILE_BITS3)
-
-static __always_inline pgoff_t pte_to_pgoff(pte_t pte)
-{
-	return (pgoff_t)
-		(pte_bitop(pte.pte_low, PTE_FILE_SHIFT1, PTE_FILE_MASK1,  0)		    +
-		 pte_bitop(pte.pte_low, PTE_FILE_SHIFT2, PTE_FILE_MASK2,  PTE_FILE_LSHIFT2) +
-		 pte_bitop(pte.pte_low, PTE_FILE_SHIFT3, PTE_FILE_MASK3,  PTE_FILE_LSHIFT3) +
-		 pte_bitop(pte.pte_low, PTE_FILE_SHIFT4,           -1UL,  PTE_FILE_LSHIFT4));
-}
-
-static __always_inline pte_t pgoff_to_pte(pgoff_t off)
-{
-	return (pte_t){
-		.pte_low =
-			pte_bitop(off,                0, PTE_FILE_MASK1,  PTE_FILE_SHIFT1) +
-			pte_bitop(off, PTE_FILE_LSHIFT2, PTE_FILE_MASK2,  PTE_FILE_SHIFT2) +
-			pte_bitop(off, PTE_FILE_LSHIFT3, PTE_FILE_MASK3,  PTE_FILE_SHIFT3) +
-			pte_bitop(off, PTE_FILE_LSHIFT4,           -1UL,  PTE_FILE_SHIFT4) +
-			_PAGE_FILE,
-	};
-}
-
-#else /* CONFIG_MEM_SOFT_DIRTY */
-
 /*
  * Bits _PAGE_BIT_PRESENT, _PAGE_BIT_FILE and _PAGE_BIT_PROTNONE are taken,
  * split up the 29 bits of offset into this range.
@@ -145,8 +98,6 @@ static __always_inline pte_t pgoff_to_pt
 	};
 }
 
-#endif /* CONFIG_MEM_SOFT_DIRTY */
-
 /* Encode and de-code a swap entry */
 #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1)
 #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1)
Index: linux-2.6.git/arch/x86/include/asm/pgtable.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/pgtable.h
+++ linux-2.6.git/arch/x86/include/asm/pgtable.h
@@ -297,6 +297,7 @@ static inline pmd_t pmd_mknotpresent(pmd
 	return pmd_clear_flags(pmd, _PAGE_PRESENT);
 }
 
+#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
 static inline int pte_soft_dirty(pte_t pte)
 {
 	return pte_flags(pte) & _PAGE_SOFT_DIRTY;
@@ -332,6 +333,8 @@ static inline int pte_file_soft_dirty(pt
 	return pte_flags(pte) & _PAGE_SOFT_DIRTY;
 }
 
+#endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */
+
 /*
  * Mask out unsupported bits in a present pgprot.  Non-present pgprots
  * can use those bits for other purposes, so leave them be.
@@ -865,6 +868,7 @@ static inline void update_mmu_cache_pmd(
 {
 }
 
+#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
 static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
 {
 	VM_BUG_ON(pte_present_nonuma(pte));
@@ -882,6 +886,7 @@ static inline pte_t pte_swp_clear_soft_d
 	VM_BUG_ON(pte_present_nonuma(pte));
 	return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
 }
+#endif
 
 #include <asm-generic/pgtable.h>
 #endif	/* __ASSEMBLY__ */

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker
  2014-04-25  8:10 ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker Cyrill Gorcunov
  2014-05-05 23:31   ` Andrew Morton
@ 2014-05-06 16:28   ` H. Peter Anvin
  2014-05-06 17:03     ` Cyrill Gorcunov
  1 sibling, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2014-05-06 16:28 UTC (permalink / raw)
  To: Cyrill Gorcunov, linux-kernel
  Cc: linux-mm, torvalds, mgorman, mingo, steven, riel, david.vrabel,
	akpm, peterz, xemul

On 04/25/2014 01:10 AM, Cyrill Gorcunov wrote:
> Tracking dirty status on 2 level pages requires very ugly macros
> and taking into account how old the machines who can operate
> without PAE mode only are, lets drop soft dirty tracker from
> them for code simplicity (note I can't drop all the macros
> from 2 level pages by now since _PAGE_BIT_PROTNONE and
> _PAGE_BIT_FILE are still used even without tracker).
> 
> Linus proposed to completely rip off softdirty support on
> x86-32 (even with PAE) and since for CRIU we're not planning
> to support native x86-32 mode, lets do that.
> 
> (Softdirty tracker is relatively new feature which mostly used
>  by CRIU so I don't expect if such API change would cause problems
>  on userspace).

I have to wonder which one is more likely to actually matter on whatever
legacy 32-bit are going to remain.  This pretty much comes down to what
kind of advanced features are going to matter in deep embedded
applications in the future: checkpoint/restart or NUMA.  My guess is
that it is actually checkpoint/restart...

How much does it actually simplify to leave this feature in for PAE?  I
could care less about non-PAE... NX has pretty much killed that off cold.

	-hpa



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker
  2014-05-06 16:28   ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker H. Peter Anvin
@ 2014-05-06 17:03     ` Cyrill Gorcunov
  0 siblings, 0 replies; 7+ messages in thread
From: Cyrill Gorcunov @ 2014-05-06 17:03 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: linux-kernel, linux-mm, torvalds, mgorman, mingo, steven, riel,
	david.vrabel, akpm, peterz, xemul

On Tue, May 06, 2014 at 09:28:07AM -0700, H. Peter Anvin wrote:
> On 04/25/2014 01:10 AM, Cyrill Gorcunov wrote:
> > Tracking dirty status on 2 level pages requires very ugly macros
> > and taking into account how old the machines who can operate
> > without PAE mode only are, lets drop soft dirty tracker from
> > them for code simplicity (note I can't drop all the macros
> > from 2 level pages by now since _PAGE_BIT_PROTNONE and
> > _PAGE_BIT_FILE are still used even without tracker).
> > 
> > Linus proposed to completely rip off softdirty support on
> > x86-32 (even with PAE) and since for CRIU we're not planning
> > to support native x86-32 mode, lets do that.
> > 
> > (Softdirty tracker is relatively new feature which mostly used
> >  by CRIU so I don't expect if such API change would cause problems
> >  on userspace).
> 
> I have to wonder which one is more likely to actually matter on whatever
> legacy 32-bit are going to remain.  This pretty much comes down to what
> kind of advanced features are going to matter in deep embedded
> applications in the future: checkpoint/restart or NUMA.  My guess is
> that it is actually checkpoint/restart...
> 
> How much does it actually simplify to leave this feature in for PAE?  I
> could care less about non-PAE... NX has pretty much killed that off cold.

At the current state -- not much I would say. Initially the idea was to
drop x86-32 and use page-soft-dirty-bit (ie 11) inside swap entries dropping
off page-swap-soft-dirty bit completely, this would simplify all the things
but eventually I realized that if I do so the number of maximum swap entries
will get more shrinked which is inacceptable I think.

Thus, currently (ie even with this patches) we can work on x86-32+PAE but
desided to drop x86-32 completely to simplify things in future.

Peter, deep embedded applications I guess would be working on systems
with really small amount of memory installed in a system I suppose and
I doubt if they would need c/r?

If we deside to leave x86-32+PAE then don't apply this patch, I will
need to update it, (The first patch is safe to apply anyway).

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-06 17:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25  8:10 [patch 0/2] A few simplifications for softdirty memory tracker code Cyrill Gorcunov
2014-04-25  8:10 ` [patch 1/2] mm: pgtable -- Drop unneeded preprocessor ifdef Cyrill Gorcunov
2014-04-25  8:10 ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker Cyrill Gorcunov
2014-05-05 23:31   ` Andrew Morton
2014-05-06  8:25     ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker, v2 Cyrill Gorcunov
2014-05-06 16:28   ` [patch 2/2] mm: pgtable -- Require X86_64 for soft-dirty tracker H. Peter Anvin
2014-05-06 17:03     ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).