From: Matthew Wilcox <willy@infradead.org>
To: Kundan Kumar <kundan.kumar@samsung.com>
Cc: axboe@kernel.dk, hch@lst.de, linux-block@vger.kernel.org,
joshi.k@samsung.com, mcgrof@kernel.org, anuj20.g@samsung.com,
nj.shetty@samsung.com, c.gameti@samsung.com,
gost.dev@samsung.com
Subject: Re: [PATCH v3 2/3] block: add folio awareness instead of looping through pages
Date: Fri, 24 May 2024 16:40:20 +0100 [thread overview]
Message-ID: <ZlC05KHAB7tswaQV@casper.infradead.org> (raw)
In-Reply-To: <20240524092231.pijr74qryxo5fazk@green245>
On Fri, May 24, 2024 at 02:52:31PM +0530, Kundan Kumar wrote:
> On 15/05/24 09:55PM, Matthew Wilcox wrote:
> > On Tue, May 07, 2024 at 08:15:08PM +0530, Kundan Kumar wrote:
> > > Add a bigger size from folio to bio and skip processing for pages.
> > >
> > > Fetch the offset of page within a folio. Depending on the size of folio
> > > and folio_offset, fetch a larger length. This length may consist of
> > > multiple contiguous pages if folio is multiorder.
> >
> > The problem is that it may not. Here's the scenario:
> >
> > int fd, fd2;
> > fd = open(src, O_RDONLY);
> > char *addr = mmap(NULL, 1024 * 1024, PROT_READ | PROT_WRITE,
> > MAP_PRIVATE | MAP_HUGETLB, fd, 0);
>
> I also added MAP_ANONYMOUS flag here, otherwise mmap fails.
I didn't test this code, but MAP_ANONYMOUS is wrong. I'm trying to get
a file mapping here, not an anoymous mapping.
The intent is to hit the
if (vm_flags & VM_HUGEPAGE) {
case in do_sync_mmap_readahead().
Ah, I see.
ksys_mmap_pgoff:
if (!(flags & MAP_ANONYMOUS)) {
...
if (is_file_hugepages(file)) {
len = ALIGN(len, huge_page_size(hstate_file(file)));
} else if (unlikely(flags & MAP_HUGETLB)) {
retval = -EINVAL;
goto out_fput;
}
Maybe we need something like this:
diff --git a/mm/mmap.c b/mm/mmap.c
index 83b4682ec85c..7c5066a8a3ac 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1307,6 +1307,8 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
flags_mask = LEGACY_MAP_MASK;
if (file->f_op->fop_flags & FOP_MMAP_SYNC)
flags_mask |= MAP_SYNC;
+ if (flags & MAP_HUGETLB)
+ vm_flags |= VM_HUGEPAGE;
switch (flags & MAP_TYPE) {
case MAP_SHARED:
@@ -1414,12 +1416,8 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
file = fget(fd);
if (!file)
return -EBADF;
- if (is_file_hugepages(file)) {
+ if (is_file_hugepages(file))
len = ALIGN(len, huge_page_size(hstate_file(file)));
- } else if (unlikely(flags & MAP_HUGETLB)) {
- retval = -EINVAL;
- goto out_fput;
- }
} else if (flags & MAP_HUGETLB) {
struct hstate *hs;
@@ -1441,7 +1439,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
}
retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff);
-out_fput:
if (file)
fput(file);
return retval;
(compile tested only)
next prev parent reply other threads:[~2024-05-24 15:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240507145232epcas5p481986099a82b1880758b7770cdeaf2d2@epcas5p4.samsung.com>
2024-05-07 14:45 ` [PATCH v3 0/3] block: add larger order folio instead of pages Kundan Kumar
2024-05-07 14:45 ` [PATCH v3 1/3] nvme: adjust multiples of NVME_CTRL_PAGE_SIZE in offset Kundan Kumar
2024-05-23 8:51 ` Christoph Hellwig
2024-05-23 10:07 ` Kundan Kumar
2024-05-07 14:45 ` [PATCH v3 2/3] block: add folio awareness instead of looping through pages Kundan Kumar
2024-05-15 20:55 ` Matthew Wilcox
2024-05-24 9:22 ` Kundan Kumar
2024-05-24 15:40 ` Matthew Wilcox [this message]
2024-05-07 14:45 ` [PATCH v3 3/3] block: unpin user pages belonging to a folio Kundan Kumar
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=ZlC05KHAB7tswaQV@casper.infradead.org \
--to=willy@infradead.org \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=c.gameti@samsung.com \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=joshi.k@samsung.com \
--cc=kundan.kumar@samsung.com \
--cc=linux-block@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=nj.shetty@samsung.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.