From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 532FBC8303D for ; Fri, 4 Jul 2025 18:22:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCE9F6B8068; Fri, 4 Jul 2025 14:22:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7E486B8067; Fri, 4 Jul 2025 14:22:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C45C16B8068; Fri, 4 Jul 2025 14:22:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AC54B6B8067 for ; Fri, 4 Jul 2025 14:22:28 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 37F6D124D8A for ; Fri, 4 Jul 2025 18:22:28 +0000 (UTC) X-FDA: 83627402376.06.627A660 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id AC5F6C0005 for ; Fri, 4 Jul 2025 18:22:25 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XgMNGEAA; spf=pass (imf22.hostedemail.com: domain of luizcap@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=luizcap@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751653345; h=from:from:sender: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:dkim-signature; bh=Ao5yV0OWlWrLaBBV5SLduZ6Vw0gfsxB0sugrEeYXGWQ=; b=ADzLeUNG/aUDz7ai/CoKToEc2olLnUK6D1x3LQ1GAwEaHgG5EhKb66wp6SFXbmButXJgcs 07KBJSIRTp7vt4WeLlLj2b2Kbb/5IXFOBDp8JFwikGJ8MJtIecitzVrbp3OrpOq4t7Amx/ Yy/qYLe5MTayFBbIlhIZn7p3JevjFfE= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XgMNGEAA; spf=pass (imf22.hostedemail.com: domain of luizcap@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=luizcap@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751653346; a=rsa-sha256; cv=none; b=rsc65thvSZAWvrPvPkEu9Wt415wkYbJYuqebMAxrPCUfNtZSeO+Lf13kQ1ju9CyXvuUhlR omGqnM+EOnAbGnI4xy0jNy+ivZXL82+v9RJfrLoPsmuPlFA5aiA9S7bfwIieaUHiGH+z7H VluRNDiSa2pzk4+NE0B114w1P/w03hg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751653345; 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=Ao5yV0OWlWrLaBBV5SLduZ6Vw0gfsxB0sugrEeYXGWQ=; b=XgMNGEAAaI3oNymZAVICo72kkLRH79Z9e1q3LzZONM7kv/FVFr5yIZSHX4euZ5oGMCOhiH 67EI4s5PqOcyaSNyh3VatP76IHSeToLPMzz1RbZ2oMGswxiLunwoccqHtCzAxqjD7ksBSw PnAnJNswBoVpoGBQ+FYL8+iDc1NGjKs= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-eX1bX2dKNu2tapR9BXW8jQ-1; Fri, 04 Jul 2025 14:22:24 -0400 X-MC-Unique: eX1bX2dKNu2tapR9BXW8jQ-1 X-Mimecast-MFC-AGG-ID: eX1bX2dKNu2tapR9BXW8jQ_1751653343 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6fab979413fso21590926d6.2 for ; Fri, 04 Jul 2025 11:22:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751653343; x=1752258143; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ao5yV0OWlWrLaBBV5SLduZ6Vw0gfsxB0sugrEeYXGWQ=; b=IBz201N2uTbeXwkU3Oy1LpLPSb2WWvSkHA1UgBqzSG/TFBQFwugul33lJYvDdfuQyr sAkJRNqK7uyi/XixM4Y0FmSN8470tNq56Qf4+GQipL+eS338gZeNi/gcO5cTmCm+At88 6nDJBPbX5BsJjh+SfpGybxhC2aOgJQc9c9Dn1hiT6vMTAC3JXFGN7y3dUgS79QQzGtbE rwGFMu1trqNuthi+TA4mtpkhtBUBdjoTKaen6ZmQNvX7dAJ+TxmMmvXoJmkpjRW+FKvI 72LwNEO01EaM7lOe2HhCsdNQ7du36LPQNV8oyxWcBm2GHvQz4Iwdh85ttEJbDGFx8HGH 6F6A== X-Forwarded-Encrypted: i=1; AJvYcCVPTQthSI7zvsin90x+EdRovWb993XmqMLWcytJQrYg8z9xhySnmBp48l9M/UMNVzBiKeWPk3/Rfg==@kvack.org X-Gm-Message-State: AOJu0YxMjFMV0zB0PZ1PY54/rV5ICZYMIueX9wxZ+no8U08Q+Gf94/S4 5OUzTO0OirOekc6I86LlGrSvixcinSGcWU5uIo+CnTkOjuIqV5t4JGuMyxE8kzRB0Z/mnFPnfB3 4FqIffcat/Bqf/PyLFwkpyx85ifbbw4HaRKhrz7zTKSsyebH15B1F X-Gm-Gg: ASbGncsMF2wJwzCp34iBRPJRv74/VEvYCIuIcf8aLLOWnFdDQpjCECOgYwiCuS7/fgp MTZHUrT+uuxvoW4sKDyKeZRrUt9Jl/8aRtf3e+DZ1TGFaZyFgzoc02aLtMOxqIHpqJNOv+goVpd HKYsF9zlFJt6pr4GSy0G4mNskbVBRAYF9nhxZeVQhOmLJja9Ldc8u7XB2mtAp0EJIZe9/SPoVlE YNSXOB9cB+qN3ZVey+HO6n3EG68+AK+MboCbrAPRMTDmb/5MN3GwoDiaR1oXScEyfzJJBP/KqQB uUvMvl+1/Wab07lnQicPzH6M X-Received: by 2002:a05:6214:e4b:b0:702:c15f:3291 with SMTP id 6a1803df08f44-702c6d7a145mr47717976d6.22.1751653343411; Fri, 04 Jul 2025 11:22:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOOAnVJ2nhxq4q+rgZ9MWxRastPRZ+F+UsTkduj/PWXspmSODVR5v/cT1qpEPk5qddOrytUA== X-Received: by 2002:a05:6214:e4b:b0:702:c15f:3291 with SMTP id 6a1803df08f44-702c6d7a145mr47717576d6.22.1751653342959; Fri, 04 Jul 2025 11:22:22 -0700 (PDT) Received: from [192.168.2.110] ([69.156.206.24]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702c4cd2c1esm16472856d6.50.2025.07.04.11.22.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jul 2025 11:22:22 -0700 (PDT) Message-ID: <34be0c05-a805-4173-b8bd-8245b5eb0df8@redhat.com> Date: Fri, 4 Jul 2025 14:22:11 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] mm: fix the inaccurate memory statistics issue for users To: Andrew Morton , Vlastimil Babka , Baolin Wang Cc: "Ritesh Harjani (IBM)" , Michal Hocko , david@redhat.com, shakeel.butt@linux.dev, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, rppt@kernel.org, surenb@google.com, donettom@linux.ibm.com, aboorvad@linux.ibm.com, sj@kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <87bjqx4h82.fsf@gmail.com> <890b825e-b3b1-4d32-83ec-662495e35023@linux.alibaba.com> <87a56h48ow.fsf@gmail.com> <4c113d58-c858-4ef8-a7f1-bae05c293edf@suse.cz> <06d9981e-4a4a-4b99-9418-9dec0a3420e8@suse.cz> <20250609171758.afc946b81451e1ad5a8ce027@linux-foundation.org> From: Luiz Capitulino In-Reply-To: <20250609171758.afc946b81451e1ad5a8ce027@linux-foundation.org> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: I3Jwp2oO6GYHjmu7LoVosFyoCqzGSz4Ywm1_-JuOJXA_1751653343 X-Mimecast-Originator: redhat.com Content-Language: en-US, en-CA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: bq8upf3tiisixdef4fzw8g337r39hqyk X-Rspamd-Queue-Id: AC5F6C0005 X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1751653345-29769 X-HE-Meta: U2FsdGVkX19dK3a3mcMfT9y3Rv0JiRRvA7Qe6TOrSgv2xVUBXEFBeNaX1mAAWyRb7+1Rbg/ATfdcE9oCtWb3+8ERVY/RMHUkqgOdml6riA+bTioX3cD74vJyympMAWF07UutwwX5Q57eYjag8l0tiVvOaPv/fMspUnTsDF3IfAoMYH1mA6yhqw6/zPipo/paengtyUj0C3UX4sQADtnsttRLx8SDbJsIl5hOiQ4MlJCQjIBHZ8wI7EMDMbcdds6/kjYmvizc0FzF5Uf8dnzmK2K5cFYd+CvFYWUxsU9HJXhNNKNPalCoC3wW6qW3/QzssPOgMMCKJilQNqtS65ohLyxvb3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3lm/YAc0/dNgaI2CqFAS8JNj+MMcrtHw4hXSn1YuySIs2CW0gHjbLkG46uErhYHrlVX8Fqudo04ytFW6/IBeMikL7xdNf4ZFFUly4/9a3zR6Yn8ndXEGE2n9trH7aYLipOYFxWjm8uoCLOKGe97IWl4Y X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025-06-09 20:17, Andrew Morton wrote: > On Mon, 9 Jun 2025 10:56:46 +0200 Vlastimil Babka wrote: > >> On 6/9/25 10:52 AM, Vlastimil Babka wrote: >>> On 6/9/25 10:31 AM, Ritesh Harjani (IBM) wrote: >>>> Baolin Wang writes: >>>> >>>>> On 2025/6/9 15:35, Michal Hocko wrote: >>>>>> On Mon 09-06-25 10:57:41, Ritesh Harjani wrote: >>>>>>> >>>>>>> Any reason why we dropped the Fixes tag? I see there were a series of >>>>>>> discussion on v1 and it got concluded that the fix was correct, then why >>>>>>> drop the fixes tag? >>>>>> >>>>>> This seems more like an improvement than a bug fix. >>>>> >>>>> Yes. I don't have a strong opinion on this, but we (Alibaba) will >>>>> backport it manually, >>>>> >>>>> because some of user-space monitoring tools depend >>>>> on these statistics. >>>> >>>> That sounds like a regression then, isn't it? >>> >>> Hm if counters were accurate before f1a7941243c1 and not afterwards, and >>> this is making them accurate again, and some userspace depends on it, >>> then Fixes: and stable is probably warranted then. If this was just a >>> perf improvement, then not. But AFAIU f1a7941243c1 was the perf >>> improvement... >> >> Dang, should have re-read the commit log of f1a7941243c1 first. It seems >> like the error margin due to batching existed also before f1a7941243c1. >> >> " This patch converts the rss_stats into percpu_counter to convert the >> error margin from (nr_threads * 64) to approximately (nr_cpus ^ 2)." >> >> so if on some systems this means worse margin than before, the above >> "if" chain of thought might still hold. > > f1a7941243c1 seems like a good enough place to tell -stable > maintainers where to insert the patch (why does this sound rude). > > The patch is simple enough. I'll add fixes:f1a7941243c1 and cc:stable > and, as the problem has been there for years, I'll leave the patch in > mm-unstable so it will eventually get into LTS, in a well tested state. Andrew, are you considering submitting this patch for 6.16? I think we should, it does look like a regression for larger systems built with 64k base page size. On comparing a very simple app which just allocates & touches some memory against v6.1 (which doesn't have f1a7941243c1) and latest Linus tree (4c06e63b9203) I can see that on latest Linus tree the values for VmRSS, RssAnon and RssFile from /proc/self/status are all zeroes while they do report values on v6.1 and a Linus tree with this patch. My test setup is a arm64 VM with 80 CPUs running a kernel with 64k pagesize. The kernel only reports the RSS values starting at 10MB (which makes sense since the Per-CPU counters will cache up to two times the number of CPUs and the kernel accounts pages). The situation will be worse on larger systems, of course.