From patchwork Mon Oct 18 22:16:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12568201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6789CC433FE for ; Mon, 18 Oct 2021 22:16:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 170BD6115A for ; Mon, 18 Oct 2021 22:16:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 170BD6115A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id B041B940010; Mon, 18 Oct 2021 18:16:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8BAC940007; Mon, 18 Oct 2021 18:16:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9543C940010; Mon, 18 Oct 2021 18:16:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 76B5F940007 for ; Mon, 18 Oct 2021 18:16:08 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1BAA0181AEF0B for ; Mon, 18 Oct 2021 22:16:08 +0000 (UTC) X-FDA: 78710967216.18.77CB847 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf06.hostedemail.com (Postfix) with ESMTP id 1D175801A89B for ; Mon, 18 Oct 2021 22:16:07 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 962CD610FB; Mon, 18 Oct 2021 22:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1634595367; bh=FQO3/artqDNMfwd2Y8MSjvc/OYRcYxGEuGudqkf7YZU=; h=Date:From:To:Subject:In-Reply-To:From; b=ZLlRUt5FQE4PDhLfpRTl2vUUmHtoOrcgjZ2dXpVbVrljjf+FciAIQ/WWU2OAombhr yzQO5lvbvFvGVmnPECdfeG6zQAApIbzNz0SJQSPJr6bD3whm7JjL4fjznXEeKLsWMA r9uxe7Y4FlLrxb6eLle+BuLqbmbx7EwbRBygLEKE= Date: Mon, 18 Oct 2021 15:16:06 -0700 From: Andrew Morton To: akpm@linux-foundation.org, andreyknvl@gmail.com, bharata@linux.ibm.com, cl@linux.com, faiyazm@codeaurora.org, gregkh@linuxfoundation.org, guro@fb.com, iamjoonsoo.kim@lge.com, keescook@chromium.org, linmiaohe@huawei.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, penberg@kernel.org, rientjes@google.com, ryabinin.a.a@gmail.com, stable@vger.kernel.org, torvalds@linux-foundation.org, vbabka@suse.cz Subject: [patch 14/19] mm, slub: fix incorrect memcg slab count for bulk free Message-ID: <20211018221606.0wZ3nwZSc%akpm@linux-foundation.org> In-Reply-To: <20211018151438.f2246e2656c041b6753a8bdd@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 1D175801A89B Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=ZLlRUt5F; spf=pass (imf06.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: 7t98jh5kt4jcia7hkw5jiijb4hoh61rd X-Rspamd-Server: rspam05 X-HE-Tag: 1634595367-481072 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: From: Miaohe Lin Subject: mm, slub: fix incorrect memcg slab count for bulk free kmem_cache_free_bulk() will call memcg_slab_free_hook() for all objects when doing bulk free. So we shouldn't call memcg_slab_free_hook() again for bulk free to avoid incorrect memcg slab count. Link: https://lkml.kernel.org/r/20210916123920.48704-6-linmiaohe@huawei.com Fixes: d1b2cf6cb84a ("mm: memcg/slab: uncharge during kmem_cache_free_bulk()") Signed-off-by: Miaohe Lin Reviewed-by: Vlastimil Babka Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Bharata B Rao Cc: Christoph Lameter Cc: David Rientjes Cc: Faiyaz Mohammed Cc: Greg Kroah-Hartman Cc: Joonsoo Kim Cc: Kees Cook Cc: Pekka Enberg Cc: Roman Gushchin Cc: Signed-off-by: Andrew Morton --- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/mm/slub.c~mm-slub-fix-incorrect-memcg-slab-count-for-bulk-free +++ a/mm/slub.c @@ -3420,7 +3420,9 @@ static __always_inline void do_slab_free struct kmem_cache_cpu *c; unsigned long tid; - memcg_slab_free_hook(s, &head, 1); + /* memcg_slab_free_hook() is already called for bulk free. */ + if (!tail) + memcg_slab_free_hook(s, &head, 1); redo: /* * Determine the currently cpus per cpu slab.