Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp726964rwb; Wed, 9 Nov 2022 08:01:03 -0800 (PST) X-Google-Smtp-Source: AMsMyM7G4I0CWTsBDrTGUaxz1zXdgkcFFhsxPOdiXjUVl7BS6VlH5+qbaWPcmfOlecMKsiPK6COT X-Received: by 2002:a17:906:6a02:b0:7ae:2793:aa19 with SMTP id qw2-20020a1709066a0200b007ae2793aa19mr29608660ejc.265.1668009662984; Wed, 09 Nov 2022 08:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668009662; cv=none; d=google.com; s=arc-20160816; b=0NU6XOJSCdWUhWH3y6Xey+EWaa34H7eUR4rCE0kIdbv46kCB64ERNsbh+QUrEGei0X NnMGxRjbAHJa9HW5LwutUjg5hUYhYb663d7qMWuMmTKXq8b03T7HgQS2VxK9xhy+Az0+ SXgWl23TIChHK0jE0PpeI6m1PkP1AELjR1WdOUckjLyRKs1tkv2AtEtBI8kqyzZ4QFn8 UM419vFZyUDWSGKISG9qGar/aAhIj82n1qP2d7fHN76QuENVkWRphz7mBA5FhpVw/F3R yz3n9flMlHwQ3dT9ddfw9KO0bOaAx9NmvtFpDrUSBpzaMC23rZ/RoZoHBiFtHKYsVkCP kL+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=zBg+Z1aFme+TLOIlqtukCwZuDFUjslPu8A7paRx6kSQ=; b=OlRp+3ixc2DqrziW6Nq1ySfLYzmCuVC50L2An52yyJd34qinFi3DQTdbJhU470q93c ncjp3qj6p2Kn3haEIRh0790P4WumOKNkDVGeRiGi4YyBbcTXx0qMqbH5MseHxM6Q9Wq5 wn2nx3b7J8f7vXtJ2dre5TmBcF9xr6VbipOCyQl58rncdjoq2ZqyLIgD1QxTYh4mFQ3F 4oBRlAuOceCbnr+gbac/0VwsDvEiy2kWDeADV7XODNdURUV1Vz5CAhnVODuV2Hoi0TiZ r6oFaZ3e9nIBo85BKLrM4PZi15fOZX+UrxSGMwFkomUWD9P+sjg/OwbMeU8ngzcx1Bla 7uNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=ovXcExtR; 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=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a1709061b5b00b007a4feae7adfsi11514299ejg.565.2022.11.09.08.00.40; Wed, 09 Nov 2022 08:01:02 -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=@efficios.com header.s=smtpout1 header.b=ovXcExtR; 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=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231908AbiKIPJe (ORCPT + 92 others); Wed, 9 Nov 2022 10:09:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbiKIPJb (ORCPT ); Wed, 9 Nov 2022 10:09:31 -0500 Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:5aae::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F1A81CB24; Wed, 9 Nov 2022 07:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1668006569; bh=JEJysdOirf9b1qalbUU8Yx+Cw0Eu6WznZk97FtOqlTs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ovXcExtRmcK8u+r/oQWKDojSsbEI+lGG949UMreX0oANwWktQFsc5YqvTvaWYKdcV cWkP7wQL5qfofI9Ki36j7WctaX4iAVoUZgIPsXa+AwJVVjjv9vghWbKLm9Yghj1rSg C0MG+pKKaEJMM8qgNUcINXIv6w8DmfC+4BJshlSiO0qs0c8VvjxbmmhJkcmovvVwnj uNhPzXCBpEFC6Czcb93bohOF3Cng144ViIMfGoda1NdfqZ7lqNCUkErPuVf3c+GdBv FMS/ck79UxdQYh50q9otR1Vw+6bV9uCgMY+1Rhbalm07oXHyAwnXnArcteGaeZOSUC 9rTjHH2LhidIA== Received: from [172.16.0.153] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4N6pKN3TpczgLh; Wed, 9 Nov 2022 10:09:28 -0500 (EST) Message-ID: Date: Wed, 9 Nov 2022 10:09:36 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v5 08/24] sched: Introduce per memory space current virtual cpu id Content-Language: en-US To: Peter Zijlstra 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 References: <20221103200359.328736-1-mathieu.desnoyers@efficios.com> <20221103200359.328736-9-mathieu.desnoyers@efficios.com> From: Mathieu Desnoyers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 On 2022-11-09 04:42, Peter Zijlstra wrote: > On Thu, Nov 03, 2022 at 04:03:43PM -0400, Mathieu Desnoyers wrote: > >> +void sched_vcpu_exit_signals(struct task_struct *t) >> +{ >> + struct mm_struct *mm = t->mm; >> + unsigned long flags; >> + >> + if (!mm) >> + return; >> + local_irq_save(flags); >> + mm_vcpu_put(mm, t->mm_vcpu); >> + t->mm_vcpu = -1; >> + t->mm_vcpu_active = 0; >> + local_irq_restore(flags); >> +} >> + >> +void sched_vcpu_before_execve(struct task_struct *t) >> +{ >> + struct mm_struct *mm = t->mm; >> + unsigned long flags; >> + >> + if (!mm) >> + return; >> + local_irq_save(flags); >> + mm_vcpu_put(mm, t->mm_vcpu); >> + t->mm_vcpu = -1; >> + t->mm_vcpu_active = 0; >> + local_irq_restore(flags); >> +} >> + >> +void sched_vcpu_after_execve(struct task_struct *t) >> +{ >> + struct mm_struct *mm = t->mm; >> + unsigned long flags; >> + >> + WARN_ON_ONCE((t->flags & PF_KTHREAD) || !t->mm); >> + >> + local_irq_save(flags); >> + t->mm_vcpu = mm_vcpu_get(mm); >> + t->mm_vcpu_active = 1; >> + local_irq_restore(flags); >> + rseq_set_notify_resume(t); >> +} > >> +static inline void mm_vcpu_put(struct mm_struct *mm, int vcpu) >> +{ >> + lockdep_assert_irqs_disabled(); >> + if (vcpu < 0) >> + return; >> + spin_lock(&mm->vcpu_lock); >> + __cpumask_clear_cpu(vcpu, mm_vcpumask(mm)); >> + spin_unlock(&mm->vcpu_lock); >> +} >> + >> +static inline int mm_vcpu_get(struct mm_struct *mm) >> +{ >> + int ret; >> + >> + lockdep_assert_irqs_disabled(); >> + spin_lock(&mm->vcpu_lock); >> + ret = __mm_vcpu_get(mm); >> + spin_unlock(&mm->vcpu_lock); >> + return ret; >> +} > > > This: > > local_irq_disable() > spin_lock() > > thing is a PREEMPT_RT anti-pattern. > > At the very very least this should then be raw_spin_lock(), not in the > least because you're calling this from under rq->lock, which itself is a > raw_spin_lock_t. Very good point, will fix using raw_spinlock_t. Thanks, Mathieu > -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com