lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5dfd4ff3-082f-5621-01b0-cf789eff8835@suse.cz>
Date:   Wed, 19 Jan 2022 18:58:54 +0100
From:   Vlastimil Babka <vbabka@...e.cz>
To:     Liam Howlett <liam.howlett@...cle.com>,
        "maple-tree@...ts.infradead.org" <maple-tree@...ts.infradead.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     Song Liu <songliubraving@...com>,
        Davidlohr Bueso <dave@...olabs.net>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Matthew Wilcox <willy@...radead.org>,
        Laurent Dufour <ldufour@...ux.ibm.com>,
        David Rientjes <rientjes@...gle.com>,
        Axel Rasmussen <axelrasmussen@...gle.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Rik van Riel <riel@...riel.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Michel Lespinasse <walken.cr@...il.com>,
        Jerome Glisse <jglisse@...hat.com>,
        Minchan Kim <minchan@...gle.com>,
        Joel Fernandes <joelaf@...gle.com>,
        Rom Lemarchand <romlem@...gle.com>
Subject: Re: [PATCH v4 52/66] mm/ksm: Use maple tree iterators instead of vma
 linked list

On 12/1/21 15:30, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@...cle.com>

Acked-by: Vlastimil Babka <vbabka@...e.cz>

> ---
>  mm/ksm.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/ksm.c b/mm/ksm.c
> index 0662093237e4..d309249c95a4 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -973,11 +973,13 @@ static int unmerge_and_remove_all_rmap_items(void)
>  						struct mm_slot, mm_list);
>  	spin_unlock(&ksm_mmlist_lock);
>  
> -	for (mm_slot = ksm_scan.mm_slot;
> -			mm_slot != &ksm_mm_head; mm_slot = ksm_scan.mm_slot) {
> +	for (mm_slot = ksm_scan.mm_slot; mm_slot != &ksm_mm_head;
> +	     mm_slot = ksm_scan.mm_slot) {
> +		MA_STATE(mas, &mm_slot->mm->mm_mt, 0, 0);

VMA_ITERATOR would be a bit shorter.

> +
>  		mm = mm_slot->mm;
>  		mmap_read_lock(mm);
> -		for (vma = mm->mmap; vma; vma = vma->vm_next) {
> +		mas_for_each(&mas, vma, ULONG_MAX) {
>  			if (ksm_test_exit(mm))
>  				break;
>  			if (!(vma->vm_flags & VM_MERGEABLE) || !vma->anon_vma)
> @@ -2226,6 +2228,7 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page)
>  	struct vm_area_struct *vma;
>  	struct rmap_item *rmap_item;
>  	int nid;
> +	MA_STATE(mas, NULL, 0, 0);
>  
>  	if (list_empty(&ksm_mm_head.mm_list))
>  		return NULL;
> @@ -2283,13 +2286,14 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page)
>  	}
>  
>  	mm = slot->mm;
> +	mas.tree = &mm->mm_mt;
> +	mas_set(&mas, ksm_scan.address);
> +
>  	mmap_read_lock(mm);
>  	if (ksm_test_exit(mm))
> -		vma = NULL;
> -	else
> -		vma = find_vma(mm, ksm_scan.address);
> +		goto no_vmas;
>  
> -	for (; vma; vma = vma->vm_next) {
> +	mas_for_each(&mas, vma, ULONG_MAX) {
>  		if (!(vma->vm_flags & VM_MERGEABLE))
>  			continue;
>  		if (ksm_scan.address < vma->vm_start)
> @@ -2327,6 +2331,7 @@ static struct rmap_item *scan_get_next_rmap_item(struct page **page)
>  	}
>  
>  	if (ksm_test_exit(mm)) {
> +no_vmas:
>  		ksm_scan.address = 0;
>  		ksm_scan.rmap_list = &slot->rmap_list;
>  	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