Skip to contentSkip to conversation

common/cnxk: use cas with release semantics for batch alloc

PATCH Applied Ashwin Sekhar T K 4 participants 10 messages Nov 30, 2021 – Jan 12, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/cnxk: use cas with release semantics for batch alloc

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
 drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
 drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
 drivers/common/cnxk/roc_npa.h        |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_io.h +12 -0
index fe5f7f46d0..4f15503c29 100644
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr)
 	return compare;
 }
 
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr)
+{
+	asm volatile(PLT_CPU_FEATURE_PREAMBLE
+		     "casl %[compare], %[swap], [%[ptr]]\n"
+		     : [compare] "+r"(compare)
+		     : [swap] "r"(swap), [ptr] "r"(ptr)
+		     : "memory");
+
+	return compare;
+}
+
 static __plt_always_inline uint64_t
 roc_atomic64_add_nosync(int64_t incr, int64_t *ptr)
 {
drivers/common/cnxk/roc_io_generic.h +9 -0
index ceaa3a38d8..5f90835c09 100644
@@ -41,6 +41,15 @@ roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr)
 	return compare;
 }
 
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr)
+{
+	PLT_SET_USED(swap);
+	PLT_SET_USED(ptr);
+
+	return compare;
+}
+
 static inline uint64_t
 roc_atomic64_add_nosync(int64_t incr, int64_t *ptr)
 {
drivers/common/cnxk/roc_npa.h +1 -1
index 46350fdb48..19b9a9352c 100644
@@ -218,7 +218,7 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
 	cmp.compare_s.dis_wait = dis_wait;
 	cmp.compare_s.count = num;
 
-	res = roc_atomic64_cas(cmp.u, (uint64_t)buf, addr);
+	res = roc_atomic64_casl(cmp.u, (uint64_t)buf, addr);
 	if (res != ALLOC_RESULT_ACCEPTED && res != ALLOC_RESULT_NOCORE)
 		return -1;
 
Signature · 1 line
2.32.0
Acked-by on v1 1/1 Applied
#1 lore raw
Quoted 6 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

Changed cas -> CAS in git commit

Applied to dpdk-next-net-mrvl/for-next-net. Thanks

Quoted 65 lines
---
 drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
 drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
 drivers/common/cnxk/roc_npa.h        |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_io.h +12 -0
index fe5f7f46d0..4f15503c29 100644
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr)
        return compare;
 }
 
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr)
+{
+       asm volatile(PLT_CPU_FEATURE_PREAMBLE
+                    "casl %[compare], %[swap], [%[ptr]]\n"
+                    : [compare] "+r"(compare)
+                    : [swap] "r"(swap), [ptr] "r"(ptr)
+                    : "memory");
+
+       return compare;
+}
+
 static __plt_always_inline uint64_t
 roc_atomic64_add_nosync(int64_t incr, int64_t *ptr)
 {
drivers/common/cnxk/roc_io_generic.h +9 -0
index ceaa3a38d8..5f90835c09 100644
@@ -41,6 +41,15 @@ roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr)
        return compare;
 }
 
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr)
+{
+       PLT_SET_USED(swap);
+       PLT_SET_USED(ptr);
+
+       return compare;
+}
+
 static inline uint64_t
 roc_atomic64_add_nosync(int64_t incr, int64_t *ptr)
 {
drivers/common/cnxk/roc_npa.h +1 -2
index 46350fdb48..19b9a9352c 100644
@@ -218,7 +218,7 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf,
        cmp.compare_s.dis_wait = dis_wait;
        cmp.compare_s.count = num;
 
-       res = roc_atomic64_cas(cmp.u, (uint64_t)buf, addr);
+       res = roc_atomic64_casl(cmp.u, (uint64_t)buf, addr);
        if (res != ALLOC_RESULT_ACCEPTED && res != ALLOC_RESULT_NOCORE)
                return -1;
 
--

2.32.0

#2 lore raw
In reply to Ashwin Sekhar T K
Quoted 18 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
  drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
  drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
  drivers/common/cnxk/roc_npa.h        |  2 +-
  3 files changed, 22 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_io.h +0 -0
index fe5f7f46d0..4f15503c29 100644
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr)
  	return compare;
  }

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr) · line 89

Quoted 10 lines
drivers/common/cnxk/roc_io.h +9 -0
 
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr)
+{
+	asm volatile(PLT_CPU_FEATURE_PREAMBLE
+		     "casl %[compare], %[swap], [%[ptr]]\n"
+		     : [compare] "+r"(compare)
+		     : [swap] "r"(swap), [ptr] "r"(ptr)
+		     : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

#3 lore raw
Quoted 23 lines · Ferruh Yigit
Quoted 22 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
  drivers/common/cnxk/roc_io.h         | 12 ++++++++++++ drivers/common/cnxk/roc_io_generic.h |  9 +++++++++ drivers/common/cnxk/roc_npa.h        |  2 +-

  3 files changed, 22 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_io.h +4 -0
index fe5f7f46d0..4f15503c29 100644
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr)
       return compare;
   }
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr)
+{
+    asm volatile(PLT_CPU_FEATURE_PREAMBLE
Quoted 8 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr) · line 89

Quoted 5 lines
drivers/common/cnxk/roc_io.h +5 -0
+             "casl %[compare], %[swap], [%[ptr]]\n"
+             : [compare] "+r"(compare)
+             : [swap] "r"(swap), [ptr] "r"(ptr)
+             : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

+ Honnappa & Ruifeng,

Isn't this API Arm wide, instead of being cnxk specific? Does it make sense to make this API for arm and cnxk use from there?

#4 lore raw

CAS is compare and swap. CASL is compare and swap with release semantics.

But on CNXK platform, the functionality of CAS* instructions is completely different when it is done to specific addresses. These APIs are meant for use for such special cases. These cannot be made ARM generic.

Ashwin Sekhar T K

Quoted 57 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 5:42 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang (Arm Technology China) <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

External Email

----------------------------------------------------------------------

Quoted 12 lines · Ferruh Yigit
Quoted 11 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
  drivers/common/cnxk/roc_io.h         | 12 ++++++++++++ drivers/common/cnxk/roc_io_generic.h |  9 +++++++++ drivers/common/cnxk/roc_npa.h        |  2 +-

  3 files changed, 22 insertions(+), 1 deletion(-)
Quoted 5 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/common/cnxk/roc_io.h index fe5f7f46d0..4f15503c29 100644

drivers/common/cnxk/roc_io.h +0 -0
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t

swap,

Quoted 6 lines
Quoted 6 lines
drivers/common/cnxk/roc_io.h +3 -0
 int64_t *ptr)
       return compare;
   }
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr) {
+    asm volatile(PLT_CPU_FEATURE_PREAMBLE
Quoted 8 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr) · line 89

Quoted 5 lines
drivers/common/cnxk/roc_io.h +5 -0
+             "casl %[compare], %[swap], [%[ptr]]\n"
+             : [compare] "+r"(compare)
+             : [swap] "r"(swap), [ptr] "r"(ptr)
+             : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

+ Honnappa & Ruifeng,

Isn't this API Arm wide, instead of being cnxk specific? Does it make sense to make this API for arm and cnxk use from there?

#5 lore raw
Quoted 2 lines · Ashwin Sekhar Thalakalath Kottilveetil

CAS is compare and swap. CASL is compare and swap with release semantics.

What does 'release semantics' mean? What is functional difference in both?

Quoted 61 lines

But on CNXK platform, the functionality of CAS* instructions is completely different when it is done to specific addresses. These APIs are meant for use for such special cases. These cannot be made ARM generic.

Ashwin Sekhar T K

Quoted 57 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 5:42 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang (Arm Technology China) <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

External Email

----------------------------------------------------------------------

Quoted 12 lines · Ferruh Yigit
Quoted 11 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
   drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
   drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
   drivers/common/cnxk/roc_npa.h        |  2 +-
   3 files changed, 22 insertions(+), 1 deletion(-)
Quoted 5 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/common/cnxk/roc_io.h index fe5f7f46d0..4f15503c29 100644

drivers/common/cnxk/roc_io.h +0 -0
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t

swap,

Quoted 6 lines
Quoted 6 lines
drivers/common/cnxk/roc_io.h +3 -0
 int64_t *ptr)
       return compare;
   }
