Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2453737rdb; Mon, 20 Nov 2023 11:09:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoNUMrvYthpXDEpepGtQxcIGr2uOvOVGCSC3IMmOy5WVJDhhNMUcaUhKjPlPqRY23UOiV8 X-Received: by 2002:a17:902:e9c4:b0:1ce:5b93:1596 with SMTP id 4-20020a170902e9c400b001ce5b931596mr6364402plk.5.1700507356047; Mon, 20 Nov 2023 11:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700507356; cv=none; d=google.com; s=arc-20160816; b=lfUmZH+EYMFXAhnnvTsi2I1+qhnpJK+lWxh0zIvk57qzl4fQlpJ1LKJC/EQPvqjnXk ySh3smfd311lWxvIthLxuvcH2jH7Y/tm8P3LWNgWED5x2AKgbM57X1nJzgBWnmzj3JLQ 7hc9rAXEFysYPUEdbEgbzPTueaM7KoGIB2XyGCmxmrjNXGjPGExz+3C1iTLQ93DQXx+F 7QQ42ZMvxKxEbPXoLBxSyZnmYPkAXXKzOg5beae42wSSBgZAN6kiKGOJhaD7tzBt8QYs BS3d5dlFpO7bTtcDk3gRvMTxPAY4iYEkpzTSmA3jsjpTW0HNyl5rDqqYOBc4WRYso3ab xr+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date; bh=B/ekZlEJY+xwHJFCVFiJZFG/oIBThuROvM33wyPHXL8=; fh=yCfdKXuOwfgvF3mtQUf79mMaq0MdKvFHdMXBcTtbfhI=; b=AIwhYo0TP8d1GL9NNDgkiUeAzXyDSFrGFJkE7S2rc2AblNwcnEkCd7VmZ+ONRlMgQd Q7Z1RpRvxKdeq54QegMP3xfOwwWysFDNOLZ5cAOXG8H1FhRaqt79sIrK4V4apk675VBe 8g7L4m4wWfUKq2NzZ0mMSyVWevoC7XhpwqowAkLlwMyDxcYPxc2i9m+5pyjJlPrTvs31 ED6rkJOe/h3nHWA5pVpnpiiiy9XPDOOaWcLBI/JhtMvksFHL2Fu9dNNOnTptP0vx+xUp ClBl0JInLf4VjYbvKsLAIQTCUUwjprnZvGciDfxvvnqpMWiKYB3MXs8vpwafrU10qoPf nWPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id c8-20020a170902aa4800b001ca8e7953besi8395083plr.497.2023.11.20.11.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 11:09:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2A641802F7C7; Mon, 20 Nov 2023 11:08:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231859AbjKTTIm (ORCPT + 99 others); Mon, 20 Nov 2023 14:08:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbjKTTIl (ORCPT ); Mon, 20 Nov 2023 14:08:41 -0500 Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DEF96D2; Mon, 20 Nov 2023 11:08:36 -0800 (PST) Received: from uucp by elvis.franken.de with local-rmail (Exim 3.36 #1) id 1r59dK-0000eh-00; Mon, 20 Nov 2023 20:08:34 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id 821E1C0136; Mon, 20 Nov 2023 20:08:24 +0100 (CET) Date: Mon, 20 Nov 2023 20:08:24 +0100 From: Thomas Bogendoerfer To: Jiaxun Yang , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, syq@debian.org, stable@vger.kernel.org Subject: Re: [PATCH] MIPS: process: Remove lazy context flags for new kernel thread Message-ID: References: <20231026111715.1281728-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 11:08:50 -0800 (PST) On Sat, Nov 18, 2023 at 04:36:45PM +0100, Aurelien Jarno wrote: > > Anyway, I have been able to test a backport of the patch onto the 5.10 > > kernel (with minor adjustments) and I confirm it fixes the reported > > issue. > > > > Tested-by: Aurelien Jarno > > It seems that this patch hasn't been merged yet, either in Linus' tree > or in the MIPS tree. Is there anything blocking? sorry, took some time to get really back from vacation... I don't like the patch doing too much code restructing. I can't reproduce on my loongson machine, so I can't test below patch... What cmake version do I need and what would be a package to reproduce the bug ? Thomas. diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 5387ed0a5186..b630604c577f 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -121,6 +121,19 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) /* Put the stack after the struct pt_regs. */ childksp = (unsigned long) childregs; p->thread.cp0_status = (read_c0_status() & ~(ST0_CU2|ST0_CU1)) | ST0_KERNEL_CUMASK; + + /* + * New tasks lose permission to use the fpu. This accelerates context + * switching for most programs since they don't use the fpu. + */ + clear_tsk_thread_flag(p, TIF_USEDFPU); + clear_tsk_thread_flag(p, TIF_USEDMSA); + clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE); + +#ifdef CONFIG_MIPS_MT_FPAFF + clear_tsk_thread_flag(p, TIF_FPUBOUND); +#endif /* CONFIG_MIPS_MT_FPAFF */ + if (unlikely(args->fn)) { /* kernel thread */ unsigned long status = p->thread.cp0_status; @@ -149,20 +162,8 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) p->thread.reg29 = (unsigned long) childregs; p->thread.reg31 = (unsigned long) ret_from_fork; - /* - * New tasks lose permission to use the fpu. This accelerates context - * switching for most programs since they don't use the fpu. - */ childregs->cp0_status &= ~(ST0_CU2|ST0_CU1); - clear_tsk_thread_flag(p, TIF_USEDFPU); - clear_tsk_thread_flag(p, TIF_USEDMSA); - clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE); - -#ifdef CONFIG_MIPS_MT_FPAFF - clear_tsk_thread_flag(p, TIF_FPUBOUND); -#endif /* CONFIG_MIPS_MT_FPAFF */ - #ifdef CONFIG_MIPS_FP_SUPPORT atomic_set(&p->thread.bd_emu_frame, BD_EMUFRAME_NONE); #endif -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]