From patchwork Tue Oct 25 20:06:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 10972 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1197011wru; Tue, 25 Oct 2022 13:15:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4BExWXTvbN8M+mOda7Ia3JCB28feLELbQVOy3c+Kdo/3wKEIwkDI4l7FdCSw+iYSAYpcvd X-Received: by 2002:a63:64d:0:b0:46b:158f:102e with SMTP id 74-20020a63064d000000b0046b158f102emr35268596pgg.150.1666728905435; Tue, 25 Oct 2022 13:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666728905; cv=none; d=google.com; s=arc-20160816; b=vSGCT34sQFCfpuwLFnm+jF4TvsB1Io3ch9mrTCVk7v8+U3BXfWd05Q1Bi8ZVy8cOGV J0ZguE+TtJS9mQHpmoyEPUT4TPpjF31qHBgxdE3rMRe6dp3CprLZcqfZ0LoYUhlxH//r clTxNb0kvEOCxQPIoJh/56V5kgTpcoIKGjUSVvd0pT+eO8/zbMG89bsUfI2yUfMS75K2 irQ0MhcNLteWTTFzoRfbby3k7WMkmjoAgj9EnpfLxvOkTZzjbAhA1PMxAc3gE5fHBGQR fKtMEoc7oxLoc/GRjnrV2NsoHc9GVGJw9Bjkpll7kFnWsCRsrzXdUM9yJAHozgp7k0S1 9NkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=ttT6NbRi8PNEZh+vmTM7YkYkKivgXBYrKgPGhOWejO8=; b=mROrDuVjD9PvBjDRBPqM9FmNB1C80a0rDFb/TS8Cd/Xki1bMlu+nbwJHtHqUh/SQZ2 XKCsCbwFSWfJ6By3cgJh+rvaTrOkMVVb93bfWqLiwNwRAXj1Ygd9NdP/AGrzeNvQhNWT qQNEq5f/PxGle2a4L3zR8cYxRv6ggHxizTNX5lCe+1d06mefXgi2GK6WpD0/hq0mHZFd RYfqYywgtmvRKDmBc/SLe0AyZyAjY56paD51x5lybWZFY7hQPS6MUuA+/DUMhR5gs3Yh NlrrkwuTuek+QobTbS23gGVFMzcXI0tci2ZQq8BAtkuzTIuVCFLYmgCIUhbbvFhRBexu kxBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=CCp5CtY4; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o20-20020a170903301400b0016f1eb1317esi3398140pla.471.2022.10.25.13.14.37; Tue, 25 Oct 2022 13:15:05 -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=@infradead.org header.s=desiato.20200630 header.b=CCp5CtY4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232706AbiJYUMA (ORCPT + 99 others); Tue, 25 Oct 2022 16:12:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiJYULj (ORCPT ); Tue, 25 Oct 2022 16:11:39 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE2267A774 for ; Tue, 25 Oct 2022 13:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=ttT6NbRi8PNEZh+vmTM7YkYkKivgXBYrKgPGhOWejO8=; b=CCp5CtY4T2ASXO7NOuGpEDuCUr D6t4vGtY4Jh7x11ri+mThqWYX9jTtY9HLfICzpS4f012b0R/vJMwUK0dvPo8jdUI3zbjrekgkGyDd 1wj7UY+UC1G4hOubbmL1R7N9O+Cf/Z3v2vz4w89B5NXDn9Pk9I5tXmz0gCauho/WDdQLBqP31sMeA Eaa5jOAOsz3YdrjHdvt1LTxCrE7vUUoWy1Osae/6CMuOaKXAqDVvvqPw8wimINajbonMTePqD2vMt Xu7TxQV5MJrXT3uMz/z6IXdMWjhH6bPzi2DCP3LfZbjkATjOHXFqU2B0AUJKXQp62fMPct8jpVcbY OfM9pnBw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1onQGh-006OK5-Sv; Tue, 25 Oct 2022 20:11:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A678630020C; Tue, 25 Oct 2022 22:11:22 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 8E23B2C4502EB; Tue, 25 Oct 2022 22:11:22 +0200 (CEST) Message-ID: <20221025201057.816175235@infradead.org> User-Agent: quilt/0.66 Date: Tue, 25 Oct 2022 22:06:58 +0200 From: Peter Zijlstra To: torvalds@linux-foundation.org, rostedt@goodmis.org, dave.hansen@intel.com Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, x86@kernel.org, keescook@chromium.org, seanjc@google.com Subject: [PATCH 2/5] x86/mm: Use mm_alloc() in poking_init() References: <20221025200656.951281799@infradead.org> MIME-Version: 1.0 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_NONE,URIBL_BLOCKED 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?1747691929011045474?= X-GMAIL-MSGID: =?utf-8?q?1747691929011045474?= Instead of duplicating init_mm, allocate a fresh mm. The advantage is that mm_alloc() has much simpler dependencies. Additionally it makes more conceptual sense, init_mm has no (and must not have) user state to duplicate. Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/mm/init.c | 2 +- include/linux/sched/task.h | 1 - kernel/fork.c | 5 ----- 3 files changed, 1 insertion(+), 7 deletions(-) --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -801,7 +801,7 @@ void __init poking_init(void) spinlock_t *ptl; pte_t *ptep; - poking_mm = copy_init_mm(); + poking_mm = mm_alloc(); BUG_ON(!poking_mm); /* --- a/include/linux/sched/task.h +++ b/include/linux/sched/task.h @@ -91,7 +91,6 @@ extern void exit_itimers(struct task_str extern pid_t kernel_clone(struct kernel_clone_args *kargs); struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node); struct task_struct *fork_idle(int); -struct mm_struct *copy_init_mm(void); extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); extern pid_t user_mode_thread(int (*fn)(void *), void *arg, unsigned long flags); extern long kernel_wait4(pid_t, int __user *, int, struct rusage *); --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2592,11 +2592,6 @@ struct task_struct * __init fork_idle(in return task; } -struct mm_struct *copy_init_mm(void) -{ - return dup_mm(NULL, &init_mm); -} - /* * This is like kernel_clone(), but shaved down and tailored to just * creating io_uring workers. It returns a created task, or an error pointer.