Skip to contentSkip to conversation

CodeSamples/defer: Make hazard partition consistent with hazptr_thread_exit

PATCH In review Alan Huang 3 participants 5 messages Apr 20, 2023 – Apr 25, 2023

lore
Share & tools
lore

Alan Huang

author
#0 lore raw

PATCH 1/1 CodeSamples/defer: Make hazard partition consistent with hazptr_thread_exit

---
 CodeSamples/defer/hazptrtorture.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/defer/hazptrtorture.h +1 -1
index 29761e3d..acdd532b 100644
@@ -99,7 +99,7 @@ void *hazptr_read_perf_test(void *arg)
 {
 	int i;
 	int me = (long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;
 	long long n_reads_local = 0;
 	hazptr_head_t hh;
 	hazptr_head_t *hhp = &hh;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 10 lines · Alan Huang
---
 CodeSamples/defer/hazptrtorture.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/defer/hazptrtorture.h +0 -0
index 29761e3d..acdd532b 100644

CodeSamples/defer/hazptrtorture.h void *hazptr_read_perf_test(void *arg) · line 102

Quoted 5 lines
CodeSamples/defer/hazptrtorture.h +1 -1
@@ -99,7 +99,7 @@ void *hazptr_read_perf_test(void *arg)
 {
 	int i;
 	int me = (long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;

Suppose specify a number of threads greater than the number of CPUs. For example, on my 12-hardware-thread laptop:

./route_hazptr --stresstest --nreaders 24

In that case, don't we want "me" rather than "smp_thread_id()"?

Thanx, Paul

Quoted 6 lines
CodeSamples/defer/hazptrtorture.h +0 -0
 	long long n_reads_local = 0;
 	hazptr_head_t hh;
 	hazptr_head_t *hhp = &hh;
Signature · 1 line
2.34.1
#2 lore raw
Quoted 20 lines · Paul E. McKenney
Quoted 10 lines · Alan Huang
---
 CodeSamples/defer/hazptrtorture.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/defer/hazptrtorture.h +0 -0
index 29761e3d..acdd532b 100644

CodeSamples/defer/hazptrtorture.h void *hazptr_read_perf_test(void *arg) · line 102

Quoted 5 lines
CodeSamples/defer/hazptrtorture.h +1 -1
@@ -99,7 +99,7 @@ void *hazptr_read_perf_test(void *arg)
 {
 	int i;
 	int me = (long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;

Suppose specify a number of threads greater than the number of CPUs. For example, on my 12-hardware-thread laptop:

Quoted 3 lines

./route_hazptr --stresstest --nreaders 24

In that case, don't we want "me" rather than "smp_thread_id()"?

But route_hazptr.c includes routetorture.h Furthermore, route_hazptr.c doesn't call hp_record() which just got fixed.

So it looks to me that Alan's fixes won't have any effect on route_hazptr ...

But I might be missing something here.

Thanks, Akira

Quoted 9 lines

Thanx, Paul

Quoted 6 lines
CodeSamples/defer/hazptrtorture.h +0 -0
 	long long n_reads_local = 0;
 	hazptr_head_t hh;
 	hazptr_head_t *hhp = &hh;
Signature · 1 line
2.34.1
author
#3 lore raw
In reply to Paul E. McKenney
Quoted 22 lines

2023年4月25日 00:02,Paul E. McKenney <[email protected]> 写道:

Quoted 10 lines · Alan Huang

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

1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/defer/hazptrtorture.h +0 -0
index 29761e3d..acdd532b 100644

CodeSamples/defer/hazptrtorture.h void *hazptr_read_perf_test(void *arg) · line 102

Quoted 5 lines
CodeSamples/defer/hazptrtorture.h +1 -1
@@ -99,7 +99,7 @@ void *hazptr_read_perf_test(void *arg)
 {
 	int i;
 	int me = (long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;

Suppose specify a number of threads greater than the number of CPUs. For example, on my 12-hardware-thread laptop:

Quoted 3 lines

./route_hazptr --stresstest --nreaders 24

In that case, don't we want "me" rather than "smp_thread_id()"?

As Akira said, route_hazptr.c includes routetorture.h and route_hazptr.c doesn't call hp_record(). The fix won't have any effect on route_hazptr.

Thanks,
Alan

Quoted 9 lines

Thanx, Paul

Quoted 6 lines
CodeSamples/defer/hazptrtorture.h +0 -0
 	long long n_reads_local = 0;
 	hazptr_head_t hh;
 	hazptr_head_t *hhp = &hh;
Signature · 1 line
2.34.1
#4 lore raw
Quoted 22 lines · Alan Huang
Quoted 22 lines

2023年4月25日 00:02,Paul E. McKenney <[email protected]> 写道:

Quoted 10 lines · Alan Huang

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

1 file changed, 1 insertion(+), 1 deletion(-)
CodeSamples/defer/hazptrtorture.h +0 -0
index 29761e3d..acdd532b 100644

CodeSamples/defer/hazptrtorture.h void *hazptr_read_perf_test(void *arg) · line 102

Quoted 5 lines
CodeSamples/defer/hazptrtorture.h +1 -1
@@ -99,7 +99,7 @@ void *hazptr_read_perf_test(void *arg)
 {
 	int i;
 	int me = (long)arg;
-	int base = me * K;
+	int base = smp_thread_id() * K;

Suppose specify a number of threads greater than the number of CPUs. For example, on my 12-hardware-thread laptop:

Quoted 3 lines
Quoted 3 lines

./route_hazptr --stresstest --nreaders 24

In that case, don't we want "me" rather than "smp_thread_id()"?

Never mind, I was confused. Maybe I should have waited another day after return before looking at this. :-/

$ ./hazptr 24 perf
sched_setaffinity: Invalid argument
Aborted (core dumped)

But that is a pre-existing problem. If I keep the number within the number of hardware threads, it works fine:

$ ./hazptr 12 perf
n_reads: 576608000  n_updates: 314343  nreaders: 12  nupdaters: 1 duration: 1
ns/read: 20.8114  ns/update: 3181.24

I am not all that worried about this. Running multiple threads per hardware thread in a performance test isn't all that useful, after all. And there is a robust diagnostic. Perhaps not as helpful as one might like, but definitely robust. ;-)

Quoted 2 lines

As Akira said, route_hazptr.c includes routetorture.h and route_hazptr.c doesn't call hp_record(). The fix won't have any effect on route_hazptr.

Agreed, again, my post-vacation confusion, apologies!!!

Thanx, Paul