From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53D87327C0D for ; Tue, 19 May 2026 02:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779159105; cv=none; b=cSwYBBwy2Dy9OFA0xbAQpDqAJfkhKixt2x+96wBOYi7PdYfr9o69orP2WoSJTdjEljIADjZoBlS0BH3r8CeRdkdPXPJ9XSxYtueUe9g4aPYVdSD58jaTAlwiEKK+s20QgLeyM8WpId8PqrUgVRgFs0TpqxLGfADOhXbZ9vLkJ+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779159105; c=relaxed/simple; bh=4oGT1ayBDkwYn3Qr/LaW+fN6OEZZOIq/CCNtj+5nbvg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YE2h+Joe/6GPoGXtGEHs462/xJheicWM/kHNLkSVTsMmuuGyMPpxyRk5EvQJ9g9+y1HvOhd7Gmws3sFYEv74UEMsnyphAVzBlzfFFNBSbu0WP4mjYUWwPI52socAVH+9Du8ax4nmiye28yZj75LfLnTvs3zRAPm3GP43klmJzdk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aTtOFDpz; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aTtOFDpz" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4890d945eb4so21528315e9.0 for ; Mon, 18 May 2026 19:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779159102; x=1779763902; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=HUvEeG4/QGY098FJMB5ch64NaoSvyes0bxvJyMtkahY=; b=aTtOFDpzGkOExIOjas1ec+WbGZq9qIcD2K2nZHTKr/4shMPfeftc/arap4ouJYGYGM F6ziBxBLRf7QybeEIBbzHjUMvNbYaFHy07iUp0UnrEvB8ioLn4UVNo75bfRwVkhjqcXt TzPL+wDi7URtTZwcN6V74s9OBT3JqLzQE0eJGmHFnU6OzWBTHz8V2HPbDBYjE15u4uTu SIrTzRTmd9JesTNDZPyv7S8jGDZEeGbJT57fXCcHp9pLBz0JxViwoRdQOTWuD1uEzFDE H7kDr2BaLPb+Cg7UfOWJq3WsfH9ETfiWbi5rvveyXceYmrGrubM7ZVLybA4faWqtDho9 jUoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779159102; x=1779763902; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HUvEeG4/QGY098FJMB5ch64NaoSvyes0bxvJyMtkahY=; b=plIht7KUYXEjOWCqiRU2ENZ5G1qfuUie+vvqWk2nWEKv7S12qC6Wy4fzMMkMthp+XD IAQq4/heYyYGuYF1dT9CbIc7zUZ6jSToO7WA7l0822IBY1/s4yvyOb4/hbXiI/Ic+M8g Z2uqtqWWvAqEGCRqyE8hHrKUbRWfX1S8l6bQK5vvPMSmcrfhF8AJTGEsXD0YX0x40JKm g0sJYEIrTYlEeMTfBhoV8yd8VST/SefWaQ4fv0kThsTm2xMgBGxnJSZ1usD2J6yJ7nYn V+z3lxtx0sIbuzCV5AY7lVkaj+q8R24Vngei592dPiuiKDr6qa+kHIs/PtdW7YnEZ6MZ xKsw== X-Forwarded-Encrypted: i=1; AFNElJ8vxskBjkrutjkOdmUeODW6btXg3LPVfhngQk7oi24fpwS8z9lBL/dfDgQHELFeSnRqh030GW2vs2/lGEU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0XiF96xWxZxEjYHrCOu2rwFCmO4ELQ4ntjLz6sUCnRqqhQ61+ 8GvdJDpilRwelczyjKnvQhOcppwQE3hvDnhTkMt47NPdb93HTdJwLVSY X-Gm-Gg: Acq92OGP+9P7cbytABABTgFHswnOvugosF3OFkdxgXcOYr1LdgJUB49M7ZqTzskoBfZ 8L5BZiWjsf2MTK2iF5l/DXeDVzQdPFddr8hOKiykkfN+IjsSz2qpVL65Xle4hrvsRdyE78Ka5ah XL9xhThydit9olUQYAuHPV0WMUzw1MggUXlL2ar7KCAue8ps/Ya0PCyaEO06R8jDx7Wb5nItmuE gLnDzD4/laFGaU6omD4UK33DjAic6rbeQe5lkwq5Gl2JzlQKGjS6Kte7jAOyLH71eItedPByWbU duMuFPu/hIWe5W+JpzsdwQosrY6ryePClvBtVupf4bL+zEhm2s3seqT3gCi0gY5CvLgY1yw8Ud2 FmI67qPn05ObUpjtT2k5+z8t5ItRZRp2qNuCeqx5l4IHJ/bkNY9mTjGO/IX4vYnWE+K5U/WFABq 2UUZerw1VTsLY8IKVm8ief6g== X-Received: by 2002:a05:600c:5010:b0:486:faa8:9e4 with SMTP id 5b1f17b1804b1-48fe5388407mr256024315e9.12.1779159102140; Mon, 18 May 2026 19:51:42 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe5ab3977sm319672855e9.9.2026.05.18.19.51.41 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 May 2026 19:51:41 -0700 (PDT) Date: Tue, 19 May 2026 02:51:41 +0000 From: Wei Yang To: Andrew Morton Cc: Wei Yang , Vineet Agarwal , david@kernel.org, ljs@kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests/mm: check file initialization writes in split_huge_page_test Message-ID: <20260519025141.lguv7mrtvqgqpltc@master> Reply-To: Wei Yang References: <20260512074924.27721-1-agarwal.vineet2006@gmail.com> <20260515092211.qkmaxcofxwfdexld@master> <20260518163553.447a45c54a3d419b9bb916ca@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260518163553.447a45c54a3d419b9bb916ca@linux-foundation.org> User-Agent: NeoMutt/20170113 (1.7.2) On Mon, May 18, 2026 at 04:35:53PM -0700, Andrew Morton wrote: >On Fri, 15 May 2026 09:22:11 +0000 Wei Yang wrote: > >> On Tue, May 12, 2026 at 01:19:24PM +0530, Vineet Agarwal wrote: >> >create_pagecache_thp_and_fd() fills the backing file for the >> >pagecache THP tests using repeated write() calls, but the return >> >value is never checked. >> > >> >If a write fails or completes only partially, the test may continue >> >with an incompletely initialized file and produce misleading results. >> > >> >Check the result of write() and fail the test if the expected number >> >of bytes was not written. >> > >> >Signed-off-by: Vineet Agarwal >> >--- >> > tools/testing/selftests/mm/split_huge_page_test.c | 13 ++++++++++--- >> > 1 file changed, 10 insertions(+), 3 deletions(-) >> > >> >diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c >> >index 500d07c4938b..eab69b0f59a0 100644 >> >--- a/tools/testing/selftests/mm/split_huge_page_test.c >> >+++ b/tools/testing/selftests/mm/split_huge_page_test.c >> >@@ -609,9 +609,16 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, >> > assert(fd_size % sizeof(buf) == 0); >> > for (i = 0; i < sizeof(buf); i++) >> > buf[i] = (unsigned char)i; >> >- for (i = 0; i < fd_size; i += sizeof(buf)) >> >- write(*fd, buf, sizeof(buf)); >> >- >> >+ for (i = 0; i < fd_size; i += sizeof(buf)) { >> >+ ssize_t written; >> >+ >> >+ written = write(*fd, buf, sizeof(buf)); >> >+ if (written != sizeof(buf)) { >> >+ ksft_perror("write testfile"); >> >+ close(*fd); >> >+ goto err_out_unlink; >> >> Maybe we can "goto err_out_close" and remove the close() here? > >AI review suggested the same: > https://sashiko.dev/#/patchset/20260512074924.27721-1-agarwal.vineet2006%40gmail.com > >And it complained about the handling of short writes in the added code. > >> Apart from this, I found on error writing to /proc/sys/vm/drop_caches in below, >> it just goto err_out_unlink, which left fd open. > >Not understanding - cab you please describe more completely? > I mean do this below. diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index 460fa1f606fd..f30402ece608 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -469,7 +469,7 @@ static int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, } if (write(*fd, "3", 1) != 1) { ksft_perror("write to drop_caches"); - goto err_out_unlink; + goto err_out_close; } close(*fd); On error writing this fd, /proc/sys/vm/drop_caches, we forget to close it. >> How about fix that at the same time. >> >> Generally, the change look good. >> -- Wei Yang Help you, Help me