From: SeongJae Park <[email protected]>
To: Honggyu Kim <[email protected]>
Cc: SeongJae Park <[email protected]>,
[email protected],
Andrew Morton <[email protected]>,
Jens Axboe <[email protected]>,
Pavel Begunkov <[email protected]>,
[email protected], [email protected],
[email protected], [email protected],
[email protected]
Subject: Re: [RFC PATCH] mm/madvise: remove redundant mmap_lock operations from process_madvise()
Date: Tue, 14 Jan 2025 22:19:10 -0800 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Hi Honggyu,
On Wed, 15 Jan 2025 13:35:48 +0900 Honggyu Kim <[email protected]> wrote:
> Hi SeongJae,
>
> I have a simple comment on this.
>
> On 1/11/2025 9:46 AM, SeongJae Park wrote:
> > process_madvise() calls do_madvise() for each address range. Then, each
> > do_madvise() invocation holds and releases same mmap_lock. Optimize the
> > redundant lock operations by doing the locking in process_madvise(), and
> > inform do_madvise() that the lock is already held and therefore can be
> > skipped.
[...]
> > ---
> > include/linux/mm.h | 3 ++-
> > io_uring/advise.c | 2 +-
> > mm/damon/vaddr.c | 2 +-
> > mm/madvise.c | 54 +++++++++++++++++++++++++++++++++++-----------
> > 4 files changed, 45 insertions(+), 16 deletions(-)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 612b513ebfbd..e3ca5967ebd4 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -3459,7 +3459,8 @@ int do_vmi_align_munmap(struct vma_iterator *vmi, struct vm_area_struct *vma,
> > unsigned long end, struct list_head *uf, bool unlock);
> > extern int do_munmap(struct mm_struct *, unsigned long, size_t,
> > struct list_head *uf);
> > -extern int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behavior);
> > +extern int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in,
> > + int behavior, bool lock_held);
> >
> > #ifdef CONFIG_MMU
> > extern int __mm_populate(unsigned long addr, unsigned long len,
> > diff --git a/io_uring/advise.c b/io_uring/advise.c
> > index cb7b881665e5..010b55d5a26e 100644
> > --- a/io_uring/advise.c
> > +++ b/io_uring/advise.c
> > @@ -56,7 +56,7 @@ int io_madvise(struct io_kiocb *req, unsigned int issue_flags)
> >
> > WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK);
> >
> > - ret = do_madvise(current->mm, ma->addr, ma->len, ma->advice);
> > + ret = do_madvise(current->mm, ma->addr, ma->len, ma->advice, false);
>
> I feel like this doesn't look good in terms of readability. Can we
> introduce an enum for this?
I agree that's not good to read. Liam alos pointed out a similar issue but
suggested splitting functions with clear names[1]. I think that also fairly
improves readability, and I slightly prefer that way, since it wouldn't
introduce a new type for only a single use case. Would that also work for your
concern, or do you have a different opinion?
[1] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]
next prev parent reply other threads:[~2025-01-15 6:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-11 0:46 [RFC PATCH] mm/madvise: remove redundant mmap_lock operations from process_madvise() SeongJae Park
2025-01-14 18:13 ` Shakeel Butt
2025-01-14 18:47 ` Lorenzo Stoakes
2025-01-14 19:54 ` SeongJae Park
2025-01-14 21:55 ` Shakeel Butt
2025-01-15 3:44 ` Liam R. Howlett
2025-01-15 4:17 ` SeongJae Park
2025-01-15 4:35 ` Honggyu Kim
2025-01-15 6:19 ` SeongJae Park [this message]
2025-01-15 7:15 ` Honggyu Kim
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox