Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3861830imu; Mon, 28 Jan 2019 12:11:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN6y7SR/DBEo8u+qq+8yURIgLYAb3xOZeVcse52qPfWkzljswAVzrD65bSRN+6dwqPXVVREV X-Received: by 2002:a63:6f0d:: with SMTP id k13mr14395267pgc.42.1548706310744; Mon, 28 Jan 2019 12:11:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548706310; cv=none; d=google.com; s=arc-20160816; b=RB0pv+kbcYme/ft1ygszZTv1LU9hl8E8pmSVTL6cSe+uKX8fmJ2qmVjAct6T+uHE3x le6AwdhjGMMPy16kxV0TOzqldpB3fk6TK3j5Socqv1RI1GxJc+aFqyvh8pbvTqZTVxNT RJ7xzA2iLVeafkHqdah8PuRzjU2Bp6/DMBvinyjSNGfm0SEG74KQUK8AusNOZBCHulvO FVq4QXm0wf4kVn1msJ+aKATucdIx4piueOfHosyZLL3tVYAZx7vlcr3aRWyyXWEGLJQs 04IpAfjzA7CY6dLMClwShvz6disfrRP82ELCaV+aiekIIbgJee/9IwQVGFgveoPxZfA0 DQ+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=CecL8b+tKskywcifeIVmF8MMnmie8dzPPpaXoA75yJA=; b=QeomGOVNUztHODzBzpPAOhdXVQm37vsVJ/0sZzu7tTFvaimL9W6Rw5hGD3bvjG8Lb6 FH9ZJYDz62SWLkUs/ZqxZuPZMlu8b/RJkuIpBeWuSs3YxGjuTkDqGrzWCSE+5h4ziGkP WOpQltWaZPpZOkHlsIxUPLW8h+wPYhRvOSEe/616TOXHdKBVAqcpisZtCLer1Jsu9Ty+ EUmHlbApqvVJvrBMTMUNO3qtvUtDJg42vR86LROycucGKhDx+ia1icwbefKcv1ujVBu9 ZwqJeNRVvOsw+8R1BBcYZUcZ1FP/Vcqp9r3oftoSxAcbv+W/J/MYk5OWgzibqsfu48lo 4Cdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si5596086pgt.343.2019.01.28.12.11.34; Mon, 28 Jan 2019 12:11:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbfA1UKb (ORCPT + 99 others); Mon, 28 Jan 2019 15:10:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47326 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbfA1UKb (ORCPT ); Mon, 28 Jan 2019 15:10:31 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E475623FA; Mon, 28 Jan 2019 20:10:29 +0000 (UTC) Date: Mon, 28 Jan 2019 12:10:28 -0800 From: Andrew Morton To: Rik van Riel Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com, Johannes Weiner , Chris Mason , Roman Gushchin , Michal Hocko Subject: Re: [PATCH] mm,slab,vmscan: accumulate gradual pressure on small slabs Message-Id: <20190128121028.8ef4c19dd3fd1d60d2e3284c@linux-foundation.org> In-Reply-To: <8ddf2ea674711f373062f4e056dd14fb81c5a2fe.camel@surriel.com> References: <20190128143535.7767c397@imladris.surriel.com> <20190128115424.df3f4647023e9e43e75afe67@linux-foundation.org> <8ddf2ea674711f373062f4e056dd14fb81c5a2fe.camel@surriel.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Jan 2019 15:03:28 -0500 Rik van Riel wrote: > On Mon, 2019-01-28 at 11:54 -0800, Andrew Morton wrote: > > On Mon, 28 Jan 2019 14:35:35 -0500 Rik van Riel > > wrote: > > > > > /* > > > * Make sure we apply some minimal pressure on default priority > > > - * even on small cgroups. Stale objects are not only consuming > > > memory > > > + * even on small cgroups, by accumulating pressure across > > > multiple > > > + * slab shrinker runs. Stale objects are not only consuming > > > memory > > > * by themselves, but can also hold a reference to a dying > > > cgroup, > > > * preventing it from being reclaimed. A dying cgroup with all > > > * corresponding structures like per-cpu stats and kmem caches > > > * can be really big, so it may lead to a significant waste of > > > memory. > > > */ > > > - delta = max_t(unsigned long long, delta, min(freeable, > > > batch_size)); > > > + if (!delta) { > > > + shrinker->small_scan += freeable; > > > + > > > + delta = shrinker->small_scan >> priority; > > > + shrinker->small_scan -= delta << priority; > > > + > > > + delta *= 4; > > > + do_div(delta, shrinker->seeks); > > > > What prevents shrinker->small_scan from over- or underflowing over > > time? > > We only go into this code path if > delta >> DEF_PRIORITY is zero. > > That is, freeable is smaller than 4096. > I'm still not understanding. If `freeable' always has a value of (say) 1, we'll eventually overflow shrinker->small_scan? Or at least, it's unobvious why this cannot happen.