From patchwork Fri May 31 12:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13681646 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7F27C25B75 for ; Fri, 31 May 2024 12:29:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C00F6B0099; Fri, 31 May 2024 08:29:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 270406B009A; Fri, 31 May 2024 08:29:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15F216B009B; Fri, 31 May 2024 08:29:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EE7D06B0099 for ; Fri, 31 May 2024 08:29:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9D7FE1C2BEF for ; Fri, 31 May 2024 12:29:08 +0000 (UTC) X-FDA: 82178620776.08.BE70BC4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 0032AC0009 for ; Fri, 31 May 2024 12:29:06 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bnPtnHnF; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717158547; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=4ULSdoZS/Z0xXr1FqcxhAavImmsuIW9aNCUNhbRdNB4=; b=5FeELho1DImQVlCZiQ3ggjXwhSa+EF+DCdoZiXb3FJko51evl6VAYURFBpucHwWs84CLhG tAvBVUWNzDAMKECT+jE4q8GRmY71TOwv+MClvStP9ZACRTZEKqhubIxUQDC0lp2igkY4fn YCtc/KCfOjN5EMZfV1KAa0UE+aPnKCs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717158547; a=rsa-sha256; cv=none; b=U1It6l5+ptCLOCUxqtaHe3X1IZYRzS/FBGzqxa0mqt/rEsh6xn2rLjUeArvodLNssYcuoM hjKZH9KWWfjfTZCuhdN3odh/ycbaqXKqg7OPebmRRK42acABXjWfrIuR2SPsZk1PM32K2a e3Idl13IrKlbovvS3IoayA+1UUVzy+A= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bnPtnHnF; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=4ULSdoZS/Z0xXr1FqcxhAavImmsuIW9aNCUNhbRdNB4=; b=bnPtnHnFvUcTWSRn9QGIBnZ8N6 b14/rbqq5O3mjq6Dy+2XHZLoLuMI1rqRDDP7MrVF1uk8jI1NconEzQYqrNgCZ0aNaUHaRdch+E7cb RKHEuSkc97UauHAwHbg+vnRJxruDwBs6qwELwO3I6RFucHf9tvcOsvYGwwvL1tAbDsbmzLmWOU8vk 0k7Eb0wPmobpSuA9uZ/Q4KqkqNu/B3xLONX2XetqClhdGGVL00wAutzVfOblTXt71yonClgeJ1NOt GGRYdMEf1BlmkUsCRwVAAwt0kRnO5FLKeatadzKGDqqDMru4joOrWf7N0EqmOltmu2uWWLvZGXg5h 3SPsUDkQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sD1NZ-0000000Bhp2-0z7M; Fri, 31 May 2024 12:29:05 +0000 From: "Matthew Wilcox (Oracle)" To: Vlastimil Babka Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH] mm: Reduce the number of slab->folio casts Date: Fri, 31 May 2024 13:29:02 +0100 Message-ID: <20240531122904.2790052-1-willy@infradead.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: kmftkwakzdhmm5hgd3x3qdz83heyn6mi X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0032AC0009 X-HE-Tag: 1717158546-866498 X-HE-Meta: U2FsdGVkX18NjYQ/88IjmvTBDCNkdFwLC6ABwLvCO8ESbIUZop604TXkFEbp5FwRtPQGwrnwnh/nZjFQGCTqVr6N7piQK3mqd9HBqE0gkreH1Ky3RggrzvV/gXoeyBgqmSfQ587JVPM/DZ49eR3Eju23eK1z2LyeNg87JCnUOcOYm7duPAiCRKL6Ws83oK13hXs3vPbc6pEfVWUWPEmfbXYi7hlNSQtd4I122H5f3kHbSKSHIuUaLKv4EdRUW2LyvJi1r4yE91VLlPAZW7NkVHPfMgBBN8T2iKS3kh1kbaiqkL7BhH4+j7GwlMWd1EgLa0DHNGFtNUfmLTKRKxbVJwPDx9cCJyTpdP6RwdlRsLTn5HZGcG3H3QWCB06c5itc1tDr+NjjQFgsjety6UiPylFpwtaWDfTb4VvJvHCg8HynZMaYZzRkZK3GNO68ASuaOEDpJ2Oby+xlDc6D/u1ZwF4t22eUiaHJ/Z3q6ccKmxrG7fdszcIiqonSizvLcbUgpSmQ4Ia3gLPr7AUTm+So1/dHU8pXrLO0xOfg41ydXpbDwygOvYEmllJYvafEI2sP5pCTuYRnLMUDbf/W/z6h2dua2xT/gIKt4Swnlji3H27wONSsTMgbIKZ/EFj6x/2wWl3AyClz0tlOjfm0xVePaH2z+bU55RH4x/yw9VZCeiwl+fBbJNBeG3uBaHp+cjiMn6XgtezEpLba6SyhlNx2MQ+WPnD65Mdgl/wd2ykLEWDXwCBu99YmLiK/wy1+GFGwb6vw2NFWbNld3RNV2YOi9ebHnHbCHEqjeoJxcRaIKrvc0pm57nW3dJTUYOF+SkFjs5rl64nAuUoahVZ8SGHoCLymH0BQUMoH4aLYuFjp2v1NjQqQz8OWWENGfdzWPpJTe4rdAy88/eVwXJ9+ltY8IHwQwKc5RaazAnfTT2SK7phqry0URpanYnUSX2juzpPEhLwAFDGTjaS2GiFNAAE JNLte+a5 WEIf2y/wAwcTfphdOcIYwx9GCh6YLf8ROOyipHoq+YZgEoQTy1gzaXgQBAl3hPOzioeU41SILpCIVuKo+gnz28rfalX355ugp2GnNXRJVtNrb78P7EUgrRO+h23RNyLXGTm2IO7YFMenb+hnzlDs7ePVez4ky5YhqJWoFl1GjeYWzymDo8aYPIv6/6w== 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: List-Subscribe: List-Unsubscribe: Mark a few more folio functions as taking a const folio pointer, which allows us to remove a few places in slab which cast away the const. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 6 +++--- mm/slab.h | 4 ++-- mm/slub.c | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a20a6be730a1..4bb841086438 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1105,7 +1105,7 @@ static inline unsigned int compound_order(struct page *page) * * Return: The order of the folio. */ -static inline unsigned int folio_order(struct folio *folio) +static inline unsigned int folio_order(const struct folio *folio) { if (!folio_test_large(folio)) return 0; @@ -2148,7 +2148,7 @@ static inline struct folio *folio_next(struct folio *folio) * it from being split. It is not necessary for the folio to be locked. * Return: The base-2 logarithm of the size of this folio. */ -static inline unsigned int folio_shift(struct folio *folio) +static inline unsigned int folio_shift(const struct folio *folio) { return PAGE_SHIFT + folio_order(folio); } @@ -2161,7 +2161,7 @@ static inline unsigned int folio_shift(struct folio *folio) * it from being split. It is not necessary for the folio to be locked. * Return: The number of bytes in this folio. */ -static inline size_t folio_size(struct folio *folio) +static inline size_t folio_size(const struct folio *folio) { return PAGE_SIZE << folio_order(folio); } diff --git a/mm/slab.h b/mm/slab.h index 5f8f47c5bee0..b16e63191578 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -166,7 +166,7 @@ static_assert(IS_ALIGNED(offsetof(struct slab, freelist), sizeof(freelist_aba_t) */ static inline bool slab_test_pfmemalloc(const struct slab *slab) { - return folio_test_active((struct folio *)slab_folio(slab)); + return folio_test_active(slab_folio(slab)); } static inline void slab_set_pfmemalloc(struct slab *slab) @@ -211,7 +211,7 @@ static inline struct slab *virt_to_slab(const void *addr) static inline int slab_order(const struct slab *slab) { - return folio_order((struct folio *)slab_folio(slab)); + return folio_order(slab_folio(slab)); } static inline size_t slab_size(const struct slab *slab) diff --git a/mm/slub.c b/mm/slub.c index 95e0a3332c44..b8ba068ca079 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -962,11 +962,9 @@ void print_tracking(struct kmem_cache *s, void *object) static void print_slab_info(const struct slab *slab) { - struct folio *folio = (struct folio *)slab_folio(slab); - pr_err("Slab 0x%p objects=%u used=%u fp=0x%p flags=%pGp\n", slab, slab->objects, slab->inuse, slab->freelist, - folio_flags(folio, 0)); + &slab->__page_flags); } /* @@ -2532,7 +2530,7 @@ static void discard_slab(struct kmem_cache *s, struct slab *slab) */ static inline bool slab_test_node_partial(const struct slab *slab) { - return folio_test_workingset((struct folio *)slab_folio(slab)); + return folio_test_workingset(slab_folio(slab)); } static inline void slab_set_node_partial(struct slab *slab)