From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 51B4835975 for ; Fri, 22 May 2026 02:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779417056; cv=none; b=Pl7YaH4jpwEZJHJSaBrgRdZRskVAx5Wc2T11d7wppP5QKat/WfFKljUIcVnYNgdONQr/UbB4VtRc4eadNJL+vr7Ntt+XHZyjBbvoCx6m9JLTsHXg6Rd8UsXANHXd6dCPFf6mfLzGOoAuIBo9Igy7bNqn8DgDGa3aZFk2o5TXkeM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779417056; c=relaxed/simple; bh=JlAMzr2xikoexAXyuk8T7ILbBNiLCnPyDXeh3P0WP8Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IvLCxQKaTmMDyBxG0RIlxyNSvFlt7BBFxlcOlWxCLm0kp2nQ/jhBLP6lr0/h6Udhi0nH66RD9h9W+mUPUIu1XyLsSvcrODG11wTfAFQRroqgCCkiaNSHscHGgJVnMqcAay/8flYioCJfWV/FkAewiF6FFjHLbyolXvOVR0mfbMA= 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=uUx+J4o8; arc=none smtp.client-ip=95.215.58.183 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="uUx+J4o8" Message-ID: <73ecdf3d-b570-409f-8337-a0cc1b4c6bcf@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779417053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=enZ07UUD/dUvPxdM28XuPg5nVhcBIDCqUxCVn7GaHkI=; b=uUx+J4o8nnyoKeh/N/7P6AhF3Rw1Uq+7o3h84Q8MltYeqoXUHp0hK4wY2bgSulGOGq3tTC OHjClnYtV2KLFy4c5df57NsJPFCYUzvYJB4pu/VvqP0l39sH+UGw55PdPlzvZZXlU1fa1Z Rn9sRAnPNPM68hASVmlvM54qT4W9lN0= Date: Fri, 22 May 2026 10:30:33 +0800 Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2 3/4] memcg: int16_t for cached slab stats To: Shakeel Butt , Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Alexandre Ghiti , Joshua Hahn , Harry Yoo , Meta kernel team , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot References: <20260522011908.1669332-1-shakeel.butt@linux.dev> <20260522011908.1669332-4-shakeel.butt@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: <20260522011908.1669332-4-shakeel.butt@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 5/22/26 9:19 AM, Shakeel Butt wrote: > Currently struct obj_stock_pcp stores cached slab stats in 'int' which > is 4 bytes per counter on 64-bit machines. Switch them to int16_t to > shrink the cached metadata. > > The existing PAGE_SIZE flush in __account_obj_stock() bounds *bytes at > PAGE_SIZE on 4KiB and 16KiB page archs, well within int16_t. On 64KiB > pages PAGE_SIZE is well above S16_MAX so that flush never fires, and a > sufficiently long run of accumulations would overflow the cache. Add > an explicit S16_MAX guard before each add: when the next add would > push abs(*bytes) past S16_MAX, fold the cached value into @nr and > flush directly via mod_objcg_mlstate() before the accumulation. > > Fixes: 01b9da291c49 ("mm: memcontrol: convert objcg to be per-memcg per-node type") > Tested-by: kernel test robot > Signed-off-by: Shakeel Butt > Reviewed-by: Harry Yoo (Oracle) > --- > > Changes since v2: > - Collected tags > > mm/memcontrol.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > Acked-by: Qi Zheng Thanks!