Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: Hongfu Li <hongfu.li@linux.dev>
Cc: SJ Park <sj@kernel.org>,
	akpm@linux-foundation.org, david@kernel.org, liam@infradead.org,
	lihongfu@kylinos.cn, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-mm@kvack.org,
	ljs@kernel.org, mhocko@suse.com, rppt@kernel.org,
	shuah@kernel.org, surenb@google.com, vbabka@kernel.org
Subject: Re: [PATCH v2] selftests/mm: Drop duplicate test_seal_mprotect_two_vma_with_gap() call
Date: Fri,  7 Aug 2026 17:15:20 -0700	[thread overview]
Message-ID: <20260808001521.1467-1-sj@kernel.org> (raw)
In-Reply-To: <20260807071533.48130-1-hongfu.li@linux.dev>

On Fri,  7 Aug 2026 15:15:33 +0800 Hongfu Li <hongfu.li@linux.dev> wrote:

> > > ---
> > > v2:
> > > - update ksft_set_plan(88) to 87 to match the actual number of tests
> > >   after removing the duplicate call.
> > 
> > I wonder if there could be an automated way for this.  Obviously not a question
> > to the author but just my loud thought.
> 
> Glad you brought this up, I totally agree with your thought.
> 
> Something like the below refactor could achieve that automation:
> 
> +typedef void (*test_fn)(void);
> +typedef void (*test_fn_seal)(bool seal);
> +
> +static const struct {
> +    test_fn_seal fn;
> +    bool seal;
> +} tests_seal[] = {
> +    { test_seal_mprotect, false },
> +    { test_seal_mprotect, true },
> ...
> +};
> +
> +static const test_fn tests[] = {
> +    test_seal_addseal,
> +    test_seal_unmapped_start,
> ...
> +};
> +
> +
>  int main(void)
>  {
> ...
> -       ksft_set_plan(87);
> +       ksft_set_plan(ARRAY_SIZE(tests) + ARRAY_SIZE(tests_seal));
> +       for (size_t i = 0; i < ARRAY_SIZE(tests); i++)
> +               tests[i]();
> +       for (size_t i = 0; i < ARRAY_SIZE(tests_seal); i++)
> +        tests_seal[i].fn(tests_seal[i].seal);

Thank you for sharing your great idea.

> 
> Though I'm still unsure whether this extra complexity is really worthwhile.

Agreed.  I believe it is good to have this as is for now.

If we have to add such automation, I think kselftest framework is a better
place to change, than each test.


Thanks,
SJ


  reply	other threads:[~2026-08-08  0:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06  3:08 [PATCH v2] selftests/mm: Drop duplicate test_seal_mprotect_two_vma_with_gap() call Hongfu Li
2026-08-07  0:31 ` SJ Park
2026-08-07  7:15   ` Hongfu Li
2026-08-08  0:15     ` SJ Park [this message]
2026-08-07  6:00 ` Anshuman Khandual

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=20260808001521.1467-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=hongfu.li@linux.dev \
    --cc=liam@infradead.org \
    --cc=lihongfu@kylinos.cn \
    --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=rppt@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox