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 B4615C369A1 for ; Tue, 8 Apr 2025 22:12:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E24CF6B00C5; Tue, 8 Apr 2025 18:12:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD3EB6B00C6; Tue, 8 Apr 2025 18:12:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9A746B00C7; Tue, 8 Apr 2025 18:12:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AC3436B00C5 for ; Tue, 8 Apr 2025 18:12:30 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 56402C1590 for ; Tue, 8 Apr 2025 22:12:30 +0000 (UTC) X-FDA: 83312276460.02.F329F48 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) by imf23.hostedemail.com (Postfix) with ESMTP id 8A315140008 for ; Tue, 8 Apr 2025 22:12:28 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="cErtYA/O"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.173 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744150348; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s2wPsDuusYDf71v3DeNeWAxNbKxR+CVPefFzBRS96uE=; b=IfU4YGmAnMw6ZTlx+ffmBrRwSBEP0WAb6e0Zb9AHkf9rFucjFvgVK9xGPsqRrct9nP1fe5 5nb13j/0SAKuQXPDvwxZmwUXguwRibMUHoUYp9VlWoD1KGxySbB0aQDoeH73oilGfuw56L 2oBFIHvnabd9JyZ6HhGcOwiknV/O7GA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="cErtYA/O"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.173 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744150348; a=rsa-sha256; cv=none; b=u2oE+8VE84drwGLSFytX8mbUKawb5elQpzjemsxP1tSqgBDQbysZCuS2j/kmEPAzPokhaC yE3ZkpbNhJ9R/LDpZEY+xXpnUUd4ktOGYzCPHnr3DfTv84eviiOKhSelCIV84eGMPgBXDT 3Pq8TIgJly4qARp3ZFBuoz1k7BxEYpk= Date: Tue, 8 Apr 2025 22:12:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1744150346; 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: in-reply-to:in-reply-to:references:references; bh=s2wPsDuusYDf71v3DeNeWAxNbKxR+CVPefFzBRS96uE=; b=cErtYA/O/BdV+KS0Mrqub2uMCUCXuY9uyQM2TrHpIEYBIISYN274V/rYMsjirEsFGl8XMD Ne8VwR4KwyOP14rQhu99BvvuyPOjMJ2dBYPMkXwZ5YdChxBgfyPcH80cs8pnScWKllFP+c ftBGvZgweM/tg3OaNzi06a5Ih90lVC8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Mathieu Desnoyers Cc: Sweet Tea Dorminy , Mateusz Guzik , linux-kernel@vger.kernel.org, Andrew Morton , "Paul E. McKenney" , Steven Rostedt , Masami Hiramatsu , Dennis Zhou , Tejun Heo , Christoph Lameter , Martin Liu , David Rientjes , christian.koenig@amd.com, Shakeel Butt , Johannes Weiner , Lorenzo Stoakes , "Liam R . Howlett" , Suren Baghdasaryan , Vlastimil Babka , Christian Brauner , Wei Yang , David Hildenbrand , Miaohe Lin , Al Viro , linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org, Yu Zhao , Matthew Wilcox Subject: Re: [RFC PATCH v2] Introduce Hierarchical Per-CPU Counters Message-ID: References: <20250408160508.991738-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250408160508.991738-1-mathieu.desnoyers@efficios.com> X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam01 X-Stat-Signature: aisgowuiewo8jpupqf6p9jocxes655kh X-Rspam-User: X-Rspamd-Queue-Id: 8A315140008 X-HE-Tag: 1744150348-633369 X-HE-Meta: U2FsdGVkX1/jpw7am8GinL/af1LmYStAqdw1y3Atv8SEuz3Ts8ELse68Zluj+aiQzfOWe0qs1dINek5Ct3TBpc/yfRIaUW49mmA9jbEEi3WTbXXNYgqa/DRcKb2DHKxh8ViwMAu3v/gzNnMkvY7WOlwy+doqW/Lnw34baksyjMN3dOcV9HNV3tGRfA8qGEoyvoXeiRp4c5pgmMBC4p+UYv5tC1S54KbA2RYqjmA+AmiyBKf1CoWhHoSPT5PtZp6u+28V7iErbstK7pXcE6naBjHHk/8HgXFo0qST791MLU1Mnt/Z3SqNScEz2o4aIoTCq8V1zNMKnlxOfW5yiOaJ1w2KFbBE6Xl3VxI4YgIKiOK+9V27C/NiUfBnzoZ6EZIDvuak/FGjOa6ZosK0efu8V9xfj+bKI/xn2IgkzSSwukEEEgjKbaenY2ZZ2cnZE2Urx8egZnvKeWFZd2RTpJWd3T+2wWwiyoN8Y9+FM62ERDxtq0N4A600l+KAdMgLkoSFd5w7FuqG6bBQFecGaM+SSmnd89f5ST7D5AsoMxHs7183if/9hOE0f98+lJSe0uP+Yz0/9CVmzEh0XEvJ46PLwakh/VcLhICkyJyzQtYj/MS6Q8vkNPgSjlFiWgx/dtJ6k5LQeA4VzqFBoJMYvhK3I9nkvufMkT3Rd7B9zooKZBabcK+7coAksK+2PqmNceX/PWxT5QvEBDeeL0lFfvz54P2ecJ8JBliQTVpo92ai1kvbkhsLJNUMfvtCnYQplu1p3iYACHmOTk4pidtbVAfkTVQjs/Ds25o+2ff4yOFn7bvzerkc9Rghfb7ZYo1Od+jklJqh2sj7y5bKRSVogax+VbB4oiJ1/K4i3ZPtXWLMy7fG1blAoAyzufUUdFom9WeJnp0HYoUQdiKit8wFSOIbMVTvVSoWkby55/dF2Qd5Lq8tZSsuMTEHn8jS76F3hF6SHEi7WDM7Ze2prUM9g0J 7cPTnkWC 2rSSraw7BYNNfFIRC8OXw9ulRNOjGLeGa0w87naLh0lsFyIP5IJXrBGd/dJpSfWpgXTEgtmfiwzU8Y5JBgg7PFm6y7LGBLFJXlg5jNAxidEK/8+rwnkiARKqUVcF6JBN6oT14egjbVMIvjrmXN/OvLzHt0+p0DbA7pGWmGolKtFSZBH2EKbHUHMvR9fzhIxAllLrWDJFxUXmrGBe4w5Ut+DgCnU18kL0w+DzEUEPs8nDkToZm6qMzRLvKkLHqqnVseu3Vs1rOJknntCOpqGnaXqOSNlvz+nqGG4wL X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, 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 Tue, Apr 08, 2025 at 12:05:08PM -0400, Mathieu Desnoyers wrote: > * Motivation > > The purpose of this hierarchical split-counter scheme is to: > > - Minimize contention when incrementing and decrementing counters, > - Provide fast access to a sum approximation, > - Provide a sum approximation with an acceptable accuracy level when > scaling to many-core systems. > - Provide approximate and precise comparison of two counters, and > between a counter and a value. > > It aims at fixing the per-mm RSS tracking which has become too > inaccurate for OOM killer purposes on large many-core systems [1]. It might be an overkill for the task from the memory overhead perspective. Sure, for a very large process on a large machine it makes total sense, but for smaller process it will waste a ton of memory. Also, for relatively small number of CPUs (e.g. 8) it's also an overkill from the complexity standpoint. But as an idea it makes total sense to me, maybe just applicable to some other tasks, e.g. global memory stats. For the RSS tracking I wonder if what we really need is to go back to the per-thread caching, but with some time-based propagation. E.g. a thread should dump their cached value on going to sleep or being rescheduled. This will bound the error to (64 * number of currently running threads), which should be acceptable. We can also think of making the central counter be an upper bound by increasing it first and moving the "pre-charged" value to per-thread counters. Thanks!