From patchwork Tue Nov 16 00:16:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 12620677 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 4DC65C433F5 for ; Tue, 16 Nov 2021 00:16:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0060263259 for ; Tue, 16 Nov 2021 00:16:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0060263259 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4F5A66B0083; Mon, 15 Nov 2021 19:16:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 285826B0088; Mon, 15 Nov 2021 19:16:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB1966B0080; Mon, 15 Nov 2021 19:16:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A65C86B0080 for ; Mon, 15 Nov 2021 19:16:39 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 695861815CBE8 for ; Tue, 16 Nov 2021 00:16:39 +0000 (UTC) X-FDA: 78812877318.11.6760536 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf16.hostedemail.com (Postfix) with ESMTP id 439A4F00008E for ; Tue, 16 Nov 2021 00:16:27 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A5AB32191A; Tue, 16 Nov 2021 00:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1637021797; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=meFsT1bG0/wA8qkM/MDL8mIb5s7Qedh2RarYRL3sGSY=; b=tE+pNmQTdpac1VtI+uUx9DyVGXXouBhxhbS+PZ5E5aXdfq+5PUkQlIwz3OFsyQxecwmq68 JOIi+cZIDzBI8UbPDjn8yFkCB0ZVg1C5ITDZ/i+xpSoVDtX/nqxYysBt2C5/0cLPkDauuK envCgfarGb5ShhU2AyuDlxH51jnIxyA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1637021797; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=meFsT1bG0/wA8qkM/MDL8mIb5s7Qedh2RarYRL3sGSY=; b=hyjuDk/oqT0cbXnOvVjCD0bBsWgVMPOuouAoaj7bHtGHogoi0JIr1H40BE1A5YZAc8Y4iI 0ev/cTpSzkoB0sAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 809A1139DB; Tue, 16 Nov 2021 00:16:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4L8ZHmX4kmFjXAAAMHmgww (envelope-from ); Tue, 16 Nov 2021 00:16:37 +0000 From: Vlastimil Babka To: Matthew Wilcox , linux-mm@kvack.org, Christoph Lameter , David Rientjes , Joonsoo Kim , Pekka Enberg Cc: Vlastimil Babka Subject: [RFC PATCH 04/32] mm: Add account_slab() and unaccount_slab() Date: Tue, 16 Nov 2021 01:16:00 +0100 Message-Id: <20211116001628.24216-5-vbabka@suse.cz> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211116001628.24216-1-vbabka@suse.cz> References: <20211116001628.24216-1-vbabka@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3391; i=vbabka@suse.cz; h=from:subject; bh=WwUdOzUhe1YqdlcN4Zd71ekEnRDyjpShLeuMJEAnlLo=; b=owEBbQGS/pANAwAIAeAhynPxiakQAcsmYgBhkvgnwagwZGLfFoCXdMb7y40MBhj8yBluwDBXZdHX N29mqMWJATMEAAEIAB0WIQSNS5MBqTXjGL5IXszgIcpz8YmpEAUCYZL4JwAKCRDgIcpz8YmpEEjAB/ 9c8fwLhLwfEGt7KCXZ6LM84suF78oKOR9cOGho3uZu7HJrQiIijDauwhQ7cP4eDa43vjdjNfa0Wp20 RKT/VjkS67gY5YB/mJ+5WD8piijW0F1fJb4eC8+//6Rt17sOZk3gpnwDNrjC/Lk9vrdgItHpAd017Z UbBMGp+SFbPKP/wER/++BI/u2IX5VrHc2cxPTG2mPbrhE7mbVoXwjmcchJ0eNtRJvfvRuK/3brTTrq 2DNSfg1sua2oBiIpDasW+NnDmx02glSNZzRGM5sxVzxJ6gIYnqBJ1J39bykAxPu7Lhcjjy9OP7y3aH GY/5vf5LLZ5T/bd8OxgLRw/5L+LUwi X-Developer-Key: i=vbabka@suse.cz; a=openpgp; fpr=A940D434992C2E8E99103D50224FA7E7CC82A664 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 439A4F00008E X-Stat-Signature: qoazpr3secohudr8mzti1njmf5nokq13 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tE+pNmQT; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="hyjuDk/o"; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-HE-Tag: 1637021787-772802 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: "Matthew Wilcox (Oracle)" These functions take struct slab instead of struct page and replace (un)account_slab_page(). For now their callers just convert page to slab. [ vbabka@suse.cz: replace existing functions instead of calling them ] Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Vlastimil Babka --- mm/slab.c | 4 ++-- mm/slab.h | 17 ++++++++--------- mm/slub.c | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 8e71968300c8..a8e35265c1c5 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1380,7 +1380,7 @@ static struct page *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, return NULL; } - account_slab_page(page, cachep->gfporder, cachep, flags); + account_slab(page_slab(page), cachep->gfporder, cachep, flags); __SetPageSlab(page); /* Record if ALLOC_NO_WATERMARKS was set when allocating the slab */ if (sk_memalloc_socks() && page_is_pfmemalloc(page)) @@ -1405,7 +1405,7 @@ static void kmem_freepages(struct kmem_cache *cachep, struct page *page) if (current->reclaim_state) current->reclaim_state->reclaimed_slab += 1 << order; - unaccount_slab_page(page, order, cachep); + unaccount_slab(page_slab(page), order, cachep); __free_pages(page, order); } diff --git a/mm/slab.h b/mm/slab.h index 9b2c7072a290..be42a467eeac 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -583,24 +583,23 @@ static inline struct kmem_cache *virt_to_cache(const void *obj) return page->slab_cache; } -static __always_inline void account_slab_page(struct page *page, int order, - struct kmem_cache *s, - gfp_t gfp) +static __always_inline void account_slab(struct slab *slab, int order, + struct kmem_cache *s, gfp_t gfp) { if (memcg_kmem_enabled() && (s->flags & SLAB_ACCOUNT)) - memcg_alloc_page_obj_cgroups(page, s, gfp, true); + memcg_alloc_page_obj_cgroups(slab_page(slab), s, gfp, true); - mod_node_page_state(page_pgdat(page), cache_vmstat_idx(s), + mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s), PAGE_SIZE << order); } -static __always_inline void unaccount_slab_page(struct page *page, int order, - struct kmem_cache *s) +static __always_inline void unaccount_slab(struct slab *slab, int order, + struct kmem_cache *s) { if (memcg_kmem_enabled()) - memcg_free_page_obj_cgroups(page); + memcg_free_page_obj_cgroups(slab_page(slab)); - mod_node_page_state(page_pgdat(page), cache_vmstat_idx(s), + mod_node_page_state(slab_pgdat(slab), cache_vmstat_idx(s), -(PAGE_SIZE << order)); } diff --git a/mm/slub.c b/mm/slub.c index a0124ee8f865..725f1332f936 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1943,7 +1943,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) page->objects = oo_objects(oo); - account_slab_page(page, oo_order(oo), s, flags); + account_slab(page_slab(page), oo_order(oo), s, flags); page->slab_cache = s; __SetPageSlab(page); @@ -2014,7 +2014,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page) page->slab_cache = NULL; if (current->reclaim_state) current->reclaim_state->reclaimed_slab += pages; - unaccount_slab_page(page, order, s); + unaccount_slab(page_slab(page), order, s); __free_pages(page, order); }