linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	liubo <liubo254@huawei.com>, Matthew Wilcox <willy@infradead.org>,
	Hugh Dickins <hughd@google.com>, Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Mel Gorman <mgorman@suse.de>,
	Shuah Khan <shuah@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v3 6/7] selftest/mm: ksm_functional_tests: test in mmap_and_merge_range() if anything got merged
Date: Fri, 4 Aug 2023 19:56:28 +0200	[thread overview]
Message-ID: <859496c5-3971-0b65-c297-d29083719a75@redhat.com> (raw)
In-Reply-To: <ZMv6cZH2PdyeTmw1@x1n>

On 03.08.23 21:05, Peter Xu wrote:
> On Thu, Aug 03, 2023 at 04:32:07PM +0200, David Hildenbrand wrote:
>> Let's extend mmap_and_merge_range() to test if anything in the current
>> process was merged. range_maps_duplicates() is too unreliable for that
>> use case, so instead look at KSM stats.
>>
>> Trigger a complete unmerge first, to cleanup the stable tree and
>> stabilize accounting of merged pages.
>>
>> Note that we're using /proc/self/ksm_merging_pages instead of
>> /proc/self/ksm_stat, because that one is available in more existing
>> kernels.
>>
>> If /proc/self/ksm_merging_pages can't be opened, we can't perform any
>> checks and simply skip them.
>>
>> We have to special-case the shared zeropage for now. But the only user
>> -- test_unmerge_zero_pages() -- performs its own merge checks.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
> 

Hi Peter,

thanks for the review!

> Acked-by: Peter Xu <peterx@redhat.com>
> 
> One nitpick:
> 
>> ---
>>   .../selftests/mm/ksm_functional_tests.c       | 47 +++++++++++++++++++
>>   1 file changed, 47 insertions(+)
>>
>> diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
>> index 0de9d33cd565..cb63b600cb4f 100644
>> --- a/tools/testing/selftests/mm/ksm_functional_tests.c
>> +++ b/tools/testing/selftests/mm/ksm_functional_tests.c
>> @@ -30,6 +30,7 @@
>>   static int ksm_fd;
>>   static int ksm_full_scans_fd;
>>   static int proc_self_ksm_stat_fd;
>> +static int proc_self_ksm_merging_pages_fd;
>>   static int ksm_use_zero_pages_fd;
>>   static int pagemap_fd;
>>   static size_t pagesize;
>> @@ -88,6 +89,22 @@ static long get_my_ksm_zero_pages(void)
>>   	return my_ksm_zero_pages;
>>   }
>>   
>> +static long get_my_merging_pages(void)
>> +{
>> +	char buf[10];
>> +	ssize_t ret;
>> +
>> +	if (proc_self_ksm_merging_pages_fd < 0)
>> +		return proc_self_ksm_merging_pages_fd;
> 
> Better do the fds check all in main(), e.g. not all callers below considers
> negative values, so -1 can pass "if (get_my_merging_pages())" etc.

The two existing callers should be handling it correctly:

if (get_my_merging_pages() > 0)
	-> fail

if (val && !get_my_merging_pages()
	-> fail

Both will pass on negative values, unless I am missing something.

I tried to keep the test working also on older kernels where 
ksm_merging_pages does not exist yet (it's ~1 year old).


Anyhow, if you think it's better to make the test fail on these setups, 
I can change it.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2023-08-04 17:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 14:32 [PATCH v3 0/7] smaps / mm/gup: fix gup_can_follow_protnone fallout David Hildenbrand
2023-08-03 14:32 ` [PATCH v3 1/7] mm/gup: reintroduce FOLL_NUMA as FOLL_HONOR_NUMA_FAULT David Hildenbrand
2023-08-03 14:32 ` [PATCH v3 2/7] smaps: use vm_normal_page_pmd() instead of follow_trans_huge_pmd() David Hildenbrand
2023-08-03 14:32 ` [PATCH v3 3/7] kvm: explicitly set FOLL_HONOR_NUMA_FAULT in hva_to_pfn_slow() David Hildenbrand
2023-08-03 14:32 ` [PATCH v3 4/7] mm/gup: don't implicitly set FOLL_HONOR_NUMA_FAULT David Hildenbrand
2023-08-03 14:32 ` [PATCH v3 5/7] pgtable: improve pte_protnone() comment David Hildenbrand
2023-08-03 14:32 ` [PATCH v3 6/7] selftest/mm: ksm_functional_tests: test in mmap_and_merge_range() if anything got merged David Hildenbrand
2023-08-03 19:05   ` Peter Xu
2023-08-04 17:56     ` David Hildenbrand [this message]
2023-08-03 14:32 ` [PATCH v3 7/7] selftest/mm: ksm_functional_tests: Add PROT_NONE test David Hildenbrand
2023-08-03 19:06   ` Peter Xu
2023-08-04 18:00     ` David Hildenbrand
2023-08-07 15:36   ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=859496c5-3971-0b65-c297-d29083719a75@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liubo254@huawei.com \
    --cc=mgorman@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=shuah@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox