* [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink()
@ 2020-08-09 23:20 Wei Yang
2020-08-09 23:20 ` [PATCH 2/2] mm/mmap: leverage vma_rb_erase_ignore() to implement vma_rb_erase() Wei Yang
2020-08-19 20:12 ` [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Andrew Morton
0 siblings, 2 replies; 4+ messages in thread
From: Wei Yang @ 2020-08-09 23:20 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, Wei Yang
__vma_unlink_common() and __vma_unlink() are counterparts. Since there is
not function named __vma_unlink(), let's rename it to __vma_unlink() to
make the code more self-explain and easy for audience to understand.
Otherwise we may expect there are several variants of vma_unlink and
__vma_unlink_common() is used by them.
Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
---
mm/mmap.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index dcdab2675a21..ec780925da94 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -677,7 +677,7 @@ static void __insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
mm->map_count++;
}
-static __always_inline void __vma_unlink_common(struct mm_struct *mm,
+static __always_inline void __vma_unlink(struct mm_struct *mm,
struct vm_area_struct *vma,
struct vm_area_struct *ignore)
{
@@ -859,7 +859,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
* us to remove next before dropping the locks.
*/
if (remove_next != 3)
- __vma_unlink_common(mm, next, next);
+ __vma_unlink(mm, next, next);
else
/*
* vma is not before next if they've been
@@ -870,7 +870,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start,
* "next" (which is stored in post-swap()
* "vma").
*/
- __vma_unlink_common(mm, next, vma);
+ __vma_unlink(mm, next, vma);
if (file)
__remove_shared_vm_struct(next, file, mapping);
} else if (insert) {
--
2.20.1 (Apple Git-117)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mm/mmap: leverage vma_rb_erase_ignore() to implement vma_rb_erase()
2020-08-09 23:20 [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Wei Yang
@ 2020-08-09 23:20 ` Wei Yang
2020-08-19 20:12 ` [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Andrew Morton
1 sibling, 0 replies; 4+ messages in thread
From: Wei Yang @ 2020-08-09 23:20 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, Wei Yang
These two functions share the same logic except ignore a different vma.
Let's reuse the code.
Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
---
mm/mmap.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index ec780925da94..90b1298d4222 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -474,8 +474,12 @@ static __always_inline void vma_rb_erase_ignore(struct vm_area_struct *vma,
{
/*
* All rb_subtree_gap values must be consistent prior to erase,
- * with the possible exception of the "next" vma being erased if
- * next->vm_start was reduced.
+ * with the possible exception of
+ *
+ * a. the "next" vma being erased if next->vm_start was reduced in
+ * __vma_adjust() -> __vma_unlink()
+ * b. the vma being erased in detach_vmas_to_be_unmapped() ->
+ * vma_rb_erase()
*/
validate_mm_rb(root, ignore);
@@ -485,13 +489,7 @@ static __always_inline void vma_rb_erase_ignore(struct vm_area_struct *vma,
static __always_inline void vma_rb_erase(struct vm_area_struct *vma,
struct rb_root *root)
{
- /*
- * All rb_subtree_gap values must be consistent prior to erase,
- * with the possible exception of the vma being erased.
- */
- validate_mm_rb(root, vma);
-
- __vma_rb_erase(vma, root);
+ vma_rb_erase_ignore(vma, root, vma);
}
/*
--
2.20.1 (Apple Git-117)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink()
2020-08-09 23:20 [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Wei Yang
2020-08-09 23:20 ` [PATCH 2/2] mm/mmap: leverage vma_rb_erase_ignore() to implement vma_rb_erase() Wei Yang
@ 2020-08-19 20:12 ` Andrew Morton
2020-08-20 2:15 ` Wei Yang
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2020-08-19 20:12 UTC (permalink / raw)
To: Wei Yang; +Cc: linux-mm, linux-kernel
On Mon, 10 Aug 2020 07:20:56 +0800 Wei Yang <richard.weiyang@linux.alibaba.com> wrote:
> __vma_unlink_common() and __vma_unlink() are counterparts. Since there is
I assume you meant "__vma_link()" here?
> not function named __vma_unlink(), let's rename it to __vma_unlink() to
> make the code more self-explain and easy for audience to understand.
>
> Otherwise we may expect there are several variants of vma_unlink and
> __vma_unlink_common() is used by them.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink()
2020-08-19 20:12 ` [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Andrew Morton
@ 2020-08-20 2:15 ` Wei Yang
0 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2020-08-20 2:15 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wei Yang, linux-mm, linux-kernel
On Wed, Aug 19, 2020 at 01:12:10PM -0700, Andrew Morton wrote:
>On Mon, 10 Aug 2020 07:20:56 +0800 Wei Yang <richard.weiyang@linux.alibaba.com> wrote:
>
>> __vma_unlink_common() and __vma_unlink() are counterparts. Since there is
>
>I assume you meant "__vma_link()" here?
>
Oops, my fault. You are right.
Do you prefer a v2, or you would like to fix it online?
>> not function named __vma_unlink(), let's rename it to __vma_unlink() to
>> make the code more self-explain and easy for audience to understand.
>>
>> Otherwise we may expect there are several variants of vma_unlink and
>> __vma_unlink_common() is used by them.
--
Wei Yang
Help you, Help me
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-20 2:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-09 23:20 [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Wei Yang
2020-08-09 23:20 ` [PATCH 2/2] mm/mmap: leverage vma_rb_erase_ignore() to implement vma_rb_erase() Wei Yang
2020-08-19 20:12 ` [PATCH 1/2] mm/mmap: rename __vma_unlink_common() to __vma_unlink() Andrew Morton
2020-08-20 2:15 ` Wei Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).