From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C24AC83F1B for ; Thu, 10 Jul 2025 13:42:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA3AF6B0088; Thu, 10 Jul 2025 09:42:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7A926B0089; Thu, 10 Jul 2025 09:42:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB6FF6B008A; Thu, 10 Jul 2025 09:42:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A972A6B0088 for ; Thu, 10 Jul 2025 09:42:26 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3D0CB10B034 for ; Thu, 10 Jul 2025 13:42:26 +0000 (UTC) X-FDA: 83648469492.30.1CBFF94 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf05.hostedemail.com (Postfix) with ESMTP id 8469E10000D for ; Thu, 10 Jul 2025 13:42:24 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ocyvsUWm; spf=pass (imf05.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752154944; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8+dncgPqAHvdkvAXPV9oF1a2T6em6EhSIYAwldRSOTE=; b=fFk3pMEpKRy7w8aD4+v0Efus70HBF6GtXnCyFyX6OMNyKYR0n28gSaeq1s4LEqPyevWF71 ZhEOE3CO+kd8ppIFhWsZgi4bBt0el2fHw0bWR7jlwb94X4CzWWp3Tf4hTCqKCH7nBL8vlM /+TA6UJl9sdvwm0HYdp7ZjmktVZPSZE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752154944; a=rsa-sha256; cv=none; b=0MkA/g3riGNQ6Nuek+3Fz3gTghu9H7/boM4+YH7zVv6od7frC5wWAo/LIiB4VGlXEMy5Py FnVEQRDZ4wumw2TpSBZKGfQV2bxiSpxvxFGiEZ67fDEiuRmtid/XhdvyunIGRnkm995cZg 2gR4vFL92edZ0ohpDS9bzhYRiTjUXe8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ocyvsUWm; spf=pass (imf05.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id B2744A54ACF; Thu, 10 Jul 2025 13:42:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1081EC4CEE3; Thu, 10 Jul 2025 13:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752154943; bh=O2w/SrY5DG8vVLbvJhBCppXT7i2aFFp1w3GpcEDJZYc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ocyvsUWmeyX/jVDFjgpEWtnc/Geca+FwAttm6LhCXok/nvdY5B3MLJeEfxLULOq8J yu5SM/k7mG4ZxtVw5Gp7MQ17e3Yl3y2+mRXkWZOuXCt8keVFRfLM9GbgxxdlZxlfgR 8opp23wa8A5Nzo1830EWrtVfwLV9EYhQsPQcCNdGOYMtZmXKFUHsKHGuqdEGOinCTk Es/C2bZ3ndP9uFsi05hsdAvUpViWsW4YF3W4JzfPH6ZZHzrHjPYV/T49HxB2VuRheh rEf4VMbTcvrAI2X606n8ARgQWJbuluoeBKKuClkLrTuTeDpn4RXsUa7cWivE5wqQ5F 13TBFAVlUvOvA== Date: Thu, 10 Jul 2025 14:42:20 +0100 From: Mark Brown To: wang lian Cc: akpm@linux-foundation.org, ziy@nvidia.com, lorenzo.stoakes@oracle.com, david@redhat.com, sj@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, Liam.Howlett@oracle.com, brauner@kernel.org, gkwang@linx-info.com, jannh@google.com, p1ucky0923@gmail.com, ryncsn@gmail.com, vbabka@suse.cz, zijing.zhang@proton.me Subject: Re: [PATCH v4] selftests/mm: add process_madvise() tests Message-ID: References: <20250710112249.58722-1-lianux.mm@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JxpZ0RoUQgE6HJjN" Content-Disposition: inline In-Reply-To: <20250710112249.58722-1-lianux.mm@gmail.com> X-Cookie: Do not cut switchbacks. X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 8469E10000D X-Stat-Signature: suynwowj1o6kbmwko1647zh4qf5r6r8i X-HE-Tag: 1752154944-44014 X-HE-Meta: U2FsdGVkX18BhjmbhBqu7mi+ol1bGneVcxzshR/lWcNZrUhVyee33ecRkR7xsIJlXRNykGpJt4ENjCkpu9qUVYA8dkvnZ2WFm3rFopiO+zG/1Xk0ilD8ooLEm1FJSmMS8Zu0xvjKTo5xgj5v241bf8HlxutQyT2Q2ibqTF8MI4yVeNMQk4+iaMzh1urN67PzK4HrtW1c5frXAtBlcqpT56hf+Fo5g2evrAPUR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ZPoyp/m2tqi3Nnp5oqAnYqBe+dxML1gw9w7aHirolo1d0Jn+U23aBZ5vBK9FirxF5EV9R193jjkLazLyxr5hUouKUDsARJjEClNN0VdCb4a2lv1ZW0szhxB1X56DYchYUg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: --JxpZ0RoUQgE6HJjN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 10, 2025 at 07:22:49PM +0800, wang lian wrote: > Add tests for process_madvise(), focusing on verifying behavior under > various conditions including valid usage and error cases. > --- a/tools/testing/selftests/mm/guard-regions.c > +++ b/tools/testing/selftests/mm/guard-regions.c > -static void handle_fatal(int c) > -{ > - if (!signal_jump_set) > - return; > - > - siglongjmp(signal_jmp_buf, c); > -} I see from looking later in the patch that you're factoring this out of the guard regions test into vm_util.c so that it can be used by your new test. This is good and sensible but it's a bit surprising, especially since your changelog only said you were adding a new test. It would be better to split this out into a separate refactoring patch that just does the code motion, as covered in submitting-patches.rst it's better if changes just do one thing. > +#include > +#include Does this work without 'make headers_install' for the systems that were affectd by missing headers? Lorenzo mentioned that we shouldn't depend on that for the mm tests (I'm not enthusiastic about that approach myself, but if it's what mm needs). > + ret =3D read(pipe_info[0], &info, sizeof(info)); > + if (ret <=3D 0) { > + waitpid(self->child_pid, NULL, 0); > + ksft_exit_skip("Failed to read child info from pipe.\n"); > + } If you're using the harness you should use SKIP() rather than the ksft APIs for reporting test results. Don't mix and match the result reporting APIs, harness will call the ksft_ APIs appropriately for you. > + /* > + * MADV_COLLAPSE lost the race to khugepaged, which > + * likely held a page lock. The kernel correctly > + * reports this temporary contention with EAGAIN. > + */ > + if (errno =3D=3D EAGAIN) { > + ksft_test_result_skip( > + "THP is 'always', process_madvise returned EAGAIN due to an expecte= d race with khugepaged.\n"); > + } else { > + ksft_test_result_fail( > + "process_madvise failed with unexpected errno %d in 'always' mode.\= n", > + errno); > + } Similarly, to fail use an ASSERT or EXPECT. Note also that when using the ksft_ API for reporting results each test should report a consistent test name as the string, if you want to report an error message print it separately to the test result.=20 This applies throughout the program. > +/* > + * Test process_madvise() with various invalid pidfds to ensure correct = error > + * handling. This includes negative fds, non-pidfd fds, and pidfds for > + * processes that no longer exist. > + */ This sounds like it should be a series of small tests rather than a single omnibus test, that'd result in clearer error reporting from test frameworks since they will say which operation failed directly rather than having to look at the logs then match them to the source. > + pidfd =3D syscall(__NR_pidfd_open, child_pid, 0); > + ASSERT_GE(pidfd, 0); This is particularly the case given the use of ASSERTs, we'll not report any issues other than the first one we hit. --JxpZ0RoUQgE6HJjN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmhvwzIACgkQJNaLcl1U h9B9Iwf/fvpOkRD8HNeEFM0rMg/Fod98NV2uGuIyKgK6Hl5gAzErKqNHVMxsEKY7 AMsj9qiWyBGvjCYarJAQOUjaODDhIQneeAfsLpNekzU/zlP9ATZywL8zRJEjGKxO vOgpThb5FtX5BIk9enHmbMavCkqHVis/H/SW394EAdWOuRRHuQ8xx3OWIh49H0a/ EG60q8SJzg9/f/F0RiznX03w+tnPsGgCM4cfW4bLs6WKqIL0ZSj1bUswJ2jE7VrI HBYQF7e87dy+NB2myp5c1mlxI52xxgAJnrp6HjyyqlnqITo+MOb+BPnawTaZ1rpY srJpsaZtAtnsj2j3tiugOU4nhnoqZg== =uYWZ -----END PGP SIGNATURE----- --JxpZ0RoUQgE6HJjN--