All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
	David Vrabel <david.vrabel@citrix.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Xen-devel@lists.xen.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	Ingo Molnar <mingo@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: Regression: x86/mm: new _PTE_SWP_SOFT_DIRTY bit conflicts with existing use
Date: Thu, 22 Aug 2013 15:27:27 +0400	[thread overview]
Message-ID: <20130822112727.GL18673@moon> (raw)
In-Reply-To: <5215D99102000078000ED838@nat28.tlf.novell.com>

On Thu, Aug 22, 2013 at 08:27:45AM +0100, Jan Beulich wrote:
> >>> On 22.08.13 at 09:03, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> > Ok, how about this?
> > 
> > static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
> > {
> > 	BUG_ON(pte_present(pte));
> > 	return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
> > }
> 
> Sure, fine with me. Perhaps VM_BUG_ON() or some other similar
> construct limiting the scope when any extra code gets generated
> would do too.

Sorry for delay, the patch is below.

> 
> But as said, even better would perhaps be to have it act on a
> swp_entry_t.

swp_entry_t is too small already to keep additional status bit,
unfortunately.
---
From: Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH] mm: Make sure _PAGE_SWP_SOFT_DIRTY bit is not set on present pte

_PAGE_SOFT_DIRTY bit should never be set on present pte so add
VM_BUG_ON to catch any potential future abuse.

Also add a comment on _PAGE_SWP_SOFT_DIRTY definition explaining
scope of its usage.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Jan Beulich <jbeulich@suse.com>
---
 arch/x86/include/asm/pgtable.h       |   34 +++++++++++++++++++---------------
 arch/x86/include/asm/pgtable_types.h |    3 +++
 2 files changed, 22 insertions(+), 15 deletions(-)

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
@@ -314,21 +314,6 @@ static inline pmd_t pmd_mksoft_dirty(pmd
 	return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
 }
 
