Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7461905rwb; Tue, 6 Dec 2022 06:10:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5zchYDBcZoMm+mdFebd3Ry4KDCdRvH/yAY4hfKdUjj3WF/lOhA0xMN9RSzS8/IdZdO9ebv X-Received: by 2002:a05:6402:3203:b0:46c:fabe:8372 with SMTP id g3-20020a056402320300b0046cfabe8372mr4420914eda.347.1670335804316; Tue, 06 Dec 2022 06:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670335804; cv=none; d=google.com; s=arc-20160816; b=R29c0VZ3kzLI21uudB3+6v6SNV6YRqOvMUOsIXen4S0q8VhIv0/QjjSL71Bt7pt1Ad KUhbrNrBiFwCTY6GxqiT9eJcO+Zshnt2qgWJrFf86dYXXTETirS/0O82HoyBcn5ZgoFG SDVKiuljhTgQ/Ic/kTdMUhBgNCLCLIj9CX59ZvWXvEDR5c/Am8vNnaggth0otBgNsSow rAHrVYKHrz5DL5FsoASSPod45HX7u8htAplG+J7QaWm+yZ9gAwHSt2aqC9QvTVu128jN PeJhDVkJYnZFaWJzUYS/rSXE9lxpTlEer/UkaMGc3PvjNyTlMPymW/i7TrZG6M1OAWvq DAHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=iI12qbM8aQ4mHnBTuYsibQkXVSzIxzzhq3+3w/j4qMk=; b=QKAJ6vjQgkE2ZmXgE1m6m2fCsuK4878y9d5xbZsjVVz1dAPdQWH0iARoqdv1KTUnRq bsS8yjch47NBQ4b+3qdJyfKilkLchAwcjEFsZwYc1kae+i0LCEN+dbLu4ypCpgLskL0p Ci3VFcSOQbcj1h48L992B1TTu7YWwmchTg+HBd1jqiQHgQNtJ8nZdNskCuP3tpQ0Ncj9 lWrgA3tHPWZsPvYFXjMkVB6ox0Zhbs4JRQoq3USdCm8ft71NJLYGLHv8Zfho5pIeaVXb mWeBilntxwtT9rYYsta50iUtb8Yg6FRQUVGM1BqTMhOtowCv9GKxZFqgo8M8tPeDAWun P0WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@n8pjl.ca header.s=protonmail header.b="1H7Cdv/Z"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=n8pjl.ca Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020aa7c642000000b0046bb2fd3299si1948868edr.381.2022.12.06.06.09.26; Tue, 06 Dec 2022 06:10:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@n8pjl.ca header.s=protonmail header.b="1H7Cdv/Z"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=n8pjl.ca Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231866AbiLFODx (ORCPT + 99 others); Tue, 6 Dec 2022 09:03:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbiLFODv (ORCPT ); Tue, 6 Dec 2022 09:03:51 -0500 Received: from mail-4022.proton.ch (mail-4022.proton.ch [185.70.40.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09C372A26D for ; Tue, 6 Dec 2022 06:03:48 -0800 (PST) Date: Tue, 06 Dec 2022 14:03:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=n8pjl.ca; s=protonmail; t=1670335425; x=1670594625; bh=iI12qbM8aQ4mHnBTuYsibQkXVSzIxzzhq3+3w/j4qMk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=1H7Cdv/ZMoq+ZpuB0+ArGn7ucqhPLWzCLL1VMb55DszsJ+VjInCVu/eB+B5MY3gGm CQD8wLteOV71sAEEPaevLcn5iKU6R6WJ454c8Ox0LfLHj7oI91xr3x8yUbL99KtbHp JSrf4Qy6fboVs2C0A1qjqBoJrXw+O+H8jXnaaImEoJOyCVKOhSs4m01k5c9eI3Lywy r/+WVCes2BaiuI/Ylue9YDvkRN6qyYSvnkK31dsvd5SH25sr//oNHHcSrwiwXQzqsj yz0WQwn05KKCr9onduxV1HAGOiw0+H8PZDEqkmaS6QCYa/u92JGYgVmWP5id/YKBjR EXEZvDft0B25w== To: Herbert Xu From: Peter Lafreniere Cc: "Elliott, Robert (Servers)" , "Jason A. Donenfeld" , "davem@davemloft.net" , "tim.c.chen@linux.intel.com" , "ap420073@gmail.com" , "ardb@kernel.org" , "David.Laight@aculab.com" , "ebiggers@kernel.org" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v4 10/24] crypto: x86/poly - limit FPU preemption Message-ID: <5TnEjVPNm7Eyw-GH7C0LeJJvgRSpOLb2NUshnG407s3TGTXL1lq4RpsoAMTpVGKWk7tVxDI5f2G9aH6lDbATR6QqXXkE7q54o7TUzO91ibI=@n8pjl.ca> In-Reply-To: References: <20221103042740.6556-1-elliott@hpe.com> <20221116041342.3841-1-elliott@hpe.com> <20221116041342.3841-11-elliott@hpe.com> Feedback-ID: 53133685:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham 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-crypto@vger.kernel.org > > > BTW, just a minor nit but you can delete the cond_resched() call > > > because kernel_fpu_end()/preempt_enable() will do it anyway. > >=20 > > That happens under > > CONFIG_PREEMPTION=3Dy > > (from include/Linux/preempt.h and arch/x86/include/asm/preempt.h) > >=20 > > Is calling cond_resched() still helpful if that is not the configuratio= n? >=20 >=20 > Perhaps, but then again perhaps if preemption is off, maybe we > shouldn't even bother with the 4K split. Were the initial > warnings with or without preemption? >=20 > Personally I don't really care since I always use preemption. >=20 > The PREEMPT Kconfigs do provide a bit of nuance with the split > between PREEMPT_NONE vs. PREEMPT_VOLUNTARY. But perhaps that is > just overkill for our situation. I was thinking about this a few days ago, and my 2=C2=A2 is that it's=20 probably best to not preempt the kernel in the middle of a crypto=20 operation under PREEMPT_VOLUNTARY. We're already not preempting during=20 these operations, and there haven't been complaints of excessive latency=20 because of these crypto operations. If we skip the kernel_fpu_{begin,end} pair when not under=20 CONFIG_PREEMPT, we'll save a significant cycle count that is wasted=20 currently. See Elliot Robert's numbers on conditional begin/end in sha=20 to see the benefits of not saving/restoring unnecessarily: "10% of the=20 CPU cycles spent making the [kernel_fpu_{begin,end}] calls". > I'll leave it to you to decide :) One extra thought: commit 827ee47: "crypto: x86 - add some helper macros=20 for ECB and CBC modes" makes a mention of fpu save/restore being done=20 lazily. I don't know the details, so would that change this discussion? Thanks for listening, Peter Lafreniere