Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5676332ybh; Wed, 7 Aug 2019 09:35:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx23HOw00gpDf+kT0ZkVjBRktx/gtKeVVVG9SvC+sx1KcEl/oNrrhzAE5Tqomp7ltaTOcky X-Received: by 2002:a17:90a:b394:: with SMTP id e20mr799190pjr.76.1565195701950; Wed, 07 Aug 2019 09:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565195701; cv=none; d=google.com; s=arc-20160816; b=seX8wc/aODmrbRTYCRtp6axxuaQaUo5+RbRE//ngp6A1zPlprTd1d/2ue/xmKO+bVl a1z/1KvldIaO/qEEugMbPyphNcS88T8MPlZ1qt3sMS/WuJt0JGj75QWh0ljyCpAweH0k m9C0n59Z47pm+8++aiaYKOfmqdKPPXdu2ut1yOFHmnSr9AJmqpFbmg6L21vtuQ5S9z1J YHlhrYyXHUtbF2OetUjyy5iAc5Hxl/wLVawUmSl2L9eennVF+EPC25pb0TdrNSfkZYnr lVwRqjErwZS97csLAtjdT40cB3343V/o1XgokgoW0raWy+iuEXyA0dkCl2VwI3vTUXGB ZpxA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=HPTyuxZECDYpmL7fNV0I27d9sRoi6aXt4bKBtbLftII=; b=P9ITe78bza3btn3kY4VPb1bBHUpHgJwQ43rUk+VqAaEkZFLSORZfKNu1AGLihIrHzw j86+As9ebGggioaFUCxsSDRIuVdpQYZMEYNysg7vm43pSwc5uIGbJWeQhC2mKZ2Ym3Mf okcUDamt8ufn6lsQ0egwHJfb6oZCT+Mcmshh/SmQe/E5EDxW5KEHSTUmpf29+VBE2fzE IHtXsRo+VThFeX44GttjOvWAmbajHTMBSLjicOy1tithj0sdQ4n4UkLV9H9xEiS5awRC UcCqev9GZlMpchwp33vsFbCGpRlJnH5m0yPa57TBIlNIO+te92xxlnNe/y/J4thbz+72 wV5g== 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 o63si276631pjo.94.2019.08.07.09.34.46; Wed, 07 Aug 2019 09:35:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388827AbfHGQdl (ORCPT + 99 others); Wed, 7 Aug 2019 12:33:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:48604 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388026AbfHGQdk (ORCPT ); Wed, 7 Aug 2019 12:33:40 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F06F7AF93; Wed, 7 Aug 2019 16:33:38 +0000 (UTC) Subject: Re: [PATCH] mm, slab: Extend slab/shrink to shrink all the memcg caches To: Waiman Long , peter enderborg , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Alexander Viro , Jonathan Corbet , Luis Chamberlain , Kees Cook , Johannes Weiner , Michal Hocko , Vladimir Davydov Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Roman Gushchin , Shakeel Butt , Andrea Arcangeli References: <20190702183730.14461-1-longman@redhat.com> <71ab6307-9484-fdd3-fe6d-d261acf7c4a5@sony.com> From: Vlastimil Babka Message-ID: <85f9074a-064c-acbc-2a22-968026f0a8c3@suse.cz> Date: Wed, 7 Aug 2019 18:33:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/23/19 4:30 PM, Waiman Long wrote: > On 7/22/19 8:46 AM, peter enderborg wrote: >> On 7/2/19 8:37 PM, Waiman Long wrote: >>> Currently, a value of '1" is written to /sys/kernel/slab//shrink >>> file to shrink the slab by flushing all the per-cpu slabs and free >>> slabs in partial lists. This applies only to the root caches, though. >>> >>> Extends this capability by shrinking all the child memcg caches and >>> the root cache when a value of '2' is written to the shrink sysfs file. >>> >>> On a 4-socket 112-core 224-thread x86-64 system after a parallel kernel >>> build, the the amount of memory occupied by slabs before shrinking >>> slabs were: >>> >>> # grep task_struct /proc/slabinfo >>> task_struct 7114 7296 7744 4 8 : tunables 0 0 >>> 0 : slabdata 1824 1824 0 >>> # grep "^S[lRU]" /proc/meminfo >>> Slab: 1310444 kB >>> SReclaimable: 377604 kB >>> SUnreclaim: 932840 kB >>> >>> After shrinking slabs: >>> >>> # grep "^S[lRU]" /proc/meminfo >>> Slab: 695652 kB >>> SReclaimable: 322796 kB >>> SUnreclaim: 372856 kB >>> # grep task_struct /proc/slabinfo >>> task_struct 2262 2572 7744 4 8 : tunables 0 0 >>> 0 : slabdata 643 643 0 >> >> What is the time between this measurement points? Should not the shrinked memory show up as reclaimable? > > In this case, I echoed '2' to all the shrink sysfs files under > /sys/kernel/slab. The purpose of shrinking caches is to reclaim as much > unused memory slabs from all the caches, irrespective if they are > reclaimable or not. Well, SReclaimable counts pages allocated by kmem caches with SLAB_RECLAIM_ACCOUNT flags, which should match those that have a shrinker associated and can thus actually reclaim objects. That shrinking slabs affected SReclaimable just a bit while reducing SUnreclaim by more than 50% looks certainly odd. For example the task_struct cache is not a reclaimable one, yet shows massive reduction. Could be that the reclaimable objects were pinning non-reclaimable ones, so the shrinking had secondary effects in non-reclaimable caches. > We do not reclaim any used objects. That is why we > see the numbers were reduced in both cases. > > Cheers, > Longman >