From patchwork Tue Sep 3 14:20:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13788791 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 45F82CD343A for ; Tue, 3 Sep 2024 14:22:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBA318D017F; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B19118D0151; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96C198D017F; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 771758D0151 for ; Tue, 3 Sep 2024 10:22:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3121F16049C for ; Tue, 3 Sep 2024 14:22:46 +0000 (UTC) X-FDA: 82523643132.14.73BB533 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf13.hostedemail.com (Postfix) with ESMTP id 6A87520011 for ; Tue, 3 Sep 2024 14:22:44 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZIqDi3Qn; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725373294; a=rsa-sha256; cv=none; b=OvCTdM/vvcXAoLqFNFesGECLtFKeTWHJTZ817jwXIba22UM6+4Xvdx7mr18B7l+9/siu3I Fwud1YOHZv3uVD97rAynOCpsGXNEIyiwsy7MNJjcZnvUYaPj7XZQHZcR+JpfajjV83qU3k qpYJ99SQlHGSbyWNqWD8IQWwTQ3s95s= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZIqDi3Qn; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of brauner@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=brauner@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725373294; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=siTqtc1OnM67NaS3OzQvKJYHjkGXxYArN7ctaraJEz0=; b=1b6gDYUtTLSyzDEghVRRhO0/vy/KDBdRLx42tjKp+XzM1UmgLZhAhBXnAGpwkg16MK+gs9 Fz6IEsInFiMkWH94as/xTSa9m3De3r20x2CLEZfmS3x0/6WdZxBZ+qlHhBy+t/YSzoaK0V SrepGenTuBCvZry4sDGj9KylMwMfNMA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A2489A43677; Tue, 3 Sep 2024 14:22:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE620C4CEC4; Tue, 3 Sep 2024 14:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725373363; bh=+kTwNa1m6b/Hnr0YtIDtx0q9W42j7lzgwCx+jUzI5rs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZIqDi3QnJT6V+K28/jD+UNtuaEDHlnJWqYR8lxhqiapVrTdtG0h22hWUu81vD5O2+ jXFZjjBzQ8TZLgYQuZUDqWdgcND9G8Rz9UOfeQPM2XeImc+frsoPSL6onkde1jl1tY VAHgG1WziE9j9W4rFM9UIyvhpxLFqaxvTZkQ6SCPA8Gu4Mjyk55DAavUexXA9nChen uI00cTePs9fVCgmjPnmJbiR3TTTuRimy87cmxjPvCWtB3zu5XJAE3ncQJwG/bdg/RC 6t2651rDtNYBxxp2lsxTdiw2E/iwWxq/nt4y7EyD2YVjPFboFkKnXucewOKJb5i21q 76YuSfJsqpdfQ== From: Christian Brauner Date: Tue, 03 Sep 2024 16:20:50 +0200 Subject: [PATCH v2 09/15] sl*b: remove rcu_freeptr_offset from struct kmem_cache MIME-Version: 1.0 Message-Id: <20240903-work-kmem_cache_args-v2-9-76f97e9a4560@kernel.org> References: <20240903-work-kmem_cache_args-v2-0-76f97e9a4560@kernel.org> In-Reply-To: <20240903-work-kmem_cache_args-v2-0-76f97e9a4560@kernel.org> To: Vlastimil Babka , Jens Axboe , Jann Horn , Linus Torvalds , Mike Rapoport Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=3722; i=brauner@kernel.org; h=from:subject:message-id; bh=+kTwNa1m6b/Hnr0YtIDtx0q9W42j7lzgwCx+jUzI5rs=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdl57jvoPX02rSPSWTt/ddD73463HOrSVxeqTj4aOzw 5g3SP541FHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRBysY/unOE+Ll3uq9eeUC ieve17+IL5eOKJ3Vxv1pX/e6yVsDmu8yMvy9e2/elMKab78eFp99eugk338zkZNyMxfOisxszz/ 89zQ7AA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 X-Rspamd-Queue-Id: 6A87520011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: k4og8rhfdjwo8aht9y3wu7pa3drexfg7 X-HE-Tag: 1725373364-237585 X-HE-Meta: U2FsdGVkX1+gQU4DxYwFYjpREl6uUtEhPfkvrNUyuVDSPHqSSisWklqRv7GAY3JtuWZ8+a+yEhwWicnJQG2EbtBG4/KFcd1UH8LbwXFO8wtJPRAUU6oN7gM77xbG7SKv2czeG05eQC0GRG+F+yxR8t3wtSFjwrF7BzfcRs92JTU+ML8l9mqExhSM87K/BMc+l/W1F2tylr8lUTXIWyvToJ7c9konICKOD211nPEwS5Q2f0IqEr1/xaHHfKOhYiTjI2PmLmYHvBSBkGB827tvs6szOx+X5Lms4xN4EKciwujB6/t5UEincA0bqsc1cI5JpdAS+MXuRN52oIfT8d8gx7ba/nBSZ0fFy/HyvVy/K9kH3eI1LP5je1hyrR9XpODpTTVau18Qg6Oq1uJpd4YB6uGGz4xG3riY10FQ4BNvbx7oTM0vZWqiSxtpQ0gDEKfSYvB30CA9kOUKuAb9zXnnij3sSMCW1FSqlxQMp00kI4r1l5pJ//MianTChLgMUn9PbFOvJpzSx5wkJpIL823hGw4DSXAAFh8xRs6Jhy7n49hllTVSiCUCdmo6FikwJLVsO7bh6YjXxiz4A9Ei8A2eXbgde43WcPfLTpvPhshVwC1dGuFmHvElHm8xbfF3LdC6DNAgg6UZxQdNmI87lH3hrqtuJSssAqJjpnYin/UBxRNXXixux+UmuiNt+9/JqUuiMBOgCiv70KaAfKtFxEqosmiqKt0jal5n7zAUsbLonJFE3JvDDhEyLVhyQdUd91oL/eDzRuajA9QI5LuIQ4Bcw8biaBIoLQTupuVPF8El2TaamuapQ/vmoGJ7NrIRlIco5mCsDlX7B+JT2acuH8jIOXDFWCqBItPlzxebmehfw/sacSb6t8soRWkO17eToRg3501FPC5VZ24K8XdIMKd4OB2QUKoHVGaCCYZANCSUlZ0YDQc7T5ssRqPLuH0vyXC45EDIEqFRRUKCMn9DgS2 h8uOnXUv qJViEtoAvhD0lU1tmoKIC2iQpXydAdigNc+fJ+5VXhe+VeBheXzeYgDmNfreKc0SJVFE7WP+7NAc/gQylR4WWyRlEaUyja1XGbsUJMAFsFoy44cEtONL+zhI0WAgnJupgOky6NYVtzWuaA8Q6FHYnM3XWECQOLirx0/dnJYXPVwZ6khd3pXsH43mYrSgjrbLVmx2zBa5eqfNHNPaYprdBSzZcagwLuqSjbtAgpboT5Ehj8QO/KXJpVwVqCAWHaAPB8x/RTLDTzCJTGFTKtJzgylN5v+VP8E+cfRPAMJX1ltZWQ1hMqnEjx95oKlorvkTjMgR5 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: Now that we pass down struct kmem_cache_args to calculate_sizes() we don't need it anymore. Signed-off-by: Christian Brauner Reviewed-by: Mike Rapoport (Microsoft) --- mm/slab.h | 2 -- mm/slub.c | 25 +++++++------------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index c7a4e0fc3cf1..36ac38e21fcb 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -261,8 +261,6 @@ struct kmem_cache { unsigned int object_size; /* Object size without metadata */ struct reciprocal_value reciprocal_size; unsigned int offset; /* Free pointer offset */ - /* Specific free pointer requested (if not UINT_MAX) */ - unsigned int rcu_freeptr_offset; #ifdef CONFIG_SLUB_CPU_PARTIAL /* Number of per cpu partial objects to keep around */ unsigned int cpu_partial; diff --git a/mm/slub.c b/mm/slub.c index 4719b60215b8..a23c7036cd61 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -3916,8 +3916,7 @@ static void *__slab_alloc_node(struct kmem_cache *s, * If the object has been wiped upon free, make sure it's fully initialized by * zeroing out freelist pointer. * - * Note that we also wipe custom freelist pointers specified via - * s->rcu_freeptr_offset. + * Note that we also wipe custom freelist pointers. */ static __always_inline void maybe_wipe_obj_freeptr(struct kmem_cache *s, void *obj) @@ -5141,17 +5140,11 @@ static void set_cpu_partial(struct kmem_cache *s) #endif } -/* Was a valid freeptr offset requested? */ -static inline bool has_freeptr_offset(const struct kmem_cache *s) -{ - return s->rcu_freeptr_offset != UINT_MAX; -} - /* * calculate_sizes() determines the order and the distribution of data within * a slab object. */ -static int calculate_sizes(struct kmem_cache *s) +static int calculate_sizes(struct kmem_cache_args *args, struct kmem_cache *s) { slab_flags_t flags = s->flags; unsigned int size = s->object_size; @@ -5192,7 +5185,7 @@ static int calculate_sizes(struct kmem_cache *s) */ s->inuse = size; - if (((flags & SLAB_TYPESAFE_BY_RCU) && !has_freeptr_offset(s)) || + if (((flags & SLAB_TYPESAFE_BY_RCU) && !args->use_freeptr_offset) || (flags & SLAB_POISON) || s->ctor || ((flags & SLAB_RED_ZONE) && (s->object_size < sizeof(void *) || slub_debug_orig_size(s)))) { @@ -5214,8 +5207,8 @@ static int calculate_sizes(struct kmem_cache *s) */ s->offset = size; size += sizeof(void *); - } else if ((flags & SLAB_TYPESAFE_BY_RCU) && has_freeptr_offset(s)) { - s->offset = s->rcu_freeptr_offset; + } else if ((flags & SLAB_TYPESAFE_BY_RCU) && args->use_freeptr_offset) { + s->offset = args->freeptr_offset; } else { /* * Store freelist pointer near middle of object to keep @@ -5856,10 +5849,6 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, #ifdef CONFIG_SLAB_FREELIST_HARDENED s->random = get_random_long(); #endif - if (args->use_freeptr_offset) - s->rcu_freeptr_offset = args->freeptr_offset; - else - s->rcu_freeptr_offset = UINT_MAX; s->align = args->align; s->ctor = args->ctor; #ifdef CONFIG_HARDENED_USERCOPY @@ -5867,7 +5856,7 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, s->usersize = args->usersize; #endif - if (!calculate_sizes(s)) + if (!calculate_sizes(args, s)) goto out; if (disable_higher_order_debug) { /* @@ -5877,7 +5866,7 @@ int do_kmem_cache_create(struct kmem_cache *s, const char *name, if (get_order(s->size) > get_order(s->object_size)) { s->flags &= ~DEBUG_METADATA_FLAGS; s->offset = 0; - if (!calculate_sizes(s)) + if (!calculate_sizes(args, s)) goto out; } }