cryptodev: fix restore crypto op alignment and layout
PATCH 1/1 cryptodev: fix restore crypto op alignment and layout
in 18.08 new cache-aligned structure rte_crypto_asym_op was introduced. As it also was included into rte_crypto_op, it caused implicit change in rte_crypto_op layout and alignment: now rte_crypto_op is cahce-line aligned has a hole of 40/104 bytes between phys_addr and sym/asym op. It looks like unintended ABI breakage, plus such change can cause negative performance effects:
- now status and sym[0].m_src lies on different cache-lines, so post-process code would need extra cache-line read.
- new alignment causes grow of the space requirements and cache-line reads/updates for structures that contain rte_crypto_op inside.
As there seems no actual need to have rte_crypto_asym_op cache-line aligned, and rte_crypto_asym_op is not intended to be used on it's own - the simplest fix is just to remove cache-line alignment for it. As the immediate positive effect: on IA ipsec-secgw performance increased by 5-10% (depending on the crypto-dev and algo used).
My guess that on machines with 128B cache-line and lookaside-protocol capable crypto devices the impact will be even more noticeable.
--- doc/guides/rel_notes/release_19_05.rst | 7 +++++++ lib/librte_cryptodev/Makefile | 2 +- lib/librte_cryptodev/meson.build | 2 +- lib/librte_cryptodev/rte_crypto_asym.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-)
doc/guides/rel_notes/release_19_05.rst +7 -0
@@ -116,6 +116,13 @@ ABI Changes Also, make sure to start the actual text at the margin. ========================================================= +* cryptodev: in 18.08 new structure ``rte_crypto_asym_op`` was introduced and + included into ``rte_crypto_op``. As ``rte_crypto_asym_op`` structure was + defined as cache-line aligned that caused unintended changes in + ``rte_crypto_op`` structure layout and alignment. Remove cache-line + alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` + layout and alignment. + Shared Library Versions -----------------------
lib/librte_cryptodev/Makefile +1 -1
@@ -7,7 +7,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_cryptodev.a # library version -LIBABIVER := 6 +LIBABIVER := 7 # build flags CFLAGS += -O3
lib/librte_cryptodev/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017-2019 Intel Corporation -version = 6 +version = 7 allow_experimental_apis = true sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c') headers = files('rte_cryptodev.h',
lib/librte_cryptodev/rte_crypto_asym.h +1 -1
@@ -487,7 +487,7 @@ struct rte_crypto_asym_op {struct rte_crypto_dh_op_param dh;struct rte_crypto_dsa_op_param dsa; }; -} __rte_cache_aligned; +}; #ifdef __cplusplus }
Signature · 1 line
2.17.1
Quoted 29 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Konstantin Ananyev
Sent: Thursday, March 7, 2019 2:13 PM
To: [email protected]
Cc: [email protected]; [email protected]; De Lara Guarch, Pablo <[email protected]>; [email protected]; Ananyev, Konstantin <[email protected]>
Subject: [dpdk-dev] [PATCH] cryptodev: fix restore crypto op alignment and layoutin 18.08 new cache-aligned structure
rte_crypto_asym_opwas introduced. As it also was included intorte_crypto_op, it caused implicit change inrte_crypto_oplayout and alignment: nowrte_crypto_opis cahce-line aligned has a hole of 40/104 bytes betweenphys_addrand sym/asym op. It looks like unintended ABI breakage, plus such change can cause negative performance effects:
- now status and sym[0].m_src lies on different cache-lines, so post-process code would need extra cache-line read.
- new alignment causes grow of the space requirements and cache-line reads/updates for structures that containrte_crypto_opinside.
As there seems no actual need to haverte_crypto_asym_opcache-line aligned, andrte_crypto_asym_opis not intended to be used on it's own - the simplest fix is just to remove cache-line alignment for it. As the immediate positive effect: on IA ipsec-secgw performance increased by 5-10% (depending on the crypto-dev and algo used).
My guess that on machines with 128B cache-line and lookaside-protocol capable crypto devices the impact will be even more noticeable.
Quoted 3 lines
Fixes 26008aaed14c ("cryptodev: add asymmetric xform and op definitions")Signed-off-by Konstantin Ananyev <[email protected]>
Quoted 30 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Konstantin Ananyev
Sent: Thursday, March 7, 2019 7:43 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Konstantin Ananyev <[email protected]>
Subject: [dpdk-dev] [PATCH] cryptodev: fix restore crypto op alignment and layoutin 18.08 new cache-aligned structure
rte_crypto_asym_opwas introduced. As it also was included intorte_crypto_op, it caused implicit change inrte_crypto_oplayout and alignment: nowrte_crypto_opis cahce-line aligned has a hole of 40/104 bytes betweenphys_addrand sym/asym op.
It looks like unintended ABI breakage, plus such change can cause negative performance effects:
- now status and sym[0].m_src lies on different cache-lines, so post-process code would need extra cache-line read.
- new alignment causes grow of the space requirements and cache-line reads/updates for structures that containrte_crypto_opinside.
As there seems no actual need to haverte_crypto_asym_opcache-line aligned, andrte_crypto_asym_opis not intended to be used on it's own - the simplest fix is just to remove cache-line alignment for it.
As the immediate positive effect: on IA ipsec-secgw performance increased by 5-10% (depending on the crypto-dev and algo used).
My guess that on machines with 128B cache-line and lookaside-protocol capable crypto devices the impact will be even more noticeable.
Quoted 4 lines
Fixes 26008aaed14c ("cryptodev: add asymmetric xform and op definitions")Signed-off-by Konstantin Ananyev <[email protected]>---
It's a valid point that asym_op is not going to be used standalone. Thanks for pointing it out.
Hi Konstantin,
Quoted 34 lines · Konstantin Ananyev
in 18.08 new cache-aligned structure
rte_crypto_asym_opwas introduced. As it also was included intorte_crypto_op, it caused implicit change inrte_crypto_oplayout and alignment: nowrte_crypto_opis cahce-line aligned has a hole of 40/104 bytes betweenphys_addrand sym/asym op. It looks like unintended ABI breakage, plus such change can cause negative performance effects:
- now status and sym[0].m_src lies on different cache-lines, so post-process code would need extra cache-line read.
- new alignment causes grow of the space requirements and cache-line reads/updates for structures that containrte_crypto_opinside.
As there seems no actual need to haverte_crypto_asym_opcache-line aligned, andrte_crypto_asym_opis not intended to be used on it's own - the simplest fix is just to remove cache-line alignment for it. As the immediate positive effect: on IA ipsec-secgw performance increased by 5-10% (depending on the crypto-dev and algo used).
My guess that on machines with 128B cache-line and lookaside-protocol capable crypto devices the impact will be even more noticeable.Fixes 26008aaed14c ("cryptodev: add asymmetric xform and op definitions")Signed-off-by Konstantin Ananyev <[email protected]>--- doc/guides/rel_notes/release_19_05.rst | 7 +++++++ lib/librte_cryptodev/Makefile | 2 +- lib/librte_cryptodev/meson.build | 2 +- lib/librte_cryptodev/rte_crypto_asym.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-)doc/guides/rel_notes/release_19_05.rst +0
-0@@ -116,6 +116,13 @@ ABI Changes Also, make sure to start the actual text at the margin.
doc/guides/rel_notes/release_19_05.rst ABI Changes · line 126
Quoted 10 lines
doc/guides/rel_notes/release_19_05.rst +7
-0========================================================= +* cryptodev: in 18.08 new structure ``rte_crypto_asym_op`` was introduced and + included into ``rte_crypto_op``. As ``rte_crypto_asym_op`` structure was + defined as cache-line aligned that caused unintended changes in + ``rte_crypto_op`` structure layout and alignment. Remove cache-line + alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` + layout and alignment. +
ABI version should be bumped in the release notes as well. I will update that while merging.
Apart from that
Quoted 3 lines
doc/guides/rel_notes/release_19_05.rst +0
-0Shared Library Versions -----------------------
Akhil Goyal
AppliedQuoted 50 lines · Akhil Goyal
Hi Konstantin,
Quoted 34 lines · Konstantin Ananyev
in 18.08 new cache-aligned structure
rte_crypto_asym_opwas introduced. As it also was included intorte_crypto_op, it caused implicit change inrte_crypto_oplayout and alignment: nowrte_crypto_opis cahce-line aligned has a hole of 40/104 bytes betweenphys_addrand sym/asym op. It looks like unintended ABI breakage, plus such change can cause negative performance effects:
- now status and sym[0].m_src lies on different cache-lines, so post-process code would need extra cache-line read.
- new alignment causes grow of the space requirements and cache-line reads/updates for structures that containrte_crypto_opinside.
As there seems no actual need to haverte_crypto_asym_opcache-line aligned, andrte_crypto_asym_opis not intended to be used on it's own - the simplest fix is just to remove cache-line alignment for it. As the immediate positive effect: on IA ipsec-secgw performance increased by 5-10% (depending on the crypto-dev and algo used).
My guess that on machines with 128B cache-line and lookaside-protocol capable crypto devices the impact will be even more noticeable.Fixes 26008aaed14c ("cryptodev: add asymmetric xform and op definitions")Signed-off-by Konstantin Ananyev <[email protected]>--- doc/guides/rel_notes/release_19_05.rst | 7 +++++++ lib/librte_cryptodev/Makefile | 2 +- lib/librte_cryptodev/meson.build | 2 +- lib/librte_cryptodev/rte_crypto_asym.h | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-)doc/guides/rel_notes/release_19_05.rst +0
-0@@ -116,6 +116,13 @@ ABI Changes Also, make sure to start the actual text at the margin.doc/guides/rel_notes/release_19_05.rst ABI Changes · line 126
Quoted 10 lines
doc/guides/rel_notes/release_19_05.rst +7
-0========================================================= +* cryptodev: in 18.08 new structure ``rte_crypto_asym_op`` was introduced and + included into ``rte_crypto_op``. As ``rte_crypto_asym_op`` structure was + defined as cache-line aligned that caused unintended changes in + ``rte_crypto_op`` structure layout and alignment. Remove cache-line + alignment for ``rte_crypto_asym_op`` to restore expected ``rte_crypto_op`` + layout and alignment. +ABI version should be bumped in the release notes as well. I will update that while merging.
Apart from that
Quoted 4 lines
Acked-by Akhil Goyal <[email protected]>Quoted 3 lines
doc/guides/rel_notes/release_19_05.rst +0
-0Shared Library Versions -----------------------
Applied to dpdk-next-crypto
Thanks.