From: Mike Rapoport <rppt@kernel.org>
To: Vineet Agarwal <agarwal.vineet2006@gmail.com>
Cc: shuah@kernel.org, akpm@linux-foundation.org,
linux-kselftest@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, david@kernel.org, ljs@kernel.org,
Liam.Howlett@oracle.com, vbabka@kernel.org, surenb@google.com,
mhocko@suse.com
Subject: Re: [PATCH v2] selftests/mm: ksm-functional-tests: fix partial write handling
Date: Sun, 3 May 2026 10:48:36 +0200 [thread overview]
Message-ID: <afcL5KGuOuUev8by@kernel.org> (raw)
In-Reply-To: <20260503060234.644650-1-agarwal.vineet2006@gmail.com>
On Sun, May 03, 2026 at 11:30:30AM +0530, Vineet Agarwal wrote:
> Update write() checks to properly detect and handle partial writes.
>
> Previously, partial writes (ret > 0 && ret != len) would return
> -errno, but write() does not set errno in this case. This could
> result in returning 0 and incorrectly signaling success.
>
> Fix this by:
> - returning -errno only on actual failures (ret < 0)
> - returning -EIO when a partial write is detected
>
> This ensures partial writes are treated as errors and prevents
> false success reporting in tests.
>
> Signed-off-by: Vineet Agarwal <agarwal.vineet2006@gmail.com>
>
> Changes in v2:
> - Fix incorrect use of -errno on partial writes
> - Return -EIO when write() completes partially
Please start a new thread for a new version of the patch.
> ---
> tools/testing/selftests/mm/ksm_functional_tests.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
> index 9a8c852acd68..c80254cda926 100644
> --- a/tools/testing/selftests/mm/ksm_functional_tests.c
> +++ b/tools/testing/selftests/mm/ksm_functional_tests.c
> @@ -507,9 +507,13 @@ static int start_ksmd_and_set_frequency(char *pages_to_scan, char *sleep_ms)
> if (write(ksm_fd, "1", 1) != 1)
> return -errno;
>
> - ret = write(pages_to_scan_fd, pages_to_scan, strlen(pages_to_scan));
> - if (ret < 0 || ret != strlen(pages_to_scan))
> + ssize_t len = strlen(pages_to_scan);
The v2 diff should be against the base, not against v1.
> +
> + ret = write(pages_to_scan_fd, pages_to_scan, len);
> + if (ret < 0)
> return -errno;
> + if (ret != len)
> + return -EIO;
Just return -1 if write() != strlen(), the actual error code does not
matter anyway.
> ret = write(sleep_millisecs_fd, sleep_ms, strlen(sleep_ms));
> if (ret < 0 || ret != strlen(sleep_ms))
> @@ -531,8 +535,10 @@ static int stop_ksmd_and_restore_frequency(void)
> return -errno;
>
> ret = write(pages_to_scan_fd, "100", 3);
> - if (ret < 0 || ret != 3)
> + if (ret < 0)
> return -errno;
> + if (ret != 3)
> + return -EIO;
>
> ret = write(sleep_millisecs_fd, "20", 2);
> if (ret < 0 || ret != 2)
> --
> 2.54.0
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2026-05-03 8:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 0:57 [PATCH] selftests/mm: ksm-functional-tests: fix partial writes Vineet Agarwal
2026-05-03 6:00 ` [PATCH v2] selftests/mm: ksm-functional-tests: fix partial write handling Vineet Agarwal
2026-05-03 8:48 ` Mike Rapoport [this message]
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=afcL5KGuOuUev8by@kernel.org \
--to=rppt@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=agarwal.vineet2006@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=shuah@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.