Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp219349imj; Wed, 13 Feb 2019 07:15:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IYsmHUgWJqXF4EwYwZwhA0yVcE2D51DaMXHwnl0Kebm5Peiv3PLagoXC0ZdqC0bdvyUgAgC X-Received: by 2002:a63:f148:: with SMTP id o8mr887322pgk.337.1550070923976; Wed, 13 Feb 2019 07:15:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550070923; cv=none; d=google.com; s=arc-20160816; b=U+fWksEVTSVy7RaKXZNX4mvN9KyAIsAP6C8oerIYbaIegaSc3YFeRfuRHu6+fauel0 uzbjpKtInG9Jo/WgZqp+PPbM37LjxBEJkn8SrgXNxOK70vRScC4qAk8J+M2/l2e2mZXN NKQqEHWel2X5odYH6v96Ws09+39Qos4hvYP5cEtO4opGqXkIPzpFrNn9saRL9kz4HtQq e2b4zW4SmXCco6w2dlxPIEoBurVb17x/BXbsh550iJzf0avlHA9zD1mVDhMK3u7BzBvo c70+MJ8VtroGGqY5yJNhArRHO18BVbY/P23HzMjlC5FBFyKDsZngSi2SsIIsQ5ptMftF QRDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=CDDDmtwVpfIWkBr+SwUTpRKFsD3LRNezUogYHLThRO4=; b=fcTMZYU7IwTzUUCqkvUhyGUeSEoJvRmdUrA/H3YEhIhu9iF1itJWB9Ip+cpbkC4q7R 3C+AaLMRSkJ8mnyWQgSl7tY+kQfx/8pTFabYA9XbWIhAzzTdRrCo/uVtU1298AScj4ak 0WgaAFwvQtyFw6QIr0oksHs8MyKzb2A6z4xlpg3Pmz51AScW7KMOmEkr79XyzYQV/exL LxDb4Auvrwaff3EWy+UGyYCwEkD7Qg6vj/07oNTqo3QjbDwtpMwfBytmfDHQa2rVQZyz FlaMDhq6vE0eDUlHGh3kyHWcdyclfgeqTiTILpy5FG+9m0LsF/SUqx66X/DezJXgs0sz rBEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e67si18996840pfh.212.2019.02.13.07.15.07; Wed, 13 Feb 2019 07:15:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392244AbfBMOae (ORCPT + 99 others); Wed, 13 Feb 2019 09:30:34 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:46651 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731144AbfBMOae (ORCPT ); Wed, 13 Feb 2019 09:30:34 -0500 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1gtvYT-0003RW-9D; Wed, 13 Feb 2019 15:30:29 +0100 Date: Wed, 13 Feb 2019 15:30:29 +0100 From: Sebastian Andrzej Siewior To: Julien Grall Cc: linux-arm-kernel@lists.infradead.org, Dave.Martin@arm.com, linux-rt-users@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] arm64/fpsimd: Don't disable softirq when touching FPSIMD/SVE state Message-ID: <20190213143029.ad2kzg7vtuo3zpjk@linutronix.de> References: <20190208165513.8435-1-julien.grall@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190208165513.8435-1-julien.grall@arm.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-02-08 16:55:13 [+0000], Julien Grall wrote: > When the kernel is compiled with CONFIG_KERNEL_MODE_NEON, some part of > the kernel may be able to use FPSIMD/SVE. This is for instance the case > for crypto code. > > Any use of FPSIMD/SVE in the kernel are clearly marked by using the > function kernel_neon_{begin, end}. Furthermore, this can only be used > when may_use_simd() returns true. This is equal what x86 is currently doing. The naming is slightly different, there is irq_fpu_usable(). > The current implementation of may_use_simd() allows softirq to use > FPSIMD/SVE unless it is currently in used (i.e kernel_neon_busy is true). > When in used, softirqs usually fallback to a software method. > > At the moment, as a softirq may use FPSIMD/SVE, softirqs are disabled > when touching the FPSIMD/SVE context. This has the drawback to disable > all softirqs even if they are not using FPSIMD/SVE. Is this bad? This means also that your crypto code will not be interrupted by a softirq. Also if you would get rid of it, you could avoid the software fallback in case may_use_simd() says false. > As a softirq should not rely on been able to use simd at a given time, > there are limited reason to keep softirq disabled when touching the > FPSIMD/SVE context. Instead, we can only disable preemption and tell > the NEON unit is currently in use. > > This patch introduces two new helpers kernel_neon_{disable, enable} to > mark the area using FPSIMD/SVE context and use them in replacement of > local_bh_{disable, enable}. The functions kernel_neon_{begin, end} are > also re-implemented to use the new helpers. > > Signed-off-by: Julien Grall > > --- > > I have been exploring this solution as an alternative approach to the RT > patch "arm64: fpsimd: use preemp_disable in addition to local_bh_disable()". > > So far, the patch has only been lightly tested. > > For RT-linux, it might be possible to use migrate_{enable, disable}. I > am quite new with RT and have some trouble to understand the semantics > of migrate_{enable, disable}. So far, I am still unsure if it is possible > to run another userspace task on the same CPU while getting preempted > when the migration is disabled. In RT: - preemt_disable() is the same as !RT. A thread can not be suspend. An interrupt may interrupt. However on RT we have threaded interrupts so the interrupt is limited to the first-level handler (not the threaded handler). - migrate_disable() means that the thread can not be moved to another CPU. It can be suspended. - local_bh_disable() disables the BH: No softirq can run. In RT local_bh_disable() does not inherit preempt_disable(). Two different softirqs can be executed in parallel. The BH is usually invoked at the end of the threaded interrupt (because the threaded interrupt handler raises the softirq). It can also run in the ksoftirqd. Usually you should not get preempted in a migrate_disable() section. A SCHED_OTHER task should not interrupt another SCHED_OTHER task in a migrate_disable() section. A task with a higher priority (a RT/DL task) will. Since threaded interrupts run with a RT priority of 50, they will interrupt your task in a migrate_disable() section. Sebastian