Commit ba0f428
dm-verity: use SHA-256 library for SHA-256
When the hash algorithm is SHA-256 and the verity version is not 0, use
the SHA-256 library instead of crypto_shash.
This is a prerequisite for making dm-verity interleave the computation
of SHA-256 hashes for increased performance. That optimization is
available in the SHA-256 library but not in crypto_shash.
Even without interleaved hashing, switching to the library also slightly
improves performance by itself because it avoids the overhead of
crypto_shash, including indirect calls and other API overhead.
(Benchmark on x86_64, AMD Zen 5: hashing 4K blocks gets 2.1% faster.)
SHA-256 is by far the most common hash algorithm used with dm-verity.
It makes sense to optimize for the common case and fall back to the
generic crypto layer for uncommon cases, as suggested by Linus:
https://lore.kernel.org/r/CAHk-=wgp-fOSsZsYrbyzqCAfEvrt5jQs1jL-97Wc4seMNTUyng@mail.gmail.com
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>1 parent 3ee6c4b commit ba0f428
3 files changed
Lines changed: 64 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| 550 | + | |
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
123 | 137 | | |
124 | | - | |
| 138 | + | |
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
131 | 145 | | |
132 | | - | |
| 146 | + | |
133 | 147 | | |
134 | 148 | | |
135 | 149 | | |
| |||
1004 | 1018 | | |
1005 | 1019 | | |
1006 | 1020 | | |
1007 | | - | |
| 1021 | + | |
1008 | 1022 | | |
1009 | 1023 | | |
1010 | 1024 | | |
| |||
1069 | 1083 | | |
1070 | 1084 | | |
1071 | 1085 | | |
1072 | | - | |
1073 | | - | |
| 1086 | + | |
1074 | 1087 | | |
1075 | 1088 | | |
1076 | 1089 | | |
| |||
1256 | 1269 | | |
1257 | 1270 | | |
1258 | 1271 | | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
1259 | 1286 | | |
1260 | 1287 | | |
1261 | 1288 | | |
| |||
1276 | 1303 | | |
1277 | 1304 | | |
1278 | 1305 | | |
1279 | | - | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
1280 | 1318 | | |
1281 | 1319 | | |
1282 | 1320 | | |
1283 | 1321 | | |
1284 | 1322 | | |
1285 | 1323 | | |
1286 | 1324 | | |
1287 | | - | |
| 1325 | + | |
1288 | 1326 | | |
1289 | | - | |
| 1327 | + | |
1290 | 1328 | | |
1291 | 1329 | | |
1292 | 1330 | | |
1293 | 1331 | | |
1294 | 1332 | | |
1295 | 1333 | | |
1296 | | - | |
| 1334 | + | |
1297 | 1335 | | |
1298 | 1336 | | |
1299 | 1337 | | |
| |||
1555 | 1593 | | |
1556 | 1594 | | |
1557 | 1595 | | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | 1596 | | |
1562 | 1597 | | |
1563 | 1598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| |||
59 | 63 | | |
60 | 64 | | |
61 | 65 | | |
| 66 | + | |
62 | 67 | | |
63 | 68 | | |
64 | 69 | | |
| |||
98 | 103 | | |
99 | 104 | | |
100 | 105 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
104 | 111 | | |
105 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
| |||
0 commit comments