From: Matthew Wilcox <willy@linux.intel.com>
To: Toshi Kani <toshi.kani@hpe.com>
Cc: jack@suse.cz, linux-nvdimm@lists.01.org,
linux-kernel@vger.kernel.org, xfs@oss.sgi.com,
adilger.kernel@dilger.ca, kirill.shutemov@linux.intel.com,
linux-fsdevel@vger.kernel.org, tytso@mit.edu,
akpm@linux-foundation.org, linux-ext4@vger.kernel.org,
ross.zwisler@linux.intel.com, dan.j.williams@intel.com,
viro@zeniv.linux.org.uk
Subject: Re: [PATCH v2 1/5] dax: add dax_get_unmapped_area for pmd mappings
Date: Tue, 12 Apr 2016 23:18:01 -0400 [thread overview]
Message-ID: <20160413031801.GO2781@linux.intel.com> (raw)
In-Reply-To: <1460493555-31611-2-git-send-email-toshi.kani@hpe.com>
On Tue, Apr 12, 2016 at 02:39:15PM -0600, Toshi Kani wrote:
> + * When the target file is not a DAX file, @addr is specified, the
> + * request is not suitable for pmd mappings, or mm->get_unmapped_area()
> + * failed with extended @len, it simply calls the default handler,
> + * mm->get_unmapped_area(), with the original arguments.
I think you can lose this paragraph. It describes what the function
does, not why it does it ... and we can see what the function does from
reading the code.
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
> + return addr_pmd;
> + }
> + }
> + }
> +
> + return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
> +}
I think this is one of those functions which is actually improved with
gotos, purely to reduce the indentation level.
unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
if (!IS_ENABLED(CONFIG_FS_DAX_PMD) ||
!filp || addr || !IS_DAX(filp->f_mapping->host))
goto out;
off = pgoff << PAGE_SHIFT;
off_end = off + len;
off_pmd = round_up(off, PMD_SIZE);
if ((off_end <= off_pmd) || ((off_end - off_pmd) < PMD_SIZE))
goto out;
len_pmd = len + PMD_SIZE;
addr_pmd = current->mm->get_unmapped_area(filp, addr, len_pmd,
pgoff, flags);
if (!IS_ERR_VALUE(addr_pmd)) {
addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
return addr_pmd;
}
out:
return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
}
Now ... back to the original version, some questions:
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
Can off + len wrap here, or did that get checked earlier?
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
We're only going to look for a PMD-aligned mapping if the mapping is at
least double PMD_SIZE? I don't understand that decision. Seems to me
that if I ask to map offset 4MB, length 2MB, I should get a PMD-aligned
mapping.
Speaking of offset, we don't have any checks that offset is a multiple
of PMD_SIZE. I know that theoretically we could map offset 1.5MB, length
3MB and see the first 0.5MB filled with small pages, then the next 2MB
filled with one large page, and the tail filled with small pages, but I
think we're better off only looking for PMD-alignment if the user asked
for an aligned offset in the file.
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
... then you wouldn't need this calculation ;-)
> + return addr_pmd;
> + }
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
WARNING: multiple messages have this Message-ID (diff)
From: Matthew Wilcox <willy@linux.intel.com>
To: Toshi Kani <toshi.kani@hpe.com>
Cc: jack@suse.cz, linux-nvdimm@lists.01.org, david@fromorbit.com,
linux-kernel@vger.kernel.org, xfs@oss.sgi.com,
adilger.kernel@dilger.ca, kirill.shutemov@linux.intel.com,
linux-fsdevel@vger.kernel.org, tytso@mit.edu,
akpm@linux-foundation.org, linux-ext4@vger.kernel.org,
viro@zeniv.linux.org.uk
Subject: Re: [PATCH v2 1/5] dax: add dax_get_unmapped_area for pmd mappings
Date: Tue, 12 Apr 2016 23:18:01 -0400 [thread overview]
Message-ID: <20160413031801.GO2781@linux.intel.com> (raw)
In-Reply-To: <1460493555-31611-2-git-send-email-toshi.kani@hpe.com>
On Tue, Apr 12, 2016 at 02:39:15PM -0600, Toshi Kani wrote:
> + * When the target file is not a DAX file, @addr is specified, the
> + * request is not suitable for pmd mappings, or mm->get_unmapped_area()
> + * failed with extended @len, it simply calls the default handler,
> + * mm->get_unmapped_area(), with the original arguments.
I think you can lose this paragraph. It describes what the function
does, not why it does it ... and we can see what the function does from
reading the code.
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
> + return addr_pmd;
> + }
> + }
> + }
> +
> + return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
> +}
I think this is one of those functions which is actually improved with
gotos, purely to reduce the indentation level.
unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
if (!IS_ENABLED(CONFIG_FS_DAX_PMD) ||
!filp || addr || !IS_DAX(filp->f_mapping->host))
goto out;
off = pgoff << PAGE_SHIFT;
off_end = off + len;
off_pmd = round_up(off, PMD_SIZE);
if ((off_end <= off_pmd) || ((off_end - off_pmd) < PMD_SIZE))
goto out;
len_pmd = len + PMD_SIZE;
addr_pmd = current->mm->get_unmapped_area(filp, addr, len_pmd,
pgoff, flags);
if (!IS_ERR_VALUE(addr_pmd)) {
addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
return addr_pmd;
}
out:
return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
}
Now ... back to the original version, some questions:
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
Can off + len wrap here, or did that get checked earlier?
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
We're only going to look for a PMD-aligned mapping if the mapping is at
least double PMD_SIZE? I don't understand that decision. Seems to me
that if I ask to map offset 4MB, length 2MB, I should get a PMD-aligned
mapping.
Speaking of offset, we don't have any checks that offset is a multiple
of PMD_SIZE. I know that theoretically we could map offset 1.5MB, length
3MB and see the first 0.5MB filled with small pages, then the next 2MB
filled with one large page, and the tail filled with small pages, but I
think we're better off only looking for PMD-alignment if the user asked
for an aligned offset in the file.
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
... then you wouldn't need this calculation ;-)
> + return addr_pmd;
> + }
_______________________________________________
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: Matthew Wilcox <willy@linux.intel.com>
To: Toshi Kani <toshi.kani@hpe.com>
Cc: akpm@linux-foundation.org, dan.j.williams@intel.com,
viro@zeniv.linux.org.uk, ross.zwisler@linux.intel.com,
kirill.shutemov@linux.intel.com, david@fromorbit.com,
jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca,
linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org,
linux-ext4@vger.kernel.org, xfs@oss.sgi.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/5] dax: add dax_get_unmapped_area for pmd mappings
Date: Tue, 12 Apr 2016 23:18:01 -0400 [thread overview]
Message-ID: <20160413031801.GO2781@linux.intel.com> (raw)
In-Reply-To: <1460493555-31611-2-git-send-email-toshi.kani@hpe.com>
On Tue, Apr 12, 2016 at 02:39:15PM -0600, Toshi Kani wrote:
> + * When the target file is not a DAX file, @addr is specified, the
> + * request is not suitable for pmd mappings, or mm->get_unmapped_area()
> + * failed with extended @len, it simply calls the default handler,
> + * mm->get_unmapped_area(), with the original arguments.
I think you can lose this paragraph. It describes what the function
does, not why it does it ... and we can see what the function does from
reading the code.
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
> + return addr_pmd;
> + }
> + }
> + }
> +
> + return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
> +}
I think this is one of those functions which is actually improved with
gotos, purely to reduce the indentation level.
unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
if (!IS_ENABLED(CONFIG_FS_DAX_PMD) ||
!filp || addr || !IS_DAX(filp->f_mapping->host))
goto out;
off = pgoff << PAGE_SHIFT;
off_end = off + len;
off_pmd = round_up(off, PMD_SIZE);
if ((off_end <= off_pmd) || ((off_end - off_pmd) < PMD_SIZE))
goto out;
len_pmd = len + PMD_SIZE;
addr_pmd = current->mm->get_unmapped_area(filp, addr, len_pmd,
pgoff, flags);
if (!IS_ERR_VALUE(addr_pmd)) {
addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
return addr_pmd;
}
out:
return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
}
Now ... back to the original version, some questions:
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
Can off + len wrap here, or did that get checked earlier?
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
We're only going to look for a PMD-aligned mapping if the mapping is at
least double PMD_SIZE? I don't understand that decision. Seems to me
that if I ask to map offset 4MB, length 2MB, I should get a PMD-aligned
mapping.
Speaking of offset, we don't have any checks that offset is a multiple
of PMD_SIZE. I know that theoretically we could map offset 1.5MB, length
3MB and see the first 0.5MB filled with small pages, then the next 2MB
filled with one large page, and the tail filled with small pages, but I
think we're better off only looking for PMD-alignment if the user asked
for an aligned offset in the file.
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
... then you wouldn't need this calculation ;-)
> + return addr_pmd;
> + }
WARNING: multiple messages have this Message-ID (diff)
From: Matthew Wilcox <willy@linux.intel.com>
To: Toshi Kani <toshi.kani@hpe.com>
Cc: akpm@linux-foundation.org, dan.j.williams@intel.com,
viro@zeniv.linux.org.uk, ross.zwisler@linux.intel.com,
kirill.shutemov@linux.intel.com, david@fromorbit.com,
jack@suse.cz, tytso@mit.edu, adilger.kernel@dilger.ca,
linux-nvdimm@ml01.01.org, linux-fsdevel@vger.kernel.org,
linux-ext4@vger.kernel.org, xfs@oss.sgi.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/5] dax: add dax_get_unmapped_area for pmd mappings
Date: Tue, 12 Apr 2016 23:18:01 -0400 [thread overview]
Message-ID: <20160413031801.GO2781@linux.intel.com> (raw)
In-Reply-To: <1460493555-31611-2-git-send-email-toshi.kani@hpe.com>
On Tue, Apr 12, 2016 at 02:39:15PM -0600, Toshi Kani wrote:
> + * When the target file is not a DAX file, @addr is specified, the
> + * request is not suitable for pmd mappings, or mm->get_unmapped_area()
> + * failed with extended @len, it simply calls the default handler,
> + * mm->get_unmapped_area(), with the original arguments.
I think you can lose this paragraph. It describes what the function
does, not why it does it ... and we can see what the function does from
reading the code.
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
> + return addr_pmd;
> + }
> + }
> + }
> +
> + return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
> +}
I think this is one of those functions which is actually improved with
gotos, purely to reduce the indentation level.
unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
unsigned long len, unsigned long pgoff, unsigned long flags)
{
unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
if (!IS_ENABLED(CONFIG_FS_DAX_PMD) ||
!filp || addr || !IS_DAX(filp->f_mapping->host))
goto out;
off = pgoff << PAGE_SHIFT;
off_end = off + len;
off_pmd = round_up(off, PMD_SIZE);
if ((off_end <= off_pmd) || ((off_end - off_pmd) < PMD_SIZE))
goto out;
len_pmd = len + PMD_SIZE;
addr_pmd = current->mm->get_unmapped_area(filp, addr, len_pmd,
pgoff, flags);
if (!IS_ERR_VALUE(addr_pmd)) {
addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
return addr_pmd;
}
out:
return current->mm->get_unmapped_area(filp, addr, len, pgoff, flags);
}
Now ... back to the original version, some questions:
> +unsigned long dax_get_unmapped_area(struct file *filp, unsigned long addr,
> + unsigned long len, unsigned long pgoff, unsigned long flags)
> +{
> + unsigned long off, off_end, off_pmd, len_pmd, addr_pmd;
> +
> + if (IS_ENABLED(CONFIG_FS_DAX_PMD) &&
> + filp && !addr && IS_DAX(filp->f_mapping->host)) {
> + off = pgoff << PAGE_SHIFT;
> + off_end = off + len;
Can off + len wrap here, or did that get checked earlier?
> + off_pmd = round_up(off, PMD_SIZE);
> +
> + if ((off_end > off_pmd) && ((off_end - off_pmd) >= PMD_SIZE)) {
We're only going to look for a PMD-aligned mapping if the mapping is at
least double PMD_SIZE? I don't understand that decision. Seems to me
that if I ask to map offset 4MB, length 2MB, I should get a PMD-aligned
mapping.
Speaking of offset, we don't have any checks that offset is a multiple
of PMD_SIZE. I know that theoretically we could map offset 1.5MB, length
3MB and see the first 0.5MB filled with small pages, then the next 2MB
filled with one large page, and the tail filled with small pages, but I
think we're better off only looking for PMD-alignment if the user asked
for an aligned offset in the file.
> + len_pmd = len + PMD_SIZE;
> +
> + addr_pmd = current->mm->get_unmapped_area(
> + filp, addr, len_pmd, pgoff, flags);
> +
> + if (!IS_ERR_VALUE(addr_pmd)) {
> + addr_pmd += (off - addr_pmd) & (PMD_SIZE - 1);
... then you wouldn't need this calculation ;-)
> + return addr_pmd;
> + }
next prev parent reply other threads:[~2016-04-13 3:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-12 20:39 [PATCH v2 0/5] Align mmap address for DAX pmd mappings Toshi Kani
2016-04-12 20:39 ` Toshi Kani
2016-04-12 20:39 ` Toshi Kani
2016-04-12 20:39 ` Toshi Kani
2016-04-12 20:39 ` [PATCH v2 1/5] dax: add dax_get_unmapped_area for " Toshi Kani
2016-04-12 20:39 ` Toshi Kani
2016-04-12 20:39 ` Toshi Kani
2016-04-12 20:39 ` Toshi Kani
2016-04-13 3:18 ` Matthew Wilcox [this message]
2016-04-13 3:18 ` Matthew Wilcox
2016-04-13 3:18 ` Matthew Wilcox
2016-04-13 3:18 ` Matthew Wilcox
2016-04-13 14:55 ` Toshi Kani
2016-04-13 14:55 ` Toshi Kani
2016-04-13 14:55 ` Toshi Kani
2016-04-13 14:55 ` Toshi Kani
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=20160413031801.GO2781@linux.intel.com \
--to=willy@linux.intel.com \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=jack@suse.cz \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=ross.zwisler@linux.intel.com \
--cc=toshi.kani@hpe.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=xfs@oss.sgi.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.