Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp727357ybz; Fri, 24 Apr 2020 08:17:27 -0700 (PDT) X-Google-Smtp-Source: APiQypILH85DGcBSVH9+B/1k18lbuY/Tllxf1RTmmV5gHP+j4p6y8ePOEBowmmPuC6rSzuaf2+ru X-Received: by 2002:a17:906:48c:: with SMTP id f12mr7838206eja.93.1587741447088; Fri, 24 Apr 2020 08:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587741447; cv=none; d=google.com; s=arc-20160816; b=NM5F0kPqsk7hBFBQeBZLcfqjxLvZ+WSHJQqsaOjbYQsdoOWtSPduWIdAYsHgQH+9Uy FON1vTk5+UXGFQpPp4PCPAfJdhH8qhFgAPJMVugQwrXIe468Cx5pGIp7j3kC31BsrKbn NivnjjuYQ0GWKGV6F1cX8+g4XuId7ABa8PLKeeBcEGnY680pENz7328u9/OD01/1Fzpq b4XuNJgEC/VjQg+NTHQVAeeaVN6d4z1KCHL6AuwPPaMAh9wdkUjGoqJymD+c1IGs0Nnx JX96bQYWceeAJ7FTi960rW/Eyk4Q2vk61zP5sPSm1T51r4SPzm8/BkcE9CjQ+rXnitwF NhcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=bG+oOpvHV7fdGOI3xpfAnUa5ETjwSHs1N5A5bl4B/qU=; b=HTNE9KrsLNs0aRaIvczceMDqAqWQqIewfLGc2kdSYDjtCpOsdmz0HfmL1t4j+gjiKN n5yb2QD+iNmIaiNaHrvw2+q7PQiybxwjlgUW1Xnt1vg9UjKdpZLxFAJU6O4uKgvgtl+T guUMt2xZXbLB3KOrY9OXzTbaKN8+DWeoyyjI5jeWo2tfTVkc3wruaR8u/2hrhNnzQ3R+ BU0zoSBW35tyo3KSjq59hMYhu4BjLbioj20QBmCfOBwByBo5In2GJhy5P+89Pm5Sekza qyng+XsOssUhW6eyaI2+L4quhyBSdM71cVyLYSyLqIsaWi6tJagonMNQipkKXjrblB7e iRHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LPEFeciB; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qo19si3352442ejb.239.2020.04.24.08.17.02; Fri, 24 Apr 2020 08:17:27 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=LPEFeciB; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727971AbgDXPM4 (ORCPT + 99 others); Fri, 24 Apr 2020 11:12:56 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:56735 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726791AbgDXPM4 (ORCPT ); Fri, 24 Apr 2020 11:12:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587741174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=bG+oOpvHV7fdGOI3xpfAnUa5ETjwSHs1N5A5bl4B/qU=; b=LPEFeciBqF+uwpvOphb8R4jlc1OA7HZEvCm/xpdlsmXEruy31S7rN6D9psOYal6pCTI5ZZ XwuklUkJReuRqEQZkEvHbTIKbfMmvwlDic8wCNogC6QZPF56ajEWIovjFGsXF7YHTZze09 el88dEw6srFJq9wS420ytc53Lv2oU/g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-gN5GtHAxOB2uwdFK9C4rvg-1; Fri, 24 Apr 2020 11:12:51 -0400 X-MC-Unique: gN5GtHAxOB2uwdFK9C4rvg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E86645F; Fri, 24 Apr 2020 15:12:49 +0000 (UTC) Received: from llong.com (ovpn-112-86.rdu2.redhat.com [10.10.112.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77294600F5; Fri, 24 Apr 2020 15:12:38 +0000 (UTC) From: Waiman Long To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Juri Lelli , Waiman Long Subject: [PATCH 1/2] mm, slab: Revert "extend slab/shrink to shrink all memcg caches" Date: Fri, 24 Apr 2020 11:12:24 -0400 Message-Id: <20200424151225.10966-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the slub shrink sysfs file is written into, the function call sequence is as follows: kernfs_fop_write => slab_attr_store => shrink_store => kmem_cache_shrink_all It turns out that doing a memcg cache scan in kmem_cache_shrink_all() is redundant as the same memcg cache scan is being done in slab_attr_store(). So revert the commit 04f768a39d55 ("mm, slab: extend slab/shrink to shrink all memcg caches") except the documentation change which is still valid. Signed-off-by: Waiman Long --- mm/slab.h | 1 - mm/slab_common.c | 37 ------------------------------------- mm/slub.c | 2 +- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 207c83ef6e06..0937cb2ae8aa 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -237,7 +237,6 @@ int __kmem_cache_shrink(struct kmem_cache *); void __kmemcg_cache_deactivate(struct kmem_cache *s); void __kmemcg_cache_deactivate_after_rcu(struct kmem_cache *s); void slab_kmem_cache_release(struct kmem_cache *); -void kmem_cache_shrink_all(struct kmem_cache *s); struct seq_file; struct file; diff --git a/mm/slab_common.c b/mm/slab_common.c index 23c7500eea7d..2e367ab8c15c 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -995,43 +995,6 @@ int kmem_cache_shrink(struct kmem_cache *cachep) } EXPORT_SYMBOL(kmem_cache_shrink); -/** - * kmem_cache_shrink_all - shrink a cache and all memcg caches for root cache - * @s: The cache pointer - */ -void kmem_cache_shrink_all(struct kmem_cache *s) -{ - struct kmem_cache *c; - - if (!IS_ENABLED(CONFIG_MEMCG_KMEM) || !is_root_cache(s)) { - kmem_cache_shrink(s); - return; - } - - get_online_cpus(); - get_online_mems(); - kasan_cache_shrink(s); - __kmem_cache_shrink(s); - - /* - * We have to take the slab_mutex to protect from the memcg list - * modification. - */ - mutex_lock(&slab_mutex); - for_each_memcg_cache(c, s) { - /* - * Don't need to shrink deactivated memcg caches. - */ - if (s->flags & SLAB_DEACTIVATED) - continue; - kasan_cache_shrink(c); - __kmem_cache_shrink(c); - } - mutex_unlock(&slab_mutex); - put_online_mems(); - put_online_cpus(); -} - bool slab_is_available(void) { return slab_state >= UP; diff --git a/mm/slub.c b/mm/slub.c index 9bf44955c4f1..183ccc364ccf 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5343,7 +5343,7 @@ static ssize_t shrink_store(struct kmem_cache *s, const char *buf, size_t length) { if (buf[0] == '1') - kmem_cache_shrink_all(s); + kmem_cache_shrink(s); else return -EINVAL; return length; -- 2.18.1