> Von: Ard Biesheuvel [ard.biesheu...@linaro.org] > Gesendet: Sonntag, 29. März 2015 12:38 > An: Markus Stockhausen > Cc: linux-arm-ker...@lists.infradead.org; linux-crypto@vger.kernel.org; > samitolva...@google.com; herb...@gondor.apana.org.au; jussi.kivili...@iki.fi > Betreff: Re: [RFC PATCH 1/6] crypto: sha512: implement base layer for SHA-512 > >>> ... >>> +int sha512_base_do_update(struct shash_desc *desc, const u8 *data, >>> + unsigned int len, sha512_block_fn *block_fn, void >>> *p) >>> +{ >>> + struct sha512_state *sctx = shash_desc_ctx(desc); >>> + unsigned int partial = sctx->count[0] % SHA512_BLOCK_SIZE; >>> + >>> + sctx->count[0] += len; >>> + if (sctx->count[0] < len) >>> + sctx->count[1]++; >>> >> You should check if early kick out at this point if the buffer won't be >> filled up >> is faster than first taking care about big data. That can improve performance >> for small blocks while large blocks might be unaffected. >> >>> + >>> + if ((partial + len) >= SHA512_BLOCK_SIZE) { > >Isn't this early kickout? The if is only entered if there is enough >data to run the block function, otherwise it is a straight memcpy. I >could add an unlikely() here to favor the small data case
I did my tests only on low end hardware. 32bit PPC e500 single core 800MHz 256K cache. Maybe it prefers early return statements. Additionally I ended up clearing the context in the finish function with a simple inlined 32bit writes loop. Everything else (e.g. memzero) resulted in slower processing. Don't know what your clearing syntax will produce after compilation. Markus
**************************************************************************** Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. Ãber das Internet versandte E-Mails können unter fremden Namen erstellt oder manipuliert werden. Deshalb ist diese als E-Mail verschickte Nachricht keine rechtsverbindliche Willenserklärung. Collogia Unternehmensberatung AG Ubierring 11 D-50678 Köln Vorstand: Kadir Akin Dr. Michael Höhnerbach Vorsitzender des Aufsichtsrates: Hans Kristian Langva Registergericht: Amtsgericht Köln Registernummer: HRB 52 497 This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. e-mails sent over the internet may have been written under a wrong name or been manipulated. That is why this message sent as an e-mail is not a legally binding declaration of intention. Collogia Unternehmensberatung AG Ubierring 11 D-50678 Köln executive board: Kadir Akin Dr. Michael Höhnerbach President of the supervisory board: Hans Kristian Langva Registry office: district court Cologne Register number: HRB 52 497 ****************************************************************************