Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2482545pxb; Mon, 18 Jan 2021 20:43:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0RgBEQruZiXBsiWC88OWQH6Rz2H+NhoqYqwpEs7NvECQn1LwTpfnkFgwPqHrIrGtr8BaQ X-Received: by 2002:a17:906:80c9:: with SMTP id a9mr1726646ejx.78.1611031424601; Mon, 18 Jan 2021 20:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611031424; cv=none; d=google.com; s=arc-20160816; b=SdB+ILGSmhRutfWy+KyMZnkZNN/lO3Nn5XRPi+ssofP/l7q8bLXN8qpDlZMpaBlfE/ cjE2BjEGiUvsYeC5LZsgCWk0d4jRPGM0q/erNzoF5rL/zlbswQBXOe5/pZPQVZhlbVzN AkaX8qo+EAwE1vqJekBqqPahr/IN7OyqrgABTslPQFY9bh+ePOCcpkEqldzsAcmVD61h QK0Z3ZFASr/lGcz0uCbaSctCw5ZqYfbaZuQ1707udBVlWNzx0FauhPkwa9mzx2pVzjB0 6TGW3I40/zz4QA0oKArfkMT0wVEa/uzwMuDGBZ47T6raYM1tPsoKq1Jv7475GckiKSQO xEfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JNQs8E/IK8Nde3e0PCSuz8+Pj2HndUD2dN/6u3bCedk=; b=sreMEgYAhXRT7d3A95gzlBCMrHULdmV94iLktyw/57xOGVYeScMkJ2c3irSJMLCE5l EKe4iZdOjInAX7ChIMJtS4Mf0IeD2t9RcZAUuzYRJqYiXSq5lx7wYhC8L0xA0vtFgzif bJu2pnqJQBwsuGv0rDnCJRZ4BJnP/w7dY32FbU2+jVwH7CkaKF3xhShBSyNNLnSWHLr+ cvHQT2stjx7nv7euinLFN+bcaZpnMRJoL/glsPdzwQFIdHnI4wt0IJ4hh0clY7PDjWAz IvLeSpLtKnrSTngzjXkR0tus/o2rBECJCtERTdRD7FKbETmD4o71WUVF63CuKVkPzLmT aV3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=GWaRX4Iu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn23si5652089ejc.12.2021.01.18.20.43.21; Mon, 18 Jan 2021 20:43:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=GWaRX4Iu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406424AbhARQJi (ORCPT + 99 others); Mon, 18 Jan 2021 11:09:38 -0500 Received: from mx2.suse.de ([195.135.220.15]:58790 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406078AbhARQIP (ORCPT ); Mon, 18 Jan 2021 11:08:15 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1610986046; h=from:from:reply-to: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=JNQs8E/IK8Nde3e0PCSuz8+Pj2HndUD2dN/6u3bCedk=; b=GWaRX4IuWfbZ7SJ3piEOKp5lCKRKnVuAMZA0GxbUsuyMiIw769sw7d63xngi+B0XzJ7z1q iZd7uzetTEUuA8Pj04XAG8y0FmFg0394YpeSxQ3H3mONYynGJSdsgFrekw7GewRvVsmGkY RYDV1qqdOX2EBuFcEeUp3XWI/ljG/4Q= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 584BEAD19; Mon, 18 Jan 2021 16:07:26 +0000 (UTC) Date: Mon, 18 Jan 2021 17:07:22 +0100 From: Michal Hocko To: Christoph Lameter Cc: Vlastimil Babka , Jann Horn , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Linux-MM , kernel list , Thomas Gleixner , Sebastian Andrzej Siewior , Roman Gushchin , Johannes Weiner , Shakeel Butt , Suren Baghdasaryan , Minchan Kim Subject: Re: SLUB: percpu partial object count is highly inaccurate, causing some memory wastage and maybe also worse tail latencies? Message-ID: <20210118160722.GG14336@dhcp22.suse.cz> References: <20210118110319.GC14336@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 18-01-21 15:46:43, Cristopher Lameter wrote: > On Mon, 18 Jan 2021, Michal Hocko wrote: > > > > Hm this would be similar to recommending a periodical echo > drop_caches > > > operation. We actually discourage from that (and yeah, some tools do that, and > > > we now report those in dmesg). I believe the kernel should respond to memory > > > pressure and not OOM prematurely by itself, including SLUB. > > > > Absolutely agreed! Partial caches are a very deep internal > > implementation detail of the allocator and admin has no bussiness into > > fiddling with that. This would only lead to more harm than good. > > Comparision to drop_caches is really exact! > > Really? The maximum allocation here has a upper boundary that depends on > the number of possible partial per cpu slabs. And number of cpus and caches... > There is a worst case > scenario that is not nice and wastes some memory but it is not an OOM > situation and the system easily recovers from it. There is no pro-active shrinking of those when we are close to the OOM so we still can go and kill a task while there is quite some memory sitting in a freeable slub caches unless I am missing something. We have learned about this in a memcg environment on our distribution kernels where the problem is amplified by the use in memcgs with a small limit. This is an older kernel and I would expect the current upstream will behave better with Roman's accounting rework. But still it would be great if the allocator could manage its caches depending on the memory demand. > The slab shrinking is not needed but if you are concerned about reclaiming > more memory right now then I guess you may want to run the slab shrink > operation. Yes, you can do that. In a same way you can shrink the page cache. Moreover it is really hard to do that somehow inteligently because you would need to watch the system very closely in order to shrink when it is really needed. That requires a deep understanding of the allocator. > Dropping the page cache is bad? Well sometimes you want more free memory > due to a certain operation that needs to be started and where you do not > want the overhead of page cache processing. It is not bad if used properly. My experience is that people have developed instinct to drop caches whenever something is not quite right because Internet has recommended that. -- Michal Hocko SUSE Labs