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]
Date:   Tue, 13 Sep 2022 10:06:20 +0200
From:   David Hildenbrand <david@...hat.com>
To:     Alistair Popple <apopple@...dia.com>, linux-mm@...ck.org,
        akpm@...ux-foundation.org
Cc:     John Hubbard <jhubbard@...dia.com>, Peter Xu <peterx@...hat.com>,
        Nadav Amit <nadav.amit@...il.com>,
        huang ying <huang.ying.caritas@...il.com>,
        LKML <linux-kernel@...r.kernel.org>,
        "Sierra Guiza, Alejandro (Alex)" <alex.sierra@....com>,
        Felix Kuehling <Felix.Kuehling@....com>,
        Jason Gunthorpe <jgg@...dia.com>,
        Ralph Campbell <rcampbell@...dia.com>,
        Matthew Wilcox <willy@...radead.org>,
        Karol Herbst <kherbst@...hat.com>,
        Lyude Paul <lyude@...hat.com>, Ben Skeggs <bskeggs@...hat.com>,
        Logan Gunthorpe <logang@...tatee.com>, paulus@...abs.org,
        linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH] hmm-tests: Fix migrate_dirty_page test

On 13.09.22 07:22, Alistair Popple wrote:
> As noted by John Hubbard the original test relied on side effects of the
> implementation of migrate_vma_setup() to detect if pages had been
> swapped to disk or not. This is subject to change in future so
> explicitly check for swap entries via pagemap instead. Fix a spelling
> mistake while we're at it.
> 
> Signed-off-by: Alistair Popple <apopple@...dia.com>
> Fixes: 5cc88e844e87 ("selftests/hmm-tests: add test for dirty bits")
> ---
>   tools/testing/selftests/vm/hmm-tests.c | 50 +++++++++++++++++++++++---
>   1 file changed, 46 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/vm/hmm-tests.c b/tools/testing/selftests/vm/hmm-tests.c
> index 70fdb49b59ed..b5f6a7dc1f12 100644
> --- a/tools/testing/selftests/vm/hmm-tests.c
> +++ b/tools/testing/selftests/vm/hmm-tests.c
> @@ -1261,9 +1261,47 @@ static int destroy_cgroup(void)
>   	return 0;
>   }
>   
> +static uint64_t get_pfn(int fd, uint64_t ptr)
> +{
> +	uint64_t pfn;
> +	int ret;
> +
> +	ret = pread(fd, &pfn, sizeof(ptr),
> +		(uint64_t) ptr / getpagesize() * sizeof(ptr));
> +	if (ret != sizeof(ptr))
> +		return 0;
> +
> +	return pfn;
> +}
> +
> +#define PAGEMAP_SWAPPED (1ULL << 62)
> +
> +/* Returns true if at least one page in the range is on swap */
> +static bool pages_swapped(void *ptr, unsigned long pages)
> +{
> +	uint64_t pfn;
> +	int fd = open("/proc/self/pagemap", O_RDONLY);
> +	unsigned long i;
> +
> +	if (fd < 0)
> +		return false;
> +
> +	for (i = 0; i < pages; i++) {
> +		pfn = get_pfn(fd, (uint64_t) ptr + i * getpagesize());
> +
> +		if (pfn & PAGEMAP_SWAPPED) {
> +			close(fd);
> +			return true;
> +		}

We do have pagemap_get_entry() in vm_util.c to query the pagemap entry.

Can you further, add pagemap_is_swapped() to vm_util.c?

I'll be also needing that (including a variant for testing a range) in 
anon COW tests.


-- 
Thanks,

David / dhildenb

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