+static __plt_always_inline uint64_t
+roc_atomic64_casl(uint64_t compare, uint64_t swap, int64_t *ptr) {
+    asm volatile(PLT_CPU_FEATURE_PREAMBLE
Quoted 8 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr) · line 89

Quoted 5 lines
drivers/common/cnxk/roc_io.h +5 -0
+             "casl %[compare], %[swap], [%[ptr]]\n"
+             : [compare] "+r"(compare)
+             : [swap] "r"(swap), [ptr] "r"(ptr)
+             : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

+ Honnappa & Ruifeng,

Isn't this API Arm wide, instead of being cnxk specific? Does it make sense to make this API for arm and cnxk use from there?

#6 lore raw
Quoted 15 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 9:46 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: Re: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

Quoted 6 lines
Quoted 1 line · Ashwin Sekhar Thalakalath Kottilveetil

CAS is compare and swap. CASL is compare and swap with release

semantics.

Quoted 1 line

What does 'release semantics' mean? What is functional difference in both?

'release semantics' is semantics in memory ordering for store operations. It ensures store-store ordering.

And some comments below.

Quoted 61 lines
Quoted 2 lines

But on CNXK platform, the functionality of CAS* instructions is completely

different when it is done to specific addresses. These APIs are meant for use for such special cases. These cannot be made ARM generic.

Quoted 57 lines

Ashwin Sekhar T K

Quoted 54 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 5:42 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang (Arm Technology China) <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

External Email

---------------------------------------------------------------------

Quoted 12 lines · Ferruh Yigit
Quoted 11 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
   drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
   drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
   drivers/common/cnxk/roc_npa.h        |  2 +-
   3 files changed, 22 insertions(+), 1 deletion(-)
Quoted 5 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/common/cnxk/roc_io.h index fe5f7f46d0..4f15503c29 100644

drivers/common/cnxk/roc_io.h +0 -0
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t

swap,

Quoted 6 lines
Quoted 6 lines
drivers/common/cnxk/roc_io.h +3 -0
 int64_t *ptr)
       return compare;
   }
+static __plt_always_inline uint64_t roc_atomic64_casl(uint64_t
+compare, uint64_t swap, int64_t *ptr) {
+    asm volatile(PLT_CPU_FEATURE_PREAMBLE
Quoted 8 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr) · line 89

Quoted 5 lines
drivers/common/cnxk/roc_io.h +5 -0
+             "casl %[compare], %[swap], [%[ptr]]\n"
+             : [compare] "+r"(compare)
+             : [swap] "r"(swap), [ptr] "r"(ptr)
+             : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

+ Honnappa & Ruifeng,

Thanks Ferruh for adding me in this loop.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Isn't this API Arm wide, instead of being cnxk specific? Does it make sense to make this API for arm and cnxk use from there?

Yes, CAS operation can be used Arm wide.
Generally, CAS is available via __atomic_compare_exchange/_n() compiler built-ins. This is the way we use atomic in DPDK. So there is no need to add another generic API.

#7 lore raw
Quoted 112 lines

-----Original Message-----
From: Ruifeng Wang <[email protected]>
Sent: Wednesday, January 12, 2022 11:01 AM
To: Ferruh Yigit <[email protected]>; Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; nd <[email protected]>
Subject: RE: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

Quoted 15 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 9:46 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: Re: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

Quoted 6 lines
Quoted 1 line · Ashwin Sekhar Thalakalath Kottilveetil

CAS is compare and swap. CASL is compare and swap with release

semantics.

Quoted 1 line

What does 'release semantics' mean? What is functional difference in both?

'release semantics' is semantics in memory ordering for store operations. It ensures store-store ordering.

And some comments below.

Quoted 13 lines
Quoted 3 lines

But on CNXK platform, the functionality of CAS* instructions is completely

different when it is done to specific addresses. These APIs are meant for use for such special cases. These cannot be made ARM generic.

Quoted 8 lines

Ashwin Sekhar T K

Quoted 5 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 5:42 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Ruifeng Wang (Arm Technology China) <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul

<[email protected]>;

Quoted 1 line
Quoted 1 line
Quoted 1 line

Anoob Joseph <[email protected]>; Akhil Goyal

<[email protected]>

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines

Subject: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

External Email

-------------------------------------------------------------------
--

Quoted 12 lines · Ferruh Yigit
Quoted 11 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
   drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
   drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
   drivers/common/cnxk/roc_npa.h        |  2 +-
   3 files changed, 22 insertions(+), 1 deletion(-)
Quoted 6 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t

Quoted 6 lines
(quoted diff) +0 -0

b/drivers/common/cnxk/roc_io.h index fe5f7f46d0..4f15503c29 100644

drivers/common/cnxk/roc_io.h +0 -0
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t

swap,

Quoted 14 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t swap, int64_t *ptr) · line 89

Quoted 11 lines
drivers/common/cnxk/roc_io.h +8 -0
 int64_t *ptr)
       return compare;
   }
