Received: by 10.213.65.68 with SMTP id h4csp1608860imn; Mon, 19 Mar 2018 08:38:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELs/am4QEd9NRQWZiZYldzU4quybXAlO5Vsd2KMuZH6PhZSVd3yFdxkUFqMLxef1uzI8ztWQ X-Received: by 2002:a17:902:7589:: with SMTP id j9-v6mr4177319pll.143.1521473931042; Mon, 19 Mar 2018 08:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521473931; cv=none; d=google.com; s=arc-20160816; b=bfCZ3nNr54E0JP/73vDY8Knvtxn0i/boY/98RoPryDOzYqTQNhm1Inp9askS7ZNeIS NHBdhB2pa7OJ4a7MmoQ3lJhXYsrLZGZzYcQYH7vmIJfBfo0I1R8kr4l6vZxUrLJbmBSP UuL18cSBTYxp3y2vd7Ox9Su15AgWUr2rSaxk/thz5PJ/I46iEC7SHi3i9bmMq6ofqLOs /Eov1zQrqQose4KWC4K8nBaF9C2RttDeyHLSxsAFAAczTaxFqsvsU0YyI5MPIj/u+lzo f3nZlxN3A78W+sJqKlNI0gwu/bn3BI3Oo8XnWqisKZGx0d3R4xABXJRntFdyLlaTCyr5 y+6A== 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=3fN0MKUBuuSR2FfvJ+YRfj3gVd+mMzf9GskXqEvpWTs=; b=cB2cW9furTmewFeCVM8X3iV/1HlkEQMnfHUY/npkYC/TBZOkqF34EyQo8raACfT0UN uKJpZkAY7fmXURXj8j8qBbdeWHkuyMk1oKacV8YXbikRkxNugkPCqSPgHBaP78KEepwh REcrloeiEghSwCDZNtR3/DzbHyun8Yb/pR3rffkfVvXZECnDWUn2Ypcnmf1Qa3JsfhjL roRFoezY3kH5iGlqJ6xBTRqgTOIMakHcSq9tUzGpLFheGtkbT38EVz1ARKbx4EEVguCv ONT+REJpuIs+nSjUz5nMeh3CcyPySmMfhCB0V2azjSf+LvsX+WciRmilf4hKftjlw5ZN 2CFw== 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 w123si156032pfd.14.2018.03.19.08.38.36; Mon, 19 Mar 2018 08:38:51 -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 S1755925AbeCSPhc (ORCPT + 99 others); Mon, 19 Mar 2018 11:37:32 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:60579 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755897AbeCSPh2 (ORCPT ); Mon, 19 Mar 2018 11:37:28 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1exwqg-0001gh-Ck; Mon, 19 Mar 2018 16:37:22 +0100 Date: Mon, 19 Mar 2018 16:37:21 +0100 (CET) From: Thomas Gleixner To: David Laight cc: 'Rahul Lakkireddy' , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "mingo@redhat.com" , "hpa@zytor.com" , "davem@davemloft.net" , "akpm@linux-foundation.org" , "torvalds@linux-foundation.org" , "ganeshgr@chelsio.com" , "nirranjan@chelsio.com" , "indranil@chelsio.com" Subject: RE: [RFC PATCH 0/3] kernel: add support for 256-bit IO access In-Reply-To: <7f8d811e79284a78a763f4852984eb3f@AcuMS.aculab.com> Message-ID: References: <7f0ddb3678814c7bab180714437795e0@AcuMS.aculab.com> <7f8d811e79284a78a763f4852984eb3f@AcuMS.aculab.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Mar 2018, David Laight wrote: > From: Thomas Gleixner > > Sent: 19 March 2018 15:05 > > > > On Mon, 19 Mar 2018, David Laight wrote: > > > From: Rahul Lakkireddy > > > In principle it ought to be possible to get access to one or two > > > (eg) AVX registers by saving them to stack and telling the fpu > > > save code where you've put them. > > > > No. We have functions for this and we are not adding new ad hoc magic. > > I was thinking that a real API might do this... We have a real API and that's good enough for the stuff we have using AVX in the kernel. > Useful also for code that needs AVX-like registers to do things like CRCs. x86/crypto/ has a lot of AVX optimized code. > > > OTOH, for x86, if the code always runs in process context (eg from a > > > system call) then, since the ABI defines them all as caller-saved > > > the AVX(2) registers, it is only necessary to ensure that the current > > > FPU registers belong to the current process once. > > > The registers can be set to zero by an 'invalidate' instruction on > > > system call entry (hope this is done) and after use. > > > > Why would a system call touch the FPU registers? The kernel normally does > > not use FPU instructions and the code which explicitely does has to take > > care of save/restore. It would be performance madness to fiddle with the > > FPU stuff unconditionally if nothing uses it. > > If system call entry reset the AVX registers then any FP save/restore > would be faster because the AVX registers wouldn't need to be saved > (and the cpu won't save them). > I believe the instruction to reset the AVX registers is fast. > The AVX registers only ever need saving if the process enters the > kernel through an interrupt. Wrong. The x8664 ABI clearly states: Linux Kernel code is not allowed to change the x87 and SSE units. If those are changed by kernel code, they have to be restored properly before sleeping or leav- ing the kernel. That means the syscall interface relies on FPU state being not changed by the kernel. So if you want to clear AVX on syscall entry you need to save it first and then restore before returning. That would be a huge performance hit. Thanks, tglx