Skip to contentSkip to conversation

CodeSamples/defer: Fix hazard torture

PATCH Superseded Alan Huang 2 participants 4 messages Apr 20, 2023 – Apr 22, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Alan Huang

author
#0 lore raw

PATCH 1/1 CodeSamples/defer: Fix hazard torture

This patch fixes hazard torture.

---
 CodeSamples/defer/hazptr.h        | 2 +-
 CodeSamples/defer/hazptrtorture.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
CodeSamples/defer/hazptr.h +1 -1
index 759ab53d..e061303d 100644
@@ -87,7 +87,7 @@ static inline void *hp_record(void **p,			//\lnlbl{hr:b}
 	void *tmp;
 
 	do {
-		tmp = hp_try_record(*p, hp);
+		tmp = hp_try_record(p, hp);
 	} while (tmp == (void *)HAZPTR_POISON);
 	return tmp;
 }							//\lnlbl{hr:e}
CodeSamples/defer/hazptrtorture.h +1 -2
index 53efa259..29761e3d 100644
@@ -241,8 +241,7 @@ DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count);
 
 void *hazptr_read_stress_test(void *arg)
 {
-	int me = (int)(long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;
 	struct hazptr_stress *p;
 	int pc;
 
Signature · 1 line
2.34.1
#1 lore raw

Hi Alan,

Quoted 1 line · Alan Huang

This patch fixes hazard torture.

Please describe what bug you are fixing.

Quoted 12 lines
---
 CodeSamples/defer/hazptr.h        | 2 +-
 CodeSamples/defer/hazptrtorture.h | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
CodeSamples/defer/hazptr.h +0 -0
index 759ab53d..e061303d 100644

CodeSamples/defer/hazptr.h static inline void *hp_record(void **p, //\lnlbl{hr:b} · line 90

Quoted 5 lines
CodeSamples/defer/hazptr.h +1 -1
@@ -87,7 +87,7 @@ static inline void *hp_record(void **p,			//\lnlbl{hr:b}
 	void *tmp;
 
 	do {
-		tmp = hp_try_record(*p, hp);
+		tmp = hp_try_record(p, hp);

This looks to me fixes the regression introduced by commit a082aba85ce0 ("defer/hazptr: Checkpoint for text/code update") made back on Apr 1, 2019.

Was it an April fool? I don't know, but Paul planted this bug to see if there is somebody who would catch it. ;-)

Quoted 8 lines
CodeSamples/defer/hazptr.h +0 -0
 	} while (tmp == (void *)HAZPTR_POISON);
 	return tmp;
 }							//\lnlbl{hr:e}
CodeSamples/defer/hazptrtorture.h +0 -0
index 53efa259..29761e3d 100644

CodeSamples/defer/hazptrtorture.h DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count); · line 244

Quoted 6 lines
CodeSamples/defer/hazptrtorture.h +1 -2
@@ -241,8 +241,7 @@ DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count);
 
 void *hazptr_read_stress_test(void *arg)
 {
-	int me = (int)(long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;

I'm not sure if this change is related to the fix above.

Or are you fixing an independent issue? If so, can you make this part a follow-up patch, with the other patch squashed?

Thanks, Akira

Quoted 3 lines
CodeSamples/defer/hazptrtorture.h +0 -0
 	struct hazptr_stress *p;
 	int pc;
 
author
#2 lore raw

Hi Akira,

I have sent out the patch v2 with a more clear commit message.

Thanks,
Alan

Quoted 58 lines

2023年4月22日 16:28,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 1 line · Alan Huang

This patch fixes hazard torture.

Please describe what bug you are fixing.

Quoted 12 lines

---
CodeSamples/defer/hazptr.h | 2 +-
CodeSamples/defer/hazptrtorture.h | 3 +--

2 files changed, 2 insertions(+), 3 deletions(-)
CodeSamples/defer/hazptr.h +0 -0
index 759ab53d..e061303d 100644

CodeSamples/defer/hazptr.h static inline void *hp_record(void **p, //\lnlbl{hr:b} · line 90

Quoted 5 lines
CodeSamples/defer/hazptr.h +1 -1
@@ -87,7 +87,7 @@ static inline void *hp_record(void **p,			//\lnlbl{hr:b}
 	void *tmp;
 
 	do {
-		tmp = hp_try_record(*p, hp);
+		tmp = hp_try_record(p, hp);

This looks to me fixes the regression introduced by commit a082aba85ce0 ("defer/hazptr: Checkpoint for text/code update") made back on Apr 1, 2019.

Was it an April fool? I don't know, but Paul planted this bug to see if there is somebody who would catch it. ;-)

Quoted 8 lines
CodeSamples/defer/hazptr.h +0 -0
 	} while (tmp == (void *)HAZPTR_POISON);
 	return tmp;
 }							//\lnlbl{hr:e}
CodeSamples/defer/hazptrtorture.h +0 -0
index 53efa259..29761e3d 100644

CodeSamples/defer/hazptrtorture.h DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count); · line 244

Quoted 6 lines
CodeSamples/defer/hazptrtorture.h +1 -2
@@ -241,8 +241,7 @@ DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count);
 
 void *hazptr_read_stress_test(void *arg)
 {
-	int me = (int)(long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;

I'm not sure if this change is related to the fix above.

Or are you fixing an independent issue? If so, can you make this part a follow-up patch, with the other patch squashed?

Thanks, Akira

Quoted 2 lines
CodeSamples/defer/hazptrtorture.h +0 -0
 	struct hazptr_stress *p;
 	int pc;
author
#3 lore raw
In reply to Akira Yokosawa

Hi Akira,

I have sent patch v2 with a more clear commit message.

Thanks,
Alan

Quoted 58 lines

2023年4月22日 16:28,Akira Yokosawa <[email protected]> 写道:

Hi Alan,

Quoted 1 line · Alan Huang

This patch fixes hazard torture.

Please describe what bug you are fixing.

Quoted 12 lines

---
CodeSamples/defer/hazptr.h | 2 +-
CodeSamples/defer/hazptrtorture.h | 3 +--

2 files changed, 2 insertions(+), 3 deletions(-)
CodeSamples/defer/hazptr.h +0 -0
index 759ab53d..e061303d 100644

CodeSamples/defer/hazptr.h static inline void *hp_record(void **p, //\lnlbl{hr:b} · line 90

Quoted 5 lines
CodeSamples/defer/hazptr.h +1 -1
@@ -87,7 +87,7 @@ static inline void *hp_record(void **p, //\lnlbl{hr:b}
 void *tmp;
 
 do {
- tmp = hp_try_record(*p, hp);
+ tmp = hp_try_record(p, hp);

This looks to me fixes the regression introduced by commit a082aba85ce0 ("defer/hazptr: Checkpoint for text/code update") made back on Apr 1, 2019.

Was it an April fool? I don't know, but Paul planted this bug to see if there is somebody who would catch it. ;-)

Quoted 8 lines
CodeSamples/defer/hazptr.h +0 -0
 } while (tmp == (void *)HAZPTR_POISON);
 return tmp;
 } //\lnlbl{hr:e}
CodeSamples/defer/hazptrtorture.h +0 -0
index 53efa259..29761e3d 100644

CodeSamples/defer/hazptrtorture.h DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count); · line 244

Quoted 6 lines
CodeSamples/defer/hazptrtorture.h +1 -2
@@ -241,8 +241,7 @@ DEFINE_PER_THREAD(long long [HAZPTR_STRESS_PIPE_LEN + 1], hazptr_stress_count);
 
 void *hazptr_read_stress_test(void *arg)
 {
- int me = (int)(long)arg;
- int base = me * K;
+ int base = smp_thread_id() * K;

I'm not sure if this change is related to the fix above.

Or are you fixing an independent issue? If so, can you make this part a follow-up patch, with the other patch squashed?

Thanks, Akira

Quoted 2 lines
CodeSamples/defer/hazptrtorture.h +0 -0
 struct hazptr_stress *p;
 int pc;