Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp176361iob; Mon, 2 May 2022 16:20:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJVF4APkB6SJyPhxUFZCkUmVj6sAV36nPbPgQ5bJzU87RewhRfSzxNwQmtyalTGgqij6Yv X-Received: by 2002:a63:81c6:0:b0:3ab:6167:74b5 with SMTP id t189-20020a6381c6000000b003ab616774b5mr11460764pgd.527.1651533636800; Mon, 02 May 2022 16:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651533636; cv=none; d=google.com; s=arc-20160816; b=hoFVcEipQhD6plF1Bg5kI2uzVwFFXwPus1bUgg4ybXtDa+dL4vhrf5ezcETmSDQrxx xF62KEb2I9ZzdhcyheOuBnzwt80hP4xgGFYIb2klC3unjH0xQDXdFkBVJPAc6o6/oNkD YtOT1ELoGfCAcHGpCp34mESZ4WrJRc+TAwgCZSlXQhyaKg4myiYYjFxinUcZiNPCYxHY 6qAZSczK1MVewX50Jp/miVaaY6G/A7q/JQx0dQ9HdLa4SxQ8SLH7X7E1SuNYzDaNSM+G q8K4mGlFjeka9fa00Ivl1txBpdd4GZdTTHrulOgOgB+e9mKw5N+uZFlFez+4KNUxKsiM aO/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=v+9fFLHr/r9ZBLxNWhpzb94rMAgopHuWB0AJT/8ddKg=; b=Fdjhtk7SoM77KL+jTDdINjfPSBKflS7wHbyT8YWotVx5rBBC+7SJFnZdU1Jwc97zFq 3Aw66zEO+S8C5aYAamkVz0LjCDn0yD7BiZ7Vatxtd3lj5VDy3AvXHzAxfdUxYB/ONbtB mHGMcftUKUzYRD67j9fz3Kd4oB1yuM48hJh/4Gjlee5KRvgxucebQ2C4q6FRLzzDsYFC 4hsmqtz+k3SA8yLJP1UBg752o4PrkTodBQv8//3+nT1eqweKzSNXK1G3JxAHd2BiuaWr zHIiLRcP9dLGD10yy2MD9uFoIR2vrGOoHXpiiSVZ5lk9yTuVz5V1L8WqkMLUZ7sk8oTX vfWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eGtwhc+Q; dkim=neutral (no key) header.i=@linutronix.de header.b=J+bagRZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h193-20020a636cca000000b003816043efd9si14876694pgc.462.2022.05.02.16.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eGtwhc+Q; dkim=neutral (no key) header.i=@linutronix.de header.b=J+bagRZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E477F3123B; Mon, 2 May 2022 16:19:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353787AbiEATfR (ORCPT + 99 others); Sun, 1 May 2022 15:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349167AbiEATfP (ORCPT ); Sun, 1 May 2022 15:35:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43F1D4EA0D for ; Sun, 1 May 2022 12:31:47 -0700 (PDT) Message-ID: <20220501193102.647328777@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651433505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=v+9fFLHr/r9ZBLxNWhpzb94rMAgopHuWB0AJT/8ddKg=; b=eGtwhc+QBZi1YdFqmtGrp5p+Th+WoXuSO2++6ssLMDNgFpGTsy9Uj+dmQDueSsvBN5GS7H 72TRA1diVbdd+SkYjVumwiy4e887jD2rrizSCx+q1Xe7v0DbJJN1znsZ5QKexL8qsFsUZl 2vL6vT24MeixrAiiz3HRO+An86nBghRXYAfkUF7J1YJJDhouNiwNfmd9F0bgvpGUSf4eJd pKlmIJS8xoqJof34s39f1T4mop0dHfF37BpD+tO6t8UillLrWC3EwUBfXyw/jIl7TpfRHx 3c+PsszqwAMLS5W/s1bzTVUxDbAN3F4skiuOrjNDWXk2Wi4zdPh+fetegbYMaA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651433505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=v+9fFLHr/r9ZBLxNWhpzb94rMAgopHuWB0AJT/8ddKg=; b=J+bagRZ6UzP1AwhFr5tWI4cxwd3UnSW7FZkyQ6cENZRy2BguA6WOWOae1nlHrW6IO5gHV3 LD5MDKrumNArnoAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Filipe Manana Subject: [patch 2/3] x86/fpu: Rename irq_fpu_usable() References: <20220501192740.203963477@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Sun, 1 May 2022 21:31:45 +0200 (CEST) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 This can be invoked from almost any context, except NMI. The only requirement is that the context is not migrateable. Rename it to kernel_fpu_usable(). Signed-off-by: Thomas Gleixner --- arch/um/include/asm/fpu/api.h | 2 +- arch/x86/include/asm/fpu/api.h | 4 ++-- arch/x86/include/asm/simd.h | 2 +- arch/x86/kernel/fpu/core.c | 13 +++++++------ net/netfilter/nft_set_pipapo_avx2.c | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) --- a/arch/um/include/asm/fpu/api.h +++ b/arch/um/include/asm/fpu/api.h @@ -11,7 +11,7 @@ #define kernel_fpu_begin() (void)0 #define kernel_fpu_end() (void)0 -static inline bool irq_fpu_usable(void) +static inline bool kernel_fpu_usable(void) { return true; } --- a/arch/x86/include/asm/fpu/api.h +++ b/arch/x86/include/asm/fpu/api.h @@ -19,7 +19,7 @@ * disables preemption so be careful if you intend to use it for long periods * of time. * If you intend to use the FPU in irq/softirq you need to check first with - * irq_fpu_usable() if it is possible. + * kernel_fpu_usable() if it is possible. */ /* Kernel FPU states to initialize in kernel_fpu_begin_mask() */ @@ -28,7 +28,7 @@ extern void kernel_fpu_begin_mask(unsigned int kfpu_mask); extern void kernel_fpu_end(void); -extern bool irq_fpu_usable(void); +extern bool kernel_fpu_usable(void); extern void fpregs_mark_activate(void); /* Code that is unaware of kernel_fpu_begin_mask() can use this */ --- a/arch/x86/include/asm/simd.h +++ b/arch/x86/include/asm/simd.h @@ -8,5 +8,5 @@ */ static __must_check inline bool may_use_simd(void) { - return irq_fpu_usable(); + return kernel_fpu_usable(); } --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -49,11 +49,12 @@ static DEFINE_PER_CPU(bool, in_kernel_fp */ DEFINE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx); -/* - * Can we use the FPU in kernel mode with the - * whole "kernel_fpu_begin/end()" sequence? +/** + * kernel_fpu_usable - Check whether kernel FPU usage is possible + * + * Has to be invoked before calling kernel_fpu_begin(). */ -bool irq_fpu_usable(void) +bool kernel_fpu_usable(void) { if (WARN_ON_ONCE(in_nmi())) return false; @@ -81,7 +82,7 @@ bool irq_fpu_usable(void) */ return !softirq_count(); } -EXPORT_SYMBOL(irq_fpu_usable); +EXPORT_SYMBOL(kernel_fpu_usable); /* * Track AVX512 state use because it is known to slow the max clock @@ -409,7 +410,7 @@ void kernel_fpu_begin_mask(unsigned int { preempt_disable(); - WARN_ON_FPU(!irq_fpu_usable()); + WARN_ON_FPU(!kernel_fpu_usable()); WARN_ON_FPU(this_cpu_read(in_kernel_fpu)); this_cpu_write(in_kernel_fpu, true); --- a/net/netfilter/nft_set_pipapo_avx2.c +++ b/net/netfilter/nft_set_pipapo_avx2.c @@ -1128,7 +1128,7 @@ bool nft_pipapo_avx2_lookup(const struct bool map_index; int i, ret = 0; - if (unlikely(!irq_fpu_usable())) + if (unlikely(!kernel_fpu_usable())) return nft_pipapo_lookup(net, set, key, ext); m = rcu_dereference(priv->match);