Re: [PATCH v5 17/36] mm/vmscan: disallow reclaim of private node memory

[email protected]
Newsgroups dev.linux.lists.damon,dev.linux.lists.nvdimm,org.kernel.vger.kvm,org.kernel.vger.linux-cxl
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Soft-limit reclaim bypasses the new private node filter, allowing eviction on private nodes.
--

--- Patch [17]: [PATCH v5 17/36] mm/vmscan: disallow reclaim of private node memory ---
commit 9fc4bff86adde3091fee2924952f9af9700e6308
Author: Gregory Price <[email protected]>

mm/vmscan: disallow reclaim of private node memory

This commit attempts to prevent reclaim on private nodes by adding a filter
to shrink_node().

> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index e26c6931f5fde..86b2334c23b98 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -6141,6 +6141,13 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
>  	struct lruvec *target_lruvec;
>  	bool reclaimable = false;
>  
> +	/*
> +	 * Private nodes do not support reclaim by default, filtering here
> +	 * captures all normal reclaim paths that may attempt eviction.
> +	 */
> +	if (node_is_private(pgdat->node_id))
> +		return;
> +

[Severity: High]
Does this filter successfully capture all normal reclaim paths?

When the system uses memcg v1 and a cgroup exceeds its soft limit, global
direct reclaim in shrink_zones() or kswapd in balance_pgdat() will invoke
memcg1_soft_limit_reclaim(). This bypasses shrink_node() entirely:

mm/vmscan.c:shrink_zones() {
    ...
    nr_soft_reclaimed = memcg1_soft_limit_reclaim(zone->zone_pgdat,
                                                  sc->order, sc->gfp_mask,
                                                  &nr_soft_scanned);
    ...
}

This leads to mem_cgroup_shrink_node() directly calling shrink_lruvec()
without checking if the node is private:

mm/vmscan.c:mem_cgroup_shrink_node() {
    ...
    shrink_lruvec(lruvec, &sc);
    ...
}

Will this allow unintended eviction on private nodes during soft limit reclaim?

>  	if ((lru_gen_enabled() || lru_gen_switching()) && root_reclaim(sc)) {
>  		memset(&sc->nr, 0, sizeof(sc->nr));
>  		lru_gen_shrink_node(pgdat, sc);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.