Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1867234imm; Mon, 3 Sep 2018 11:31:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZOkJeFUS8QM+sC9oXgQCJQ4gxw23RMjXHXcJdp8RHzZsLTzLztIeRE/pV9EERolVZXeJEp X-Received: by 2002:a62:a65a:: with SMTP id t87-v6mr30546153pfe.225.1535999489059; Mon, 03 Sep 2018 11:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535999489; cv=none; d=google.com; s=arc-20160816; b=p2NQABu8yi4DWy1EENtanRExKKPVL9NjEZgD3oxzLRg5QvRnYYobBn76ZDSs9UpuPC KSMFReREdUaFEa8s6FbjTQAjiQ1A7uIwLFt/yKEmMLbSkofT16r+JCI7htgl0+SNYnFn ClVlkMYyS7gCtrypsruRMs6c+F9j7tlUtrMcPR5qDuyFQkn6a0mItryK1voNhKwsMJrh 6rnhMnyQrk34kq2y2qiskMjOK0sUThcSeGMiv1MlKIDvlZn/YQDIh3KIz34q5unjuJb1 AIqDykstiheHiu2ATzETp6qUEfFjAjwql7YQ+iIIZCuewLwCFYdzOd1ej5Nz9w+zHmGo exKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=a37eRxa9/ASFePo42N0pjQwEhe2TXcm/bPexSyGyyuA=; b=Z17ZcUcVb+3WUFG2MVwbVxBd8ha58FCvC1ia8txq3Xs3KWxkgDSnK8nlLtvFSMu5+n AihmbAlQ11HpkyntTwJ9nIxFGI+jmD0hYekN1LiHhYxl5tiZVb9DZg0wYmMfhy/Zdcdt r3MLhL0EO51+kFxGJUb6q/e3sQuOQP5XcZA++jfmoqAB4BFSi/1MPk/sm9p8kpayaXjf hZqDov+G/9gZ5QWp94yMskR/t8iAwSUz+K4xD6p/ahuPl8htCU/Z1YF9yIysOXjZUznK KwnY/Gin/VfmS2a4gPyqZEVRyRc8zEIE39VUzTCz73wYn7DRTN7LNhtIq/Jn2npQH4+e qtSg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si18218622pgm.509.2018.09.03.11.31.13; Mon, 03 Sep 2018 11:31:29 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727590AbeICWvc (ORCPT + 99 others); Mon, 3 Sep 2018 18:51:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:35310 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727430AbeICWvc (ORCPT ); Mon, 3 Sep 2018 18:51:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C0549AF7A; Mon, 3 Sep 2018 18:30:06 +0000 (UTC) Date: Mon, 3 Sep 2018 20:29:56 +0200 From: Michal Hocko To: Roman Gushchin Cc: Rik van Riel , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Josef Bacik , Johannes Weiner , Andrew Morton Subject: Re: [PATCH] mm: slowly shrink slabs with a relatively small number of objects Message-ID: <20180903182956.GE15074@dhcp22.suse.cz> References: <20180831203450.2536-1-guro@fb.com> <3b05579f964cca1d44551913f1a9ee79d96f198e.camel@surriel.com> <20180831213138.GA9159@tower.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180831213138.GA9159@tower.DHCP.thefacebook.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 31-08-18 14:31:41, Roman Gushchin wrote: > On Fri, Aug 31, 2018 at 05:15:39PM -0400, Rik van Riel wrote: > > On Fri, 2018-08-31 at 13:34 -0700, Roman Gushchin wrote: > > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > > index fa2c150ab7b9..c910cf6bf606 100644 > > > --- a/mm/vmscan.c > > > +++ b/mm/vmscan.c > > > @@ -476,6 +476,10 @@ static unsigned long do_shrink_slab(struct > > > shrink_control *shrinkctl, > > > delta = freeable >> priority; > > > delta *= 4; > > > do_div(delta, shrinker->seeks); > > > + > > > + if (delta == 0 && freeable > 0) > > > + delta = min(freeable, batch_size); > > > + > > > total_scan += delta; > > > if (total_scan < 0) { > > > pr_err("shrink_slab: %pF negative objects to delete > > > nr=%ld\n", > > > > I agree that we need to shrink slabs with fewer than > > 4096 objects, but do we want to put more pressure on > > a slab the moment it drops below 4096 than we applied > > when it had just over 4096 objects on it? > > > > With this patch, a slab with 5000 objects on it will > > get 1 item scanned, while a slab with 4000 objects on > > it will see shrinker->batch or SHRINK_BATCH objects > > scanned every time. > > > > I don't know if this would cause any issues, just > > something to ponder. > > Hm, fair enough. So, basically we can always do > > delta = max(delta, min(freeable, batch_size)); > > Does it look better? Why don't you use the same heuristic we use for the normal LRU raclaim? /* * If the cgroup's already been deleted, make sure to * scrape out the remaining cache. */ if (!scan && !mem_cgroup_online(memcg)) scan = min(size, SWAP_CLUSTER_MAX); -- Michal Hocko SUSE Labs