linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Honggyu Kim <honggyu.kim@sk.com>
To: SeongJae Park <sj@kernel.org>
Cc: kernel_team@skhynix.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	damon@lists.linux.dev, io-uring@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com
Subject: Re: [RFC PATCH] mm/madvise: remove redundant mmap_lock operations from process_madvise()
Date: Wed, 15 Jan 2025 16:15:34 +0900	[thread overview]
Message-ID: <c210f152-5eb7-456a-8cd3-ec75e1a5b266@sk.com> (raw)
In-Reply-To: <20250115061910.58938-1-sj@kernel.org>

Hi SeongJae,

I'm resending this because my new mail client mistakenly set the mail
format to HTML. Sorry for the noise.

On 1/15/2025 3:19 PM, SeongJae Park wrote:
> Hi Honggyu,
> 
> On Wed, 15 Jan 2025 13:35:48 +0900 Honggyu Kim <honggyu.kim@sk.com> 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

Right. I didn't carefully read his comment. Thanks for the info.

> 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/20250115041750.58164-1-sj@kernel.org

I don't have any other concern.

Thanks,
Honggyu

> Thanks,
> SJ
> 
> [...]



      parent reply	other threads:[~2025-01-15  7:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-11  0:46 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
2025-01-15  6:41     ` Honggyu Kim
2025-01-15  7:15     ` Honggyu Kim [this message]

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=c210f152-5eb7-456a-8cd3-ec75e1a5b266@sk.com \
    --to=honggyu.kim@sk.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=damon@lists.linux.dev \
    --cc=io-uring@vger.kernel.org \
    --cc=kernel_team@skhynix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=sj@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox