xen/arm: Correct the coding style of get_cycles
PATCH v2 1/2 xen/arm: Correct the coding style of get_cycles
It seems the arm inline function get_cycles has used 8 spaces for line indent since 2012. This patch correct them to 4 spaces and remove extra space between function name and bracket.
--- xen/include/asm-arm/time.h | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
xen/include/asm-arm/time.h +20 -20
@@ -11,29 +11,29 @@typedef uint64_t cycles_t ; -static inline cycles_t get_cycles (void ) +static inline cycles_t get_cycles (void ) { -isb (); +isb (); +/* +* ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read +* can return a wrong value when the counter crosses a 32bit boundary. +*/ +if ( !check_workaround_858921 () ) +return READ_SYSREG64 (CNTPCT_EL0 ); +else + {/* -* ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read -* can return a wrong value when the counter crosses a 32bit boundary. +* A recommended workaround for erratum 858921 is to: +* 1- Read twice CNTPCT. +* 2- Compare bit[32] of the two read values. +* - If bit[32] is different, keep the old value. +* - If bit[32] is the same, keep the new value. */ -if ( !check_workaround_858921 () ) -return READ_SYSREG64 (CNTPCT_EL0 ); -else - { -/* -* A recommended workaround for erratum 858921 is to: -* 1- Read twice CNTPCT. -* 2- Compare bit[32] of the two read values. -* - If bit[32] is different, keep the old value. -* - If bit[32] is the same, keep the new value. -*/ -cycles_t old, new; - old =READ_SYSREG64 (CNTPCT_EL0 ); - new =READ_SYSREG64 (CNTPCT_EL0 ); -return (((old ^ new) >>32 ) &1 ) ? old : new; - } +cycles_t old, new; + old =READ_SYSREG64 (CNTPCT_EL0 ); + new =READ_SYSREG64 (CNTPCT_EL0 ); +return (((old ^ new) >>32 ) &1 ) ? old : new; + } }/* List of timer's IRQ */
Signature · 1 line
2.25.1
PATCH v2 2/2 xen/arm: Add defensive barrier in get_cycles for Arm64
Per the discussion [1] on the mailing list, we'd better to have a barrier after reading CNTPCT in get_cycles. If there is not any barrier there. When get_cycles being used in some seqlock critical context in the future, the seqlock can be speculated potentially.
We import Linux commit 75a19a0202db21638a1c2b424afb867e1f9a2376:
arm64: arch_timer: Ensure counter register reads occur with seqlock held
When executing clock_gettime(), either in the vDSO or via a system call, we need to ensure that the read of the counter register occurs within the seqlock reader critical section. This ensures that updates to the clocksource parameters (e.g. the multiplier) are consistent with the counter value and therefore avoids the situation where time appears to go backwards across multiple reads.
Extend the vDSO logic so that the seqlock critical section covers the read of the counter register as well as accesses to the data page. Since reads of the counter system registers are not ordered by memory barrier instructions, introduce dependency ordering from the counter read to a subsequent memory access so that the seqlock memory barriers apply to the counter access in both the vDSO and the system call paths.
While we are not aware of such use in Xen, it would be best to add the barrier to avoid any suprise.
In order to reduce the impact of new barrier, we perfer to use enforce order instead of ISB [2].
Currently, enforce order is not applied to arm32 as this is not done in Linux at the date of this patch. If this is done in Linux it will need to be also done in Xen.
[1] https://lists.xenproject.org/archives/html/xen-devel/2020-12/msg00181.html
[2] https://lkml.org/lkml/2020/3/13/645
---
v1 -> v2:
1. Update commit message to refer Linux commit.
2. Change u64 to uint64_t
--- xen/include/asm-arm/time.h | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
xen/include/asm-arm/time.h +41 -2
@@ -11,9 +11,26 @@typedef uint64_t cycles_t ; -static inline cycles_t get_cycles (void ) +/* +* Ensure that reads of the counter are treated the same as memory reads +* for the purposes of ordering by subsequent memory barriers. +*/ +#if defined(CONFIG_ARM_64 ) +#define read_cntpct_enforce_ordering (val) do { \ + uint64_t tmp, _val = (val); \ + \ + asm volatile( \ + "eor %0, %1, %1\n" \ + "add %0, sp, %0\n" \ + "ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \ +} while (0) +#else +#define read_cntpct_enforce_ordering (val) do {} while (0) +#endif + +static inline cycles_t read_cntpct_stable (void ) { -isb ();/* * ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read * can return a wrong value when the counter crosses a 32bit boundary.
@@ -36,6 +53,28 @@ static inline cycles_t get_cycles(void) } } +static inline cycles_t get_cycles (void ) +{ +cycles_t cnt; + +isb (); + cnt =read_cntpct_stable (); + +/* +* If there is not any barrier here. When get_cycles being used in +* some seqlock critical context in the future, the seqlock can be +* speculated potentially. +* +* To prevent seqlock from being speculated silently, we add a barrier +* here defensively. Normally, we just need an ISB here is enough, but +* considering the minimum performance cost. We prefer to use enforce +* order here. +*/ +read_cntpct_enforce_ordering (cnt); + +return cnt; +} +/* List of timer's IRQ */ enum timer_ppi {
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] xen/arm: Add defensive barrier in get_cycles for Arm64
Hi Wei,
Quoted 70 lines · Wei Chen
Per the discussion [1] on the mailing list, we'd better to have a barrier after reading CNTPCT in
get_cycles. If there is not any barrier there. Whenget_cyclesbeing used in some seqlock critical context in the future, the seqlock can be speculated potentially.We import Linux commit
75a19a0202db21638a1c2b424afb867e1f9a2376:
arm64:arch_timer: Ensure counter register reads occur with seqlock heldWhen executing
clock_gettime(), either in the vDSO or via a system call, we need to ensure that the read of the counter register occurs within the seqlock reader critical section. This ensures that updates to the clocksource parameters (e.g. the multiplier) are consistent with the counter value and therefore avoids the situation where time appears to go backwards across multiple reads.Extend the vDSO logic so that the seqlock critical section covers the read of the counter register as well as accesses to the data page. Since reads of the counter system registers are not ordered by memory barrier instructions, introduce dependency ordering from the counter read to a subsequent memory access so that the seqlock memory barriers apply to the counter access in both the vDSO and the system call paths.
Cc <[email protected]>Cc Marc Zyngier <[email protected]>Tested-by Vincenzo Frascino <[email protected]>Reported-by Thomas Gleixner <[email protected]>Signed-off-by Will Deacon <[email protected]>While we are not aware of such use in Xen, it would be best to add the barrier to avoid any suprise.
In order to reduce the impact of new barrier, we perfer to use enforce order instead of ISB [2].
Currently, enforce order is not applied to arm32 as this is not done in Linux at the date of this patch. If this is done in Linux it will need to be also done in Xen.
[1] https://lists.xenproject.org/archives/html/xen-devel/2020-12/msg00181.html
[2] https://lkml.org/lkml/2020/3/13/645Signed-off-by Wei Chen <[email protected]>---
v1 -> v2:
1. Update commit message to refer Linux commit.
2. Change u64 touint64_t--- xen/include/asm-arm/time.h | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)xen/include/asm-arm/time.h +9
-1@@ -11,9 +11,26 @@typedef uint64_t cycles_t ; -static inline cycles_t get_cycles (void ) +/* +* Ensure that reads of the counter are treated the same as memory reads +* for the purposes of ordering by subsequent memory barriers. +*/ +#if defined(CONFIG_ARM_64 ) +#define read_cntpct_enforce_ordering (val) do { \ + uint64_t tmp, _val = (val); \ + \ + asm volatile( \
xen/include/asm-arm/time.h line 32
Quoted 10 lines
xen/include/asm-arm/time.h +10
-0+ "eor %0, %1, %1\n" \ + "add %0, sp, %0\n" \ + "ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \ +} while (0) +#else +#define read_cntpct_enforce_ordering (val) do {} while (0) +#endif + +static inline cycles_t read_cntpct_stable (void )
OOI, is there any particular reason to create a new helper?
Quoted 16 lines
xen/include/asm-arm/time.h +7
-1{ -isb ();/* * ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read * can return a wrong value when the counter crosses a 32bit boundary. @@ -36,6 +53,28 @@ static inline cycles_t get_cycles(void) } } +static inline cycles_t get_cycles (void ) +{ +cycles_t cnt; + +isb (); + cnt =read_cntpct_stable (); +
xen/include/asm-arm/time.h static inline cycles_t get_cycles(void) · line 72
Quoted 10 lines
xen/include/asm-arm/time.h +10
-0+/* +* If there is not any barrier here. When get_cycles being used in +* some seqlock critical context in the future, the seqlock can be +* speculated potentially. +* +* To prevent seqlock from being speculated silently, we add a barrier +* here defensively. Normally, we just need an ISB here is enough, but +* considering the minimum performance cost. We prefer to use enforce +* order here. +*/
I thought, we agreed to remove the comment. Did I miss anything?
I can fix this one on commit if there is no need for a new revision.
Cheers,
Quoted 9 lines
xen/include/asm-arm/time.h +5
-0+read_cntpct_enforce_ordering (cnt); + +return cnt; +} +/* List of timer's IRQ */ enum timer_ppi {
Signature · 1 line
Julien Grall
RE: [PATCH v2 2/2] xen/arm: Add defensive barrier in get_cycles for Arm64
HI Julien,
Quoted 91 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2021年1月8日 19:56
To: Wei Chen <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Penny Zheng <[email protected]>; Jiamei Xie <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 2/2] xen/arm: Add defensive barrier inget_cyclesfor Arm64Hi Wei,
Quoted 23 lines · Wei Chen
Per the discussion [1] on the mailing list, we'd better to have a barrier after reading CNTPCT in
get_cycles. If there is not any barrier there. Whenget_cyclesbeing used in some seqlock critical context in the future, the seqlock can be speculated potentially.We import Linux commit
75a19a0202db21638a1c2b424afb867e1f9a2376:
arm64:arch_timer: Ensure counter register reads occur with seqlock heldWhen executing
clock_gettime(), either in the vDSO or via a system call, we need to ensure that the read of the counter register occurs within the seqlock reader critical section. This ensures that updates to the clocksource parameters (e.g. the multiplier) are consistent with the counter value and therefore avoids the situation where time appears to go backwards across multiple reads.Extend the vDSO logic so that the seqlock critical section covers the read of the counter register as well as accesses to the data page. Since reads of the counter system registers are not ordered by memory barrier instructions, introduce dependency ordering from the counter read to a subsequent memory access so that the seqlock memory barriers apply to the counter access in both the vDSO and the system call paths.
Quoted 4 lines
Cc <[email protected]>Cc Marc Zyngier <[email protected]>Tested-by Vincenzo Frascino <[email protected]>
kernel/[email protected]/Quoted 6 lines
Reported-by Thomas Gleixner <[email protected]>Signed-off-by Will Deacon <[email protected]>While we are not aware of such use in Xen, it would be best to add the barrier to avoid any suprise.
Quoted 8 lines
In order to reduce the impact of new barrier, we perfer to use enforce order instead of ISB [2].
Currently, enforce order is not applied to arm32 as this is not done in Linux at the date of this patch. If this is done in Linux it will need to be also done in Xen.
[1] https://lists.xenproject.org/archives/html/xen-devel/2020-
12/msg00181.html
Quoted 9 lines
[2] https://lkml.org/lkml/2020/3/13/645
Signed-off-by Wei Chen <[email protected]>---
v1 -> v2:
1. Update commit message to refer Linux commit.
2. Change u64 touint64_t--- xen/include/asm-arm/time.h | 43++++++++++++++++++++++++++++++++++++--
Quoted 24 lines
1 file changed, 41 insertions(+), 2 deletions(-)xen/include/asm-arm/time.h +13
-1@@ -11,9 +11,26 @@typedef uint64_t cycles_t ; -static inline cycles_t get_cycles (void ) +/* +* Ensure that reads of the counter are treated the same as memory reads +* for the purposes of ordering by subsequent memory barriers. +*/ +#if defined(CONFIG_ARM_64 ) +#define read_cntpct_enforce_ordering (val) do { \ + uint64_t tmp, _val = (val); \ + \ + asm volatile( \ + "eor %0, %1, %1\n" \ + "add %0, sp, %0\n" \ + "ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \
Quoted 9 lines
xen/include/asm-arm/time.h line 32
Quoted 6 lines
xen/include/asm-arm/time.h +6
-0+} while (0) +#else +#define read_cntpct_enforce_ordering (val) do {} while (0) +#endif + +static inline cycles_t read_cntpct_stable (void )OOI, is there any particular reason to create a new helper?
Yes, I try to reduce the #if defined(CONFIG_ARM_64) chunks. I think if we introduce an empty helper for Arm32, we can reduce the other chunk inside get_cycles. In addition, if we need to do the same work for Arm32 in the future, we may not need to modify get_cycles.
Quoted 29 lines
Quoted 16 lines
xen/include/asm-arm/time.h +7
-1{ -isb ();/* * ARM_WORKAROUND_858921: Cortex-A73 (all versions) counter read * can return a wrong value when the counter crosses a 32bit boundary. @@ -36,6 +53,28 @@ static inline cycles_t get_cycles(void) } } +static inline cycles_t get_cycles (void ) +{ +cycles_t cnt; + +isb (); + cnt =read_cntpct_stable (); +xen/include/asm-arm/time.h static inline cycles_t get_cycles(void) · line 72
Quoted 10 lines
xen/include/asm-arm/time.h +10
-0+/* +* If there is not any barrier here. When get_cycles being used in +* some seqlock critical context in the future, the seqlock can be +* speculated potentially. +* +* To prevent seqlock from being speculated silently, we add a barrier +* here defensively. Normally, we just need an ISB here is enough, but +* considering the minimum performance cost. We prefer to use enforce +* order here. +*/ I thought, we agreed to remove the comment. Did I miss anything?
Quoted 2 lines
I can fix this one on commit if there is no need for a new revision.
Ah, sorry I forget that. If we don't need a new revision, please help me to remove it.
Thanks.
Quoted 14 lines
Cheers,
xen/include/asm-arm/time.h static inline cycles_t get_cycles(void) · line 80
Quoted 9 lines
xen/include/asm-arm/time.h +5
-0+read_cntpct_enforce_ordering (cnt); + +return cnt; +} +/* List of timer's IRQ */ enum timer_ppi {--
Julien Grall
Re: [PATCH v2 2/2] xen/arm: Add defensive barrier in get_cycles for Arm64
Quoted 1 line · Wei Chen
HI Julien,
Hi Wei,
Quoted 101 lines
Quoted 91 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2021年1月8日 19:56
To: Wei Chen <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Penny Zheng <[email protected]>; Jiamei Xie <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 2/2] xen/arm: Add defensive barrier inget_cyclesfor Arm64Hi Wei,
Quoted 23 lines · Wei Chen
Per the discussion [1] on the mailing list, we'd better to have a barrier after reading CNTPCT in
get_cycles. If there is not any barrier there. Whenget_cyclesbeing used in some seqlock critical context in the future, the seqlock can be speculated potentially.We import Linux commit
75a19a0202db21638a1c2b424afb867e1f9a2376:
arm64:arch_timer: Ensure counter register reads occur with seqlock heldWhen executing
clock_gettime(), either in the vDSO or via a system call, we need to ensure that the read of the counter register occurs within the seqlock reader critical section. This ensures that updates to the clocksource parameters (e.g. the multiplier) are consistent with the counter value and therefore avoids the situation where time appears to go backwards across multiple reads.Extend the vDSO logic so that the seqlock critical section covers the read of the counter register as well as accesses to the data page. Since reads of the counter system registers are not ordered by memory barrier instructions, introduce dependency ordering from the counter read to a subsequent memory access so that the seqlock memory barriers apply to the counter access in both the vDSO and the system call paths.
Quoted 4 lines
Cc <[email protected]>Cc Marc Zyngier <[email protected]>Tested-by Vincenzo Frascino <[email protected]>
kernel/[email protected]/Quoted 6 lines
Reported-by Thomas Gleixner <[email protected]>Signed-off-by Will Deacon <[email protected]>While we are not aware of such use in Xen, it would be best to add the barrier to avoid any suprise.
Quoted 8 lines
In order to reduce the impact of new barrier, we perfer to use enforce order instead of ISB [2].
Currently, enforce order is not applied to arm32 as this is not done in Linux at the date of this patch. If this is done in Linux it will need to be also done in Xen.
[1] https://lists.xenproject.org/archives/html/xen-devel/2020-
12/msg00181.html
Quoted 9 lines
[2] https://lkml.org/lkml/2020/3/13/645
Signed-off-by Wei Chen <[email protected]>---
v1 -> v2:
1. Update commit message to refer Linux commit.
2. Change u64 touint64_t--- xen/include/asm-arm/time.h | 43++++++++++++++++++++++++++++++++++++--
Quoted 24 lines
1 file changed, 41 insertions(+), 2 deletions(-)xen/include/asm-arm/time.h +13
-1@@ -11,9 +11,26 @@typedef uint64_t cycles_t ; -static inline cycles_t get_cycles (void ) +/* +* Ensure that reads of the counter are treated the same as memory reads +* for the purposes of ordering by subsequent memory barriers. +*/ +#if defined(CONFIG_ARM_64 ) +#define read_cntpct_enforce_ordering (val) do { \ + uint64_t tmp, _val = (val); \ + \ + asm volatile( \ + "eor %0, %1, %1\n" \ + "add %0, sp, %0\n" \ + "ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \Quoted 9 lines
xen/include/asm-arm/time.h line 32
Quoted 6 lines
xen/include/asm-arm/time.h +6
-0+} while (0) +#else +#define read_cntpct_enforce_ordering (val) do {} while (0) +#endif + +static inline cycles_t read_cntpct_stable (void )OOI, is there any particular reason to create a new helper?
Quoted 1 line
Yes, I try to reduce the #if
defined(CONFIG_ARM_64)chunks.
Hmmm... There is no #ifdef chunk in read_cntpct_stable(). Did I miss anything?
Quoted 4 lines
I think
if we introduce an empty helper for Arm32, we can reduce the other chunk insideget_cycles. In addition, if we need to do the same work for Arm32 in the future, we may not need to modifyget_cycles.
I don't really follow this. I wasn't asking about read_cntpct_enforce_ordering(). Instead I was asking about read_cntpct_stable() which looks like you just split get_cycles().
This change looks completely unrelated to the purpose of this series. I am not going to ask to split it, but I think this should be explained in the commit message.
Cheers,
Signature · 1 line
Julien Grall
RE: [PATCH v2 2/2] xen/arm: Add defensive barrier in get_cycles for Arm64
Hi Julien,
Quoted 120 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2021年1月14日 2:30
To: Wei Chen <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Penny Zheng <[email protected]>; Jiamei Xie <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 2/2] xen/arm: Add defensive barrier inget_cyclesfor Arm64Quoted 1 line · Wei Chen
HI Julien,
Hi Wei,
Quoted 14 lines
Quoted 14 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: 2021年1月8日 19:56
To: Wei Chen <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Penny Zheng <[email protected]>; Jiamei Xie <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v2 2/2] xen/arm: Add defensive barrier inget_cyclesfor Arm64Hi Wei,
On 08/01/2021 06:21, Wei Chen wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Per the discussion [1] on the mailing list, we'd better to have a barrier after reading CNTPCT in
get_cycles. If there is not any barrier there. Whenget_cyclesbeing used in some seqlock critical context in the future, the seqlock can be speculated potentially.We import Linux commit
75a19a0202db21638a1c2b424afb867e1f9a2376:
arm64:arch_timer: Ensure counter register reads occur with seqlockheld
Quoted 79 lines
Quoted 78 lines
Quoted 15 lines
When executing
clock_gettime(), either in the vDSO or via a system call, we need to ensure that the read of the counter register occurs within the seqlock reader critical section. This ensures that updates to the clocksource parameters (e.g. the multiplier) are consistent with the counter value and therefore avoids the situation where time appears to go backwards across multiple reads.Extend the vDSO logic so that the seqlock critical section covers the read of the counter register as well as accesses to the data page. Since reads of the counter system registers are not ordered by memory barrier instructions, introduce dependency ordering from the counter read to a subsequent memory access so that the seqlock memory barriers apply to the counter access in both the vDSO and the system call paths.
Quoted 4 lines
Cc <[email protected]>Cc Marc Zyngier <[email protected]>Tested-by Vincenzo Frascino <[email protected]>
kernel/[email protected]/Quoted 6 lines
Reported-by Thomas Gleixner <[email protected]>Signed-off-by Will Deacon <[email protected]>While we are not aware of such use in Xen, it would be best to add the barrier to avoid any suprise.
Quoted 8 lines
In order to reduce the impact of new barrier, we perfer to use enforce order instead of ISB [2].
Currently, enforce order is not applied to arm32 as this is not done in Linux at the date of this patch. If this is done in Linux it will need to be also done in Xen.
[1] https://lists.xenproject.org/archives/html/xen-devel/2020-
12/msg00181.html
Quoted 9 lines
[2] https://lkml.org/lkml/2020/3/13/645
Signed-off-by Wei Chen <[email protected]>---
v1 -> v2:
1. Update commit message to refer Linux commit.
2. Change u64 touint64_t--- xen/include/asm-arm/time.h | 43++++++++++++++++++++++++++++++++++++--
Quoted 20 lines
1 file changed, 41 insertions(+), 2 deletions(-)xen/include/asm-arm/time.h +9
-1@@ -11,9 +11,26 @@typedef uint64_t cycles_t ; -static inline cycles_t get_cycles (void ) +/* +* Ensure that reads of the counter are treated the same as memory reads +* for the purposes of ordering by subsequent memory barriers. +*/ +#if defined(CONFIG_ARM_64 ) +#define read_cntpct_enforce_ordering (val) do { \ + uint64_t tmp, _val = (val); \ + \ + asm volatile( \xen/include/asm-arm/time.h line 32
Quoted 10 lines
xen/include/asm-arm/time.h +10
-0+ "eor %0, %1, %1\n" \ + "add %0, sp, %0\n" \ + "ldr xzr, [%0]" \ + : "=r" (tmp) : "r" (_val)); \ +} while (0) +#else +#define read_cntpct_enforce_ordering (val) do {} while (0) +#endif + +static inline cycles_t read_cntpct_stable (void )OOI, is there any particular reason to create a new helper?
Quoted 4 lines
Quoted 1 line
Yes, I try to reduce the #if
defined(CONFIG_ARM_64)chunks.Hmmm... There is no #ifdef chunk in
read_cntpct_stable(). Did I miss anything?
No, It was I who misunderstood your comments.
Quoted 5 lines
Quoted 5 lines
I think
if we introduce an empty helper for Arm32, we can reduce the other chunk insideget_cycles. In addition, if we need to do the same work for Arm32 in the future, we may not need to modifyget_cycles.
Quoted 8 lines
I don't really follow this. I wasn't asking about
read_cntpct_enforce_ordering(). Instead I was asking aboutread_cntpct_stable()which looks like you just splitget_cycles().This change looks completely unrelated to the purpose of this series. I am not going to ask to split it, but I think this should be explained in the commit message.
Yes, I forgot to explain this changes in the commit message.
When I was trying to add read_cntpct_enforce_ordering into get_cycles, there were three ways I can do:
1. Add read_cntpct_enforce_ordering to the end of each branch
2. Add a new cycles_t variable and record value of each branch. Using the function end as unique return point. And then we can add read_cntpct_enforce_ordering to the end of get_cycles.
3. Don't touch the get_cycles function body, just rename it and create another helper named get_cycles to include original function and read_cntpct_enforce_ordering
Personally, I prefer the #3, so I changed the function like this.
How about adding the explanation in the end of commit message like this:
"
.... If this is done in Linux it will need to be also done in Xen.
To avoid adding read_cntpct_enforce_ordering everywhere, we introduced a new helper read_cntpct_stable to replace original get_cycles, and turn get_cycles to a wrapper which we can add read_cntpct_enforce_ordering easily.
"
Thanks,
Wei Chen
Quoted 4 lines
Cheers,
--
Julien Grall
Julien Grall
Reviewed-byRe: [PATCH v2 2/2] xen/arm: Add defensive barrier in get_cycles for Arm64
Hi Wei,
Quoted 25 lines · Wei Chen
Quoted 4 lines
Quoted 4 lines
I think
if we introduce an empty helper for Arm32, we can reduce the other chunk insideget_cycles. In addition, if we need to do the same work for Arm32 in the future, we may not need to modifyget_cycles.Quoted 8 lines
I don't really follow this. I wasn't asking about
read_cntpct_enforce_ordering(). Instead I was asking aboutread_cntpct_stable()which looks like you just splitget_cycles().This change looks completely unrelated to the purpose of this series. I am not going to ask to split it, but I think this should be explained in the commit message.
Yes, I forgot to explain this changes in the commit message.
When I was trying to add
read_cntpct_enforce_orderingintoget_cycles, there were three ways I can do:
1. Addread_cntpct_enforce_orderingto the end of each branch
2. Add a newcycles_tvariable and record value of each branch. Using the function end as unique return point. And then we can addread_cntpct_enforce_orderingto the end ofget_cycles.
3. Don't touch theget_cyclesfunction body, just rename it and create another helper namedget_cyclesto include original function andread_cntpct_enforce_ordering
Quoted 1 line
Personally, I prefer the #3, so I changed the function like this.
I agree. Thanks for the explanation! In which case:
Quoted 10 lines
How about adding the explanation in the end of commit message like this:
"
.... If this is done in Linux it will need to be also done in Xen.To avoid adding
read_cntpct_enforce_orderingeverywhere, we introduced a new helperread_cntpct_stableto replace originalget_cycles, and turnget_cyclesto a wrapper which we can addread_cntpct_enforce_orderingeasily.
"
I have updated the commit message and committed the patch.
Thanks for your contribution.
Cheers,
Signature · 1 line
Julien Grall