From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (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 DA15539E190 for ; Wed, 29 Jul 2026 19:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785353795; cv=none; b=EMH/SrKibCXQN3OxlR/hjXBkEDwYj5Ic48uUtvTs/Xfl5C9aTIOm5vxz7GUqLqjfWu2brR/Af59SKpi2DShTjH+fNjdcApewpqbY1U/o/cINdbZIYc4RrQPPJxFtbD8bYjDFWKV3Nym4OnAJicJGEyi/nVqZp+FlggS4xoBR/e8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785353795; c=relaxed/simple; bh=QhXxzcZQQJSceml1UPzDn3CIyRDudke50j/KDUb9bgs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ehfrJAaOPIxWRtj/KPYLDUFR9P31j2eqr/4ZwJi6Wowp/szVDl1uSRozm01Hi1t8llJkZ9DW46tuplfMJs5FvOagUzccGr2ZMur2LSe1kJOp1LZsr8cU4oEE1LkjCOLNWwkucIcewAjy34h2AmfG5sR+upHMxdwdaSWv7h1Iq1g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=Sei55sEf; arc=none smtp.client-ip=209.85.160.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="Sei55sEf" Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-51c928bf172so9512761cf.3 for ; Wed, 29 Jul 2026 12:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1785353790; x=1785958590; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=YFlfsyL868lT/j3agJwNORpNx5tokno15i4G5m1Hupc=; b=Sei55sEfJ4MBMjvAjR0CD/ghrZG6hKIPAwn+uXJA/q6lrbBFOH/aK5yNX53wFr26W+ ATXBTBFvZghntXcKWyYS3YGv4v9BvSf+v/CDU1hQqEEFkCABw/5TVo6WkvhhAOEGNaxw m5oq9ai9smgvlzzkMM/GhdObu06WOYcqoenQnPArfYrcyVpH2qtSgS3KgxgjIouAaBSz XAxNZfiPdvV9c25pDRKEXRnDJQq7dupSw7BJlEipgmmvkGXbBo2FQnVWn1+s1olz275P az3LpkcE9Ed3mb8trDMTYZQNwOQLPrdo62mJT+eRHAMqetw9p6ZaWlVAifFrJ7GUfIUX xwNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785353790; x=1785958590; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YFlfsyL868lT/j3agJwNORpNx5tokno15i4G5m1Hupc=; b=B8Rb//QOaKpNwa/4q8/vD7lgvGL0jc6HH7nhnQH/l/VDonS25I3I75Vm7FRCKvYQNl zbAmpHbfgaDxhQ2LhjnVa7Vi9r1Cg8Pm5ZtpEpuu26IwtPtfpWGM7vsxnphImKMrt3/a SmecDP5wwH+9DcpmdNQ57A5zlwLTzORHDJ9ngorW6OT5zj/LmtlISaBEMYB+vEMjIWIN r8brFpEVG0RSyV6oBRfuy2aJe9GZaAqR925KkJpBzAfiG070l7wU//3GO9P8B5wStILc piiUJ8WUmhHGR7A9Z+rBlkLtgwHyg4Nzo9KOYiYfOYdju0S6HXkiXQYuc6ydGyki7Xw1 U98A== X-Forwarded-Encrypted: i=1; AHgh+RpM9sNI85Pqg9cA8JkdXFKwlmKF0I7VusyrIjT2JqbaiUbTZ/CZnUecx/Xh1MsmOcOaTWgmRFAb6FsR8Zw=@vger.kernel.org X-Gm-Message-State: AOJu0YwX+0OcB5BDylYvOc+lkcXHRZFgQOWZ3ijJxDG0fFQuOprbWnwL s0NdJKuyT1qg9RRyhB6342aVOxjcmmGFT98Lcg6PbPyYrxpw+2GEZwn8cq4DFTJgk9Q= X-Gm-Gg: AR+sD10v7nggomyVP+R4XBd+Vrar9mVj6UDMXKWtOoyF3vgUtU8WihSJadnDofQC7fX 6h1wkI6ZHG1ljSUmTYAYIBjyODsEJ0NVd+/ehONde/bc3kHMLkAEjKDan3drmiTJNfmylmhU5eX HsON5HYnj3svx191W+nr6ul9b/2brighO32449V1KYniaDKcZxsywfbxgkORBR3dkCvn8Zq9MIa YT2AFxSqrVmRyhQSNxQrNXyxAezwC8c5mfK1x2MkJs11pcY2SS4/KNMhhJioe8pDuyXJoa5c7Ua uxVzRVUKfwH78x0v+4uzPQPs2B6219j2ypBcTJGY5yxtiLzV4rI7GjbvOKj3ttNcu8hzMSvVOHX hhtqYKr3TVwhvCx2Il2bN+igBl/4kt2lB2/jYfng1EXX2fMe3zHc5V3umHBZ5JZyY+Pz+hhwPBK OJ+0rPfgikfaPr+6+XTFrwGuKFYXNoAULSyNfyTRM+yXZCDQZPMz4cN3+Hj+I= X-Received: by 2002:a05:622a:1ba2:b0:528:15e:d1d4 with SMTP id d75a77b69052e-529d709c7bdmr77022001cf.4.1785353790549; Wed, 29 Jul 2026 12:36:30 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-529e2b1a1ddsm25903541cf.5.2026.07.29.12.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 12:36:29 -0700 (PDT) Date: Wed, 29 Jul 2026 15:36:28 -0400 From: Johannes Weiner To: Andrew Morton Cc: Michal Hocko , Guopeng Zhang , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Guopeng Zhang Subject: Re: [PATCH] mm: memcg: stop reclaim when a limit update is superseded Message-ID: References: <20260724021805.1234583-1-guopeng.zhang@linux.dev> <615d091c-bd3b-4686-817e-5b29756542ff@linux.dev> <20260729121137.7b451d2d00ca5a389ebeb848@linux-foundation.org> 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: <20260729121137.7b451d2d00ca5a389ebeb848@linux-foundation.org> On Wed, Jul 29, 2026 at 12:11:37PM -0700, Andrew Morton wrote: > On Wed, 29 Jul 2026 10:02:22 +0200 Michal Hocko wrote: > > > > > Is this trying to replicate any real workload? One would expect that > > > > writers to limit do some sort of coordination otherwise the exact > > > > behavior is not really well defined. > > > > > > > > > > No, this was not motivated by a reported production workload. We found > > > it through automated randomized testing for our cgroup observability > > > work and reduced it to the reproducer above. > > > > This is an important detail to be mentioned in the changelog. Describing > > motivation for a change is really important, especially if it has direct > > impact in user interface behavior. > > I've been adding details to the changelog as they are revealed to us. > Below is the state of play. > > I await maintainer guidance on how to proceed with this! > > The worst-case effects look pretty bad actually. Should I add cc:stable? > > > From: Guopeng Zhang > Subject: mm: memcg: stop reclaim when a limit update is superseded > Date: Fri, 24 Jul 2026 10:18:05 +0800 > > kernfs serializes file operations only per open file, so separate open > files can update the same memory.high or memory.max file concurrently. > Both handlers store the new limit before synchronous reclaim, but continue > to use the writer's local target in the reclaim loop. If another writer > raises or removes the limit, the first writer can continue reclaiming > toward a stale target. > > For memory.max, this can leave the writer looping indefinitely once > reclaim retries are exhausted. The OOM path sees sufficient margin under > the current limit and returns true without killing, while the writer still > compares usage against its stale target and records another OOM event. > > Check the current limit at the start of each reclaim iteration and stop if > it no longer matches the writer's target. > > Reproducer: > > Populate a cgroup with anonymous memory and disable swapping. Lower > memory.max from one open file, then restore it to "max" through another > open file after the new limit becomes visible. > > Without the patch, the first writer remains blocked and repeatedly > increments the OOM event counter. With the patch, it returns normally. > > This was not motivated by a reported production workload. We found it > through automated randomized testing for our cgroup observability work > and reduced it to the reproducer above. > > Link: https://lore.kernel.org/20260724021805.1234583-1-guopeng.zhang@linux.dev > Fixes: 8c8c383c04f6 ("mm: memcontrol: try harder to set a new memory.high") > Fixes: b6e6edcfa405 ("mm: memcontrol: reclaim and OOM kill when shrinking memory.max below usage") > Signed-off-by: Guopeng Zhang > Acked-by: Tao Cui > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Muchun Song > Cc: Roman Gushchin > Cc: Shakeel Butt > Signed-off-by: Andrew Morton This looks good to me. If the culprits had been more recent, it might have made sense to split this in two, one for each Fixes. But it's 4.6 and 5.5, so I'd assume any still alive backport target would want them both at this point anyway. Acked-by: Johannes Weiner