From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52B0917FAC2 for ; Wed, 14 May 2025 22:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747260191; cv=none; b=XWi76sjyP/5mbB9SGI22bLJpySSyGpfTuBL9Ep3FOx1aOcqeLg0Tu+uNwi85l8WgDjQf6RfsPKDbjFHeVudCuiwEM1wheHnIE0I+Ha7LIB911xRp7B3LyWNkKIAA0gXZg4mtf+loNq5WxMkl4BJWoMEEmA/MWP2sJi48um+s9zo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747260191; c=relaxed/simple; bh=/26msIkYdJNfpbtac9t/bS9V+xP9BkxuDt5DY5mcGqA=; h=Date:To:From:Subject:Message-Id; b=Gdug8C5ioJARMtfKLjyGpTPSyi/3BAtvAm6UEX1a/Aa4F6PDE83NuoN2g1xtvRnU6fwmnLq46XGAEp4VMLRLlCt04OdidyrLxRZvVodKB3qtkqgnGco5IuXA3vPPUyWLVGkJST6tGQUjL5qjzmchzISAsmTVUOvE/foQSjnbGlM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=uUA1EVPP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="uUA1EVPP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD161C4CEE3; Wed, 14 May 2025 22:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1747260190; bh=/26msIkYdJNfpbtac9t/bS9V+xP9BkxuDt5DY5mcGqA=; h=Date:To:From:Subject:From; b=uUA1EVPPuh47+K8PlkDnBlGquJ1f5avj4+YVwkMx60CIFuZtxqZqO1Xd8tT3CtQIR 8z2M3nqM886tfMfHj5CssUjJugmc8yFpi+uFh11XRlvi/VPNr72Dpgtt7LRDvEnlBs 6CYlT4ckd3sbWpjMQYFyiiwoV6AOkr3fpbqfueaI= Date: Wed, 14 May 2025 15:03:10 -0700 To: mm-commits@vger.kernel.org,vbabka@suse.cz,roman.gushchin@linux.dev,muchun.song@linux.dev,mhocko@kernel.org,hannes@cmpxchg.org,bigeasy@linutronix.de,ast@kernel.org,shakeel.butt@linux.dev,akpm@linux-foundation.org From: Andrew Morton Subject: + memcg-make-__mod_memcg_lruvec_state-re-entrant-safe-against-irqs.patch added to mm-new branch Message-Id: <20250514220310.AD161C4CEE3@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: memcg: make __mod_memcg_lruvec_state re-entrant safe against irqs has been added to the -mm mm-new branch. Its filename is memcg-make-__mod_memcg_lruvec_state-re-entrant-safe-against-irqs.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/memcg-make-__mod_memcg_lruvec_state-re-entrant-safe-against-irqs.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Shakeel Butt Subject: memcg: make __mod_memcg_lruvec_state re-entrant safe against irqs Date: Wed, 14 May 2025 11:41:56 -0700 Let's make __mod_memcg_lruvec_state re-entrant safe and name it mod_memcg_lruvec_state(). The only thing needed is to convert the usage of __this_cpu_add() to this_cpu_add(). There are two callers of mod_memcg_lruvec_state() and one of them i.e. __mod_objcg_mlstate() will be re-entrant safe as well, so, rename it mod_objcg_mlstate(). The last caller __mod_lruvec_state() still calls __mod_node_page_state() which is not re-entrant safe yet, so keep it as is. Link: https://lkml.kernel.org/r/20250514184158.3471331-6-shakeel.butt@linux.dev Signed-off-by: Shakeel Butt Acked-by: Vlastimil Babka Cc: Alexei Starovoitov Cc: Johannes Weiner Cc: Michal Hocko Cc: Muchun Song Cc: Roman Gushchin Cc: Sebastian Andrzej Siewior Signed-off-by: Andrew Morton --- mm/memcontrol.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- a/mm/memcontrol.c~memcg-make-__mod_memcg_lruvec_state-re-entrant-safe-against-irqs +++ a/mm/memcontrol.c @@ -727,7 +727,7 @@ unsigned long memcg_page_state_local(str } #endif -static void __mod_memcg_lruvec_state(struct lruvec *lruvec, +static void mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, int val) { @@ -745,10 +745,10 @@ static void __mod_memcg_lruvec_state(str cpu = get_cpu(); /* Update memcg */ - __this_cpu_add(memcg->vmstats_percpu->state[i], val); + this_cpu_add(memcg->vmstats_percpu->state[i], val); /* Update lruvec */ - __this_cpu_add(pn->lruvec_stats_percpu->state[i], val); + this_cpu_add(pn->lruvec_stats_percpu->state[i], val); val = memcg_state_val_in_pages(idx, val); memcg_rstat_updated(memcg, val, cpu); @@ -775,7 +775,7 @@ void __mod_lruvec_state(struct lruvec *l /* Update memcg and lruvec */ if (!mem_cgroup_disabled()) - __mod_memcg_lruvec_state(lruvec, idx, val); + mod_memcg_lruvec_state(lruvec, idx, val); } void __lruvec_stat_mod_folio(struct folio *folio, enum node_stat_item idx, @@ -2527,7 +2527,7 @@ static void commit_charge(struct folio * folio->memcg_data = (unsigned long)memcg; } -static inline void __mod_objcg_mlstate(struct obj_cgroup *objcg, +static inline void mod_objcg_mlstate(struct obj_cgroup *objcg, struct pglist_data *pgdat, enum node_stat_item idx, int nr) { @@ -2537,7 +2537,7 @@ static inline void __mod_objcg_mlstate(s rcu_read_lock(); memcg = obj_cgroup_memcg(objcg); lruvec = mem_cgroup_lruvec(memcg, pgdat); - __mod_memcg_lruvec_state(lruvec, idx, nr); + mod_memcg_lruvec_state(lruvec, idx, nr); rcu_read_unlock(); } @@ -2847,12 +2847,12 @@ static void __account_obj_stock(struct o struct pglist_data *oldpg = stock->cached_pgdat; if (stock->nr_slab_reclaimable_b) { - __mod_objcg_mlstate(objcg, oldpg, NR_SLAB_RECLAIMABLE_B, + mod_objcg_mlstate(objcg, oldpg, NR_SLAB_RECLAIMABLE_B, stock->nr_slab_reclaimable_b); stock->nr_slab_reclaimable_b = 0; } if (stock->nr_slab_unreclaimable_b) { - __mod_objcg_mlstate(objcg, oldpg, NR_SLAB_UNRECLAIMABLE_B, + mod_objcg_mlstate(objcg, oldpg, NR_SLAB_UNRECLAIMABLE_B, stock->nr_slab_unreclaimable_b); stock->nr_slab_unreclaimable_b = 0; } @@ -2878,7 +2878,7 @@ static void __account_obj_stock(struct o } } if (nr) - __mod_objcg_mlstate(objcg, pgdat, idx, nr); + mod_objcg_mlstate(objcg, pgdat, idx, nr); } static bool consume_obj_stock(struct obj_cgroup *objcg, unsigned int nr_bytes, @@ -2947,13 +2947,13 @@ static void drain_obj_stock(struct obj_s */ if (stock->nr_slab_reclaimable_b || stock->nr_slab_unreclaimable_b) { if (stock->nr_slab_reclaimable_b) { - __mod_objcg_mlstate(old, stock->cached_pgdat, + mod_objcg_mlstate(old, stock->cached_pgdat, NR_SLAB_RECLAIMABLE_B, stock->nr_slab_reclaimable_b); stock->nr_slab_reclaimable_b = 0; } if (stock->nr_slab_unreclaimable_b) { - __mod_objcg_mlstate(old, stock->cached_pgdat, + mod_objcg_mlstate(old, stock->cached_pgdat, NR_SLAB_UNRECLAIMABLE_B, stock->nr_slab_unreclaimable_b); stock->nr_slab_unreclaimable_b = 0; _ Patches currently in -mm which might be from shakeel.butt@linux.dev are memcg-memcg_rstat_updated-re-entrant-safe-against-irqs.patch memcg-move-preempt-disable-to-callers-of-memcg_rstat_updated.patch memcg-make-mod_memcg_state-re-entrant-safe-against-irqs.patch memcg-make-count_memcg_events-re-entrant-safe-against-irqs.patch memcg-make-__mod_memcg_lruvec_state-re-entrant-safe-against-irqs.patch memcg-no-stock-lock-for-cpu-hot-unplug.patch memcg-objcg-stock-trylock-without-irq-disabling.patch