From patchwork Wed Nov 2 09:12:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 14139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3507325wru; Wed, 2 Nov 2022 02:21:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6XOH4SMJiEgyoyXWAsey0H2tjySspzwSuqrQkXB+6ROhVXc3AaqEeuv1ETkBuUwNLl1WkR X-Received: by 2002:a17:907:8a17:b0:7ad:b5f1:8ff7 with SMTP id sc23-20020a1709078a1700b007adb5f18ff7mr20945330ejc.529.1667380917028; Wed, 02 Nov 2022 02:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667380917; cv=none; d=google.com; s=arc-20160816; b=Gi1k6H07qekN52cRK7/Ym2VExiZO5a+5W6SjYRbhImcksj6WUU0QkY8Z/de85ySaVz Fap8sePt7h9RN1A+j1Hs+yVtVqtz+eY481yoYrkE2KMZcMxHzSJogkm7PDumBHlZ8YvN UZOaey06jJMVvDAwJvKc6UbXHpfCPt3l99o7VDLZTz+Y9hR74zENN5lJa/pmAy2cjz7j 6DAvE3ZJ1nJIbiinheOmsKZuN06iL0ETzLEA0iB8sXVDgqLXeP+vaEmCaoCPbGSE7Cbh GLheKAH07CBWRyYI0baKjWpXZgPdxP2EIBTVdjV0hIFcE+jmBIsxoWzoHNlaoZv7YnNY uDNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=oMREbSjW1m1DQRIRobOJxb5WF+kSzXiQo4pLiuFB+9U=; b=GE28eHfJV8SPZDkYGGwWEujEqdnVWlH4kHVmszwvVZA1Qkg0H++4RXIKNzpNmeczDC SFf6sWpjZFJ4hnob9obMSbpqsE7xrp/35iEnYWxyJ6WXyT+PNNtyiWHuuyAK7I7SS82f 1jHoZZ6zK1gHG/A+LURyH4t4WAUDSWKqxB7oRb6qFqqURkpvKMg+LFwm/kX6TiZpjAP9 fX0Z7ITmeYHNWv2OgBVkCWAK9kwI2zPxFCfpY22/7xeyzwO+ewf9E1oq1xSlwC8MfPh8 7L73NKcRaz1mgA2wwUxMl5X48Q/qun1ZOceSoHN6qeeQJRf/npSY7ogxU7JF2YiiLFDb Wowg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="H/8/yUcd"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=9QUDXiZe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a056402355300b0045d9ceae669si16938392edd.404.2022.11.02.02.21.32; Wed, 02 Nov 2022 02:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="H/8/yUcd"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=9QUDXiZe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbiKBJPC (ORCPT + 99 others); Wed, 2 Nov 2022 05:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbiKBJNu (ORCPT ); Wed, 2 Nov 2022 05:13:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772EE29364; Wed, 2 Nov 2022 02:12:56 -0700 (PDT) Date: Wed, 02 Nov 2022 09:12:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667380375; h=from:from:sender:sender:reply-to: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; bh=oMREbSjW1m1DQRIRobOJxb5WF+kSzXiQo4pLiuFB+9U=; b=H/8/yUcd8R/Of3fTGJL6zoT8ERF7Jc/zIW1itBszOao4E+qWJJmvnXakiOYnfTZ2grepIA fr4Fp+y+gJL9nQLDwYl7tuuGozlXy5is1rmgmRl+ih2nENufb3LGDUljvX/KZJmnOsz2nD V0P29xM/z+0vh7Vi3yXM8Rx9SHlnq6MEHDeT6n+SAUVD4XFtxZ5+zrI9+tc4c9KUhFTt7a JvYBIMPz1N8DiDJlDgoXyWddBh/uQnw58nnYNQCbGEwUMnGMhuqVIkJbQwqorzxP1P0FeT I5euODlWio0QsyVrZAkdGMXYkDEXjw1ZKXtLn8Wm+t1fkwPT+Y9WeQ9Yjw4UBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667380375; h=from:from:sender:sender:reply-to: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; bh=oMREbSjW1m1DQRIRobOJxb5WF+kSzXiQo4pLiuFB+9U=; b=9QUDXiZeBBe6Lzl1bfCFhYiXnCF/oaqw2pZbMemy/gQSw/95y7oLEIv3kJ2MpX/y7p1Y+Q wvxUcXjFRU5y6BDQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] mm: Move mm_cachep initialization to mm_init() Cc: "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221025201057.751153381@infradead.org> References: <20221025201057.751153381@infradead.org> MIME-Version: 1.0 Message-ID: <166738037356.7716.15264994823926137234.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747691786483684640?= X-GMAIL-MSGID: =?utf-8?q?1748375612260198401?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: a2e87952bf54b99e8d560c095a2c75ebc676e1fb Gitweb: https://git.kernel.org/tip/a2e87952bf54b99e8d560c095a2c75ebc676e1fb Author: Peter Zijlstra AuthorDate: Tue, 25 Oct 2022 21:38:18 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 01 Nov 2022 13:43:56 +01:00 mm: Move mm_cachep initialization to mm_init() In order to allow using mm_alloc() much earlier, move initializing mm_cachep into mm_init(). Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20221025201057.751153381@infradead.org --- include/linux/sched/task.h | 1 + init/main.c | 1 + kernel/fork.c | 32 ++++++++++++++++++-------------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h index d6c4816..8431558 100644 --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -65,6 +65,7 @@ extern void sched_dead(struct task_struct *p); void __noreturn do_task_dead(void); void __noreturn make_task_dead(int signr); +extern void mm_cache_init(void); extern void proc_caches_init(void); extern void fork_init(void); diff --git a/init/main.c b/init/main.c index aa21add..f1d1a54 100644 --- a/init/main.c +++ b/init/main.c @@ -860,6 +860,7 @@ static void __init mm_init(void) /* Should be run after espfix64 is set up. */ pti_init(); kmsan_init_runtime(); + mm_cache_init(); } #ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET diff --git a/kernel/fork.c b/kernel/fork.c index 08969f5..451ce80 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -3015,10 +3015,27 @@ static void sighand_ctor(void *data) init_waitqueue_head(&sighand->signalfd_wqh); } -void __init proc_caches_init(void) +void __init mm_cache_init(void) { unsigned int mm_size; + /* + * The mm_cpumask is located at the end of mm_struct, and is + * dynamically sized based on the maximum CPU number this system + * can have, taking hotplug into account (nr_cpu_ids). + */ + mm_size = sizeof(struct mm_struct) + cpumask_size(); + + mm_cachep = kmem_cache_create_usercopy("mm_struct", + mm_size, ARCH_MIN_MMSTRUCT_ALIGN, + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, + offsetof(struct mm_struct, saved_auxv), + sizeof_field(struct mm_struct, saved_auxv), + NULL); +} + +void __init proc_caches_init(void) +{ sighand_cachep = kmem_cache_create("sighand_cache", sizeof(struct sighand_struct), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TYPESAFE_BY_RCU| @@ -3036,19 +3053,6 @@ void __init proc_caches_init(void) SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, NULL); - /* - * The mm_cpumask is located at the end of mm_struct, and is - * dynamically sized based on the maximum CPU number this system - * can have, taking hotplug into account (nr_cpu_ids). - */ - mm_size = sizeof(struct mm_struct) + cpumask_size(); - - mm_cachep = kmem_cache_create_usercopy("mm_struct", - mm_size, ARCH_MIN_MMSTRUCT_ALIGN, - SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, - offsetof(struct mm_struct, saved_auxv), - sizeof_field(struct mm_struct, saved_auxv), - NULL); vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC|SLAB_ACCOUNT); mmap_init(); nsproxy_cache_init();