On Thu, May 29, 2025 at 04:54:34PM -0700, Linus Torvalds wrote: > On Thu, 29 May 2025 at 14:16, Eric Biggers <ebigg...@kernel.org> wrote: > > > > So using crc32c() + ext4 + x86 as an example (but SHA-256 would be very > > similar), the current behavior is that ext4.ko depends on the crc32c_arch() > > symbol. > > Yes, I think that's a good example. > > I think it's an example of something that "works", but it certainly is > a bit hacky. > > Wouldn't it be nicer if just plain "crc32c()" did the right thing, > instead of users having to do strange hacks just to get the optimized > version that they are looking for?
For crc32c() that's exactly how it works (since v6.14, when I implemented it). The users call crc32c() which is an inline function, which then calls crc32c_arch() or crc32c_base() depending on the kconfig. So that's why I said the symbol dependency is currently on crc32c_arch. Sorry if I wasn't clear. The SHA-256, ChaCha, and Poly1305 library code now has a similar design too. If we merged the arch and generic modules together, then the symbol would become crc32c. But in either case crc32c() is the API that all the users call. - Eric