From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-65.mta1.migadu.com [95.215.58.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 064112045AD for ; Tue, 1 Sep 2026 00:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788221445; cv=none; b=LjDikphJIrqwWJGAjzwhGzOR/Op+s6RkNlZgeet/HgKRxO/J9xPOWxrGHSg/02jpUdPMZcmmw1QSEwC5O0nN3p+ANCbxOU2X8ja5QHwjuQ6APXGTn7Fa0vB8onDs/jUdBljL8a40ekceKOsm0WMATgU4ZEaGjNNYt3pe9BOvkvc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788221445; c=relaxed/simple; bh=VQbX7qhToOCvYZznvKl5y3u5IYIy1k7DJaMvEMrWF3o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Y3IvIDu8s13CRIu8fYvDfnZcZ1oMR7O/CmnLPFwnNojyTt0S1Jis01KPqnSCxTPCntrMyX20rfMdAz5nF0S5eMiKdlmFxPaiaHQ2/KSHTFw0Vt+XhJlqJCR4j+JWm4I1xywvwVx9kVKFdI04xR+Z7IvKioICOiDVfSStwVdTA3Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=SKJJ3Wb1; arc=none smtp.client-ip=95.215.58.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="SKJJ3Wb1" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=VQbX7qhToOCvYZznvKl5y3u5IYIy1k7DJaMvEMrWF3o=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1788221439; v=1; x=1788826239; b=SKJJ3Wb1HujSZQSBqPuzVTR/xJGO1tdDt880sMmlpXUZEantBEzeHhnlcfOtSxPZwbKHcCFN uZ2j4wQjhFYmtuxLnMhjv2WCJvMDFh6S2XD6L1HLzmhGmZAyk3qhO+wlAZyMHWgqPD15xuKmXVM UuV2JXP0GvzSLw3esOCf5mtI= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 69816a8805fc6742; Tue, 01 Sep 2026 00:10:29 +0000 X-Mizu-Trace-ID: 69816a8805fc6742 X-Migadu-Flow: FLOW_OUT Date: Mon, 31 Aug 2026 17:10:24 -0700 From: Shakeel Butt To: David Stevens Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] memcg: Don't call schedule_work when no spinning is allowed Message-ID: References: <20260831234339.280376-1-stevensd@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260831234339.280376-1-stevensd@google.com> On Mon, Aug 31, 2026 at 04:43:39PM -0700, David Stevens wrote: > Memcg charging can be done from any context, but calling schedule_work() > isn't safe from an NMI. If memory.high is breached from a context where > spinning isn't allowed, use irq_work to schedule the reclaim work. > > Fixes: 3ac4638a734a ("memcg: make memcg_rstat_updated nmi safe") > Signed-off-by: David Stevens Did you hit this issue or just code inspection? I assume this is the done_restock code path. > --- > include/linux/memcontrol.h | 1 + > mm/memcontrol.c | 12 +++++++++++- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 8170bb8066a2..036d973ceca6 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -219,6 +219,7 @@ struct mem_cgroup { > spinlock_t peaks_lock; > > /* Range enforcement for interrupt charges */ > + struct irq_work high_irq_work; Instead of adding more complexity, let's just return if we can not spin on done_restock path.