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 15AA031716B for ; Thu, 26 Mar 2026 09:21:31 +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=1774516892; cv=none; b=IsJ17c6b6mbuOwnTYnCY31M6MFtyXtrRt7BZCnYDNSHRrHB44CIm0NCIHVFL0LnLs73uI2O+guvk7crQwonASsn+Nv5Eo+5HsKmFyWa14tlwOrWGhcr8tEMdSHSDvH/pIK07YWDuFgu6gC1RFRML+kMYvozI1hrsuaZnkuzUzUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774516892; c=relaxed/simple; bh=Irfd1dWVokwwTNpyGi/dp36i3kLufKB6DgUtTAqXdRY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eN57tlOxSDPm9b2A8DT2roxnvJlj9m0+2OTSveyCLG2ec3/5NRSx7RzWBry0jTFihvtPznIzcGyVkSeD9qd6I0y4aIcUaiS0rAOTz4gIYPWM5uJ5SMWTP6kQqiTcBGV9L1isr80eoVJ7joGxmhRUdrxmIXIg77YdaHx/So6p0qQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X8uHhCcd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X8uHhCcd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51FD2C19423; Thu, 26 Mar 2026 09:21:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774516891; bh=Irfd1dWVokwwTNpyGi/dp36i3kLufKB6DgUtTAqXdRY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=X8uHhCcddWNC2IfjOnRye9t3PX0WFxiaJdOtwE/AQYicekeENPkYDRSPp2r3Hi6pb rO1k81Fhf7fRcd68dQjz+bk2+zYfg7ZnOYYaRJLIpCySJq5khmxTgmA5kaM2DFJCCb cwTbA428S3Hymg31+a4ZpMDHam34d9Ohi7tvlGsBeMEeqh/tXTtZC3h/ec8knSRm4f IAhdJRp/PHp9Ezy8M2iVaPxuWFBxNswefEVoB5HHbKSwYpzHttu6B+cnJ83vHHMTb4 M07DHYP/NdWebyFYWLnHshrfI6b+A7xdk1nr974KgQ1jaB/cKamszSTodpKo4oZ22x 9kqiXKIAjHpAw== Date: Thu, 26 Mar 2026 09:21:23 +0000 From: "Lorenzo Stoakes (Oracle)" To: Qi Zheng Cc: hannes@cmpxchg.org, hughd@google.com, mhocko@suse.com, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, david@kernel.org, ziy@nvidia.com, harry.yoo@oracle.com, yosry.ahmed@linux.dev, imran.f.khan@oracle.com, kamalesh.babulal@oracle.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, chenridong@huaweicloud.com, mkoutny@suse.com, akpm@linux-foundation.org, hamzamahfooz@linux.microsoft.com, apais@linux.microsoft.com, lance.yang@linux.dev, bhe@redhat.com, usamaarif642@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng , "Harry Yoo (Oracle)" Subject: Re: [PATCH v2 4/4] mm: memcontrol: fix unexpected massive positive number in memcg_state_val_in_pages() Message-ID: References: <54c2b09c-84f8-4118-96a6-acc13ca2f245@lucifer.local> 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: <54c2b09c-84f8-4118-96a6-acc13ca2f245@lucifer.local> On Thu, Mar 26, 2026 at 09:16:50AM +0000, Lorenzo Stoakes (Oracle) wrote: > /* Get the absolute value of (val * unit / PAGE_SIZE). */ > res = mult_frac(abs(val), unit, PAGE_SIZE); > /* Round up zero values. */ > res = res ?: 1; > /* Retain sign. */ > return val < 0 ? -res : res; (If you think the comments are too much, you can drop them, and the code essentially spells it out anyway) Cheers, Lorenzo