All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Zhang Yi <yi.z.zhang@linux.intel.com>
Cc: "Jan Kara" <jack@suse.cz>, "Zhang, Yu C" <yu.c.zhang@intel.com>,
	"KVM list" <kvm@vger.kernel.org>,
	linux-nvdimm <linux-nvdimm@lists.01.org>,
	rkrcmar@redhat.com,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Linux MM" <linux-mm@kvack.org>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Christoph Hellwig" <hch@lst.de>
Subject: Re: [PATCH 3/3] kvm: add a function to check if page is from NVDIMM pmem.
Date: Wed, 4 Jul 2018 07:50:15 -0700	[thread overview]
Message-ID: <CAPcyv4is0T1SjsaC4Z80ND9Q_032_Tsa0hQwkO84T0FCRj5MkA@mail.gmail.com> (raw)
In-Reply-To: <359fdf0103b61014bf811d88d4ce36bc793d18f2.1530716899.git.yi.z.zhang@linux.intel.com>

[ adding Jerome ]

On Wed, Jul 4, 2018 at 8:30 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
> For device specific memory space, when we move these area of pfn to
> memory zone, we will set the page reserved flag at that time, some of
> these reserved for device mmio, and some of these are not, such as
> NVDIMM pmem.
>
> Now, we map these dev_dax or fs_dax pages to kvm for DIMM/NVDIMM
> backend, since these pages are reserved. the check of
> kvm_is_reserved_pfn() misconceives those pages as MMIO. Therefor, we
> introduce 2 page map types, MEMORY_DEVICE_FS_DAX/MEMORY_DEVICE_DEV_DAX,
> to indentify these pages are from NVDIMM pmem. and let kvm treat these
> as normal pages.
>
> Without this patch, Many operations will be missed due to this
> mistreatment to pmem pages. For example, a page may not have chance to
> be unpinned for KVM guest(in kvm_release_pfn_clean); not able to be
> marked as dirty/accessed(in kvm_set_pfn_dirty/accessed) etc.
>
> Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
> Signed-off-by: Zhang Yu <yu.c.zhang@linux.intel.com>
> ---
>  virt/kvm/kvm_main.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index afb2e6e..1365d18 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -140,10 +140,23 @@ __weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm,
>  {
>  }
>
> +static bool kvm_is_nd_pfn(kvm_pfn_t pfn)
> +{
> +       struct page *page = pfn_to_page(pfn);
> +
> +       return is_zone_device_page(page) &&
> +               ((page->pgmap->type == MEMORY_DEVICE_FS_DAX) ||
> +                (page->pgmap->type == MEMORY_DEVICE_DEV_DAX));

Jerome, might there be any use case to pass MEMORY_DEVICE_PUBLIC
memory to a guest vm?

> +}
> +
>  bool kvm_is_reserved_pfn(kvm_pfn_t pfn)
>  {
> -       if (pfn_valid(pfn))
> -               return PageReserved(pfn_to_page(pfn));
> +       struct page *page;
> +
> +       if (pfn_valid(pfn)) {
> +               page = pfn_to_page(pfn);
> +               return kvm_is_nd_pfn(pfn) ? false : PageReserved(page);
> +       }
>
>         return true;
>  }
> --
> 2.7.4
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com>
To: Zhang Yi <yi.z.zhang@linux.intel.com>
Cc: "KVM list" <kvm@vger.kernel.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	linux-nvdimm <linux-nvdimm@lists.01.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>, "Jan Kara" <jack@suse.cz>,
	"Christoph Hellwig" <hch@lst.de>,
	"Zhang, Yu C" <yu.c.zhang@intel.com>,
	"Linux MM" <linux-mm@kvack.org>,
	rkrcmar@redhat.com, "Zhang, Yi Z" <yi.z.zhang@intel.com>,
	"Jérôme Glisse" <jglisse@redhat.com>
Subject: Re: [PATCH 3/3] kvm: add a function to check if page is from NVDIMM pmem.
Date: Wed, 4 Jul 2018 07:50:15 -0700	[thread overview]
Message-ID: <CAPcyv4is0T1SjsaC4Z80ND9Q_032_Tsa0hQwkO84T0FCRj5MkA@mail.gmail.com> (raw)
In-Reply-To: <359fdf0103b61014bf811d88d4ce36bc793d18f2.1530716899.git.yi.z.zhang@linux.intel.com>

[ adding Jerome ]

On Wed, Jul 4, 2018 at 8:30 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
> For device specific memory space, when we move these area of pfn to
> memory zone, we will set the page reserved flag at that time, some of
> these reserved for device mmio, and some of these are not, such as
> NVDIMM pmem.
>
> Now, we map these dev_dax or fs_dax pages to kvm for DIMM/NVDIMM
> backend, since these pages are reserved. the check of
> kvm_is_reserved_pfn() misconceives those pages as MMIO. Therefor, we
> introduce 2 page map types, MEMORY_DEVICE_FS_DAX/MEMORY_DEVICE_DEV_DAX,
> to indentify these pages are from NVDIMM pmem. and let kvm treat these
> as normal pages.
>
> Without this patch, Many operations will be missed due to this
> mistreatment to pmem pages. For example, a page may not have chance to
> be unpinned for KVM guest(in kvm_release_pfn_clean); not able to be
> marked as dirty/accessed(in kvm_set_pfn_dirty/accessed) etc.
>
> Signed-off-by: Zhang Yi <yi.z.zhang@linux.intel.com>
> Signed-off-by: Zhang Yu <yu.c.zhang@linux.intel.com>
> ---
>  virt/kvm/kvm_main.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index afb2e6e..1365d18 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -140,10 +140,23 @@ __weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm,
>  {
>  }
>
> +static bool kvm_is_nd_pfn(kvm_pfn_t pfn)
> +{
> +       struct page *page = pfn_to_page(pfn);
> +
> +       return is_zone_device_page(page) &&
> +               ((page->pgmap->type == MEMORY_DEVICE_FS_DAX) ||
> +                (page->pgmap->type == MEMORY_DEVICE_DEV_DAX));

Jerome, might there be any use case to pass MEMORY_DEVICE_PUBLIC
memory to a guest vm?

> +}
> +
>  bool kvm_is_reserved_pfn(kvm_pfn_t pfn)
>  {
> -       if (pfn_valid(pfn))
> -               return PageReserved(pfn_to_page(pfn));
> +       struct page *page;
> +
> +       if (pfn_valid(pfn)) {
> +               page = pfn_to_page(pfn);
> +               return kvm_is_nd_pfn(pfn) ? false : PageReserved(page);
> +       }
>
>         return true;
>  }
> --
> 2.7.4
>

WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Zhang Yi <yi.z.zhang-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: "Jan Kara" <jack-AlSwsSmVLrQ@public.gmane.org>,
	"Zhang,
	Yu C" <yu.c.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"KVM list" <kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-nvdimm
	<linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org>,
	rkrcmar-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	"Linux Kernel Mailing List"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"Linux MM" <linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
	"Jérôme Glisse" <jglisse-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Paolo Bonzini"
	<pbonzini-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Christoph Hellwig" <hch-jcswGhMUV9g@public.gmane.org>,
	"Zhang,
	Yi Z" <yi.z.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 3/3] kvm: add a function to check if page is from NVDIMM pmem.
Date: Wed, 4 Jul 2018 07:50:15 -0700	[thread overview]
Message-ID: <CAPcyv4is0T1SjsaC4Z80ND9Q_032_Tsa0hQwkO84T0FCRj5MkA@mail.gmail.com> (raw)
In-Reply-To: <359fdf0103b61014bf811d88d4ce36bc793d18f2.1530716899.git.yi.z.zhang-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

[ adding Jerome ]

