linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Suresh Chandrappa <suresh.k.chandrappa@gmail.com>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: nphamcs@gmail.com, hannes@cmpxchg.org, shuah@kernel.org,
	 linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] selftests: cachestat: add tests for mmap
Date: Tue, 8 Jul 2025 23:13:01 +0530	[thread overview]
Message-ID: <CAAMO5phQQ8wMdOfuW40No4kpK5Rn2o4_414F8cgUrQ5NBsCcng@mail.gmail.com> (raw)
In-Reply-To: <20250707212603.992104-1-joshua.hahnjy@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3028 bytes --]

Hi Joshua,

Thanks for the feedback! In the first patch, both shmem and mmap operations
are present, but I hadn’t introduced any logic to distinguish between them
yet. That distinction is added in the second patch through a new API.

> +	if (type == FILE_MMAP){
> +		char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> +		if (map == MAP_FAILED) {
> +			ksft_print_msg("mmap failed.\n");
> +			ret = false;
> +			goto close_fd;
> +		}
> +		for (int i = 0; i < filesize; i++) {
> +			map[i] = 'A';
> +		}
> +		map[filesize - 1] = 'X';

I initially included the first version of the patch mainly to gather early
feedback and ensure all review comments were addressed. Based on the input,
I plan to consolidate the changes into a single patch that reflects the
final version.

Thanks,

Suresh K C

On Tue, Jul 8, 2025 at 2:56 AM Joshua Hahn <joshua.hahnjy@gmail.com> wrote:

> On Mon,  7 Jul 2025 20:55:56 +0530 Suresh K C <
> suresh.k.chandrappa@gmail.com> wrote:
>
> > From: Suresh K C <suresh.k.chandrappa@gmail.com>
> >
> > Add a test case to verify cachestat behavior with memory-mapped files
> > using mmap(). This ensures that pages accessed via mmap are correctly
> > accounted for in the page cache.
> >
> > Tested on x86_64 with default kernel config
>
> Hey Suresh,
>
> Thanks for the second version with the updates, sorry that I missed the
> first time you sent this patch.
>
> [...snip...]
>
> >       if (fd < 0) {
> > -             ksft_print_msg("Unable to create shmem file.\n");
> > +             ksft_print_msg("Unable to create file.\n");
>
> NIT: I saw that you change this in the second part of the patch. However,
> why
> not just include it in this patch? I feel that it would be good practice
> to keep the kerenl in a "correct" state, even in between patches belonging
> to the same series. If someone were to just apply this patch but not the
> next (however unlikely that is), then they will not see the description of
> what file type they failed to create. Just my 2c, no need to change this if
> you don't think this is important.
>
> [...snip...]
>
> > +     if (type == FILE_MMAP){
> > +             char *map = mmap(NULL, filesize, PROT_READ | PROT_WRITE,
> MAP_SHARED, fd, 0);
> > +             if (map == MAP_FAILED) {
> > +                     ksft_print_msg("mmap failed.\n");
> > +                     ret = false;
> > +                     goto close_fd;
> > +             }
> > +             for (int i = 0; i < filesize; i++) {
> > +                     map[i] = 'A';
> > +             }
> > +             map[filesize - 1] = 'X';
>
> NIT: Likewise, I don't know if there is a good reason to include this,
> only to
> remove it in the second patch. Perhaps it would be best to just remove it
> in this patch, so you don't have to delete it later?
>
> Please let me know what you think. Have a great day!
> Joshua
>
> Sent using hkml (https://github.com/sjp38/hackermail)
>

[-- Attachment #2: Type: text/html, Size: 4734 bytes --]

  reply	other threads:[~2025-07-08 17:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07 15:25 Suresh K C
2025-07-07 15:25 ` [PATCH v2 2/2] selftest: improve mmap test clarity Suresh K C
2025-07-07 21:26 ` [PATCH v2 1/2] selftests: cachestat: add tests for mmap Joshua Hahn
2025-07-08 17:43   ` Suresh Chandrappa [this message]
2025-07-09 17:03     ` Joshua Hahn
2025-07-09 17:12       ` Suresh Chandrappa
  -- strict thread matches above, loose matches on Subject: below --
2025-07-01 18:49 Suresh K C

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=CAAMO5phQQ8wMdOfuW40No4kpK5Rn2o4_414F8cgUrQ5NBsCcng@mail.gmail.com \
    --to=suresh.k.chandrappa@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=shuah@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