mm/madvise: remove redundant mmap_lock operations from process_madvise()
Subsystems (2)
v2 cover mm/madvise: remove redundant mmap_lock operations from process_madvise()
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 splitting do_madvise() internal logics including the mmap_lock operations, and calling the small logics directly from process_madvise() in a sequence that removes the redundant locking.
Changes from RFC v1 ([email protected])
- Split out do_madvise() and use those from vector_madvise(), instead of adding a flag to do_madvise() (Liam R. Howlett)
SeongJae Park (4):
mm/madvise: split out mmap locking operations for madvise() mm/madvise: split out madvise input validity check mm/madvise: split out madvise() behavior execution mm/madvise: remove redundant mmap_lock operations from
process_madvise()
mm/madvise.c | 150 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 47 deletions(-)
base-commit: b43ba6938d01ad4487028592109d4116a28b7afa
Signature · 1 line
2.39.5
RFC PATCH v2 1/4 mm/madvise: split out mmap locking operations for madvise()
Split out the madvise behavior-dependent mmap_lock operations from do_madvise(), for easier reuse of the logic in an upcoming change.
--- mm/madvise.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-)
mm/madvise.c +32 -13
@@ -1565,6 +1565,33 @@ int madvise_set_anon_name(struct mm_struct *mm, unsigned long start, madvise_vma_anon_name); }#endif /* CONFIG_ANON_VMA_NAME */ + +static int madvise_lock (struct mm_struct *mm,int behavior) +{ + +#ifdef CONFIG_MEMORY_FAILURE +if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE ) +return 0 ; +#endif + +if (madvise_need_mmap_write (behavior)) { +if (mmap_write_lock_killable (mm)) +return -EINTR ; + }else { +mmap_read_lock (mm); + } +return 0 ; + +} + +static void madvise_unlock (struct mm_struct *mm,int behavior) +{ +if (madvise_need_mmap_write (behavior)) +mmap_write_unlock (mm); +else +mmap_read_unlock (mm); +} +/* * The madvise(2) system call. *
@@ -1641,7 +1668,6 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh {unsigned long end;int error; -int write;size_t len;struct blk_plug plug;
@@ -1663,19 +1689,15 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behif (end == start)return 0 ; + error =madvise_lock (mm, behavior); +if (error) +return error; +#ifdef CONFIG_MEMORY_FAILURE if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE )return madvise_inject_error (behavior, start, start + len_in);#endif - write =madvise_need_mmap_write (behavior); -if (write) { -if (mmap_write_lock_killable (mm)) -return -EINTR ; - }else { -mmap_read_lock (mm); - } - start =untagged_addr_remote (mm, start); end = start + len;
@@ -1692,10 +1714,7 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh }blk_finish_plug (&plug); -if (write) -mmap_write_unlock (mm); -else -mmap_read_unlock (mm); +madvise_unlock (mm, behavior);return error; }
Signature · 1 line
2.39.5
Re: [RFC PATCH v2 1/4] mm/madvise: split out mmap locking operations for madvise()
Quoted 4 lines · SeongJae Park
Split out the madvise behavior-dependent
mmap_lockoperations fromdo_madvise(), for easier reuse of the logic in an upcoming change.Signed-off-by SeongJae Park <[email protected]>
Re: [RFC PATCH v2 1/4] mm/madvise: split out mmap locking operations for madvise()
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Split out the madvise behavior-dependent
mmap_lockoperations fromdo_madvise(), for easier reuse of the logic in an upcoming change.Signed-off-by SeongJae Park <[email protected]>
Looks good to me, a decent cleanup regardless of application.
Quoted 88 lines
--- mm/madvise.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-)mm/madvise.c +32
-14@@ -1565,6 +1565,33 @@ int madvise_set_anon_name(struct mm_struct *mm, unsigned long start, madvise_vma_anon_name); }#endif /* CONFIG_ANON_VMA_NAME */ + +static int madvise_lock (struct mm_struct *mm,int behavior) +{ + +#ifdef CONFIG_MEMORY_FAILURE +if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE ) +return 0 ; +#endif + +if (madvise_need_mmap_write (behavior)) { +if (mmap_write_lock_killable (mm)) +return -EINTR ; + }else { +mmap_read_lock (mm); + } +return 0 ; + +} + +static void madvise_unlock (struct mm_struct *mm,int behavior) +{ +if (madvise_need_mmap_write (behavior)) +mmap_write_unlock (mm); +else +mmap_read_unlock (mm); +} +/* * The madvise(2) system call. * @@ -1641,7 +1668,6 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh {unsigned long end;int error; -int write;size_t len;struct blk_plug plug;@@ -1663,19 +1689,15 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behif (end == start)return 0 ; + error =madvise_lock (mm, behavior); +if (error) +return error; +#ifdef CONFIG_MEMORY_FAILURE if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE )return madvise_inject_error (behavior, start, start + len_in);#endif - write =madvise_need_mmap_write (behavior); -if (write) { -if (mmap_write_lock_killable (mm)) -return -EINTR ; - }else { -mmap_read_lock (mm); - } - start =untagged_addr_remote (mm, start); end = start + len;@@ -1692,10 +1714,7 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh }blk_finish_plug (&plug); -if (write) -mmap_write_unlock (mm); -else -mmap_read_unlock (mm); +madvise_unlock (mm, behavior);return error; } --2.39.5
Re: [RFC PATCH v2 1/4] mm/madvise: split out mmap locking operations for madvise()
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Split out the madvise behavior-dependent
mmap_lockoperations fromdo_madvise(), for easier reuse of the logic in an upcoming change.Signed-off-by SeongJae Park <[email protected]>
RFC PATCH v2 2/4 mm/madvise: split out madvise input validity check
In reply to SeongJae ParkSplit out the madvise parameters validation logic from do_madvise(), for easy reuse of the logic from a future change.
--- mm/madvise.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
mm/madvise.c +22 -10
@@ -1592,6 +1592,27 @@ static void madvise_unlock(struct mm_struct *mm, int behavior)mmap_read_unlock (mm); } +static bool is_valid_madvise (unsigned long start,size_t len_in,int behavior) +{ +size_t len; + +if (!madvise_behavior_valid (behavior)) +return false; + +if (!PAGE_ALIGNED (start)) +return false; + len =PAGE_ALIGN (len_in); + +/* Check to see whether len was rounded up from small -ve to zero */ +if (len_in && !len) +return false; + +if (start + len < start) +return false; + +return true; +} +/* * The madvise(2) system call. *
@@ -1671,20 +1692,11 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behsize_t len;struct blk_plug plug; -if (!madvise_behavior_valid (behavior)) +if (!is_valid_madvise (start, len_in, behavior))return -EINVAL ; -if (!PAGE_ALIGNED (start)) -return -EINVAL ; len =PAGE_ALIGN (len_in); - -/* Check to see whether len was rounded up from small -ve to zero */ -if (len_in && !len) -return -EINVAL ; - end = start + len; -if (end < start) -return -EINVAL ;if (end == start)return 0 ;
Signature · 1 line
2.39.5
Re: [RFC PATCH v2 2/4] mm/madvise: split out madvise input validity check
Quoted 4 lines · SeongJae Park
Split out the madvise parameters validation logic from
do_madvise(), for easy reuse of the logic from a future change.Signed-off-by SeongJae Park <[email protected]>
Re: [RFC PATCH v2 2/4] mm/madvise: split out madvise input validity check
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Split out the madvise parameters validation logic from
do_madvise(), for easy reuse of the logic from a future change.Signed-off-by SeongJae Park <[email protected]>
Another decent cleanup, regardless of appllication, so:
Quoted 12 lines
--- mm/madvise.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)mm/madvise.c +0
-0@@ -1592,6 +1592,27 @@ static void madvise_unlock(struct mm_struct *mm, int behavior)mmap_read_unlock (mm); }
mm/madvise.c static void madvise_unlock(struct mm_struct *mm, int behavior) · line 1604
Quoted 10 lines
mm/madvise.c +10
-0+static bool is_valid_madvise (unsigned long start,size_t len_in,int behavior) +{ +size_t len; + +if (!madvise_behavior_valid (behavior)) +return false; + +if (!PAGE_ALIGNED (start)) +return false; + len =PAGE_ALIGN (len_in);
Kind of a pity to duplicate this, but not exactly a big deal.
Quoted 38 lines
mm/madvise.c +12
-11+ +/* Check to see whether len was rounded up from small -ve to zero */ +if (len_in && !len) +return false; + +if (start + len < start) +return false; + +return true; +} +/* * The madvise(2) system call. * @@ -1671,20 +1692,11 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behsize_t len;struct blk_plug plug; -if (!madvise_behavior_valid (behavior)) +if (!is_valid_madvise (start, len_in, behavior))return -EINVAL ; -if (!PAGE_ALIGNED (start)) -return -EINVAL ; len =PAGE_ALIGN (len_in); - -/* Check to see whether len was rounded up from small -ve to zero */ -if (len_in && !len) -return -EINVAL ; - end = start + len; -if (end < start) -return -EINVAL ;if (end == start)return 0 ; --2.39.5
Re: [RFC PATCH v2 2/4] mm/madvise: split out madvise input validity check
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Split out the madvise parameters validation logic from
do_madvise(), for easy reuse of the logic from a future change.Signed-off-by SeongJae Park <[email protected]>
RFC PATCH v2 3/4 mm/madvise: split out madvise() behavior execution
In reply to SeongJae ParkSplit out the madvise behavior applying logic from do_madvise() to make it easier to reuse from the following change.
--- mm/madvise.c | 53 +++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-)
mm/madvise.c +30 -23
@@ -1613,6 +1613,35 @@ static bool is_valid_madvise(unsigned long start, size_t len_in, int behavior)return true; } +static int madvise_do_behavior (struct mm_struct *mm, +unsigned long start,size_t len_in,size_t len,int behavior) +{ +struct blk_plug plug; +unsigned long end; +int error; + +#ifdef CONFIG_MEMORY_FAILURE +if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE ) +return madvise_inject_error (behavior, start, start + len_in); +#endif + start =untagged_addr_remote (mm, start); + end = start + len; + +blk_start_plug (&plug); +switch (behavior) { +case MADV_POPULATE_READ : +case MADV_POPULATE_WRITE : + error =madvise_populate (mm, start, end, behavior); +break ; +default : + error =madvise_walk_vmas (mm, start, end, behavior, + madvise_vma_behavior); +break ; + } +blk_finish_plug (&plug); +return error; +} +/* * The madvise(2) system call. *
@@ -1690,7 +1719,6 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behunsigned long end;int error;size_t len; -struct blk_plug plug;if (!is_valid_madvise (start, len_in, behavior))return -EINVAL ;
@@ -1704,28 +1732,7 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh error =madvise_lock (mm, behavior);if (error)return error; - -#ifdef CONFIG_MEMORY_FAILURE -if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE ) -return madvise_inject_error (behavior, start, start + len_in); -#endif - - start =untagged_addr_remote (mm, start); - end = start + len; - -blk_start_plug (&plug); -switch (behavior) { -case MADV_POPULATE_READ : -case MADV_POPULATE_WRITE : - error =madvise_populate (mm, start, end, behavior); -break ; -default : - error =madvise_walk_vmas (mm, start, end, behavior, - madvise_vma_behavior); -break ; - } -blk_finish_plug (&plug); - + error =madvise_do_behavior (mm, start, len_in, len, behavior);madvise_unlock (mm, behavior);return error;
Signature · 1 line
2.39.5
Re: [RFC PATCH v2 3/4] mm/madvise: split out madvise() behavior execution
Quoted 4 lines · SeongJae Park
Split out the madvise behavior applying logic from
do_madvise()to make it easier to reuse from the following change.Signed-off-by SeongJae Park <[email protected]>
Re: [RFC PATCH v2 3/4] mm/madvise: split out madvise() behavior execution
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Split out the madvise behavior applying logic from
do_madvise()to make it easier to reuse from the following change.Signed-off-by SeongJae Park <[email protected]>
Thanks, once again this is a nice cleanup, and you're doing stuff I thought of doing but never got round to :P so inevitably:
Quoted 18 lines
--- mm/madvise.c | 53 +++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-)mm/madvise.c +6
-0@@ -1613,6 +1613,35 @@ static bool is_valid_madvise(unsigned long start, size_t len_in, int behavior)return true; } +static int madvise_do_behavior (struct mm_struct *mm, +unsigned long start,size_t len_in,size_t len,int behavior) +{ +struct blk_plug plug; +unsigned long end; +int error;
mm/madvise.c static bool is_valid_madvise(unsigned long start, size_t len_in, int behavior) · line 1631
Quoted 10 lines
mm/madvise.c +10
-0+ +#ifdef CONFIG_MEMORY_FAILURE +if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE ) +return madvise_inject_error (behavior, start, start + len_in); +#endif + start =untagged_addr_remote (mm, start); + end = start + len; + +blk_start_plug (&plug); +switch (behavior) {
I kind of hate this, I'd like somebody (maybe me maybe you maybe somebody else) to go further and refactor this thing with fire and fumigation, because having multiple layers of how we do stuff is just ugh.
Not your fault.
Not even related to your series.
But a moan I shall commit to list nonetheless! ;)
Quoted 56 lines
mm/madvise.c +14
-24+case MADV_POPULATE_READ : +case MADV_POPULATE_WRITE : + error =madvise_populate (mm, start, end, behavior); +break ; +default : + error =madvise_walk_vmas (mm, start, end, behavior, + madvise_vma_behavior); +break ; + } +blk_finish_plug (&plug); +return error; +} +/* * The madvise(2) system call. * @@ -1690,7 +1719,6 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int behunsigned long end;int error;size_t len; -struct blk_plug plug;if (!is_valid_madvise (start, len_in, behavior))return -EINVAL ;@@ -1704,28 +1732,7 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh error =madvise_lock (mm, behavior);if (error)return error; - -#ifdef CONFIG_MEMORY_FAILURE -if (behavior ==MADV_HWPOISON || behavior ==MADV_SOFT_OFFLINE ) -return madvise_inject_error (behavior, start, start + len_in); -#endif - - start =untagged_addr_remote (mm, start); - end = start + len; - -blk_start_plug (&plug); -switch (behavior) { -case MADV_POPULATE_READ : -case MADV_POPULATE_WRITE : - error =madvise_populate (mm, start, end, behavior); -break ; -default : - error =madvise_walk_vmas (mm, start, end, behavior, - madvise_vma_behavior); -break ; - } -blk_finish_plug (&plug); - + error =madvise_do_behavior (mm, start, len_in, len, behavior);madvise_unlock (mm, behavior);return error; --2.39.5
RFC PATCH v2 4/4 mm/madvise: remove redundant mmap_lock operations from process_madvise()
In reply to SeongJae ParkOptimize redundant mmap lock operations from process_madvise() by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.
--- mm/madvise.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
mm/madvise.c +20 -2
@@ -1752,9 +1752,26 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter, total_len =iov_iter_count (iter); + ret =madvise_lock (mm, behavior); +if (ret) +return ret; +while (iov_iter_count (iter)) { - ret =do_madvise (mm, (unsigned long )iter_iov_addr (iter), -iter_iov_len (iter), behavior); +unsigned long start = (unsigned long )iter_iov_addr (iter); +size_t len_in =iter_iov_len (iter); +size_t len; + +if (!is_valid_madvise (start, len_in, behavior)) { + ret = -EINVAL ; +break ; + } + + len =PAGE_ALIGN (len_in); +if (start + len == start) + ret =0 ; +else + ret =madvise_do_behavior (mm, start, len_in, len, + behavior);/* * An madvise operation is attempting to restart the syscall, * but we cannot proceed as it would not be correct to repeat
@@ -1776,6 +1793,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,break ;iov_iter_advance (iter,iter_iov_len (iter)); } +madvise_unlock (mm, behavior); ret = (total_len -iov_iter_count (iter)) ? : ret;
Signature · 1 line
2.39.5
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
I've tested this against my PIDFD_SELF changes [0] and the process_madvise() invocation in the guard-pages tests which utilises process_madvise() in a perhaps 'unusual' way so is a good test bed for this, and all working fine.
Amazingly, this appears to be the only place (afaict) where process_madivse() is actually tested...
Buuuut, I think this change is incorrect, I comment on this below. Should be an easy fix though.
[0]:https://lore.kernel.org/all/[email protected]/
Quoted 10 lines
--- mm/madvise.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)mm/madvise.c +0
-0@@ -1752,9 +1752,26 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
mm/madvise.c static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter, · line 1760
Quoted 10 lines
mm/madvise.c +5
-2total_len =iov_iter_count (iter); + ret =madvise_lock (mm, behavior); +if (ret) +return ret; +while (iov_iter_count (iter)) { - ret =do_madvise (mm, (unsigned long )iter_iov_addr (iter), -iter_iov_len (iter), behavior); +unsigned long start = (unsigned long )iter_iov_addr (iter);
This is nicer than just passing in.
mm/madvise.c static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter, · line 1761
Quoted 1 line
mm/madvise.c +1
-0+size_t len_in =iter_iov_len (iter);
Equally so here...
mm/madvise.c static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter, · line 1774
Quoted 13 lines
mm/madvise.c +13
-0+size_t len; + +if (!is_valid_madvise (start, len_in, behavior)) { + ret = -EINVAL ; +break ; + } + + len =PAGE_ALIGN (len_in); +if (start + len == start) + ret =0 ; +else + ret =madvise_do_behavior (mm, start, len_in, len, + behavior);
Very slight duplication here (I wonder if we can somehow wrap the 'if zero length return 0' thing?).
But it doesn't really matter, probably better to spell it out, actually.
mm/madvise.c static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter, · line 1798
Quoted 10 lines
mm/madvise.c +1
-0/* * An madvise operation is attempting to restart the syscall, * but we cannot proceed as it would not be correct to repeat @@ -1776,6 +1793,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,break ;iov_iter_advance (iter,iter_iov_len (iter)); } +madvise_unlock (mm, behavior); ret = (total_len -iov_iter_count (iter)) ? : ret;
So I think this is now wrong because of the work I did recently. In this code:
/*
* An madvise operation is attempting to restart the syscall,
* but we cannot proceed as it would not be correct to repeat
* the operation in aggregate, and would be surprising to the
* user.
*
* As we have already dropped locks, it is safe to just loop and
* try again. We check for fatal signals in case we need exit
* early anyway.
*/
if (ret == -ERESTARTNOINTR) {
if (fatal_signal_pending(current)) {
ret = -EINTR;
break;
}
continue;
}Note that it assumes the locks have been dropped before simply trying again, as the only way this would happen is because of a race, and we may end up stuck in a loop if we just hold on to the lock.
So I'd suggest updating this comment and changing the code like this:
if (ret == -ERESTARTNOINTR) {
if (fatal_signal_pending(current)) {
ret = -EINTR;
break;
}+ /* Drop and reacquire lock to unwind race. */
+ madvise_unlock(mm, behaviour);
+ madvise_lock(mm, behaviour); continue; }
Which brings back the existing behaviour.
By the way I hate that this function swallows error codes. But that's not your fault, and is now established user-facing behaviour so yeah. Big sigh.
Quoted 3 lines
mm/madvise.c +0
-1--2.39.5
Quoted 10 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Quoted 2 lines
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
imo, this should best be done in the same patch/series. Maybe extend the benchmark to use IOV_MAX and find a sweet spot?
Thanks,
Davidlohr
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>
Quoted 7 lines
Quoted 3 lines
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Indeed, I was also concerned about this scenario.
But this method does have the added advantage of keeping the vma space in the same state as it was expected during the initial call - although the race does still exist on looking vs acting on the data. This would just remove the intermediate changes.
Quoted 6 lines
Quoted 3 lines
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
imo, this should best be done in the same patch/series. Maybe extend the benchmark to use
IOV_MAXand find a sweet spot?
Are you worried this is over-engineering for a problem that may never be an issue, or is there a particular usecase you have in mind?
It is probably worth investigating, and maybe a potential usecase would help with the targeted sweet spot?
Thanks,
Liam
Quoted 29 lines · Liam R. Howlett
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>Quoted 7 lines
Quoted 3 lines
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Indeed, I was also concerned about this scenario.
But this method does have the added advantage of keeping the vma space in the same state as it was expected during the initial call - although the race does still exist on looking vs acting on the data. This would just remove the intermediate changes.
Quoted 4 lines
Quoted 3 lines
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
Quoted 9 lines
Quoted 2 lines
imo, this should best be done in the same patch/series. Maybe extend the benchmark to use
IOV_MAXand find a sweet spot?Are you worried this is over-engineering for a problem that may never be an issue, or is there a particular usecase you have in mind?
It is probably worth investigating, and maybe a potential usecase would help with the targeted sweet spot?
Keep in mind process_madvise() is not limited by IOV_MAX, which can be rather high, but rather UIO_FASTIOV, which is limited to 8 entries.
(Some have been surprised by this limitation...!)
So I think at this point scaling isn't a huge issue, I raise it because in future we may want to increase this limit, at which point we should think about it, which is why I sort of hand-waved it away a bit.
Quoted 3 lines
Thanks,
Liam
Davidlohr Bueso
Acked-byQuoted 4 lines · Lorenzo Stoakes
Keep in mind
process_madvise()is not limited byIOV_MAX, which can be rather high, but ratherUIO_FASTIOV, which is limited to 8 entries.(Some have been surprised by this limitation...!)
Ah if that is the case then I'm fine with this patch as is.
Quoted 4 lines
So I think at this point scaling isn't a huge issue, I raise it because in future we may want to increase this limit, at which point we should think about it, which is why I sort of hand-waved it away a bit.
Agreed.
SJ, feel free to add my:
Quoted 21 lines · On Fri, 31 Jan 2025 17:51:45 +0000 Lorenzo Stoakes…
Quoted 20 lines · Liam R. Howlett
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>Quoted 7 lines
Quoted 3 lines
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Indeed, I was also concerned about this scenario.
Quoted 7 lines
Quoted 7 lines
But this method does have the added advantage of keeping the vma space in the same state as it was expected during the initial call - although the race does still exist on looking vs acting on the data. This would just remove the intermediate changes.
Quoted 2 lines
Quoted 2 lines
Probably it's ok given limited size of iov,
I think so. Also, users could adjust the batching size for their workloads.
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
but maybe in future we'd want
to set a limit on the ranges before we drop/reacquire lock?imo, this should best be done in the same patch/series. Maybe extend the benchmark to use
IOV_MAXand find a sweet spot?Are you worried this is over-engineering for a problem that may never be an issue, or is there a particular usecase you have in mind?
It is probably worth investigating, and maybe a potential usecase would help with the targeted sweet spot?
I think the sweet spot may depend on the workload and the advice type. So selection of the benchmark will be important. Do you have a benchmark in your mind? My humble microbenchmark[1] does only single-thread usage performance evaluation, so may not be appropriate to be used here. I actually do the evaluation with batching size up to the IOV_MAX (1024), but show no clear evidence of the sweet spot.
Quoted 4 lines
Quoted 1 line
Keep in mind
process_madvise()is not limited byIOV_MAX, which can be rather high, but ratherUIO_FASTIOV, which is limited to 8 entries.
process_madvise() indeed have iovec array of UIO_FASTIOV size, namely iovstack. But, if I understood the code correctly, iostack is used only for a fast path that the user requested advicing less than UIO_FASTIOV regions.
I actually confirmed I can make the loop itrate 1024 times, using my microbenchmark[1]. My step for the check was running the program with 'eval_pmadv $((4*1024*1024)) $((4*1024)) $((4*1024*1024))' command, and counting the number of the itration of the vector_madvise() main loop using printk(). Please let me know if I'm missing something.
Quoted 6 lines
(Some have been surprised by this limitation...!)
So I think at this point scaling isn't a huge issue, I raise it because in future we may want to increase this limit, at which point we should think about it, which is why I sort of hand-waved it away a bit.
I personally think this may still not be a huge issue, especially given the fact that users can test and tune the limit. But I'd like to hear more opinions if available.
[1] https://github.com/sjp38/eval_proc_madvise/blob/master/eval_pmadv.c
Thanks,
SJ
Quoted 5 lines
Quoted 4 lines
Thanks,
Liam
Quoted 16 lines · On Tue, 4 Feb 2025 11:53:43 -0800 SeongJae Park <[email protected]> wrote:
Quoted 14 lines · On Fri, 31 Jan 2025 17:51:45 +0000 Lorenzo Stoakes…
Quoted 13 lines · Liam R. Howlett
Quoted 12 lines · Davidlohr Bueso
Quoted 10 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
[...]
Quoted 17 lines
Quoted 3 lines
Keep in mind
process_madvise()is not limited byIOV_MAX, which can be rather high, but ratherUIO_FASTIOV, which is limited to 8 entries.
process_madvise()indeed have iovec array ofUIO_FASTIOVsize, namely iovstack. But, if I understood the code correctly, iostack is used only for a fast path that the user requested advicing less thanUIO_FASTIOVregions.I actually confirmed I can make the loop itrate 1024 times, using my microbenchmark[1]. My step for the check was running the program with '
eval_pmadv$((4*1024*1024)) $((4*1024)) $((4*1024*1024))' command, and counting the number of the itration of thevector_madvise()main loop usingprintk(). Please let me know if I'm missing something.Quoted 3 lines
(Some have been surprised by this limitation...!)
Quoted 7 lines
Quoted 3 lines
So I think at this point scaling isn't a huge issue, I raise it because in future we may want to increase this limit, at which point we should think about it, which is why I sort of hand-waved it away a bit.
I personally think this may still not be a huge issue, especially given the fact that users can test and tune the limit. But I'd like to hear more opinions if available.
Maybe I should wait more for the more opinions, but I just impatiently sent the next spin of this patch series[1]. Because Davidlohr and Lorenzo promised their tags based on the assumption of UIO_FASTIOV limit while I think that may not be an effective limit, I didn't add their tags on the fourth patch of the series. Please let me know if you have any concern about that, either on this thread or on the new patch series thread[1].
[1] https://lore.kernel.org/[email protected]
Quoted 2 lines
[1] https://github.com/sjp38/eval_proc_madvise/blob/master/eval_pmadv.c
Thanks,
SJ
[...]
Quoted 36 lines · Lorenzo Stoakes
Quoted 35 lines · Liam R. Howlett
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>Quoted 7 lines
Quoted 3 lines
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Indeed, I was also concerned about this scenario.
But this method does have the added advantage of keeping the vma space in the same state as it was expected during the initial call - although the race does still exist on looking vs acting on the data. This would just remove the intermediate changes.
Quoted 6 lines
Quoted 3 lines
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
imo, this should best be done in the same patch/series. Maybe extend the benchmark to use
IOV_MAXand find a sweet spot?Are you worried this is over-engineering for a problem that may never be an issue, or is there a particular usecase you have in mind?
Quoted 8 lines
Quoted 3 lines
It is probably worth investigating, and maybe a potential usecase would help with the targeted sweet spot?
Keep in mind
process_madvise()is not limited byIOV_MAX, which can be rather high, but ratherUIO_FASTIOV, which is limited to 8 entries.(Some have been surprised by this limitation...!)
Surprised, perhaps because I was wrong about this :) Apologies for that.
SJ raised this in [0] and the non-RFC version of this series is over at [1].
[0]: https://lore.kernel.org/all/[email protected]/
[1]: https://lore.kernel.org/all/[email protected]/
We should revisit this and determine whether the drop/reacquire lock is required, perhaps doing some experiments around heavy operations using UIO_MAXIOV entries?
SJ - could you take a look at this please?
Quoted 4 lines
So I think at this point scaling isn't a huge issue, I raise it because in future we may want to increase this limit, at which point we should think about it, which is why I sort of hand-waved it away a bit.
Again as I said here, I suspect _probably_ this won't be too much of an issue - but it is absolutely one we need to address.
Quoted 4 lines
Quoted 4 lines
Thanks,
Liam
Cheers, Lorenzo
Quoted 44 lines · On Sat, 17 May 2025 20:28:49 +0100 Lorenzo Stoakes…
Quoted 43 lines · Lorenzo Stoakes
Quoted 29 lines · Liam R. Howlett
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>Quoted 7 lines
Quoted 3 lines
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Indeed, I was also concerned about this scenario.
But this method does have the added advantage of keeping the vma space in the same state as it was expected during the initial call - although the race does still exist on looking vs acting on the data. This would just remove the intermediate changes.
Quoted 4 lines
Quoted 3 lines
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
Quoted 9 lines
Quoted 2 lines
imo, this should best be done in the same patch/series. Maybe extend the benchmark to use
IOV_MAXand find a sweet spot?Are you worried this is over-engineering for a problem that may never be an issue, or is there a particular usecase you have in mind?
It is probably worth investigating, and maybe a potential usecase would help with the targeted sweet spot?
Keep in mind
process_madvise()is not limited byIOV_MAX, which can be rather high, but ratherUIO_FASTIOV, which is limited to 8 entries.
Quoted 8 lines
Quoted 1 line
(Some have been surprised by this limitation...!)
Surprised, perhaps because I was wrong about this :) Apologies for that.
SJ raised this in [0] and the non-RFC version of this series is over at [1].
[0]: https://lore.kernel.org/all/[email protected]/
[1]: https://lore.kernel.org/all/[email protected]/
I actually mentioned[1] I think the real limit is UIO_MAXIOV but still that wouldn't be a real problem since users can tune the batching size. Actually jemalloc has made a change to use process_madvise() with up to 128 batching size.
I impatiently sent[3] the next revision without giving you enough time to reply, though.
Quoted 6 lines
We should revisit this and determine whether the drop/reacquire lock is required, perhaps doing some experiments around heavy operations using
UIO_MAXIOVentries?SJ - could you take a look at this please?
We had a chance to test this against a production workload, and found no visible regression. The workload is not intesively calling process_madvise() though. Our internal testing of kernels having this change also didn't find any problem so far, though process_madvise() calls from the internal testing is also not intensive to my best knowledge.
So my thought about UIO_MAXIOV is same. I anticipate no issue (until someone yells ;) ) and didn't find an evidence of the problem. But also same to the previous discussion[1], I agree more testing would be good, while I have no good list of benchmarks for this. It would be nice if someone can give me the name of the benchmarks.
Quoted 8 lines
Quoted 5 lines
So I think at this point scaling isn't a huge issue, I raise it because in future we may want to increase this limit, at which point we should think about it, which is why I sort of hand-waved it away a bit.
Again as I said here, I suspect _probably_ this won't be too much of an issue - but it is absolutely one we need to address.
Yes, I agree :)
[1] https://lore.kernel.org/[email protected]
[2] https://github.com/jemalloc/jemalloc/pull/2794/commits/c3604456d4c1f570348a
[3] https://lore.kernel.org/[email protected]
Thanks,
SJ
[...]
Quoted 29 lines · Liam R. Howlett
Quoted 9 lines · Davidlohr Bueso
Quoted 7 lines · Lorenzo Stoakes
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>Quoted 7 lines
Quoted 3 lines
I wonder if this might increase lock contention because now all of the vector operations will hold the relevant mm lock without releasing after each operation?
That was exactly my concern. While afaict the numbers presented in v1 are quite nice, this is ultimately a micro-benchmark, where no other unrelated threads are impacted by these new hold times.
Indeed, I was also concerned about this scenario.
But this method does have the added advantage of keeping the vma space in the same state as it was expected during the initial call - although the race does still exist on looking vs acting on the data. This would just remove the intermediate changes.
Quoted 4 lines
Quoted 3 lines
Probably it's ok given limited size of iov, but maybe in future we'd want to set a limit on the ranges before we drop/reacquire lock?
Quoted 10 lines
Quoted 2 lines
imo, this should best be done in the same patch/series. Maybe extend the benchmark to use
IOV_MAXand find a sweet spot?Are you worried this is over-engineering for a problem that may never be an issue, or is there a particular usecase you have in mind?
It is probably worth investigating, and maybe a potential usecase would help with the targeted sweet spot?
Lorenzo already explained that it is not an issue at the moment. I think this is good discussion to have as I think we will be expanding the limit from UIO_FASTIOV to higher value (maybe UIO_MAXIOV) soon in the followup. At the moment, my gut feeling is that batch size of regions given to the syscall will depend on the advise parameter. For example, For MADV_[NO]HUGEPAGE which is a simple flag [re]set, a single write lock and possible a single tree traversal will be better than multiple write lock/unlock operations even for large batch size. Anyways we will need some experimental data to show that.
JFYI SJ is planning to work on two improvements: (1) single tree traversal for all the given regions and (2) TLB flush batching for MADV_DONTNEED[_LOCKED] and MADV_FREE.
Thanks everyone for your time and feedback.
Quoted 6 lines · On Fri, 31 Jan 2025 16:53:17 +0000 Lorenzo Stoakes…
Quoted 5 lines · SeongJae Park
Optimize redundant mmap lock operations from
process_madvise()by directly doing the mmap locking first, and then the remaining works for all ranges in the loop.Signed-off-by SeongJae Park <[email protected]>
[...]
Quoted 3 lines
Quoted 3 lines
mm/madvise.c +0
-0@@ -1752,9 +1752,26 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
[...]
Quoted 31 lines
mm/madvise.c static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter, · line 1798
Quoted 10 lines
mm/madvise.c +1
-0/* * An madvise operation is attempting to restart the syscall, * but we cannot proceed as it would not be correct to repeat @@ -1776,6 +1793,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,break ;iov_iter_advance (iter,iter_iov_len (iter)); } +madvise_unlock (mm, behavior); ret = (total_len -iov_iter_count (iter)) ? : ret;So I think this is now wrong because of the work I did recently. In this code:
/* * An madvise operation is attempting to restart the syscall, * but we cannot proceed as it would not be correct to repeat * the operation in aggregate, and would be surprising to the * user. * * As we have already dropped locks, it is safe to just loop and * try again. We check for fatal signals in case we need exit * early anyway. */ if (ret == -ERESTARTNOINTR) { if (fatal_signal_pending(current)) { ret = -EINTR; break; } continue; }
Quoted 3 lines
Note that it assumes the locks have been dropped before simply trying again, as the only way this would happen is because of a race, and we may end up stuck in a loop if we just hold on to the lock.
Nice catch!
Quoted 15 lines
So I'd suggest updating this comment and changing the code like this:
if (ret == -ERESTARTNOINTR) { if (fatal_signal_pending(current)) { ret = -EINTR; break; }(quoted diff) +3
-0+ /* Drop and reacquire lock to unwind race. */ + madvise_unlock(mm, behaviour); + madvise_lock(mm, behaviour);continue; }
Quoted 1 line
Which brings back the existing behaviour.
Thank you for this kind suggestion. I will update next version of this patch in this way.
Quoted 7 lines
By the way I hate that this function swallows error codes. But that's not your fault, and is now established user-facing behaviour so yeah. Big sigh.
Quoted 3 lines
mm/madvise.c +0
-1--2.39.5
Thanks,
SJ
Quoted 7 lines · SeongJae Park
process_madvise()callsdo_madvise()for each address range. Then, eachdo_madvise()invocation holds and releases samemmap_lock. Optimize the redundant lock operations by splittingdo_madvise()internal logics including themmap_lockoperations, and calling the small logics directly fromprocess_madvise()in a sequence that removes the redundant locking.
You skipped the evaluation section which was present in the v1. If you decide to post a new version, please include that otherwise we can ask Andrew to pickup the evaluation section from the v1 [1].
Hi Shakeel,
Quoted 9 lines · On Wed, 29 Jan 2025 11:22:29 -0800 Shakeel Butt <[email protected]> wrote:
Quoted 7 lines · SeongJae Park
process_madvise()callsdo_madvise()for each address range. Then, eachdo_madvise()invocation holds and releases samemmap_lock. Optimize the redundant lock operations by splittingdo_madvise()internal logics including themmap_lockoperations, and calling the small logics directly fromprocess_madvise()in a sequence that removes the redundant locking.
Quoted 5 lines
You skipped the evaluation section which was present in the v1. If you decide to post a new version, please include that otherwise we can ask Andrew to pickup the evaluation section from the v1 [1].
Sure. I will run the evaluation again on the new version and include the result on the next version.
Also, thank you very much for reviews :)
Thanks,
SJ
Quoted 10 lines · SeongJae Park
process_madvise()callsdo_madvise()for each address range. Then, eachdo_madvise()invocation holds and releases samemmap_lock. Optimize the redundant lock operations by splittingdo_madvise()internal logics including themmap_lockoperations, and calling the small logics directly fromprocess_madvise()in a sequence that removes the redundant locking.Changes from RFC v1 ([email protected])
- Split outdo_madvise()and use those fromvector_madvise(), instead of adding a flag todo_madvise()(Liam R. Howlett)
I was waiting for a non-RFC to re-examine the series. It looks like a good clean up.
Do you think you'll send out a non-RFC version soon?
Quoted 15 lines
SeongJae Park (4):
mm/madvise: split out mmap locking operations formadvise()mm/madvise: split out madvise input validity check mm/madvise: split outmadvise()behavior execution mm/madvise: remove redundantmmap_lockoperations from
process_madvise()mm/madvise.c | 150 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 47 deletions(-)base-commit:
b43ba6938d01ad4487028592109d4116a28b7afaSignature · 1 line
2.39.5
Quoted 8 lines · On Fri, 31 Jan 2025 11:04:51 -0500 "Liam R. Howlett" <[email protected]>…
Quoted 7 lines · SeongJae Park
process_madvise()callsdo_madvise()for each address range. Then, eachdo_madvise()invocation holds and releases samemmap_lock. Optimize the redundant lock operations by splittingdo_madvise()internal logics including themmap_lockoperations, and calling the small logics directly fromprocess_madvise()in a sequence that removes the redundant locking.
Quoted 6 lines
Quoted 3 lines
Changes from RFC v1 ([email protected])
- Split outdo_madvise()and use those fromvector_madvise(), instead of adding a flag todo_madvise()(Liam R. Howlett)I was waiting for a non-RFC to re-examine the series. It looks like a good clean up.
Thank you Liam :)
Quoted 2 lines
Do you think you'll send out a non-RFC version soon?
I'm planning to send it next week.
Thanks,
SJ
Quoted 16 lines
Quoted 16 lines
SeongJae Park (4):
mm/madvise: split out mmap locking operations formadvise()mm/madvise: split out madvise input validity check mm/madvise: split outmadvise()behavior execution mm/madvise: remove redundantmmap_lockoperations from
process_madvise()mm/madvise.c | 150 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 47 deletions(-)base-commit:
b43ba6938d01ad4487028592109d4116a28b7afaSignature · 1 line
2.39.5
Quoted 8 lines · Liam R. Howlett
Quoted 7 lines · SeongJae Park
process_madvise()callsdo_madvise()for each address range. Then, eachdo_madvise()invocation holds and releases samemmap_lock. Optimize the redundant lock operations by splittingdo_madvise()internal logics including themmap_lockoperations, and calling the small logics directly fromprocess_madvise()in a sequence that removes the redundant locking.
Quoted 8 lines
Quoted 3 lines
Changes from RFC v1 ([email protected])
- Split outdo_madvise()and use those fromvector_madvise(), instead of adding a flag todo_madvise()(Liam R. Howlett)I was waiting for a non-RFC to re-examine the series. It looks like a good clean up.
Do you think you'll send out a non-RFC version soon?
This is definitely a great cleanup, there's a problem with patch 3/3, but SJ - feel free to un-RFC with the fix I suggested - and then happy to give R-b and T-b tags!
Thanks for doing this!
Cheers, Lorenzo
Quoted 16 lines
Quoted 16 lines
SeongJae Park (4):
mm/madvise: split out mmap locking operations formadvise()mm/madvise: split out madvise input validity check mm/madvise: split outmadvise()behavior execution mm/madvise: remove redundantmmap_lockoperations from
process_madvise()mm/madvise.c | 150 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 47 deletions(-)base-commit:
b43ba6938d01ad4487028592109d4116a28b7afa--
2.39.5
Quoted 13 lines · Lorenzo Stoakes
Quoted 12 lines · Liam R. Howlett
Quoted 10 lines · SeongJae Park
process_madvise()callsdo_madvise()for each address range. Then, eachdo_madvise()invocation holds and releases samemmap_lock. Optimize the redundant lock operations by splittingdo_madvise()internal logics including themmap_lockoperations, and calling the small logics directly fromprocess_madvise()in a sequence that removes the redundant locking.Changes from RFC v1 ([email protected])
- Split outdo_madvise()and use those fromvector_madvise(), instead of adding a flag todo_madvise()(Liam R. Howlett)
Quoted 8 lines
Quoted 4 lines
I was waiting for a non-RFC to re-examine the series. It looks like a good clean up.
Do you think you'll send out a non-RFC version soon?
This is definitely a great cleanup, there's a problem with patch 3/3, but SJ - feel free to un-RFC with the fix I suggested - and then happy to give R-b and T-b tags!
Liam's pedantry brought me here ;)
Obviously by 3/3 I mean 4/4 here.
Maybe not obviously. But anyway.
Quoted 21 lines
Thanks for doing this!
Cheers, Lorenzo
Quoted 16 lines
Quoted 16 lines
SeongJae Park (4):
mm/madvise: split out mmap locking operations formadvise()mm/madvise: split out madvise input validity check mm/madvise: split outmadvise()behavior execution mm/madvise: remove redundantmmap_lockoperations from
process_madvise()mm/madvise.c | 150 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 47 deletions(-)base-commit:
b43ba6938d01ad4487028592109d4116a28b7afa--
2.39.5