From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44B70CA0EFF for ; Thu, 21 Aug 2025 20:40:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E38A110E9EE; Thu, 21 Aug 2025 20:40:28 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="AuKM8ag3"; dkim-atps=neutral Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7C5F710E9EE for ; Thu, 21 Aug 2025 20:40:27 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e94d678e116so1459992276.2 for ; Thu, 21 Aug 2025 13:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1755808826; x=1756413626; darn=lists.freedesktop.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lHa4LrampbSXQx1Wyi9Bh9OjrywcR0PvG9lus2xsnNw=; b=AuKM8ag3rZu4UKmeBzdW6yDpC0nAYqXbRYLL4pS5fiHOktAauAmV9QmaldpATxrRDo cMa8oNc8t9097gixMwo4sXROrV/736IfTZ5aOf//kCmzbdGiQ8ee8TPzFsSgcqma2rWB vbvmuZURUmiZGKQbLRidH6buPObKO0g/gDRGY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755808826; x=1756413626; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lHa4LrampbSXQx1Wyi9Bh9OjrywcR0PvG9lus2xsnNw=; b=JbDmKfL6TxCCvnO6tYqB0E5ZL30gx8/E7RIhYTCNgrTOqyk4hL3T6UalBnKfo8CKys HfmWP7iQicQfjrZtLZFbSKkkkZVMzidZbUVpFZY2nujgcyxxA/NSGj//L67PgTIQWxxx f+nNfzTb1amZp0kkaDu9Stgcs/gKnGYeMOGvMj5bLBeOJ3pYqIVKfPuE3stxiYcwDkms Sxr9P7OqCwyWxfWeIRE7QJ8pLz8ODzInVZm4XYgkibsFj1cKnHbu/wX4off/xo8gjsqw 3VuRCaSe5f/Lwnz5MEWCd+fISx2tgm2t4UwGRr4YTtpg+mIgVT6VicLiyfgNB9Rte/3o mVzA== X-Forwarded-Encrypted: i=1; AJvYcCW9DuWQrHU5YeQYQEQkdQQTGIwrKvg+1gKWE4sAYNALs4pyKFoC9lOPycp/8DT+Ci6henYWL3LVL8k=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yy10dNpYXNzKpTh9ZO2Gw7VT4UeA1u4IqizuNCHYzUTwtGWraPW CdTR3WjjGvWPhBI+u8023Gn7sgA3QrGdKLdo1e7DK2amiStQwibLe9VRgAXdbclq0LFvAY4JvPK yfjL/2yncSkXfP0MvgrHqs0m/sTOeMgj2PqaFFhcXqg== X-Gm-Gg: ASbGncs7Ln2FrzbK6OHXhkpVMwnCOlwKDbC8xions3pD7V6bRySZ4P8/BbBqH+FVKMc HiJS6uCdeGzBa5y1OiUCMs/XLMNfVCK1sbxe57gXxstlRIKZbQmN8k5QcPSR5xcPOp0qiFAxtGl EBozx5TwyeuOwRJ739FTLKz7EneZGmsPYvzGfncGKWsiWaH2QcaB1Xc5zjGP7Q2rXz2lHbHlRx9 QtpKTrK519oPhWw X-Google-Smtp-Source: AGHT+IEDbX/Imr3oMuC/SvPpVgA4gK54+Q+BCEwHjysz7tgNECdpdXbU462KLrYXAP4tYmTYkQFLOtkp14xdKE7/w+U= X-Received: by 2002:a05:6902:c12:b0:e93:457a:37b0 with SMTP id 3f1490d57ef6-e951c33ee1bmr998901276.20.1755808826442; Thu, 21 Aug 2025 13:40:26 -0700 (PDT) MIME-Version: 1.0 References: <20250821200701.1329277-1-david@redhat.com> <20250821200701.1329277-32-david@redhat.com> <2926d7d9-b44e-40c0-b05d-8c42e99c511d@redhat.com> In-Reply-To: <2926d7d9-b44e-40c0-b05d-8c42e99c511d@redhat.com> From: Linus Torvalds Date: Thu, 21 Aug 2025 16:40:13 -0400 X-Gm-Features: Ac12FXw_AatpwCNNPCEiMwiwdQxQbayKDzVf5K7yc3iQ5tLY7APrv3zl2U8Z_SA Message-ID: Subject: Re: [PATCH RFC 31/35] crypto: remove nth_page() usage within SG entry To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Herbert Xu , "David S. Miller" , Alexander Potapenko , Andrew Morton , Brendan Jackman , Christoph Lameter , Dennis Zhou , Dmitry Vyukov , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, iommu@lists.linux.dev, io-uring@vger.kernel.org, Jason Gunthorpe , Jens Axboe , Johannes Weiner , John Hubbard , kasan-dev@googlegroups.com, kvm@vger.kernel.org, "Liam R. Howlett" , linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-ide@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mips@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, Lorenzo Stoakes , Marco Elver , Marek Szyprowski , Michal Hocko , Mike Rapoport , Muchun Song , netdev@vger.kernel.org, Oscar Salvador , Peter Xu , Robin Murphy , Suren Baghdasaryan , Tejun Heo , virtualization@lists.linux.dev, Vlastimil Babka , wireguard@lists.zx2c4.com, x86@kernel.org, Zi Yan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Thu, Aug 21, 2025 at 4:29=E2=80=AFPM David Hildenbrand wrote: > > Because doing a 64-bit shift on x86-32 is like three cycles. Doing a > > 64-bit signed division by a simple constant is something like ten > > strange instructions even if the end result is only 32-bit. > > I would have thought that the compiler is smart enough to optimize that? > PAGE_SIZE is a constant. Oh, the compiler optimizes things. But dividing a 64-bit signed value with a constant is still quite complicated. It doesn't generate a 'div' instruction, but it generates something like th= is: movl %ebx, %edx sarl $31, %edx movl %edx, %eax xorl %edx, %edx andl $4095, %eax addl %ecx, %eax adcl %ebx, %edx and that's certainly a lot faster than an actual 64-bit divide would be. An unsigned divide - or a shift - results in just shrdl $12, %ecx, %eax which is still not the fastest instruction (I think shrld gets split into two uops), but it's certainly simpler and easier to read. Linus