All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Konstantin Khorenko" <khorenko@virtuozzo.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David Hildenbrand" <david@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Alistair Popple" <apopple@nvidia.com>,
	"Dan Williams" <djbw@kernel.org>
Cc: linux-mm@kvack.org, nvdimm@lists.linux.dev
Subject: Re: [PATCH 2/2] selftests/mm: test fork of a device DAX PUD
Date: Thu, 22 Oct 2026 18:11:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-181904@kernel.org> (raw)
In-Reply-To: <20261021-vstor-150143-copy_huge_pud-folio-refcount-v1-2-8bd88551f9be@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/mm: sysfs_ul() and rss_file_kb() duplicate vm_util.h helpers
--

commit d02ba4b69f400c48de47f25c78208f1cfd2fe974
Author: Konstantin Khorenko <khorenko@virtuozzo.com>

selftests/mm: test fork of a device DAX PUD

This commit adds the fork_dax_pud selftest to verify that fork() properly
accounts a copied device DAX PUD mapping in the child's RssFile when page
tables are copied due to a guard region in the VMA.

> diff --git a/tools/testing/selftests/mm/fork_dax_pud.c b/tools/testing/selftests/mm/fork_dax_pud.c
> new file mode 100644
> index 0000000000000..1fcf46341ace2
> --- /dev/null
> +++ b/tools/testing/selftests/mm/fork_dax_pud.c
[ ... ]
> +#include "kselftest.h"
> +#include "vm_util.h"
> +
> +#define SZ_1G		(1UL << 30)
> +#define DAX_SYSFS	"/sys/bus/dax/devices"
> +
> +static sigjmp_buf sigbus_jmp;
> +
> +static void sigbus_handler(int sig)
> +{
> +	siglongjmp(sigbus_jmp, 1);
> +}
> +
> +static unsigned long sysfs_ul(const char *dev, const char *attr)
> +{
> +	char path[PATH_MAX], buf[64];
> +	unsigned long val = 0;
> +	FILE *f;
> +
> +	snprintf(path, sizeof(path), DAX_SYSFS "/%s/%s", dev, attr);
> +	f = fopen(path, "r");
> +	if (!f)
> +		return 0;
> +	if (fgets(buf, sizeof(buf), f))
> +		val = strtoul(buf, NULL, 0);
> +	fclose(f);
> +	return val;
> +}
> +
> +static bool dax_dev_ok(const char *path)
> +{
> +	const char *name = strrchr(path, '/');
> +
> +	name = name ? name + 1 : path;
> +	return sysfs_ul(name, "align") == SZ_1G &&
> +	       sysfs_ul(name, "size") >= 2 * SZ_1G;
> +}
> +
> +static long rss_file_kb(void)
> +{
> +	char line[256];
> +	long kb = -1;
> +	FILE *f = fopen("/proc/self/status", "r");
> +
> +	if (!f)
> +		return -1;
> +	while (fgets(line, sizeof(line), f))
> +		if (sscanf(line, "RssFile: %ld", &kb) == 1)
> +			break;
> +	fclose(f);
> +	return kb;
> +}

[Severity: Medium]
fork_dax_pud.c includes vm_util.h and links against vm_util.c, which already
provide shared helpers for reading sysfs attributes and parsing
/proc/self/status:

tools/testing/selftests/mm/vm_util.h:
bool check_for_pattern(FILE *fp, const char *pattern, char *buf, size_t len);
uint64_t read_pmd_pagesize(void);
unsigned long rss_anon(void);
...
int write_sysfs(const char *file_path, unsigned long val);
int read_sysfs(const char *file_path, unsigned long *val);

In main() -> dax_dev_ok() -> sysfs_ul(), the test hand-rolls sysfs unsigned
long reading with fopen(), fgets(), strtoul(), and fclose() to read the
device align and size attributes under /sys/bus/dax/devices/<dev>/.

Similarly, in the child path of main() -> rss_file_kb(), the test manually
scans /proc/self/status for RssFile using fopen(), fgets(), and sscanf().

Could sysfs_ul() use read_sysfs() (or read_file()), and could rss_file_kb()
use check_for_pattern() or be added alongside rss_anon() in vm_util.c instead
of reimplementing these helpers locally?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021-vstor-150143-copy_huge_pud-folio-refcount-v1-0-8bd88551f9be@virtuozzo.com?part=2

      reply	other threads:[~2026-10-22 18:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 18:10 [PATCH 0/2] mm/huge_memory: take a reference on a device DAX PUD copied by fork Konstantin Khorenko
2026-10-21 18:10 ` [PATCH 1/2] mm/huge_memory: take a reference on a folio " Konstantin Khorenko
2026-10-25 12:52   ` David Hildenbrand (Arm)
2026-10-21 18:10 ` [PATCH 2/2] selftests/mm: test fork of a device DAX PUD Konstantin Khorenko
2026-10-22 18:11   ` sashiko-bot [this message]

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=sashiko-outbox-181904@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=david@kernel.org \
    --cc=djbw@kernel.org \
    --cc=khorenko@virtuozzo.com \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.