Skip to content

Commit 524e00b

Browse files
howlettakpm00
authored andcommitted
mm: remove rb tree.
Remove the RB tree and start using the maple tree for vm_area_struct tracking. Drop validate_mm() calls in expand_upwards() and expand_downwards() as the lock is not held. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Liam R. Howlett <[email protected]> Tested-by: Yu Zhao <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: David Howells <[email protected]> Cc: Davidlohr Bueso <[email protected]> Cc: "Matthew Wilcox (Oracle)" <[email protected]> Cc: SeongJae Park <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 0c563f1 commit 524e00b

File tree

9 files changed

+144
-487
lines changed

9 files changed

+144
-487
lines changed

arch/x86/kernel/tboot.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ void __init tboot_probe(void)
9595

9696
static pgd_t *tboot_pg_dir;
9797
static struct mm_struct tboot_mm = {
98-
.mm_rb = RB_ROOT,
9998
.mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, tboot_mm.mmap_lock),
10099
.pgd = swapper_pg_dir,
101100
.mm_users = ATOMIC_INIT(2),

drivers/firmware/efi/efi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ static unsigned long __initdata mem_reserve = EFI_INVALID_TABLE_ADDR;
5757
static unsigned long __initdata rt_prop = EFI_INVALID_TABLE_ADDR;
5858

5959
struct mm_struct efi_mm = {
60-
.mm_rb = RB_ROOT,
6160
.mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, efi_mm.mmap_lock),
6261
.mm_users = ATOMIC_INIT(2),
6362
.mm_count = ATOMIC_INIT(1),

include/linux/mm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,8 +2654,6 @@ extern int __split_vma(struct mm_struct *, struct vm_area_struct *,
26542654
extern int split_vma(struct mm_struct *, struct vm_area_struct *,
26552655
unsigned long addr, int new_below);
26562656
extern int insert_vm_struct(struct mm_struct *, struct vm_area_struct *);
2657-
extern void __vma_link_rb(struct mm_struct *, struct vm_area_struct *,
2658-
struct rb_node **, struct rb_node *);
26592657
extern void unlink_file_vma(struct vm_area_struct *);
26602658
extern struct vm_area_struct *copy_vma(struct vm_area_struct **,
26612659
unsigned long addr, unsigned long len, pgoff_t pgoff,

include/linux/mm_types.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -410,19 +410,6 @@ struct vm_area_struct {
410410

411411
/* linked list of VM areas per task, sorted by address */
412412
struct vm_area_struct *vm_next, *vm_prev;
413-
414-
struct rb_node vm_rb;
415-
416-
/*
417-
* Largest free memory gap in bytes to the left of this VMA.
418-
* Either between this VMA and vma->vm_prev, or between one of the
419-
* VMAs below us in the VMA rbtree and its ->vm_prev. This helps
420-
* get_unmapped_area find a free area of the right size.
421-
*/
422-
unsigned long rb_subtree_gap;
423-
424-
/* Second cache line starts here. */
425-
426413
struct mm_struct *vm_mm; /* The address space we belong to. */
427414

428415
/*
@@ -488,7 +475,6 @@ struct mm_struct {
488475
struct {
489476
struct vm_area_struct *mmap; /* list of VMAs */
490477
struct maple_tree mm_mt;
491-
struct rb_root mm_rb;
492478
u64 vmacache_seqnum; /* per-thread vmacache */
493479
#ifdef CONFIG_MMU
494480
unsigned long (*get_unmapped_area) (struct file *filp,

kernel/fork.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
581581
struct mm_struct *oldmm)
582582
{
583583
struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
584-
struct rb_node **rb_link, *rb_parent;
585584
int retval;
586585
unsigned long charge = 0;
587586
LIST_HEAD(uf);
@@ -608,8 +607,6 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
608607
mm->exec_vm = oldmm->exec_vm;
609608
mm->stack_vm = oldmm->stack_vm;
610609

611-
rb_link = &mm->mm_rb.rb_node;
612-
rb_parent = NULL;
613610
pprev = &mm->mmap;
614611
retval = ksm_fork(mm, oldmm);
615612
if (retval)
@@ -701,10 +698,6 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
701698
tmp->vm_prev = prev;
702699
prev = tmp;
703700

704-
__vma_link_rb(mm, tmp, rb_link, rb_parent);
705-
rb_link = &tmp->vm_rb.rb_right;
706-
rb_parent = &tmp->vm_rb;
707-
708701
/* Link the vma into the MT */
709702
mas.index = tmp->vm_start;
710703
mas.last = tmp->vm_end - 1;
@@ -1133,7 +1126,6 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
11331126
struct user_namespace *user_ns)
11341127
{
11351128
mm->mmap = NULL;
1136-
mm->mm_rb = RB_ROOT;
11371129
mt_init_flags(&mm->mm_mt, MM_MT_FLAGS);
11381130
mt_set_external_lock(&mm->mm_mt, &mm->mmap_lock);
11391131
mm->vmacache_seqnum = 0;

mm/init-mm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/mm_types.h>
3-
#include <linux/rbtree.h>
43
#include <linux/maple_tree.h>
54
#include <linux/rwsem.h>
65
#include <linux/spinlock.h>
@@ -29,7 +28,6 @@
2928
* and size this cpu_bitmask to NR_CPUS.
3029
*/
3130
struct mm_struct init_mm = {
32-
.mm_rb = RB_ROOT,
3331
.mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, init_mm.mmap_lock),
3432
.pgd = swapper_pg_dir,
3533
.mm_users = ATOMIC_INIT(2),

0 commit comments

Comments
 (0)