All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Houghton" <jthoughton@google.com>,
	"Will Deacon" <will@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Muchun Song" <muchun.song@linux.dev>,
	"Oscar Salvador" <osalvador@suse.de>,
	"Andrew Morton" <akpm@linux-foundation.org>
Cc: "Kefeng Wang" <wangkefeng.wang@huawei.com>,
	"Nikos Nikoleris" <nikos.nikoleris@arm.com>,
	"Linu Cherian" <linu.cherian@arm.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Ryan Roberts" <ryan.roberts@arm.com>,
	"Nanyong Sun" <sunnanyong@huawei.com>,
	"Yu Zhao" <yuzhao@google.com>,
	"Frank van der Linden" <fvdl@google.com>,
	"David Rientjes" <rientjes@google.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH v3 14/19] selftests/mm: Add HugeTLB vmemmap optimization stress test
Date: Mon, 23 Nov 2026 04:08:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-228643@kernel.org> (raw)
In-Reply-To: <20261122184453.2668189-15-jthoughton@google.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] selftests/mm: offlined memory blocks not re-onlined in
  stress_phase()
- [Low] selftests/mm: unchecked mktemp failure in
  hugetlb_vmemmap_stress.sh
--

commit 15090370906fbd4c082668bfc18a1ce3c873bcb2
Author: James Houghton <jthoughton@google.com>

selftests/mm: Add HugeTLB vmemmap optimization stress test

This commit adds a kselftest script that stresses HugeTLB vmemmap
optimization (HVO) across accounting, concurrent access, and fault-injection
phases.

> diff --git a/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh b/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh
> new file mode 100755
> index 0000000000000..b64fdb3ed7614
> --- /dev/null
> +++ b/tools/testing/selftests/mm/hugetlb_vmemmap_stress.sh
[ ... ]
> +orig_nr=$(cat "$hp_dir/nr_hugepages")
> +target_nr=$(( orig_nr + nr ))
> +marker="hvo-stress-$$-$(date +%s)"
> +tmpdir=$(mktemp -d)
> +pids=()

[Severity: Low]
What happens if mktemp -d fails here?  Because only set -u is active,
tmpdir becomes empty and hotplugger() appends to /hotplug in the root
directory (which cleanup() does not remove).

[ ... ]

> +hotplugger() {
> +	local blk state removable
> +
> +	while :; do
> +		for blk in /sys/devices/system/memory/memory*; do
> +			state=$(cat "$blk/state" 2>/dev/null)
> +			removable=$(cat "$blk/removable" 2>/dev/null || echo 1)
> +			[ "$state" = online ] || continue
> +			[ "$removable" = 1 ] || continue
> +			echo "$blk" >> "$tmpdir/hotplug"
> +			# A signal aborts a pending offline_pages(). Use
> +			# --foreground so that the writer stays in the worker's
> +			# process group and is killed by stop_workers().
> +			timeout --foreground 10 \
> +				sh -c "echo offline > $blk/state" 2>/dev/null
> +			echo online > "$blk/state" 2>/dev/null
> +			sleep 1
> +		done
> +	done
> +}
[ ... ]
> +cleanup() {
> +	local blk t
> +
> +	stop_workers
> +	for t in fail_hugetlb_vmemmap_pte; do
> +		[ -d "$(fa_dir $t)" ] && fa_disable $t > /dev/null
> +	done
> +	if [ -f "$tmpdir/hotplug" ]; then
> +		sort -u "$tmpdir/hotplug" | while read -r blk; do
> +			[ "$(cat "$blk/state")" = online ] ||
> +				echo online > "$blk/state" 2>/dev/null
> +		done
> +	fi
> +	# drain() also frees free surplus pages left by failed restores.
> +	drain > /dev/null
> +	rm -rf "$tmpdir"
> +}
> +trap cleanup EXIT
> +trap 'exit $KSFT_FAIL' INT TERM
> +
> +# Run a stress phase. $1: name, $2: fault attr to enable ("" for none).
> +stress_phase() {
> +	local name=$1 fa=$2 base after injected
> +
> +	if [ -n "$fa" ] && [ ! -d "$(fa_dir "$fa")" ]; then
> +		echo "SKIP: $name (no $(fa_dir "$fa"))"
> +		return
> +	fi
> +
> +	log "phase $name: ${duration}s"
> +	base=$(memmap_total)
> +	[ -n "$fa" ] && fa_enable "$fa"
> +	start_workers
> +	sleep "$duration"
> +	stop_workers
> +	if [ -n "$fa" ]; then
> +		injected=$(fa_disable "$fa")
> +		log "$name: injected $injected failures"
> +		[ "$injected" -gt 0 ] ||
> +			log "WARNING: $name: no failures injected"
> +	fi
> +
> +	drain || return
> +	after=$(memmap_total)
> +	if [ "$after" -ne "$base" ]; then
> +		fail "$name: memmap pages $after after drain, expected $base"
> +	else
> +		pass "$name"
> +	fi
> +}

[Severity: Medium]
Should memory blocks recorded in $tmpdir/hotplug be re-onlined at the end
of each stress_phase() (or in stop_workers()) rather than only in
cleanup() on script exit?

If SIGTERM from stop_workers() terminates hotplugger() after offlining a
block and before "echo online > $blk/state" runs, that block stays offline
during drain(), the post-phase memmap_total() check, and any subsequent
phase.  When page_ext is active (such as with -o and -m together),
offlining a block frees its section page_ext table and decrements
nr_memmap_pages until the block is re-onlined:

mm/page_ext.c:free_page_ext() {
    ...
	table_size = page_ext_size * PAGES_PER_SECTION;
	memmap_pages_add(-1L * (DIV_ROUND_UP(table_size, PAGE_SIZE)));
    ...
}

