From patchwork Tue Aug 13 04:29:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 13761253 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 64F5FC52D7C for ; Tue, 13 Aug 2024 04:30:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AD156B00AB; Tue, 13 Aug 2024 00:30:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0361C6B00AC; Tue, 13 Aug 2024 00:30:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF2706B00AE; Tue, 13 Aug 2024 00:30:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id ABD706B00AB for ; Tue, 13 Aug 2024 00:30:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6C0F340613 for ; Tue, 13 Aug 2024 04:30:22 +0000 (UTC) X-FDA: 82445945484.25.413A985 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id C7A5440011 for ; Tue, 13 Aug 2024 04:30:20 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OLNzorZQ; spf=pass (imf12.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723523350; 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:in-reply-to:references:references:dkim-signature; bh=YYMIRaq+cLum7NENIPqqC0D6npIgjfOITQlSDs4Hi5Y=; b=OT/Ah9Ycq7Tc0rv+PRYHOKo9Gy9F81PDGr8zFORUcfRLZs8yoTRNKuddTHBON1wpG80b/R 7tsYaF/pLRBla9wQw/1gvhJkZ9WKEWJXcdTyIruWJ/QiZMRqmSoYAMSPJMy+mPMdslBVvD kbAwowZsRr9g6xm94+GdFNAdM7voedI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723523350; a=rsa-sha256; cv=none; b=Y6zZhbnM68p1bJh4xblEHeSQ7vSRRVaurlnlTFK8Ahhcp411d4EPNa/rAidGaNGSgdqDyI LTZWnv2Kkktokpz8kBe5l8qq29eGbdot8ggC50RhgTYhj+BCqT6rGOFXx59BEvJZCvMPVw QL6P14jJ+nvH5eQ/vXYeFp1OZdjwBs4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OLNzorZQ; spf=pass (imf12.hostedemail.com: domain of andrii@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=andrii@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0DA3F61519; Tue, 13 Aug 2024 04:30:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 948B7C4AF0E; Tue, 13 Aug 2024 04:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723523419; bh=nyRerODhqExBNZEMJor5oVWA71mTXcVPCXwFpQK87yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLNzorZQYwSeMaJO6ZfyOpi4voFgsxSZV0d5e7Qzj9EhA2qXZsvMRIgP+QZ/Gbskg ZBYVI1/3pxnqaxOfifIwgjRD5pPearLl6dOuYiGPxlC+9PlkxIphaHQocP/Mnfwhpw tvmC4tmqfNkwkFV14pqqAgBQiGt01yos3TpcaulRwZSoDwEUfEaQ/cSiBz5/qy+5fK jZo+8Q20NaEfVavXBJXBxFISIiOLjKvxVhOvy5axbn1VwexZJRmQCCwY7Q+1uueSCG K1U03rS2xYpmx0Ru+K8EnjzMNEnQMxpbsPnSM2W7a4OcCt27SFGei8XqAfYRzgMDJT Wuariw/Hk3ntQ== From: Andrii Nakryiko To: linux-trace-kernel@vger.kernel.org, peterz@infradead.org, oleg@redhat.com Cc: rostedt@goodmis.org, mhiramat@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, paulmck@kernel.org, willy@infradead.org, surenb@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, Andrii Nakryiko Subject: [PATCH RFC v3 12/13] mm: add SLAB_TYPESAFE_BY_RCU to files_cache Date: Mon, 12 Aug 2024 21:29:16 -0700 Message-ID: <20240813042917.506057-13-andrii@kernel.org> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240813042917.506057-1-andrii@kernel.org> References: <20240813042917.506057-1-andrii@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C7A5440011 X-Stat-Signature: joadmjc1teggn6fmjjwp91zwhyxzhp8g X-HE-Tag: 1723523420-846495 X-HE-Meta: U2FsdGVkX188M2Qmx/eOk3jvixwmn1BIFdPcGRFRReUyBNWLvnCUhEgc4Syih70ELoSw6TLMmNWcTDxqR4AgTh3XPFgYoUpMyVtt6Wwlz6Yfuko2NzzWCOFCSPWQycB5KBJDsXLkg+r5riqoqY3psZR298jQAqDw3wGsglrUUpaRvaeO1Q/QgL/QwmQYXzKD8YO5vsQhDieTcg4XKEJRgozOfujaQs55wiuM/zIeD0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pWvLtSgAmllf9CIH9BOGC+iheNDDMz9LoSU 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: Add RCU protection for file struct's backing memory by adding SLAB_TYPESAFE_BY_RCU flag to files_cachep. This will allow to locklessly access struct file's fields under RCU lock protection without having to take much more expensive and contended locks. This is going to be used for lockless uprobe look up in the next patch. Suggested-by: Matthew Wilcox Signed-off-by: Andrii Nakryiko --- kernel/fork.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 76ebafb956a6..91ecc32a491c 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -3157,8 +3157,8 @@ void __init proc_caches_init(void) NULL); files_cachep = kmem_cache_create("files_cache", sizeof(struct files_struct), 0, - SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, - NULL); + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TYPESAFE_BY_RCU| + SLAB_ACCOUNT, NULL); fs_cachep = kmem_cache_create("fs_cache", sizeof(struct fs_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT,