linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Usama Arif <usamaarif642@gmail.com>
To: SeongJae Park <sj@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	david@redhat.com, linux-mm@kvack.org,
	linux-fsdevel@vger.kernel.org, corbet@lwn.net, rppt@kernel.org,
	surenb@google.com, mhocko@suse.com, hannes@cmpxchg.org,
	baohua@kernel.org, shakeel.butt@linux.dev, riel@surriel.com,
	ziy@nvidia.com, laoar.shao@gmail.com, dev.jain@arm.com,
	baolin.wang@linux.alibaba.com, npache@redhat.com,
	lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com,
	ryan.roberts@arm.com, vbabka@suse.cz, jannh@google.com,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH 5/5] selftests: prctl: introduce tests for disabling THPs except for madvise
Date: Tue, 29 Jul 2025 23:17:52 +0100	[thread overview]
Message-ID: <59099cb0-638b-4ca7-b20e-f407a2d27217@gmail.com> (raw)
In-Reply-To: <20250728165549.62546-1-sj@kernel.org>


>> +	res = test_mmap_thp(COLLAPSE, pmdsize);
>> +	ASSERT_EQ(res, 1);
> 
> Seems res is not being used other than saving the return value for assertions.
> Why don't you do the assertion at once, e.g., ASSERT_EQ(test_mmap_thp(...), 1)?
> No strong opinion, but I think that could make code shorter and easier to read.
> 

Yeah this is on purpose, I found it easier to evaluate what the output should be
if I wrote code like this. As compiler will likely just optimize it out (although
we dont really care about performance :) ), although others might find without res
better.
I think you had mentioned it in the earlier thread as well. I will remove it.>> +}
>> +
>> +TEST_F(prctl_thp_disable_except_madvise, nofork)
>> +{
>> +	int res = 0;
>> +
>> +	res = prctl(PR_SET_THP_DISABLE, 1, PR_THP_DISABLE_EXCEPT_ADVISED, NULL, NULL);
>> +	ASSERT_EQ(res, 0);
> 
> Again, I think 'res' can be removed.
> 
>> +	prctl_thp_disable_except_madvise(_metadata, self->pmdsize);
>> +}
>> +
>> +TEST_F(prctl_thp_disable_except_madvise, fork)
>> +{
>> +	int res = 0, ret = 0;
>> +	pid_t pid;
>> +
>> +	res = prctl(PR_SET_THP_DISABLE, 1, PR_THP_DISABLE_EXCEPT_ADVISED, NULL, NULL);
>> +	ASSERT_EQ(res, 0);
> 
> Ditto.
> 
>> +
>> +	/* Make sure prctl changes are carried across fork */
>> +	pid = fork();
>> +	ASSERT_GE(pid, 0);
>> +
>> +	if (!pid)
>> +		prctl_thp_disable_except_madvise(_metadata, self->pmdsize);
>> +
>> +	wait(&ret);
>> +	if (WIFEXITED(ret))
>> +		ret = WEXITSTATUS(ret);
>> +	else
>> +		ret = -EINVAL;
>> +	ASSERT_EQ(ret, 0);
>> +}
>> +
>>  FIXTURE(prctl_thp_disable_completely)
>>  {
>>  	struct thp_settings settings;
>> -- 
>> 2.47.3
> 
> 
> Thanks,
> SJ




  reply	other threads:[~2025-07-29 22:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-25 16:22 [PATCH 0/5] prctl: extend PR_SET_THP_DISABLE to only provide THPs when advised Usama Arif
2025-07-25 16:22 ` [PATCH 1/5] prctl: extend PR_SET_THP_DISABLE to optionally exclude VM_HUGEPAGE Usama Arif
2025-07-30 19:31   ` Lorenzo Stoakes
2025-07-30 19:42     ` Usama Arif
2025-07-31  8:29       ` Lorenzo Stoakes
2025-07-31  8:38         ` David Hildenbrand
2025-07-31  9:09           ` Lorenzo Stoakes
2025-07-31 10:32           ` Usama Arif
2025-07-25 16:22 ` [PATCH 2/5] mm/huge_memory: convert "tva_flags" to "enum tva_type" for thp_vma_allowable_order*() Usama Arif
2025-07-28 13:28   ` David Hildenbrand
2025-07-28 14:09     ` Usama Arif
2025-07-25 16:22 ` [PATCH 3/5] mm/huge_memory: treat MADV_COLLAPSE as an advise with PR_THP_DISABLE_EXCEPT_ADVISED Usama Arif
2025-07-25 16:22 ` [PATCH 4/5] selftests: prctl: introduce tests for disabling THPs completely Usama Arif
2025-07-28 15:06   ` David Hildenbrand
2025-07-29 22:13     ` Usama Arif
2025-07-30 11:39       ` David Hildenbrand
2025-07-25 16:22 ` [PATCH 5/5] selftests: prctl: introduce tests for disabling THPs except for madvise Usama Arif
2025-07-28 16:55   ` SeongJae Park
2025-07-29 22:17     ` Usama Arif [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-07-31 12:18 [PATCH 0/5] prctl: extend PR_SET_THP_DISABLE to only provide THPs when advised Usama Arif
2025-07-31 12:18 ` [PATCH 5/5] selftests: prctl: introduce tests for disabling THPs except for madvise Usama Arif

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=59099cb0-638b-4ca7-b20e-f407a2d27217@gmail.com \
    --to=usamaarif642@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=dev.jain@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=jannh@google.com \
    --cc=kernel-team@meta.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=npache@redhat.com \
    --cc=riel@surriel.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=sj@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=ziy@nvidia.com \
    /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;
as well as URLs for NNTP newsgroup(s).