From: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
David Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org>,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-mm <linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
Andreas Dilger
<adilger.kernel-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>,
Krzysztof Kozlowski
<krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
linux-samsung-soc
<linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Joonyoung Shim
<jy0922.shim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
"Darrick J. Wong"
<darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Patrik Jakobsson
<patrik.r.jakobsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Tomi Valkeinen <tomi.valkeinen-l0cyMroinI0@public.gmane.org>,
ext4 hackers <linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>,
"linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org"
<linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org>,
Alexander Viro
<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWNGWvitb5QawA@public.gmane.org>
Subject: Re: [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed()
Date: Mon, 24 Jul 2017 09:13:03 -0600 [thread overview]
Message-ID: <20170724151303.GA1639@linux.intel.com> (raw)
In-Reply-To: <20170724111531.GG652-4I4JzKEfoa/jFM9bn6wA6Q@public.gmane.org>
On Mon, Jul 24, 2017 at 01:15:31PM +0200, Jan Kara wrote:
> On Sat 22-07-17 09:21:31, Dan Williams wrote:
> > On Fri, Jul 21, 2017 at 3:39 PM, Ross Zwisler
> > <ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> > > To be able to use the common 4k zero page in DAX we need to have our PTE
> > > fault path look more like our PMD fault path where a PTE entry can be
> > > marked as dirty and writeable as it is first inserted, rather than waiting
> > > for a follow-up dax_pfn_mkwrite() => finish_mkwrite_fault() call.
> > >
> > > Right now we can rely on having a dax_pfn_mkwrite() call because we can
> > > distinguish between these two cases in do_wp_page():
> > >
> > > case 1: 4k zero page => writable DAX storage
> > > case 2: read-only DAX storage => writeable DAX storage
> > >
> > > This distinction is made by via vm_normal_page(). vm_normal_page() returns
> > > false for the common 4k zero page, though, just as it does for DAX ptes.
> > > Instead of special casing the DAX + 4k zero page case, we will simplify our
> > > DAX PTE page fault sequence so that it matches our DAX PMD sequence, and
> > > get rid of the dax_pfn_mkwrite() helper. We will instead use
> > > dax_iomap_fault() to handle write-protection faults.
> > >
> > > This means that insert_pfn() needs to follow the lead of insert_pfn_pmd()
> > > and allow us to pass in a 'mkwrite' flag. If 'mkwrite' is set insert_pfn()
> > > will do the work that was previously done by wp_page_reuse() as part of the
> > > dax_pfn_mkwrite() call path.
> > >
> > > Signed-off-by: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > > ---
> > > drivers/dax/device.c | 2 +-
> > > drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++-
> > > drivers/gpu/drm/gma500/framebuffer.c | 2 +-
> > > drivers/gpu/drm/msm/msm_gem.c | 3 ++-
> > > drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++--
> > > drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
> > > fs/dax.c | 2 +-
> > > include/linux/mm.h | 2 +-
> > > mm/memory.c | 27 +++++++++++++++++++++------
> > > 9 files changed, 34 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> > > index e9f3b3e..3973521 100644
> > > --- a/drivers/dax/device.c
> > > +++ b/drivers/dax/device.c
> > > @@ -273,7 +273,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
> > >
> > > pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
> > >
> > > - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);
> > > + rc = vm_insert_mixed(vmf->vma, vmf->address, pfn, false);
> >
> > Ugh, I generally find bool flags unreadable. They place a tax on
> > jumping to function definition to recall what true and false mean. If
> > we want to go this 'add an argument' route can we at least add an enum
> > like:
> >
> > enum {
> > PTE_MKDIRTY,
> > PTE_MKCLEAN,
> > };
> >
> > ...to differentiate the two cases?
>
> So how I usually deal with this is that I create e.g.:
>
> __vm_insert_mixed() that takes the bool argument, make vm_insert_mixed()
> pass false, and vm_insert_mixed_mkwrite() pass true. That way there's no
> code duplication, old call sites can stay unchanged, the naming clearly
> says what's going on...
Ah, that does seem cleaner. I'll try that for v5.
WARNING: multiple messages have this Message-ID (diff)
From: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>
Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
David Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org>,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
linux-mm <linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org>,
Andreas Dilger
<adilger.kernel-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>,
Krzysztof Kozlowski
<krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
linux-samsung-soc
<linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Joonyoung Shim
<jy0922.shim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
"Darrick J. Wong"
<darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
Rob Clark <robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Patrik Jakobsson
<patrik.r.jakobsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Tomi Valkeinen <tomi.valkeinen-l0cyMroinI0@public.gmane.org>,
ext4 hackers <linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>,
"linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org"
<linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org>,
Alexander Viro
<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWNGWvitb5QawA@public.gmane.org
Subject: Re: [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed()
Date: Mon, 24 Jul 2017 09:13:03 -0600 [thread overview]
Message-ID: <20170724151303.GA1639@linux.intel.com> (raw)
In-Reply-To: <20170724111531.GG652-4I4JzKEfoa/jFM9bn6wA6Q@public.gmane.org>
On Mon, Jul 24, 2017 at 01:15:31PM +0200, Jan Kara wrote:
> On Sat 22-07-17 09:21:31, Dan Williams wrote:
> > On Fri, Jul 21, 2017 at 3:39 PM, Ross Zwisler
> > <ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> > > To be able to use the common 4k zero page in DAX we need to have our PTE
> > > fault path look more like our PMD fault path where a PTE entry can be
> > > marked as dirty and writeable as it is first inserted, rather than waiting
> > > for a follow-up dax_pfn_mkwrite() => finish_mkwrite_fault() call.
> > >
> > > Right now we can rely on having a dax_pfn_mkwrite() call because we can
> > > distinguish between these two cases in do_wp_page():
> > >
> > > case 1: 4k zero page => writable DAX storage
> > > case 2: read-only DAX storage => writeable DAX storage
> > >
> > > This distinction is made by via vm_normal_page(). vm_normal_page() returns
> > > false for the common 4k zero page, though, just as it does for DAX ptes.
> > > Instead of special casing the DAX + 4k zero page case, we will simplify our
> > > DAX PTE page fault sequence so that it matches our DAX PMD sequence, and
> > > get rid of the dax_pfn_mkwrite() helper. We will instead use
> > > dax_iomap_fault() to handle write-protection faults.
> > >
> > > This means that insert_pfn() needs to follow the lead of insert_pfn_pmd()
> > > and allow us to pass in a 'mkwrite' flag. If 'mkwrite' is set insert_pfn()
> > > will do the work that was previously done by wp_page_reuse() as part of the
> > > dax_pfn_mkwrite() call path.
> > >
> > > Signed-off-by: Ross Zwisler <ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > > ---
> > > drivers/dax/device.c | 2 +-
> > > drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++-
> > > drivers/gpu/drm/gma500/framebuffer.c | 2 +-
> > > drivers/gpu/drm/msm/msm_gem.c | 3 ++-
> > > drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++--
> > > drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
> > > fs/dax.c | 2 +-
> > > include/linux/mm.h | 2 +-
> > > mm/memory.c | 27 +++++++++++++++++++++------
> > > 9 files changed, 34 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> > > index e9f3b3e..3973521 100644
> > > --- a/drivers/dax/device.c
> > > +++ b/drivers/dax/device.c
> > > @@ -273,7 +273,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
> > >
> > > pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
> > >
> > > - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);
> > > + rc = vm_insert_mixed(vmf->vma, vmf->address, pfn, false);
> >
> > Ugh, I generally find bool flags unreadable. They place a tax on
> > jumping to function definition to recall what true and false mean. If
> > we want to go this 'add an argument' route can we at least add an enum
> > like:
> >
> > enum {
> > PTE_MKDIRTY,
> > PTE_MKCLEAN,
> > };
> >
> > ...to differentiate the two cases?
>
> So how I usually deal with this is that I create e.g.:
>
> __vm_insert_mixed() that takes the bool argument, make vm_insert_mixed()
> pass false, and vm_insert_mixed_mkwrite() pass true. That way there's no
> code duplication, old call sites can stay unchanged, the naming clearly
> says what's going on...
Ah, that does seem cleaner. I'll try that for v5.
WARNING: multiple messages have this Message-ID (diff)
From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-doc@vger.kernel.org, David Airlie <airlied@linux.ie>,
Dave Chinner <david@fromorbit.com>,
dri-devel@lists.freedesktop.org, linux-mm <linux-mm@kvack.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Krzysztof Kozlowski <krzk@kernel.org>,
Christoph Hellwig <hch@lst.de>, Jonathan Corbet <corbet@lwn.net>,
linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
Joonyoung Shim <jy0922.shim@samsung.com>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Rob Clark <robdclark@gmail.com>,
Patrik Jakobsson <patrik.r.jakobsson@gmail.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
ext4 hackers <linux-ext4@vger.kernel.org>,
linux-arm-msm@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Ingo Molnar <mingo@redhat.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Inki Dae <inki.dae@samsung.com>, Theodore Ts'o <tytso@mit.edu>,
Matthew Wilcox <mawilcox@microsoft.com>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-xfs@vger.kernel.org,
Kyungmin Park <kyungmin.park@samsung.com>,
Kukjin Kim <kgene@kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
freedreno@lists.freedesktop.org
Subject: Re: [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed()
Date: Mon, 24 Jul 2017 09:13:03 -0600 [thread overview]
Message-ID: <20170724151303.GA1639@linux.intel.com> (raw)
In-Reply-To: <20170724111531.GG652@quack2.suse.cz>
On Mon, Jul 24, 2017 at 01:15:31PM +0200, Jan Kara wrote:
> On Sat 22-07-17 09:21:31, Dan Williams wrote:
> > On Fri, Jul 21, 2017 at 3:39 PM, Ross Zwisler
> > <ross.zwisler@linux.intel.com> wrote:
> > > To be able to use the common 4k zero page in DAX we need to have our PTE
> > > fault path look more like our PMD fault path where a PTE entry can be
> > > marked as dirty and writeable as it is first inserted, rather than waiting
> > > for a follow-up dax_pfn_mkwrite() => finish_mkwrite_fault() call.
> > >
> > > Right now we can rely on having a dax_pfn_mkwrite() call because we can
> > > distinguish between these two cases in do_wp_page():
> > >
> > > case 1: 4k zero page => writable DAX storage
> > > case 2: read-only DAX storage => writeable DAX storage
> > >
> > > This distinction is made by via vm_normal_page(). vm_normal_page() returns
> > > false for the common 4k zero page, though, just as it does for DAX ptes.
> > > Instead of special casing the DAX + 4k zero page case, we will simplify our
> > > DAX PTE page fault sequence so that it matches our DAX PMD sequence, and
> > > get rid of the dax_pfn_mkwrite() helper. We will instead use
> > > dax_iomap_fault() to handle write-protection faults.
> > >
> > > This means that insert_pfn() needs to follow the lead of insert_pfn_pmd()
> > > and allow us to pass in a 'mkwrite' flag. If 'mkwrite' is set insert_pfn()
> > > will do the work that was previously done by wp_page_reuse() as part of the
> > > dax_pfn_mkwrite() call path.
> > >
> > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > > ---
> > > drivers/dax/device.c | 2 +-
> > > drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++-
> > > drivers/gpu/drm/gma500/framebuffer.c | 2 +-
> > > drivers/gpu/drm/msm/msm_gem.c | 3 ++-
> > > drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++--
> > > drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
> > > fs/dax.c | 2 +-
> > > include/linux/mm.h | 2 +-
> > > mm/memory.c | 27 +++++++++++++++++++++------
> > > 9 files changed, 34 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> > > index e9f3b3e..3973521 100644
> > > --- a/drivers/dax/device.c
> > > +++ b/drivers/dax/device.c
> > > @@ -273,7 +273,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
> > >
> > > pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
> > >
> > > - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);
> > > + rc = vm_insert_mixed(vmf->vma, vmf->address, pfn, false);
> >
> > Ugh, I generally find bool flags unreadable. They place a tax on
> > jumping to function definition to recall what true and false mean. If
> > we want to go this 'add an argument' route can we at least add an enum
> > like:
> >
> > enum {
> > PTE_MKDIRTY,
> > PTE_MKCLEAN,
> > };
> >
> > ...to differentiate the two cases?
>
> So how I usually deal with this is that I create e.g.:
>
> __vm_insert_mixed() that takes the bool argument, make vm_insert_mixed()
> pass false, and vm_insert_mixed_mkwrite() pass true. That way there's no
> code duplication, old call sites can stay unchanged, the naming clearly
> says what's going on...
Ah, that does seem cleaner. I'll try that for v5.
_______________________________________________
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: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Jan Kara <jack@suse.cz>
Cc: Dan Williams <dan.j.williams@gmail.com>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-doc@vger.kernel.org, David Airlie <airlied@linux.ie>,
Dave Chinner <david@fromorbit.com>,
dri-devel@lists.freedesktop.org, linux-mm <linux-mm@kvack.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Patrik Jakobsson <patrik.r.jakobsson@gmail.com>,
Christoph Hellwig <hch@lst.de>,
linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
Joonyoung Shim <jy0922.shim@samsung.com>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
ext4 hackers <linux-ext4@vger.kernel.org>,
Matthew Wilcox <mawilcox@microsoft.com>,
linux-arm-msm@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Inki Dae <inki.dae@samsung.com>,
"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Theodore Ts'o <tytso@mit.edu>, Jonathan Corbet <corbet@lwn.net>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
linux-xfs@vger.kernel.org, Rob Clark <robdclark@gmail.com>,
Kukjin Kim <kgene@kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
freedreno@lists.freedesktop.org
Subject: Re: [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed()
Date: Mon, 24 Jul 2017 09:13:03 -0600 [thread overview]
Message-ID: <20170724151303.GA1639@linux.intel.com> (raw)
In-Reply-To: <20170724111531.GG652@quack2.suse.cz>
On Mon, Jul 24, 2017 at 01:15:31PM +0200, Jan Kara wrote:
> On Sat 22-07-17 09:21:31, Dan Williams wrote:
> > On Fri, Jul 21, 2017 at 3:39 PM, Ross Zwisler
> > <ross.zwisler@linux.intel.com> wrote:
> > > To be able to use the common 4k zero page in DAX we need to have our PTE
> > > fault path look more like our PMD fault path where a PTE entry can be
> > > marked as dirty and writeable as it is first inserted, rather than waiting
> > > for a follow-up dax_pfn_mkwrite() => finish_mkwrite_fault() call.
> > >
> > > Right now we can rely on having a dax_pfn_mkwrite() call because we can
> > > distinguish between these two cases in do_wp_page():
> > >
> > > case 1: 4k zero page => writable DAX storage
> > > case 2: read-only DAX storage => writeable DAX storage
> > >
> > > This distinction is made by via vm_normal_page(). vm_normal_page() returns
> > > false for the common 4k zero page, though, just as it does for DAX ptes.
> > > Instead of special casing the DAX + 4k zero page case, we will simplify our
> > > DAX PTE page fault sequence so that it matches our DAX PMD sequence, and
> > > get rid of the dax_pfn_mkwrite() helper. We will instead use
> > > dax_iomap_fault() to handle write-protection faults.
> > >
> > > This means that insert_pfn() needs to follow the lead of insert_pfn_pmd()
> > > and allow us to pass in a 'mkwrite' flag. If 'mkwrite' is set insert_pfn()
> > > will do the work that was previously done by wp_page_reuse() as part of the
> > > dax_pfn_mkwrite() call path.
> > >
> > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > > ---
> > > drivers/dax/device.c | 2 +-
> > > drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++-
> > > drivers/gpu/drm/gma500/framebuffer.c | 2 +-
> > > drivers/gpu/drm/msm/msm_gem.c | 3 ++-
> > > drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++--
> > > drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
> > > fs/dax.c | 2 +-
> > > include/linux/mm.h | 2 +-
> > > mm/memory.c | 27 +++++++++++++++++++++------
> > > 9 files changed, 34 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> > > index e9f3b3e..3973521 100644
> > > --- a/drivers/dax/device.c
> > > +++ b/drivers/dax/device.c
> > > @@ -273,7 +273,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
> > >
> > > pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
> > >
> > > - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);
> > > + rc = vm_insert_mixed(vmf->vma, vmf->address, pfn, false);
> >
> > Ugh, I generally find bool flags unreadable. They place a tax on
> > jumping to function definition to recall what true and false mean. If
> > we want to go this 'add an argument' route can we at least add an enum
> > like:
> >
> > enum {
> > PTE_MKDIRTY,
> > PTE_MKCLEAN,
> > };
> >
> > ...to differentiate the two cases?
>
> So how I usually deal with this is that I create e.g.:
>
> __vm_insert_mixed() that takes the bool argument, make vm_insert_mixed()
> pass false, and vm_insert_mixed_mkwrite() pass true. That way there's no
> code duplication, old call sites can stay unchanged, the naming clearly
> says what's going on...
Ah, that does seem cleaner. I'll try that for v5.
WARNING: multiple messages have this Message-ID (diff)
From: ross.zwisler@linux.intel.com (Ross Zwisler)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed()
Date: Mon, 24 Jul 2017 09:13:03 -0600 [thread overview]
Message-ID: <20170724151303.GA1639@linux.intel.com> (raw)
In-Reply-To: <20170724111531.GG652@quack2.suse.cz>
On Mon, Jul 24, 2017 at 01:15:31PM +0200, Jan Kara wrote:
> On Sat 22-07-17 09:21:31, Dan Williams wrote:
> > On Fri, Jul 21, 2017 at 3:39 PM, Ross Zwisler
> > <ross.zwisler@linux.intel.com> wrote:
> > > To be able to use the common 4k zero page in DAX we need to have our PTE
> > > fault path look more like our PMD fault path where a PTE entry can be
> > > marked as dirty and writeable as it is first inserted, rather than waiting
> > > for a follow-up dax_pfn_mkwrite() => finish_mkwrite_fault() call.
> > >
> > > Right now we can rely on having a dax_pfn_mkwrite() call because we can
> > > distinguish between these two cases in do_wp_page():
> > >
> > > case 1: 4k zero page => writable DAX storage
> > > case 2: read-only DAX storage => writeable DAX storage
> > >
> > > This distinction is made by via vm_normal_page(). vm_normal_page() returns
> > > false for the common 4k zero page, though, just as it does for DAX ptes.
> > > Instead of special casing the DAX + 4k zero page case, we will simplify our
> > > DAX PTE page fault sequence so that it matches our DAX PMD sequence, and
> > > get rid of the dax_pfn_mkwrite() helper. We will instead use
> > > dax_iomap_fault() to handle write-protection faults.
> > >
> > > This means that insert_pfn() needs to follow the lead of insert_pfn_pmd()
> > > and allow us to pass in a 'mkwrite' flag. If 'mkwrite' is set insert_pfn()
> > > will do the work that was previously done by wp_page_reuse() as part of the
> > > dax_pfn_mkwrite() call path.
> > >
> > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > > ---
> > > drivers/dax/device.c | 2 +-
> > > drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++-
> > > drivers/gpu/drm/gma500/framebuffer.c | 2 +-
> > > drivers/gpu/drm/msm/msm_gem.c | 3 ++-
> > > drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++--
> > > drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
> > > fs/dax.c | 2 +-
> > > include/linux/mm.h | 2 +-
> > > mm/memory.c | 27 +++++++++++++++++++++------
> > > 9 files changed, 34 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> > > index e9f3b3e..3973521 100644
> > > --- a/drivers/dax/device.c
> > > +++ b/drivers/dax/device.c
> > > @@ -273,7 +273,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
> > >
> > > pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
> > >
> > > - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);
> > > + rc = vm_insert_mixed(vmf->vma, vmf->address, pfn, false);
> >
> > Ugh, I generally find bool flags unreadable. They place a tax on
> > jumping to function definition to recall what true and false mean. If
> > we want to go this 'add an argument' route can we at least add an enum
> > like:
> >
> > enum {
> > PTE_MKDIRTY,
> > PTE_MKCLEAN,
> > };
> >
> > ...to differentiate the two cases?
>
> So how I usually deal with this is that I create e.g.:
>
> __vm_insert_mixed() that takes the bool argument, make vm_insert_mixed()
> pass false, and vm_insert_mixed_mkwrite() pass true. That way there's no
> code duplication, old call sites can stay unchanged, the naming clearly
> says what's going on...
Ah, that does seem cleaner. I'll try that for v5.
WARNING: multiple messages have this Message-ID (diff)
From: Ross Zwisler <ross.zwisler@linux.intel.com>
To: Jan Kara <jack@suse.cz>
Cc: Dan Williams <dan.j.williams@gmail.com>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-doc@vger.kernel.org, David Airlie <airlied@linux.ie>,
Dave Chinner <david@fromorbit.com>,
dri-devel@lists.freedesktop.org, linux-mm <linux-mm@kvack.org>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Patrik Jakobsson <patrik.r.jakobsson@gmail.com>,
Christoph Hellwig <hch@lst.de>,
linux-samsung-soc <linux-samsung-soc@vger.kernel.org>,
Joonyoung Shim <jy0922.shim@samsung.com>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
ext4 hackers <linux-ext4@vger.kernel.org>,
Matthew Wilcox <mawilcox@microsoft.com>,
linux-arm-msm@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Inki Dae <inki.dae@samsung.com>,
"linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Theodore Ts'o <tytso@mit.edu>, Jonathan Corbet <corbet@lwn.net>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
linux-xfs@vger.kernel.org, Rob Clark <robdclark@gmail.com>,
Kukjin Kim <kgene@kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
freedreno@lists.freedesktop.org
Subject: Re: [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed()
Date: Mon, 24 Jul 2017 09:13:03 -0600 [thread overview]
Message-ID: <20170724151303.GA1639@linux.intel.com> (raw)
In-Reply-To: <20170724111531.GG652@quack2.suse.cz>
On Mon, Jul 24, 2017 at 01:15:31PM +0200, Jan Kara wrote:
> On Sat 22-07-17 09:21:31, Dan Williams wrote:
> > On Fri, Jul 21, 2017 at 3:39 PM, Ross Zwisler
> > <ross.zwisler@linux.intel.com> wrote:
> > > To be able to use the common 4k zero page in DAX we need to have our PTE
> > > fault path look more like our PMD fault path where a PTE entry can be
> > > marked as dirty and writeable as it is first inserted, rather than waiting
> > > for a follow-up dax_pfn_mkwrite() => finish_mkwrite_fault() call.
> > >
> > > Right now we can rely on having a dax_pfn_mkwrite() call because we can
> > > distinguish between these two cases in do_wp_page():
> > >
> > > case 1: 4k zero page => writable DAX storage
> > > case 2: read-only DAX storage => writeable DAX storage
> > >
> > > This distinction is made by via vm_normal_page(). vm_normal_page() returns
> > > false for the common 4k zero page, though, just as it does for DAX ptes.
> > > Instead of special casing the DAX + 4k zero page case, we will simplify our
> > > DAX PTE page fault sequence so that it matches our DAX PMD sequence, and
> > > get rid of the dax_pfn_mkwrite() helper. We will instead use
> > > dax_iomap_fault() to handle write-protection faults.
> > >
> > > This means that insert_pfn() needs to follow the lead of insert_pfn_pmd()
> > > and allow us to pass in a 'mkwrite' flag. If 'mkwrite' is set insert_pfn()
> > > will do the work that was previously done by wp_page_reuse() as part of the
> > > dax_pfn_mkwrite() call path.
> > >
> > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> > > ---
> > > drivers/dax/device.c | 2 +-
> > > drivers/gpu/drm/exynos/exynos_drm_gem.c | 3 ++-
> > > drivers/gpu/drm/gma500/framebuffer.c | 2 +-
> > > drivers/gpu/drm/msm/msm_gem.c | 3 ++-
> > > drivers/gpu/drm/omapdrm/omap_gem.c | 6 ++++--
> > > drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
> > > fs/dax.c | 2 +-
> > > include/linux/mm.h | 2 +-
> > > mm/memory.c | 27 +++++++++++++++++++++------
> > > 9 files changed, 34 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/dax/device.c b/drivers/dax/device.c
> > > index e9f3b3e..3973521 100644
> > > --- a/drivers/dax/device.c
> > > +++ b/drivers/dax/device.c
> > > @@ -273,7 +273,7 @@ static int __dev_dax_pte_fault(struct dev_dax *dev_dax, struct vm_fault *vmf)
> > >
> > > pfn = phys_to_pfn_t(phys, dax_region->pfn_flags);
> > >
> > > - rc = vm_insert_mixed(vmf->vma, vmf->address, pfn);
> > > + rc = vm_insert_mixed(vmf->vma, vmf->address, pfn, false);
> >
> > Ugh, I generally find bool flags unreadable. They place a tax on
> > jumping to function definition to recall what true and false mean. If
> > we want to go this 'add an argument' route can we at least add an enum
> > like:
> >
> > enum {
> > PTE_MKDIRTY,
> > PTE_MKCLEAN,
> > };
> >
> > ...to differentiate the two cases?
>
> So how I usually deal with this is that I create e.g.:
>
> __vm_insert_mixed() that takes the bool argument, make vm_insert_mixed()
> pass false, and vm_insert_mixed_mkwrite() pass true. That way there's no
> code duplication, old call sites can stay unchanged, the naming clearly
> says what's going on...
Ah, that does seem cleaner. I'll try that for v5.
--
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>
next prev parent reply other threads:[~2017-07-24 15:13 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-21 22:39 [PATCH v4 0/5] DAX common 4k zero page Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
[not found] ` <20170721223956.29485-1-ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-21 22:39 ` [PATCH v4 1/5] mm: add mkwrite param to vm_insert_mixed() Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-22 16:21 ` Dan Williams
2017-07-22 16:21 ` Dan Williams
2017-07-22 16:21 ` Dan Williams
2017-07-22 16:21 ` Dan Williams
2017-07-22 16:21 ` Dan Williams
2017-07-22 16:21 ` Dan Williams
2017-07-24 11:15 ` Jan Kara
2017-07-24 11:15 ` Jan Kara
2017-07-24 11:15 ` Jan Kara
2017-07-24 11:15 ` Jan Kara
2017-07-24 11:15 ` Jan Kara
2017-07-24 11:15 ` Jan Kara
[not found] ` <20170724111531.GG652-4I4JzKEfoa/jFM9bn6wA6Q@public.gmane.org>
2017-07-24 15:13 ` Ross Zwisler [this message]
2017-07-24 15:13 ` Ross Zwisler
2017-07-24 15:13 ` Ross Zwisler
2017-07-24 15:13 ` Ross Zwisler
2017-07-24 15:13 ` Ross Zwisler
2017-07-24 15:13 ` Ross Zwisler
2017-07-24 11:25 ` Jan Kara
2017-07-24 11:25 ` Jan Kara
2017-07-24 11:25 ` Jan Kara
2017-07-24 11:25 ` Jan Kara
2017-07-24 15:23 ` Ross Zwisler
2017-07-24 15:23 ` Ross Zwisler
2017-07-24 15:23 ` Ross Zwisler
2017-07-24 15:23 ` Ross Zwisler
2017-07-24 15:23 ` Ross Zwisler
2017-07-24 15:23 ` Ross Zwisler
[not found] ` <20170724152357.GB1639-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-24 15:59 ` Jan Kara
2017-07-24 15:59 ` Jan Kara
2017-07-24 15:59 ` Jan Kara
2017-07-24 15:59 ` Jan Kara
2017-07-24 15:59 ` Jan Kara
2017-07-21 22:39 ` [PATCH v4 2/5] dax: relocate some dax functions Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
[not found] ` <20170721223956.29485-3-ross.zwisler-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-07-24 11:35 ` Jan Kara
2017-07-24 11:35 ` Jan Kara
2017-07-24 11:35 ` Jan Kara
2017-07-24 11:35 ` Jan Kara
2017-07-21 22:39 ` [PATCH v4 3/5] dax: use common 4k zero page for dax mmap reads Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-24 11:46 ` Jan Kara
2017-07-24 11:46 ` Jan Kara
2017-07-24 11:46 ` Jan Kara
2017-07-24 11:46 ` Jan Kara
2017-07-24 11:46 ` Jan Kara
2017-07-21 22:39 ` [PATCH v4 4/5] dax: remove DAX code from page_cache_tree_insert() Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-24 11:47 ` Jan Kara
2017-07-24 11:47 ` Jan Kara
2017-07-24 11:47 ` Jan Kara
2017-07-24 11:47 ` Jan Kara
2017-07-24 11:47 ` Jan Kara
2017-07-21 22:39 ` [PATCH v4 5/5] dax: move all DAX radix tree defs to fs/dax.c Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-21 22:39 ` Ross Zwisler
2017-07-24 11:48 ` Jan Kara
2017-07-24 11:48 ` Jan Kara
2017-07-24 11:48 ` Jan Kara
2017-07-24 11:48 ` Jan Kara
2017-07-24 11:48 ` 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=20170724151303.GA1639@linux.intel.com \
--to=ross.zwisler-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=adilger.kernel-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org \
--cc=airlied-cv59FeDIM0c@public.gmane.org \
--cc=corbet-T1hC0tSOHrs@public.gmane.org \
--cc=darrick.wong-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=jack-AlSwsSmVLrQ@public.gmane.org \
--cc=jy0922.shim-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
--cc=krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWNGWvitb5QawA@public.gmane.org \
--cc=linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org \
--cc=linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org \
--cc=linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=patrik.r.jakobsson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org \
--cc=tomi.valkeinen-l0cyMroinI0@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/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.