+static __plt_always_inline uint64_t roc_atomic64_casl(uint64_t
+compare, uint64_t swap, int64_t *ptr) {
+    asm volatile(PLT_CPU_FEATURE_PREAMBLE
+             "casl %[compare], %[swap], [%[ptr]]\n"
+             : [compare] "+r"(compare)
+             : [swap] "r"(swap), [ptr] "r"(ptr)
+             : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ Honnappa & Ruifeng,

Thanks Ferruh for adding me in this loop.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Isn't this API Arm wide, instead of being cnxk specific? Does it make sense to make this API for arm and cnxk use from there?

Yes, CAS operation can be used Arm wide.
Generally, CAS is available via __atomic_compare_exchange/_n() compiler built-ins. This is the way we use atomic in DPDK. So there is no need to add another generic API.

Just to make my comment more clear.
For generic CAS operations, compiler built-ins can be used. No more API needed.
Given the special usage of the instructions in CNXK, the inline assembly here is not intended to be a wrapper of generic CAS operation but rather an interface to other hardware function. It doesn't make sense to make it Arm wide.

Thanks.

#8 lore raw
Quoted 120 lines · Ruifeng Wang
Quoted 112 lines

-----Original Message-----
From: Ruifeng Wang <[email protected]>
Sent: Wednesday, January 12, 2022 11:01 AM
To: Ferruh Yigit <[email protected]>; Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>; nd <[email protected]>
Subject: RE: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

Quoted 15 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 9:46 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: Re: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

Quoted 6 lines
Quoted 1 line · Ashwin Sekhar Thalakalath Kottilveetil

CAS is compare and swap. CASL is compare and swap with release

semantics.

Quoted 1 line

What does 'release semantics' mean? What is functional difference in both?

'release semantics' is semantics in memory ordering for store operations. It ensures store-store ordering.

And some comments below.

Quoted 13 lines
Quoted 3 lines

But on CNXK platform, the functionality of CAS* instructions is completely

different when it is done to specific addresses. These APIs are meant for use for such special cases. These cannot be made ARM generic.

Quoted 8 lines

Ashwin Sekhar T K

Quoted 5 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 5:42 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli

<[email protected]>;

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Ruifeng Wang (Arm Technology China) <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul

<[email protected]>;

Quoted 1 line
Quoted 1 line
Quoted 1 line

Anoob Joseph <[email protected]>; Akhil Goyal

<[email protected]>

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines

Subject: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

External Email

-------------------------------------------------------------------
--

Quoted 12 lines · Ferruh Yigit
Quoted 11 lines · Ashwin Sekhar T K

Before issuing the batch alloc, we clear the first word of cache lines so that NPA can update the status. Make sure that this line clear is flushed before the batch alloc is issued.

---
    drivers/common/cnxk/roc_io.h         | 12 ++++++++++++
    drivers/common/cnxk/roc_io_generic.h |  9 +++++++++
    drivers/common/cnxk/roc_npa.h        |  2 +-
    3 files changed, 22 insertions(+), 1 deletion(-)
Quoted 6 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t

Quoted 6 lines
(quoted diff) +0 -0

b/drivers/common/cnxk/roc_io.h index fe5f7f46d0..4f15503c29 100644

drivers/common/cnxk/roc_io.h +0 -0
@@ -78,6 +78,18 @@ roc_atomic64_cas(uint64_t compare, uint64_t

swap,

Quoted 14 lines

drivers/common/cnxk/roc_io.h roc_atomic64_cas(uint64_t compare, uint64_t · line 88

Quoted 11 lines
drivers/common/cnxk/roc_io.h +8 -0
 int64_t *ptr)
        return compare;
    }
+static __plt_always_inline uint64_t roc_atomic64_casl(uint64_t
+compare, uint64_t swap, int64_t *ptr) {
+    asm volatile(PLT_CPU_FEATURE_PREAMBLE
+             "casl %[compare], %[swap], [%[ptr]]\n"
+             : [compare] "+r"(compare)
+             : [swap] "r"(swap), [ptr] "r"(ptr)
+             : "memory");
+

out of curiosity, what is the "cas with release semantics"? briefly, what is the difference between 'cas' and 'casl'?

Quoted 1 line
Quoted 1 line
Quoted 1 line

+ Honnappa & Ruifeng,

Thanks Ferruh for adding me in this loop.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Isn't this API Arm wide, instead of being cnxk specific? Does it make sense to make this API for arm and cnxk use from there?

Yes, CAS operation can be used Arm wide.
Generally, CAS is available via __atomic_compare_exchange/_n() compiler built-ins. This is the way we use atomic in DPDK. So there is no need to add another generic API.

Quoted 5 lines

Just to make my comment more clear.
For generic CAS operations, compiler built-ins can be used. No more API needed.
Given the special usage of the instructions in CNXK, the inline assembly here is not intended to be a wrapper of generic CAS operation but rather an interface to other hardware function. It doesn't make sense to make it Arm wide.

Got it. Thanks for clarification, I will continue with the set.

#9 lore raw
In reply to Ruifeng Wang
Quoted 16 lines · Ruifeng Wang
Quoted 16 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, January 11, 2022 9:46 PM
To: Ashwin Sekhar Thalakalath Kottilveetil <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Nithin Kumar Dabilpuram <[email protected]>; [email protected]; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Pavan Nikhilesh Bhagavatula <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Satheesh Paul <[email protected]>; Anoob Joseph <[email protected]>; Akhil Goyal <[email protected]>
Subject: Re: [EXT] Re: [PATCH] common/cnxk: use cas with release semantics for batch alloc

On 1/11/2022 12:26 PM, Ashwin Sekhar Thalakalath Kottilveetil wrote:

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

CAS is compare and swap. CASL is compare and swap with release

semantics.

Quoted 1 line

What does 'release semantics' mean? What is functional difference in both?

'release semantics' is semantics in memory ordering for store operations. It ensures store-store ordering.

Thanks.