Skip to contentSkip to conversation

dm verity: log the hash algorithm implementation

PATCH In review Eric Biggers 2 participants 2 messages Dec 6, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm verity: log the hash algorithm implementation

From: Eric Biggers <[email protected]>

Log the hash algorithm's driver name when a dm-verity target is created. This will help people determine whether the expected implementation is being used. It can make an enormous difference; e.g., SHA-256 on ARM can be 8x faster with the crypto extensions than without. It can also be useful to know if an implementation using an external crypto accelerator is being used instead of a software implementation.

Example message:

[   35.281945] device-mapper: verity: sha256 using implementation "sha256-ce"

We've already found the similar message in fs/crypto/keyinfo.c to be very useful.

---
 drivers/md/dm-verity-target.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/md/dm-verity-target.c +9 -0
index fc65f0dedf7f..f4c31ffaa88e 100644
@@ -1040,6 +1040,15 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
 		v->tfm = NULL;
 		goto bad;
 	}
+
+	/*
+	 * dm-verity performance can vary greatly depending on which hash
+	 * algorithm implementation is used.  Help people debug performance
+	 * problems by logging the ->cra_driver_name.
+	 */
+	DMINFO("%s using implementation \"%s\"", v->alg_name,
+	       crypto_hash_alg_common(v->tfm)->base.cra_driver_name);
+
 	v->digest_size = crypto_ahash_digestsize(v->tfm);
 	if ((1 << v->hash_dev_block_bits) < v->digest_size * 2) {
 		ti->error = "Digest size too big";
Signature · 1 line
2.19.2
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Log the hash algorithm's driver name when a dm-verity target is created. This will help people determine whether the expected implementation is being used. It can make an enormous difference; e.g., SHA-256 on ARM can be 8x faster with the crypto extensions than without. It can also be useful to know if an implementation using an external crypto accelerator is being used instead of a software implementation.

Quoted 8 lines

Example message:

[   35.281945] device-mapper: verity: sha256 using implementation "sha256-ce"

We've already found the similar message in fs/crypto/keyinfo.c to be very useful.

Quoted 27 lines
---
 drivers/md/dm-verity-target.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/md/dm-verity-target.c +9 -1
index fc65f0dedf7f..f4c31ffaa88e 100644
@@ -1040,6 +1040,15 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv)
                v->tfm = NULL;
                goto bad;
        }
+
+       /*
+        * dm-verity performance can vary greatly depending on which hash
+        * algorithm implementation is used.  Help people debug performance
+        * problems by logging the ->cra_driver_name.
+        */
+       DMINFO("%s using implementation \"%s\"", v->alg_name,
+              crypto_hash_alg_common(v->tfm)->base.cra_driver_name);
+
        v->digest_size = crypto_ahash_digestsize(v->tfm);
        if ((1 << v->hash_dev_block_bits) < v->digest_size * 2) {
                ti->error = "Digest size too big";
--

2.19.2