-static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
-{
-	return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
-}
-
-static inline int pte_swp_soft_dirty(pte_t pte)
-{
-	return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
-}
-
-static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
-{
-	return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
-}
-
 static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
 {
 	return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
@@ -445,6 +430,7 @@ pte_t *populate_extra_pte(unsigned long
 
 #ifndef __ASSEMBLY__
 #include <linux/mm_types.h>
+#include <linux/mmdebug.h>
 #include <linux/log2.h>
 
 static inline int pte_none(pte_t pte)
@@ -863,6 +849,24 @@ static inline void update_mmu_cache_pmd(
 {
 }
 
+static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
+{
+	VM_BUG_ON(pte_present(pte));
+	return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
+}
+
+static inline int pte_swp_soft_dirty(pte_t pte)
+{
+	VM_BUG_ON(pte_present(pte));
+	return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
+}
+
+static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
+{
+	VM_BUG_ON(pte_present(pte));
+	return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
+}
+
 #include <asm-generic/pgtable.h>
 #endif	/* __ASSEMBLY__ */
 
Index: linux-2.6.git/arch/x86/include/asm/pgtable_types.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/pgtable_types.h
+++ linux-2.6.git/arch/x86/include/asm/pgtable_types.h
@@ -75,6 +75,9 @@
  * with swap entry format. On x86 bits 6 and 7 are *not* involved
  * into swap entry computation, but bit 6 is used for nonlinear
  * file mapping, so we borrow bit 7 for soft dirty tracking.
+ *
+ * Please note that this bit must be treated as swap dirty page
+ * mark if and only if the PTE has present bit clear!
  */
 #ifdef CONFIG_MEM_SOFT_DIRTY
 #define _PAGE_SWP_SOFT_DIRTY	_PAGE_PSE

  parent reply	other threads:[~2013-08-22 11:27 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-21 13:48 Regression: x86/mm: new _PTE_SWP_SOFT_DIRTY bit conflicts with existing use David Vrabel
2013-08-21 13:53 ` konrad wilk
2013-08-21 13:53 ` konrad wilk
2013-08-21 14:11 ` H. Peter Anvin
2013-08-21 14:19   ` Cyrill Gorcunov
2013-08-21 14:22     ` H. Peter Anvin
2013-08-21 14:29       ` Cyrill Gorcunov
2013-08-21 14:29       ` Cyrill Gorcunov
2013-08-21 14:22     ` H. Peter Anvin
2013-08-21 16:30     ` Linus Torvalds
2013-08-21 16:30     ` Linus Torvalds
2013-08-21 16:42       ` Cyrill Gorcunov
2013-08-21 16:42       ` Cyrill Gorcunov
2013-08-21 23:05       ` Cyrill Gorcunov
2013-08-21 23:05       ` Cyrill Gorcunov
2013-08-21 23:42         ` Andi Kleen
2013-08-21 23:42         ` Andi Kleen
2013-08-22  5:49           ` Cyrill Gorcunov
2013-08-22  6:37             ` Minchan Kim
2013-08-22 13:12               ` Cyrill Gorcunov
2013-08-22 13:12               ` Cyrill Gorcunov
2013-08-22  6:37             ` Minchan Kim
2013-08-22  5:49           ` Cyrill Gorcunov
2013-08-27 22:04       ` Benjamin Herrenschmidt
2013-08-27 22:04       ` Benjamin Herrenschmidt
2013-08-21 14:19   ` Cyrill Gorcunov
2013-08-21 14:11 ` H. Peter Anvin
2013-08-21 14:12 ` Cyrill Gorcunov
2013-08-21 14:22   ` H. Peter Anvin
2013-08-21 14:22   ` H. Peter Anvin
2013-08-21 14:53   ` Jan Beulich
2013-08-21 14:53   ` Jan Beulich
2013-08-21 14:58     ` H. Peter Anvin
2013-08-21 14:58     ` H. Peter Anvin
2013-08-21 15:42     ` Cyrill Gorcunov
2013-08-21 16:03       ` Jan Beulich
2013-08-21 16:03       ` Jan Beulich
2013-08-21 16:19         ` Cyrill Gorcunov
2013-08-21 16:56           ` David Vrabel
2013-08-21 17:25             ` Cyrill Gorcunov
2013-08-21 17:25             ` Cyrill Gorcunov
2013-08-21 18:17               ` Cyrill Gorcunov
2013-08-21 18:50                 ` H. Peter Anvin
2013-08-21 18:50                 ` H. Peter Anvin
2013-08-21 19:03                   ` Cyrill Gorcunov
2013-08-21 19:07                     ` Andy Lutomirski
2013-08-21 19:20                       ` Cyrill Gorcunov
2013-08-21 19:20                       ` Cyrill Gorcunov
2013-08-21 19:21                       ` Pavel Emelyanov
2013-08-21 19:21                       ` Pavel Emelyanov
2013-08-21 19:07                     ` Andy Lutomirski
2013-08-21 23:04                     ` Linus Torvalds
2013-08-21 23:04                     ` Linus Torvalds
2013-08-22  0:51                       ` Dave Jones
2013-08-22  5:44                         ` Cyrill Gorcunov
2013-08-22  5:44                         ` Cyrill Gorcunov
2013-08-22  6:41                         ` Pavel Emelyanov
2013-08-22  6:41                         ` Pavel Emelyanov
2013-08-22  0:51                       ` Dave Jones
2013-08-22  7:47                       ` Jan Beulich
2013-08-22  7:47                       ` Jan Beulich
2013-08-22  9:32                       ` David Vrabel
2013-08-22 10:16                         ` Pavel Emelyanov
2013-08-22 10:16                         ` Pavel Emelyanov
2013-08-22  9:32                       ` David Vrabel
2013-08-21 19:03                   ` Cyrill Gorcunov
2013-08-21 18:17               ` Cyrill Gorcunov
2013-08-21 16:56           ` David Vrabel
2013-08-22  6:56           ` Jan Beulich
2013-08-22  7:03             ` Cyrill Gorcunov
2013-08-22  7:03             ` Cyrill Gorcunov
2013-08-22  7:27               ` Jan Beulich
2013-08-22 11:27                 ` Cyrill Gorcunov
2013-08-22 11:27                 ` Cyrill Gorcunov [this message]
2013-08-22 11:33                   ` Jan Beulich
2013-08-22 12:18                     ` Pavel Emelyanov
2013-08-22 12:18                     ` Pavel Emelyanov
2013-08-22 11:33                   ` Jan Beulich
2013-08-22  7:27               ` Jan Beulich
2013-08-22  6:56           ` Jan Beulich
2013-08-21 16:19         ` Cyrill Gorcunov
2013-08-21 15:42     ` Cyrill Gorcunov
2013-08-21 14:12 ` Cyrill Gorcunov
2013-08-21 17:28 ` Andy Lutomirski
2013-08-21 17:28 ` Andy Lutomirski
2013-08-22  7:54   ` Jan Beulich
2013-08-22  9:06     ` Stefan Bader
2013-08-22  7:54   ` Jan Beulich
  -- strict thread matches above, loose matches on Subject: below --
2013-08-21 13:48 David Vrabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130822112727.GL18673@moon \
    --to=gorcunov@gmail.com \
    --cc=JBeulich@suse.com \
    --cc=Xen-devel@lists.xen.org \
    --cc=akpm@linux-foundation.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=hpa@zytor.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.