As a result, stress_phase() reads a lower memmap_total() than base and
reports a false accounting failure.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122184453.2668189-1-jthoughton@google.com?part=14


  reply	other threads:[~2026-11-23  4:09 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 18:44 [PATCH v3 00/19] Another attempt at HVO support on arm64 James Houghton
2026-11-22 18:44 ` [PATCH v3 01/19] arm64/pgtable: Clear AF with LDCLR on supported systems James Houghton
2026-11-22 18:44 ` [PATCH v3 02/19] hugetlb_vmemmap: Always flush TLB if needed upon PTE remapping James Houghton
2026-11-23  4:08   ` sashiko-bot
2026-11-24 16:37     ` James Houghton
2026-11-25  9:43       ` Muchun Song
2026-11-22 18:44 ` [PATCH v3 03/19] hugetlb_vmemmap: Leave pages partially HVOed upon restore failure James Houghton
2026-11-22 18:44 ` [PATCH v3 04/19] hugetlb_vmemmap: Use try_update_vmemmap_pte to update in-use PTEs James Houghton
2026-11-23  2:47   ` Muchun Song
2026-11-23 20:48     ` James Houghton
2026-11-24  2:29       ` Muchun Song
2026-11-24 16:29         ` James Houghton
2026-11-25  9:48           ` Muchun Song
2026-11-23  4:08   ` sashiko-bot
2026-11-24 16:39     ` James Houghton
2026-11-22 18:44 ` [PATCH v3 05/19] hugetlb_vmemmap: Allow architectures to dynamically disallow HVO James Houghton
2026-11-23  3:01   ` Muchun Song
2026-11-23 20:31     ` James Houghton
2026-11-24  2:31       ` Muchun Song
2026-11-22 18:44 ` [PATCH v3 06/19] hugetlb: Optimize bootmem folios that were not pre-HVOed James Houghton
2026-11-23  3:10   ` Muchun Song
2026-11-24 16:58     ` James Houghton
2026-11-25  9:37       ` Muchun Song
2026-11-25 16:09         ` James Houghton
2026-11-26  1:31           ` Muchun Song
2026-11-23  4:08   ` sashiko-bot
2026-11-24 16:55     ` James Houghton
2026-11-22 18:44 ` [PATCH v3 07/19] hugetlb_vmemmap: Allow architectures to make HVO enablement boot-time only James Houghton
2026-11-23  3:13   ` Muchun Song
2026-11-22 18:44 ` [PATCH v3 08/19] hugetlb_vmemmap: Expose whether HVO is enabled to architecture code James Houghton
2026-11-23  8:50   ` Muchun Song
2026-11-24 17:13     ` James Houghton
2026-11-25 11:24       ` Muchun Song
2026-11-25 16:26         ` James Houghton
2026-11-26  1:24           ` Muchun Song
2026-11-30 20:33             ` James Houghton
2026-11-22 18:44 ` [PATCH v3 09/19] arm64: Add bbm_through_af capability James Houghton
2026-11-23  4:08   ` sashiko-bot
2026-11-23 19:22     ` James Houghton
2026-11-22 18:44 ` [PATCH v3 10/19] arm64: Implement try_update_vmemmap_pte using the AF trick James Houghton
2026-11-22 18:44 ` [PATCH v3 11/19] arm64/mm: Align vmemmap to maximal folio size James Houghton
2026-11-23  3:22   ` Muchun Song
2026-11-24 17:25     ` James Houghton
2026-11-22 18:44 ` [PATCH v3 12/19] arm64: Support hugetlb vmemmap optimization James Houghton
2026-11-23  3:26   ` Muchun Song
2026-11-24 17:31     ` James Houghton
2026-11-23  4:08   ` sashiko-bot
2026-11-24 17:35     ` James Houghton
2026-11-22 18:44 ` [PATCH v3 13/19] hugetlb_vmemmap: Add fault injection for in-place vmemmap PTE updates James Houghton
2026-11-22 18:44 ` [PATCH v3 14/19] selftests/mm: Add HugeTLB vmemmap optimization stress test James Houghton
2026-11-23  4:08   ` sashiko-bot [this message]
2026-11-24 17:37     ` James Houghton
2026-11-22 18:44 ` [PATCH v3 15/19 DO-NOT-MERGE] hugetlb_vmemmap: Use try_populate_vmemmap_pmd for replacing in-use PMDs James Houghton
2026-11-22 18:44 ` [PATCH v3 16/19 DO-NOT-MERGE] arm64: Implement try_populate_vmemmap_pmd using AF trick James Houghton
2026-11-23  4:08   ` sashiko-bot
2026-11-24 17:39     ` James Houghton
2026-11-25 11:32       ` Muchun Song
2026-11-25 16:35         ` James Houghton
2026-11-26  1:47           ` Muchun Song
2026-11-30 21:16             ` James Houghton
2026-11-22 18:44 ` [PATCH v3 17/19 DO-NOT-MERGE] arm64: Drop BBML3 requirement for HVO James Houghton
2026-11-22 18:44 ` [PATCH v3 18/19 DO-NOT-MERGE] hugetlb_vmemmap: Add fault injection for in-place vmemmap PMD splits James Houghton
2026-11-22 18:44 ` [PATCH v3 19/19 DO-NOT-MERGE] selftests/mm: Add HVO pmd-split fault injection tests James Houghton

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-228643@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=david@kernel.org \
    --cc=fvdl@google.com \
    --cc=jthoughton@google.com \
    --cc=linu.cherian@arm.com \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=muchun.song@linux.dev \
    --cc=nikos.nikoleris@arm.com \
    --cc=osalvador@suse.de \
    --cc=rientjes@google.com \
    --cc=ryan.roberts@arm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sunnanyong@huawei.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=yuzhao@google.com \
    /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.