Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1237160imm; Fri, 15 Jun 2018 13:32:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK0fy0xvQ3aBFkjpkytZiGvN00cLCU7viHGS3CetSxrDjqgIRZqqrIOyzCI4hxvZG8i7NAB X-Received: by 2002:a63:7516:: with SMTP id q22-v6mr2913610pgc.443.1529094731801; Fri, 15 Jun 2018 13:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529094731; cv=none; d=google.com; s=arc-20160816; b=Y9aBSaqxQqchSWJ/8dyyR/Opb+SXEDSddFT/45sMKPqS2EDMlIvCkPKuuUUDGXjElS GyRiRtfODjcHaDBsRAufs20djQmHQVgr8a0MhBolslMLY8Kqa7pOnr60XHLtg7SnuUwt 0JdsUDeGD/kmjrUWJ+ZVgJwTuOH0efe+66pjuQq2tVmFPslvrGbdG5E8ujQUSgFG5oWO 5HUXytlqUkfDHbsxA9F3jsTYwBrjf+xV27cHJ3BBqApibN7K3q4hyXA7DyugjLE0kPI2 BvCl1//Xl7v+dEDsugzpF6Od7ngCdLyei6vkQITcoMabM/VGX8EPrZRG0vlOD8SOAPdM Ed1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=GQiXzpJR627cDXSaXvouQSIp+fR1SFoS3yiPAVa4vkU=; b=hhIUXrp1+t1MqIfmZvBfT4qujgCTwuOxqhqLWSaN9npTHvdW8OKMgLPYuyCvR+I9C8 WwVVGw+1o62aIQJZVTbvP+Z9/eK9Qype2IBlr7XcTZ1H+ngBsfSfe0mSOBQRb+UEOouz Re9hrQsCtjz6Q9YqYi+F6rSh/F04aJwaRBdSGvM18yC+S1sCCIRq6sF9xjHp16VEYzZM ktRMptNvVX0fgYwS/EIASW2IrIliry/Mrxx8sWs5bQv0np3yQxyJQjbFP1XkxQqOTEjB hXfjQqt6DKx6GEgJ0GmzsOxAzamtVWew7ZeVlnJQwyLXJtpIlODHypymy70lV/lKx4IU dENg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=uD6Jcl5v; 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=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g7-v6si8505502plt.149.2018.06.15.13.31.56; Fri, 15 Jun 2018 13:32:11 -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; dkim=pass header.i=@zx2c4.com header.s=mail header.b=uD6Jcl5v; 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=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966397AbeFOUbd (ORCPT + 99 others); Fri, 15 Jun 2018 16:31:33 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:44475 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966118AbeFOUbc (ORCPT ); Fri, 15 Jun 2018 16:31:32 -0400 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id a3f163a9 for ; Fri, 15 Jun 2018 20:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=HoGTEwbpksKQ9h0pJZ+rOAhPRbo=; b=uD6Jcl 5vNug1MvsgmafPyjhafHqI83++nxpojWdWPP725oMBEGgEOhQOzX6upVAwI24gW6 UKn84BIr7+3XlECur3SMSySB5ZHyZYwDvsw6nujpJITgUy7pX21ajcuc6LWCsqHr THUAj3Srxjlq2+NYvMuHzYbQD9baPayUPYBvwJnyPjv8Rec0DvRght4gTQVNnfKI p1jHffyROwvzSbtRbGyXpzmCMtPgJzrTpJvaF0LBrHZJdBtyP4K/EnFI6fe7D2XJ Y81YWZHQxGSfMktGGOcxxjyJdj17lCDv3S11dqJW3IQ7fMbgop2DTeduGs1tQl2z 7lds8rylvOt4IKsA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 2bb6e365 (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128:NO) for ; Fri, 15 Jun 2018 20:26:07 +0000 (UTC) Received: by mail-ot0-f169.google.com with SMTP id 92-v6so12350894otw.9 for ; Fri, 15 Jun 2018 13:31:31 -0700 (PDT) X-Gm-Message-State: APt69E21nZeixgUaodKui6kuEYmTsyTReWar6oS/JZ2EZOqBAlWLhrTz G5i591KSEZh6my4POUUxgdsThiIHyVty1L+NNMg= X-Received: by 2002:a9d:350a:: with SMTP id o10-v6mr1875799otc.247.1529094689666; Fri, 15 Jun 2018 13:31:29 -0700 (PDT) MIME-Version: 1.0 References: <20180615193438.GE2458@hirez.programming.kicks-ass.net> In-Reply-To: <20180615193438.GE2458@hirez.programming.kicks-ass.net> From: "Jason A. Donenfeld" Date: Fri, 15 Jun 2018 22:30:46 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Lazy FPU restoration / moving kernel_fpu_end() to context switch To: Peter Zijlstra Cc: Thomas Gleixner , LKML , X86 ML , Andy Lutomirski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 15, 2018 at 9:34 PM Peter Zijlstra wrote: > Didn't we recently do a bunch of crypto patches to help with this? > > I think they had the pattern: > > kernel_fpu_begin(); > for (units-of-work) { > do_unit_of_work(); > if (need_resched()) { > kernel_fpu_end(); > cond_resched(); > kernel_fpu_begin(); > } > } > kernel_fpu_end(); Right, so that's the thing -- this is an optimization easily available to individual crypto primitives. But I'm interested in applying this kind of optimization to an entire queue of, say, tiny packets, where each packet is processed individually. Or, to a cryptographic construction, where several different primitives are used, such that it'd be meaningful not to have to get the performance hit of end()begin() in between each and everyone of them.