Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9120454imu; Tue, 4 Dec 2018 22:16:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/WY+9pVCzGIBU1Jfjeoy8qIBwfF+wAvtY1MVLt4ViLjBDBnDbuvHOv+bgjslEgGicVOHN4s X-Received: by 2002:a17:902:ab92:: with SMTP id f18mr22051258plr.221.1543990565913; Tue, 04 Dec 2018 22:16:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543990565; cv=none; d=google.com; s=arc-20160816; b=Yf3ah4NhVh/GzTd7lxEnxgBsnnyxKO8dqupIwZrUUBb/GOE0XwifYBLrjX+A+0XRGs rqCmUongbs0jgmuutoUshG9sj2AGYzhuSJvo0l28UYpKsRzd/jAVr85Z0b/DYDItmpBy LhUH5CK4h13C4z+/uCcC64rQWrJdWttzHPzRjU5A6YGXfXnoSuHuUP6RHVlILNPuroEi FQBG2LKT0U/4QOR8igTn3vxOXjiSZ2nwAdT499PpACCkV75AE2ELq+RdkAJYbqu3XgvY HEXucjWiLUUBwJypXpE6jIzbq4oJkjjU1FIYj91pCfIjKWkIIog/dImZKRRRQJ3+93C6 Jz8Q== 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:dkim-signature; bh=ocQ5CKLE1lU0cPtbZ8uPQLBOs+QmfxjMnfs8z42kAHc=; b=0hhaGhYdZpF+kSEeIOUyFaBvn7s8UbiOLSeFRuKu44MV4pua5BPP+VrcNAPJ2ANrB2 Uj+SdzQO7txfQMwCVESVTrptOAh7Nkpd1VAIxivOzpmRCo87c9vb107HJSIef6XrahGX hUmtVW7Ij63NMBMiLZdVnJ2pKPn82GckWBm8YAjhXrO72uoTwEmat3if51lnPNDATGee GSaY0wSTBTScr0/IW/AEm/bWIftXshmwD4jom6SVFg3NtWdkmzNaJWMhtkyMPxPDZ6Fx FMeIh5nuQsw9A7T8QU4tCvzRAuobfzlqsIuo7DzoDtbzo3F0Frpalh1+eXJsjAmtMQUR 8TQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cbGfMFfi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si17151016pgk.323.2018.12.04.22.15.50; Tue, 04 Dec 2018 22:16:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=cbGfMFfi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726978AbeLEGPQ (ORCPT + 99 others); Wed, 5 Dec 2018 01:15:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:40988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726853AbeLEGPQ (ORCPT ); Wed, 5 Dec 2018 01:15:16 -0500 Received: from sol.localdomain (c-24-23-142-8.hsd1.ca.comcast.net [24.23.142.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 832472084C; Wed, 5 Dec 2018 06:15:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543990515; bh=HQ7Wh7LgPhqcMGTkr6mXgXPw29SZy7Zp7vMTIe5lqkI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cbGfMFfi45BsvD7JawUvmjCfWqYalDh67O1wDlwBIgJAm6IqcU5pG+/Ltz5IdXqIM Ym1tsTL1HOnhm5PDvWEJxwqgc+Sle0Hi84YFXgFekgvTdWMurtqB2prWNEX9A2q3bF q5CyvrpS2Oz0IqyVP1zn+4dh/logvvf1J/Iu9feo= Date: Tue, 4 Dec 2018 22:15:14 -0800 From: Eric Biggers To: Ard Biesheuvel Cc: Martin Willi , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Paul Crowley , Milan Broz , "Jason A. Donenfeld" , Linux Kernel Mailing List Subject: Re: [PATCH v2 3/6] crypto: x86/chacha20 - limit the preemption-disabled section Message-ID: <20181205061513.GB26750@sol.localdomain> References: <20181129230217.158038-1-ebiggers@kernel.org> <20181129230217.158038-4-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.0 (2018-11-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 03:13:37PM +0100, Ard Biesheuvel wrote: > On Sun, 2 Dec 2018 at 11:47, Martin Willi wrote: > > > > > > > To improve responsiveness, disable preemption for each step of the > > > walk (which is at most PAGE_SIZE) rather than for the entire > > > encryption/decryption operation. > > > > It seems that it is not that uncommon for IPsec to get small inputs > > scattered over multiple blocks. Doing FPU context saving for each walk > > step then can slow down things. > > > > An alternative approach could be to re-enable preemption not based on > > the walk steps, but on the amount of bytes processed. This would > > satisfy both users, I guess. > > > > In the long run we probably need a better approach for FPU context > > saving, as this really hurts performance-wise. For IPsec we should find > > a way to avoid the (multiple) per-packet FPU save/restores in softirq > > context, but I guess this requires support from process context > > switching. > > > > At Jason's Zinc talk at plumbers, this came up, and apparently someone > is working on this, i.e., to ensure that on x86, the FPU restore only > occurs lazily, when returning to userland rather than every time you > call kernel_fpu_end() [like we do on arm64 as well] > > Not sure what the ETA for that work is, though, nor did I get the name > of the guy working on it. Thanks for the suggestion; I'll replace this with a patch that re-enables preemption every 4 KiB encrypted. That also avoids having to do a kernel_fpu_begin(), kernel_fpu_end() pair just for hchacha_block_ssse3(). But yes, I'd definitely like repeated kernel_fpu_begin(), kernel_fpu_end() to not be incredibly slow. That would help in a lot of other places too. - Eric