From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDD8EC54FD0 for ; Fri, 24 Apr 2020 15:12:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 906AB20706 for ; Fri, 24 Apr 2020 15:12:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EMqc21TU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 906AB20706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2B8BB8E0006; Fri, 24 Apr 2020 11:12:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2688A8E0003; Fri, 24 Apr 2020 11:12:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A74D8E0006; Fri, 24 Apr 2020 11:12:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 014BA8E0003 for ; Fri, 24 Apr 2020 11:12:55 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B7E368248076 for ; Fri, 24 Apr 2020 15:12:55 +0000 (UTC) X-FDA: 76743091110.29.arm10_1986e3897e828 X-HE-Tag: arm10_1986e3897e828 X-Filterd-Recvd-Size: 4621 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 15:12:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587741173; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=bG+oOpvHV7fdGOI3xpfAnUa5ETjwSHs1N5A5bl4B/qU=; b=EMqc21TUdny+aL9ThLaUvXyo8yElCMDcyfRQSojMHCfWo61yDn9kYKoTpsT4+JFHVqxaw6 3tJSHSNc4O8Dd0EwMmdlxAFPiUx3bjIucW5w2uA02jJ6MEC3ZsdAK8l2+tVqVSb7x0c3SB vfWB3qWerrOrvwSoqpFjgLYOncTzP6E= 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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