From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 221742E7BDC for ; Mon, 12 Jan 2026 19:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768247290; cv=none; b=U1/PHaaKtz1uFFeXa3TOCqh3XaLWOUr+Nkml/Y5x2yNFsk0mMEIiYR2P0FFEUZvo/FcVhl73rI9a0H7pCDLx+oxoBl22s5l1NZ+hGoJctQsxOdOxllKckDnRWQ4qBWJYEGABJVxgj4p0QiqTYkHxUvDyVwuoBQZuMrtLuq8WJCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768247290; c=relaxed/simple; bh=RVjiN4DP9fSW/O10it19QP2bn8wGkaJ6vL7xbjZI3Pw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o1ZR5az7//1+eusUM2wLwAyyrmHcgVjFfzbCmNROcmeBYH06pi96rYW25fIvW/BTZHP69Cl09LNCmaHRPmBV7ikqlcFgqDDlogQJeP9J6K3nTz2PHSBJIDAInzueBYHvRRE2vHN4Z1eHv3HaxWzfcYtQU80v4jCz864PKxCDeXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=TbhnRHZh; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="TbhnRHZh" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-432d2670932so2961389f8f.2 for ; Mon, 12 Jan 2026 11:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1768247287; x=1768852087; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BGyo51WmDqtagxgoVSIwRWG3W5A40tN9gD1xGhmOgu0=; b=TbhnRHZhvuPPC/Nc46X8GJ1IBvwjdJJMOIUtkfbafW2y4yr9G+wyGKjbEv+V13gVCA VkeLkrvAw+pyqs6M2bJ6TszAQQq+82tAIYZBw566J/8sgLDtg74LDtY2jEFJkjE7pIdI tBQ1rOCZwfyzCJnTU/0eW+XkIdgDg0grcvwGvxM+mQL4felbN1NfdydYdfjO0pbMsBfW vbEDpYs7rW4LWyPhQ4MFAsYGGX5Qu+1ahP89h46+dE/ZvwN8rO1rH+uUHztBcL1/OlUH F8p7MeYDSP1VdDZ2GNp4S76LUg8q3Jj5Lu4pv7G1WaLfFHUwnIF8qshDHhJJ5nkqu4Lg xF2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768247287; x=1768852087; h=in-reply-to:content-disposition: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; bh=BGyo51WmDqtagxgoVSIwRWG3W5A40tN9gD1xGhmOgu0=; b=MbTgibnBnxxZiCId43djEHngK52Uq96T4rpQGJygaL9JlajHgwaxQyHb5xrjlkoqKj dB/yn0xABsPeP/cJ59sVB/u4MpD1AEj7cHgDKA0NES1rL3frulk4lZtJjgmGbWwYIL6V p5+AU/Rffh3ov3cZ0pkLdX7ocKKKb7nPlQ/Ujg0eeQtBkcZxt7cFKx5xJiIIVh32sed3 xeXyvonmtmcr8rAUitwN/+KwxcUD7owA82CG4xecvqLuRC9xm+MUFrt6SPioMxbRNs+P SiUGdtIxULXJ5eWMcj4a4817xrTLJVKgP+Bnb5MxA9U/U1A/ZSZql4hMsYo3/PUnkB1J /E3g== X-Forwarded-Encrypted: i=1; AJvYcCXZDTceEDPTv56hi8GKPyMneqWNm7ZLF6GpIQB0tZ8SV1cVRbB6L9OfcFdyWMASXGQQeXqGgxXR+58P9E8=@vger.kernel.org X-Gm-Message-State: AOJu0YwehcAAj9mQocskU4TrhxYlmpmp50p/UA8FDY42T7Yso0r5KQnB bemUvZXLxkoI/kBLu/5eDAZYy54JoITmeKKqP0DIrlgmrS3En+qN7XlyFuOcTMt+E7A= X-Gm-Gg: AY/fxX6V/couLlYR6tl1KTJceA6rUmQ66zXXvjhfgyFz0u51Q+11MsB3f7bYLtexKcl BWyh83KRrScrboCIEi5UvkRveBLcmE814X5p4XV54d3QCplI6XK39iiYBCw9G/tQHAHvF0Q/6Au zcdLGcUiDvxa7wtAVSwrQZgjzdSAg4TSQKXt8/lDzQeS9d5nMoUu65ZXUn7glTD2DvFOjHIiOKZ mgg4nget0YQqO/PwvqnOaDFeYBxOHs9LXuA9Fadr5ChYQhcGtMtTe/ROtO3l4BwDj67C7wVDruD k2kMFyX1d2kBhW1lpJDd89+9E9MtyW7BVkFmocf9D4wHrA5oDzrtnm2SVUPeEZa1MsgxVqpD/rK yRaqRsh654A9R8na8bzM2GBl8zh4J7pEYQnGT421WKaG1S4d4GaY6lTJ+yP8h0vnZoTIffIh7PD 3/fhtdAcLbyjkllfxzOYiVwK4P X-Google-Smtp-Source: AGHT+IHE1lXvEz53VmoWzLLJVZRvVBwxgOdGb5mMIjcwZPpGkPDDOGRk+/iknTtt3x3D/wmw7rPQqQ== X-Received: by 2002:a05:6000:1886:b0:432:a9f0:48c with SMTP id ffacd0b85a97d-432c38d26f6mr24261001f8f.63.1768247287544; Mon, 12 Jan 2026 11:48:07 -0800 (PST) Received: from localhost (109-81-19-111.rct.o2.cz. [109.81.19.111]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5ee893sm39721819f8f.37.2026.01.12.11.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 11:48:07 -0800 (PST) Date: Mon, 12 Jan 2026 20:48:06 +0100 From: Michal Hocko To: Mathieu Desnoyers Cc: Andrew Morton , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Steven Rostedt , Masami Hiramatsu , Dennis Zhou , Tejun Heo , Christoph Lameter , Martin Liu , David Rientjes , christian.koenig@amd.com, Shakeel Butt , SeongJae Park , Johannes Weiner , Sweet Tea Dorminy , Lorenzo Stoakes , "Liam R . Howlett" , Mike Rapoport , 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 , Roman Gushchin , Mateusz Guzik , Matthew Wilcox , Baolin Wang , Aboorva Devarajan Subject: Re: [PATCH v13 2/3] mm: Fix OOM killer inaccuracy on large many-core systems Message-ID: References: <20260111194958.1231477-1-mathieu.desnoyers@efficios.com> <20260111194958.1231477-3-mathieu.desnoyers@efficios.com> 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: On Mon 12-01-26 14:37:49, Mathieu Desnoyers wrote: > On 2026-01-12 03:42, Michal Hocko wrote: > > Hi, > > sorry to jump in this late but the timing of previous versions didn't > > really work well for me. > > > > On Sun 11-01-26 14:49:57, Mathieu Desnoyers wrote: > > [...] > > > Here is a (possibly incomplete) list of the prior approaches that were > > > used or proposed, along with their downside: > > > > > > 1) Per-thread rss tracking: large error on many-thread processes. > > > > > > 2) Per-CPU counters: up to 12% slower for short-lived processes and 9% > > > increased system time in make test workloads [1]. Moreover, the > > > inaccuracy increases with O(n^2) with the number of CPUs. > > > > > > 3) Per-NUMA-node counters: requires atomics on fast-path (overhead), > > > error is high with systems that have lots of NUMA nodes (32 times > > > the number of NUMA nodes). > > > > > > The approach proposed here is to replace this by the hierarchical > > > per-cpu counters, which bounds the inaccuracy based on the system > > > topology with O(N*logN). > > > > The concept of hierarchical pcp counter is interesting and I am > > definitely not opposed if there are more users that would benefit. > > > > From the OOM POV, IIUC the primary problem is that get_mm_counter > > (percpu_counter_read_positive) is too imprecise on systems when the task > > is moving around a large number of cpus. In the list of alternative > > solutions I do not see percpu_counter_sum_positive to be mentioned. > > oom_badness() is a really slow path and taking the slow path to > > calculate a much more precise value seems acceptable. Have you > > considered that option? > I must admit I assumed that since there was already a mechanism in place > to ensure it's not necessary to sum per-cpu counters when the oom killer > is trying to select tasks, it must be because this > > O(nr_possible_cpus * nr_processes) > > operation must be too slow for the oom killer requirements. > > AFAIU, the oom killer is executed when the memory allocator fails to > allocate memory, which can be within code paths which need to progress > eventually. So even though it's a slow path compared to the allocator > fast path, there must be at least _some_ expectations about it > completing within a decent amount of time. What would that ballpark be ? I do not think we have ever promissed more than the oom killer will try to unlock the system blocked on memory shortage. > To give an order of magnitude, I've tried modifying the upstream > oom killer to use percpu_counter_sum_positive and compared it to > the hierarchical approach: > > AMD EPYC 9654 96-Core (2 sockets) > Within a KVM, configured with 256 logical cpus. > > nr_processes=40 nr_processes=10000 > Counter sum: 0.4 ms 81.0 ms > HPCC with 2-pass: 0.3 ms 9.3 ms These are peanuts for the global oom situations. We have had situations when soft lockup detector triggered because of the process tree traversal so adding 100ms is not really critical. > So as we scale up the number of processes on large SMP systems, > the latency caused by the oom killer task selection greatly > increases with the counter sums compared with the hierarchical > approach. Yes, I am not really questioning the hierarchical approach will perform much better but I am thinking of a good enough solution and calculating the number might be just that stop gap solution (that would be also suitable for stable tree backports). I am not ruling out improving on top of that by a more clever solution like your hierarchical counters approach. Especially if there are more benefits from that elsewhere. -- Michal Hocko SUSE Labs