Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp993796imm; Fri, 15 Jun 2018 09:26:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIY545MK9i0DCmAtAijjUMfOwBqFhbZ3qQy+Yq/StduvpjC9NqkLtt3y+BJBGa9UxRAmPcH X-Received: by 2002:a17:902:8341:: with SMTP id z1-v6mr2872489pln.40.1529079991982; Fri, 15 Jun 2018 09:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529079991; cv=none; d=google.com; s=arc-20160816; b=FfvB5/v8PRIIEbpOgWiKECWTt6IV+KcZVvFUUysByhXZKVif8CJjMNtHPsQhT/nt51 zDnuh9wMkoM7WXJavYHfKTa/mHeLS5q9bs+XoZgnZmyGamTSBHxB3tpPXL6ch1hrSC+J azAWVQjNJ2+IwJzbuqX0DxDMGEgS7AFPcdAtptlDF/lIxIs83H/CM5KvHVcZTU1rmrDG CghLVXQQHJAhgw8AHmiTmx7Z8gHW1WUa4HOgO3Nqm6sg+H6sH9p8+TgFC/QbNKeigU7i tADKv0VDcvzz+QlSW0zRmae13q9nHC4XKgF5caa+a5vMWcM7IhukkFqfxd1BBe91iBkc bdqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=sdOMMaaSp+XWE4E1WzpGrda0zI7RdT07LcR1scAbGGY=; b=gk2p2yQmolLyv+Gxh5ujRFltibVJgmz9KRGlwt/L23yBrGjvM5AsTw0igxvEQ1rmOI WO9SlMfjlGcmqW+4vHvhEVr32MAS+TCAnNKFfB4IYMHp+yvDAAgW0qSaYxuMB588NF92 Lf1LYbYmSSUe/5azTrV3zV2qTp55xT24TJgCS9Tu163q6QJ0H5GhI8cKvhG4OMF3aTJh 7ZBvlm+Q2wYyDFwJqYTFVQDo+XhMnsr3gW7OarBDnapXOlM1Wm7EiMrM9TgobIaD3A6g h45apoDkrgjnPZuiW8iTIefMoRIVAj8huV1/SvoWg16WYOW0RV6+lwZstMOasPKNrR0b EQFQ== 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 d1-v6si8455556pll.375.2018.06.15.09.26.17; Fri, 15 Jun 2018 09:26:31 -0700 (PDT) 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 S966044AbeFOQZq (ORCPT + 99 others); Fri, 15 Jun 2018 12:25:46 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:50358 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965957AbeFOQZp (ORCPT ); Fri, 15 Jun 2018 12:25:45 -0400 Received: from p4fea482e.dip0.t-ipconnect.de ([79.234.72.46] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fTrXi-0003ME-Kg; Fri, 15 Jun 2018 18:25:42 +0200 Date: Fri, 15 Jun 2018 18:25:39 +0200 (CEST) From: Thomas Gleixner To: "Jason A. Donenfeld" cc: LKML , X86 ML , Andy Lutomirski , Peter Zijlstra Subject: Re: Lazy FPU restoration / moving kernel_fpu_end() to context switch In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Jun 2018, Jason A. Donenfeld wrote: > In a loop this looks like: > > for (thing) { > kernel_fpu_begin(); > encrypt(thing); > kernel_fpu_end(); > } > > This is obviously very bad, because begin() and end() are slow, so > WireGuard does the obvious: > > kernel_fpu_begin(); > for (thing) > encrypt(thing); > kernel_fpu_end(); > > This is fine and well, and the crypto API I'm working on will enable It might be fine crypto performance wise, but it's a total nightmare latency wise because kernel_fpu_begin() disables preemption. We've seen latencies in the larger millisecond range due to processing large data sets with kernel FPU. If you want to go there then we really need a better approach which allows kernel FPU usage in preemptible context and in case of preemption a way to stash the preempted FPU context and restore it when the task gets scheduled in again. Just using the existing FPU stuff and moving the loops inside the begin/end section and keeping preemption disabled for arbitrary time spans is not going to fly. Thanks, tglx