On Wed, Jul 4, 2018 at 8:30 AM, Zhang Yi <yi.z.zhang-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> For device specific memory space, when we move these area of pfn to
> memory zone, we will set the page reserved flag at that time, some of
> these reserved for device mmio, and some of these are not, such as
> NVDIMM pmem.
>
> Now, we map these dev_dax or fs_dax pages to kvm for DIMM/NVDIMM
> backend, since these pages are reserved. the check of
> kvm_is_reserved_pfn() misconceives those pages as MMIO. Therefor, we
> introduce 2 page map types, MEMORY_DEVICE_FS_DAX/MEMORY_DEVICE_DEV_DAX,
> to indentify these pages are from NVDIMM pmem. and let kvm treat these
> as normal pages.
>
> Without this patch, Many operations will be missed due to this
> mistreatment to pmem pages. For example, a page may not have chance to
> be unpinned for KVM guest(in kvm_release_pfn_clean); not able to be
> marked as dirty/accessed(in kvm_set_pfn_dirty/accessed) etc.
>
> Signed-off-by: Zhang Yi <yi.z.zhang-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Signed-off-by: Zhang Yu <yu.c.zhang-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>  virt/kvm/kvm_main.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index afb2e6e..1365d18 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -140,10 +140,23 @@ __weak void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm,
>  {
>  }
>
> +static bool kvm_is_nd_pfn(kvm_pfn_t pfn)
> +{
> +       struct page *page = pfn_to_page(pfn);
> +
> +       return is_zone_device_page(page) &&
> +               ((page->pgmap->type == MEMORY_DEVICE_FS_DAX) ||
> +                (page->pgmap->type == MEMORY_DEVICE_DEV_DAX));

Jerome, might there be any use case to pass MEMORY_DEVICE_PUBLIC
memory to a guest vm?

> +}
> +
>  bool kvm_is_reserved_pfn(kvm_pfn_t pfn)
>  {
> -       if (pfn_valid(pfn))
> -               return PageReserved(pfn_to_page(pfn));
> +       struct page *page;
> +
> +       if (pfn_valid(pfn)) {
> +               page = pfn_to_page(pfn);
> +               return kvm_is_nd_pfn(pfn) ? false : PageReserved(page);
> +       }
>
>         return true;
>  }
> --
> 2.7.4
>

  reply	other threads:[~2018-07-04 14:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 15:30 [PATCH 0/3] Fix kvm misconceives NVDIMM pages as reserved mmio Zhang Yi
2018-07-04 15:30 ` Zhang Yi
2018-07-04 15:30 ` Zhang Yi
2018-07-04 15:30 ` [PATCH 1/3] kvm: remove redundant reserved page check Zhang Yi
2018-07-04 15:30   ` Zhang Yi
2018-07-04 15:30   ` Zhang Yi
2018-07-04 15:30 ` [PATCH 2/3] mm: introduce memory type MEMORY_DEVICE_DEV_DAX Zhang Yi
2018-07-04 15:30   ` Zhang Yi
2018-07-04 15:30   ` Zhang Yi
2018-07-04 14:50   ` Dan Williams
2018-07-04 14:50     ` Dan Williams
2018-07-04 14:50     ` Dan Williams
2018-07-05 13:20     ` zhangyi6
2018-07-05 13:20       ` zhangyi6
2018-07-05 13:20       ` zhangyi6
2018-07-05 13:20       ` zhangyi6
2018-07-04 15:30 ` [PATCH 3/3] kvm: add a function to check if page is from NVDIMM pmem Zhang Yi
2018-07-04 15:30   ` Zhang Yi
2018-07-04 15:30   ` Zhang Yi
2018-07-04 14:50   ` Dan Williams [this message]
2018-07-04 14:50     ` Dan Williams
2018-07-04 14:50     ` Dan Williams
2018-07-04 15:27     ` Paolo Bonzini
2018-07-04 15:27       ` Paolo Bonzini
2018-07-04 15:27       ` Paolo Bonzini
2018-07-04 15:25   ` Paolo Bonzini
2018-07-04 15:25     ` Paolo Bonzini
2018-07-04 15:25     ` Paolo Bonzini
2018-07-05 13:19     ` Zhang,Yi
2018-07-05 13:19       ` Zhang,Yi
2018-07-05 13:19       ` Zhang,Yi
2018-07-05 13:19       ` Zhang,Yi
2018-07-09 12:36       ` Jan Kara
2018-07-09 12:36         ` Jan Kara
2018-07-09 12:36         ` Jan Kara
2018-07-09 12:36         ` Jan Kara

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=CAPcyv4is0T1SjsaC4Z80ND9Q_032_Tsa0hQwkO84T0FCRj5MkA@mail.gmail.com \
    --to=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=jglisse@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=yi.z.zhang@linux.intel.com \
    --cc=yu.c.zhang@intel.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.