Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp327166rwb; Wed, 9 Nov 2022 03:06:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM42aqM8RFyvRcus98nTZx4E4uEKIa3kAhdqR3Wn4+MwW0EEdZDSRBxM5QMvtVv7QQUqnVHP X-Received: by 2002:a17:902:be16:b0:188:5256:bf79 with SMTP id r22-20020a170902be1600b001885256bf79mr33571766pls.133.1667991996190; Wed, 09 Nov 2022 03:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667991996; cv=none; d=google.com; s=arc-20160816; b=f8z2RpBbQE/Meq0Wyvu8vTKJUJXZHSY8qjBuwQ+5QjQ5QYfbOMem6xsfCSaOwZJkIi zjeNRrtNsY1n6sNfaUnz+GTlRE2+9jh9Yo+HBk5u9ISzntDhgaXxJgzfPDLbCY6Lte7t sBMm4BFjOyMvAAzeWqWpYpJxjr1ObgaULlC0GMiesIAzprTffYPXr2LzSvWUTO8ldnY9 c6SRXWMTRSuKTXMxBYFyU4usNnhnW5ZEgkBI2qFh+yQrQnyXLvx+7JbzMasTKD+Kumbz 9m3OzKzddP77DetqEnaN2eKHEA2Y5hweaGogmYIC6xC8WyFy0JEkl1wtV/+WW84z7DQu O8TA== 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:cc:to:from:date:dkim-signature; bh=550k583ytKlQmS1L2KsRGrIUXS3avi+7Y1sWRHILWd4=; b=MB0qLOxJi/Que9vtPTThwuRIL8KAXT+omhurc+gimdqQ7260+Cs6Q7+PVAEj44lk8V EfFDWm3C9PRdf9/yTWJSiWu4qS3DP9ylFcqmt87dxdSTWMX9IExJmjTQBic5ITVNYrf1 hkhRCZFoEZ4aLpe7iinNTtusKeTSusd0mG5SJGZuBmreNlCCQ8VvOPw4bujkRcyYsfnZ H+Ep38VsC6vMmH8K1dlP+17QPs9BRwWsdKKp3NTJT0iYe1i+YKgRa/f+S8eGnv2JcCNJ 7P5NDqCRmp5jrAUZWbaID2gvoBqk++58KOEw9gV85lolqatY68wmhx4VZQzjCX38jiEW mY0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=s+wxmiJe; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020a170902740600b00187052a749dsi14924390pll.413.2022.11.09.03.06.24; Wed, 09 Nov 2022 03:06:36 -0800 (PST) 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=casper.20170209 header.b=s+wxmiJe; 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 S229546AbiKIJ2v (ORCPT + 93 others); Wed, 9 Nov 2022 04:28:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbiKIJ2p (ORCPT ); Wed, 9 Nov 2022 04:28:45 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACF11E4; Wed, 9 Nov 2022 01:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=550k583ytKlQmS1L2KsRGrIUXS3avi+7Y1sWRHILWd4=; b=s+wxmiJezVRJMcVS3iWJaZNuiw A0J9xsum1QBbWbBiOC495YeVzPC5WpSiDKUbSPNibk20303gRcxp7gyORmdJPgGZEAkdgbuZ9cZHo Dc9WFklokbdBybHeVKc/Ga46ztlcpvv5jDm/W59ADpJPgHizYQYqpBAkZFU8Kz64aa1OxXspnDXHH FZNgQFQOaQPJg+uhfzyazfflY9zZEy5lpi+ujVzpPQ0SLJZRJoc9B1TBH1pNLoKqQZL+N5kHiWzgo nNITMPGAx7GPJHWxyrruHDRV91HgD+rkFxog/NNqG/x6E/I6nBznEtUR+41MwnUSXlESAWpVCIyxT jKBhXCUg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oshNj-00B46i-8C; Wed, 09 Nov 2022 09:28:27 +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 6E306300392; Wed, 9 Nov 2022 10:28:18 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2A14C2BD856F7; Wed, 9 Nov 2022 10:28:18 +0100 (CET) Date: Wed, 9 Nov 2022 10:28:18 +0100 From: Peter Zijlstra To: Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@aculab.com, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly Subject: Re: [PATCH v5 08/24] sched: Introduce per memory space current virtual cpu id Message-ID: References: <20221103200359.328736-1-mathieu.desnoyers@efficios.com> <20221103200359.328736-9-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221103200359.328736-9-mathieu.desnoyers@efficios.com> 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 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 On Thu, Nov 03, 2022 at 04:03:43PM -0400, Mathieu Desnoyers wrote: > diff --git a/kernel/fork.c b/kernel/fork.c > index 08969f5aa38d..6a2323266942 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -1047,6 +1047,10 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node) > tsk->reported_split_lock = 0; > #endif > > +#ifdef CONFIG_SCHED_MM_VCPU > + tsk->mm_vcpu = -1; > + tsk->mm_vcpu_active = 0; > +#endif > return tsk; > > free_stack: Note how the above hunk does exactly the same as the below thunk, and I think they're even on the same code-path. How about moving all of this to __sched_fork() or something? > @@ -1579,6 +1586,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) > > tsk->mm = mm; > tsk->active_mm = mm; > + sched_vcpu_fork(tsk); > return 0; > } > +void sched_vcpu_fork(struct task_struct *t) > +{ > + WARN_ON_ONCE((t->flags & PF_KTHREAD) || !t->mm); > + t->mm_vcpu = -1; > + t->mm_vcpu_active = 1; > +}