From patchwork Mon Oct 4 13:46:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12534151 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 4565DC433F5 for ; Mon, 4 Oct 2021 14:29:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EB4A86136F for ; Mon, 4 Oct 2021 14:29:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EB4A86136F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7161194003A; Mon, 4 Oct 2021 10:29:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C54294000B; Mon, 4 Oct 2021 10:29:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 58E0294003A; Mon, 4 Oct 2021 10:29:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id 48B2394000B for ; Mon, 4 Oct 2021 10:29:40 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DD65330C6B for ; Mon, 4 Oct 2021 14:29:39 +0000 (UTC) X-FDA: 78658988478.18.4D2A5A7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id 7D00D3002E77 for ; Mon, 4 Oct 2021 14:29:39 +0000 (UTC) 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: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=F9wA1P4YWA/sankqM98VLszVm6D3QJEu/8dMbbYQLIM=; b=peQ52vO25QITIbT6MZT1iZyz8U r8PEmeCzX/pv2HfwVWpfXIsgxlt4LJoBJLpdcO0Px3EtJ4TOW1i0s+O6uqSQCOclOKqQ7A8DH0VuX 0dKwjkEsM/jM0YfWzD5xPwLuNdXhz8wTWnpR3/eU4a+D1beRTNVyjXyQ1hhSxOdBc4CBrnaEtpybd V54/K53Ey3qXx37IXc7POoXQn8xJeHXrIhRHcoJH2kT4BWBC/8L5F7dbKl84wKFllMihUh6PDm7PR OyB4TG6hakJdsXf8kqYfHvV24ZZZZ0kDmxLHQlqBCnPnlwAnCf6GAVmN7uldshz/bq0LH4QZHMh6A YE/gk4CQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXOwg-00GzjG-TD; Mon, 04 Oct 2021 14:28:19 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 32/62] mm/slub: Convert shuffle_freelist to struct slab Date: Mon, 4 Oct 2021 14:46:20 +0100 Message-Id: <20211004134650.4031813-33-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211004134650.4031813-1-willy@infradead.org> References: <20211004134650.4031813-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7D00D3002E77 X-Stat-Signature: 1nao7jsr73881nnyqdknna3398idq4ku Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=peQ52vO2; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam06 X-HE-Tag: 1633357779-773309 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: Improve type safety. Signed-off-by: Matthew Wilcox (Oracle) --- mm/slub.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 75a411d6b76e..9a67dda37951 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1831,32 +1831,32 @@ static void *next_freelist_entry(struct kmem_cache *s, struct page *page, } /* Shuffle the single linked freelist based on a random pre-computed sequence */ -static bool shuffle_freelist(struct kmem_cache *s, struct page *page) +static bool shuffle_freelist(struct kmem_cache *s, struct slab *slab) { void *start; void *cur; void *next; - unsigned long idx, pos, page_limit, freelist_count; + unsigned long idx, pos, slab_limit, freelist_count; - if (page->objects < 2 || !s->random_seq) + if (slab->objects < 2 || !s->random_seq) return false; freelist_count = oo_objects(s->oo); pos = get_random_int() % freelist_count; - page_limit = page->objects * s->size; - start = fixup_red_left(s, page_address(page)); + slab_limit = slab->objects * s->size; + start = fixup_red_left(s, slab_address(slab)); /* First entry is used as the base of the freelist */ - cur = next_freelist_entry(s, page, &pos, start, page_limit, + cur = next_freelist_entry(s, slab_page(slab), &pos, start, slab_limit, freelist_count); - cur = setup_object(s, page, cur); - page->freelist = cur; + cur = setup_object(s, slab_page(slab), cur); + slab->freelist = cur; - for (idx = 1; idx < page->objects; idx++) { - next = next_freelist_entry(s, page, &pos, start, page_limit, + for (idx = 1; idx < slab->objects; idx++) { + next = next_freelist_entry(s, slab_page(slab), &pos, start, slab_limit, freelist_count); - next = setup_object(s, page, next); + next = setup_object(s, slab_page(slab), next); set_freepointer(s, cur, next); cur = next; } @@ -1870,7 +1870,7 @@ static inline int init_cache_random_seq(struct kmem_cache *s) return 0; } static inline void init_freelist_randomization(void) { } -static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page) +static inline bool shuffle_freelist(struct kmem_cache *s, struct slab *slab) { return false; } @@ -1926,7 +1926,7 @@ static struct slab *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) setup_page_debug(s, slab_page(slab), start); - shuffle = shuffle_freelist(s, slab_page(slab)); + shuffle = shuffle_freelist(s, slab); if (!shuffle) { start = fixup_red_left(s, start);