linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Rik van Riel <riel@surriel.com>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Harry Yoo <harry.yoo@oracle.com>
Subject: Re: [PATCH 1/3] selftests/mm: check a valid fd with negative value
Date: Wed, 16 Jul 2025 10:52:21 +0200	[thread overview]
Message-ID: <f109b782-5081-4c5a-b11c-0c5244301c09@redhat.com> (raw)
In-Reply-To: <20250716082710.2801-2-richard.weiyang@gmail.com>

On 16.07.25 10:27, Wei Yang wrote:
> fd 0 is usually occupied by stdin, which is not expected to be returned
> by open(). But 0 is still a valid fd.
> 
> Check the valid fd with negative value like other places.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Cc: Rik van Riel <riel@surriel.com>
> Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Harry Yoo <harry.yoo@oracle.com>
> ---
>   tools/testing/selftests/mm/ksm_functional_tests.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
> index d8bd1911dfc0..6da5c3340e10 100644
> --- a/tools/testing/selftests/mm/ksm_functional_tests.c
> +++ b/tools/testing/selftests/mm/ksm_functional_tests.c
> @@ -81,7 +81,7 @@ static long get_my_ksm_zero_pages(void)
>   	ssize_t read_size;
>   	unsigned long my_ksm_zero_pages;
>   
> -	if (!proc_self_ksm_stat_fd)
> +	if (proc_self_ksm_stat_fd < 0)
>   		return 0;

Only test_unmerge_zero_pages() calls get_my_ksm_zero_pages(). And there, 
we have

if (proc_self_ksm_stat_fd < 0) {
	ksft_test_result_skip("open(\"/proc/self/ksm_stat\") failed\n");
	return;
}

As the fd is opened after others, we should never get fd=0.

So probably, this should just be handled as part of factoring it out, no 
need for this change upfront AFAIKS.

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-07-16  8:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-16  8:27 [PATCH 0/3] selftests/mm: assert rmap behave as expected Wei Yang
2025-07-16  8:27 ` [PATCH 1/3] selftests/mm: check a valid fd with negative value Wei Yang
2025-07-16  8:52   ` David Hildenbrand [this message]
2025-07-17  1:18     ` Wei Yang
2025-07-17  8:27       ` David Hildenbrand
2025-07-16  8:27 ` [PATCH 2/3] selftests/mm: put general ksm operation into vm_util Wei Yang
2025-07-16  9:20   ` David Hildenbrand
2025-07-17  2:45     ` Wei Yang
2025-07-17  3:30       ` Wei Yang
2025-07-17 11:57         ` David Hildenbrand
2025-07-17 11:56       ` David Hildenbrand
2025-07-16  8:27 ` [PATCH 3/3] selftests/mm: assert rmap behave as expected Wei Yang
2025-07-16 13:34   ` David Hildenbrand
2025-07-17  3:17     ` Wei Yang
2025-07-25  2:16       ` Wei Yang
2025-07-25 13:34         ` 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=f109b782-5081-4c5a-b11c-0c5244301c09@redhat.com \
    --to=david@redhat.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=harry.yoo@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=richard.weiyang@gmail.com \
    --cc=riel@surriel.com \
    --cc=vbabka@suse.cz \
    /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).