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 E1C2CC83F1A for ; Fri, 11 Jul 2025 12:20:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 579ED6B00A2; Fri, 11 Jul 2025 08:20:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 551236B00A3; Fri, 11 Jul 2025 08:20:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 468106B00A4; Fri, 11 Jul 2025 08:20:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 351FA6B00A2 for ; Fri, 11 Jul 2025 08:20:03 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CDFC25CFE0 for ; Fri, 11 Jul 2025 12:20:02 +0000 (UTC) X-FDA: 83651890644.18.EEEECAB Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf06.hostedemail.com (Postfix) with ESMTP id C0AAE18000D for ; Fri, 11 Jul 2025 12:20:00 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nEb3ybwA; spf=pass (imf06.hostedemail.com: domain of lianux.mm@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=lianux.mm@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752236400; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TtD/R9U6PRpAzS1nHpzjgk1+bYjlX29GjraDajvp0u0=; b=rGNftiE90ZGn4K18EIJ1LT1ZvE3ec4LmFVV9yc6ApB3VgwF1ZRe8s1RjRoNp0Fs2W5mDVa UqweAnGONdHNEVOZtGI8FvPCx7DqlqrIld5XPDgLId0sjxiZSGnsWbPsO4+dC7hIF3ll4G T/Kmkese9+idxozn+/UnigYH20RCLgk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nEb3ybwA; spf=pass (imf06.hostedemail.com: domain of lianux.mm@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=lianux.mm@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752236400; a=rsa-sha256; cv=none; b=Ray5qP1jSSNirqXJoa72j+h4fXaMc3kmONRf44raIojKs31FFw8VEdQ0U84vYy+ICxPowc 39SS9Ba5q/mU8yJWLLdli/RxRxQ/MIpj9qSAbQEqGkI1n06yskY9K0iSr8khp1nJc3m+qZ 9nrmILUg/Q5suAvzc+e1GBCDDecYW88= Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-747e41d5469so2199161b3a.3 for ; Fri, 11 Jul 2025 05:20:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752236399; x=1752841199; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TtD/R9U6PRpAzS1nHpzjgk1+bYjlX29GjraDajvp0u0=; b=nEb3ybwAYBdMpog6Af1aVSzdEbe298HEHYNuPpKW1T7f5oknreXSr7IdoXvfQu3oFs PWvJjhVstpKUCzwFwo0k/sXZl1Z9LR5Nio4FpoED2f0BfdyKHhNTr82Dgn+hOQ0XQa8a UE3CO5hXjxEdLUYSJFJV/7NlX/8wne5oNLctpegbOZSgaAyyxexVlqZ0Ei3fw9f8QVYD S0AjUTiIrnLwV33/jFV7nzWcTmT7hTcIqumseklUSEdkev/9FBAbmy+3PLxTtJOM1rRq 2aUv04RSzS1LCakU6CAuT8Gloxdy+bCVN47rw6sOQar4+P8qvOfek5E9hauwdFZ28Ewq PkDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752236399; x=1752841199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TtD/R9U6PRpAzS1nHpzjgk1+bYjlX29GjraDajvp0u0=; b=fQFBsruBEIXsXzQK5xNyFb1m/7gulHtA3Q2hHrC5NGfqjdn8OFrDMQR8LZ30sQ1qtY TLDAM964zka9SkTepWepveHne4R1qsrDIOn4+c/37cEuvoHIxMvp9UbbQF/tPM8TaONb sWokG9pACmbnZrVmZyRdIXlgTZDWezISdlOoka/YfM/PAKLcRsMzrcKGpLdHteY735D0 Tq77AUPGBc5JHpdTnCXvKXImzfraR93fLxanaHnmK5o03qZ2e/2ZfG1a5CxC4NmdX78a xhQ9ZItXgsy0U+bhu8GtXfJ9ssxk16m6BLJumAkHmvQKJOH90VBulreqsaz0apOlzTNJ N/0g== X-Forwarded-Encrypted: i=1; AJvYcCVbnGsSCNt2Yp/zWjZioZnUSvc29s1FqRKgIT/nriPCAsN1NfPbcRF+myGq8ZLjwArWeNM6hVHFYA==@kvack.org X-Gm-Message-State: AOJu0YzWWfIL8EPfzGGdg85R3ynA7qNMzRiE6rvqbTjzJLqQP0g0HPzc QG/AOJZOAQXPecJetXENwh/OA2/bsRrQ60HFMbj9hvXsoxn27bif+O/r X-Gm-Gg: ASbGnctnYMv/6Njvkq4rlQzVRNyHD2JJfZnRw7nGEHnLqgpKTIaWqHWhZh2npHahbHl WLwPn4hLmCNq1lzwzuaQKE7rzd+xHc3UcRx2WOFfQQxGx0/Gv0NRAG9YCrVyObmtViemnZarq48 PkWxmtxg8zrAZSPxVfoY1LMAg+gXGbODqfQ2XPbmvJ0Jhs6/eAy2pT81RWbJn0wxPo42YHaN2QW 8edWzJevLF5L9WTs+S74Zo+iNy17cAczgk5W3JSaeTOLm6MiDcfWusddvqVh7YWgdhUOPJFzD1H w+K0KImv6aKlW9VOtWpKALZSm6RKQQyQBsJaRx1Ccjmv4f0ngdh1sRoNob9a9rjGdpXBie7YrIS G4kp1Xiumh3sY1Cc2luKYc78s6bGfz/pqKcEo4i3yQkT5E1dQ X-Google-Smtp-Source: AGHT+IFir+KTTk8mgUXFq5lbtUVSMfktmgJYRFls6w9p8Eajyy/4y3kuXXHD32P4jlxeEkBaynv8ew== X-Received: by 2002:a05:6a21:3318:b0:1fa:9819:c0a5 with SMTP id adf61e73a8af0-231363657d3mr4445241637.11.1752236399289; Fri, 11 Jul 2025 05:19:59 -0700 (PDT) Received: from DESKTOP-GIED850.localdomain ([114.247.113.178]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b3bbe6bd97fsm4963163a12.36.2025.07.11.05.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jul 2025 05:19:58 -0700 (PDT) From: wang lian To: broonie@kernel.org Cc: Liam.Howlett@oracle.com, akpm@linux-foundation.org, brauner@kernel.org, david@redhat.com, gkwang@linx-info.com, jannh@google.com, lianux.mm@gmail.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, lorenzo.stoakes@oracle.com, p1ucky0923@gmail.com, ryncsn@gmail.com, shuah@kernel.org, sj@kernel.org, vbabka@suse.cz, zijing.zhang@proton.me, ziy@nvidia.com Subject: Re: [PATCH v3] selftests/mm: add process_madvise() tests Date: Fri, 11 Jul 2025 20:19:48 +0800 Message-ID: <20250711121952.17380-1-lianux.mm@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=yes Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C0AAE18000D X-Stat-Signature: 89w73h7wjaqrxosnrseuydpbuhxnrzns X-Rspam-User: X-HE-Tag: 1752236400-964713 X-HE-Meta: U2FsdGVkX18arOojfRtB4Mff6eZJnzKYnaOOZHBCKRGI8KytD9brllULlImepOJ04uzgD+c27z/9BBwv2dUGkl3LPOPJ5Zg3+PPND98TyhBEFN4mnA6GDG2Ye5Q7bBV8bOfcx73NsjhqMbBYIs7WLYbEK7IZHewsKcAP6kd6ZkiWPsvZ/Sg4CvVcqVG3VBR0J4K8ejA1zehlitbX9X5FH/GkTkIXyeGRBeTf/Q9sgoZsNhSk0P7vDsdDjvpSiK3mSmXeicykStfWzZ2NyRGQ5vh6072H7z/Kusbud5ERkU+toA19uGunn5ctr/+mDVvHO+m8vCCxd8TpMMHH6hWQl70z67drk8EMnKO4fM0ytGAVgfAXihCGx5msm3BkWgiBDe6Zvtf9Tn6Ly6waZzN13v8TXYakECjErkN0fj6tLZnarOP4LRjRBoIr5D3ChYaCa0An05U7I3cPHDknz2+mHdqMl8m7BPPYHLIwI/DNtwGiG80VIr99Lu+T2Wz+Q3GeMuGNm7rgHel/MZLWPjBVimEhSNs2q9HjkBcZREDNSM1XPGIn3+Lnx/W5cWEobndQR0hsX/4WvPvTJ9ZsNRIu5Ev5y9Bw8SumyHW9LEeTbSm3UI6V71BqV2tefnj8cVn9oWAUu9Oolrt2il85c6dXAI0n143qXnvqsAG/VL9ZAYc7SumeH347ynH1CU7wE/rxdO0DANYgfpNTDs8EpP+loGeRGlWJQjf2JTJ7kgfwcfIRBDqq6vFc/jXxDMZLLckLAFaHDrvfQ5IhfkOvv68aN2uFvibVTB/QvZus2E90wxahoj80YxOOG8OG6XEyNLHYnIExpW5jcRO+MUQGBFRu/ocp287YgOOdY4qT2/oZ51XKIiCs0R35oFmUR8Yow85HKGcqPRjUGy/KxXWbpNsXuJROAiXqZLEtDJn/2i5KA7Y4kxJdJdv+OuqYytXRbyAW0odTPBQThOYHbgmvVci dGVM3/p3 9YMDc0v3e76+oPmi2vJd6ts8slnCmXtBWZc6f8RD7PNx6LC3GiSqCZ/rXhYu+oiPY1OVyRJBFblCFBDUchoTDR6hwX326HEIHdEyfy89W84c7QiCFYSYq4z+pAEpoKdHpBQu++uf+7/ZFwJw9OfZVN5TbRMtMfBedSsgl8DflGsLA525UpWvcfQUxFYtTsKKl1sYKhr2p9VPfgVwHO/DJLOTQDbKDzklW7SsETRzJAd/1Way7Ry/XKoUxQ7ALIfSNu8IsEwaQd/vbHvFrb0bQ6PiWe10Z5EWmTZAp/fu/Bhswo3T/xzgVouH1IPBMMrdY2FOVCQ1/Slfd9IjSqblOg6fMaUyPjxiQSDKofgna36474I72S+n/y7n0zQkTpfKqIMUFAsivdAMZoc7j+Cd2IR4dkugpuz7YJMW3aonUPUU4yhWdewDxC/qFHpdx3+g7JIs5cMzoXMcM16E4HYk+4Xlg9Zu1rE45T0ELUvTc2taTrILjfIXL9kr1C+zExUgLjje8M9V8g8Fgkhl0uOUgWEfTiUkgJpEkWCPicC0VsZX02kfwwutRgk7ycqFgVWgIVAHh 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: Hi Mark Brown, > 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. Thanks for the suggestion. I’ll split this out into a separate patch that just moves the helper to vm_util.c, and follow up with the new test in a second patch. > > +#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). You're right, and I’ve seen build issues due to that as well. I’ll drop and define PIDFD_SELF locally to avoid requiring installed headers. > > + ret = read(pipe_info[0], &info, sizeof(info)); > > + if (ret <= 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. Understood. I’ll convert this and other cases to use SKIP() and ensure the test consistently uses the test harness macros. > > + if (errno == EAGAIN) { > > + ksft_test_result_skip( > > + "THP is 'always', process_madvise returned EAGAIN due to an expected 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. I’ll revise this to use ASSERT/EXPECT, and separate error output from test result strings, as you suggested. > > + * 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. That makes sense. I’ll break this out into multiple smaller tests so each case reports independently. > > + pidfd = 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. Thanks, I’ll switch to EXPECT_* where appropriate to allow multiple checks per test case. Thanks again for the detailed review! Best regards, Wang Lian