<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Andre,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks for your help, patch enqueued to 23.11 LTS patch list.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Xueming</div>
<div id="appendonsend"></div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Andre Muezerie <andremue@linux.microsoft.com><br>
<b>Sent:</b> Monday, December 9, 2024 11:56 PM<br>
<b>To:</b> stable@dpdk.org <stable@dpdk.org><br>
<b>Cc:</b> Andre Muezerie <andremue@linux.microsoft.com><br>
<b>Subject:</b> [PATCH 23.11] rcu: fix implicit conversion in bit shift</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText">[ upstream commit ffe827f38e6e0be8a307d7ef9c0e1347874f0af7 ]<br>
<br>
../lib/rcu/rte_rcu_qsbr.c(101): warning C4334: '<<': result of 32-bit<br>
shift implicitly converted to 64 bits (was 64-bit shift intended?)<br>
../lib/rcu/rte_rcu_qsbr.c(107): warning C4334: '<<': result of 32-bit<br>
shift implicitly converted to 64 bits (was 64-bit shift intended?)<br>
../lib/rcu/rte_rcu_qsbr.c(145): warning C4334: '<<': result of 32-bit<br>
shift implicitly converted to 64 bits (was 64-bit shift intended?)<br>
<br>
These warnings are being issued by the MSVC compiler. Since the result is<br>
being stored in a variable of type uint64_t, it makes sense to shift a<br>
64-bit number instead of shifting a 32-bit number and then having the<br>
compiler to convert the result implicitly to 64 bits.<br>
UINT64_C was used in the fix as it is the portable way to define a 64-bit<br>
constant (ULL suffix is architecture dependent).<br>
<br>
>From reading the code this is also a bugfix:<br>
(1 << id), where id = thread_id & 0x3f, was wrong when thread_id > 0x1f.<br>
<br>
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com><br>
---<br>
lib/rcu/rte_rcu_qsbr.c | 16 ++++++++--------<br>
1 file changed, 8 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c<br>
index 41a44be4b9..e46ce7958e 100644<br>
--- a/lib/rcu/rte_rcu_qsbr.c<br>
+++ b/lib/rcu/rte_rcu_qsbr.c<br>
@@ -104,11 +104,11 @@ rte_rcu_qsbr_thread_register(struct rte_rcu_qsbr *v, unsigned int thread_id)<br>
/* Check if the thread is already registered */<br>
old_bmap = rte_atomic_load_explicit(__RTE_QSBR_THRID_ARRAY_ELM(v, i),<br>
rte_memory_order_relaxed);<br>
- if (old_bmap & 1UL << id)<br>
+ if (old_bmap & RTE_BIT64(id))<br>
return 0;<br>
<br>
do {<br>
- new_bmap = old_bmap | (1UL << id);<br>
+ new_bmap = old_bmap | RTE_BIT64(id);<br>
success = rte_atomic_compare_exchange_strong_explicit(<br>
__RTE_QSBR_THRID_ARRAY_ELM(v, i),<br>
&old_bmap, new_bmap,<br>
@@ -117,7 +117,7 @@ rte_rcu_qsbr_thread_register(struct rte_rcu_qsbr *v, unsigned int thread_id)<br>
if (success)<br>
rte_atomic_fetch_add_explicit(&v->num_threads,<br>
1, rte_memory_order_relaxed);<br>
- else if (old_bmap & (1UL << id))<br>
+ else if (old_bmap & RTE_BIT64(id))<br>
/* Someone else registered this thread.<br>
* Counter should not be incremented.<br>
*/<br>
@@ -156,11 +156,11 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id)<br>
/* Check if the thread is already unregistered */<br>
old_bmap = rte_atomic_load_explicit(__RTE_QSBR_THRID_ARRAY_ELM(v, i),<br>
rte_memory_order_relaxed);<br>
- if (!(old_bmap & (1UL << id)))<br>
+ if (!(old_bmap & RTE_BIT64(id)))<br>
return 0;<br>
<br>
do {<br>
- new_bmap = old_bmap & ~(1UL << id);<br>
+ new_bmap = old_bmap & ~RTE_BIT64(id);<br>
/* Make sure any loads of the shared data structure are<br>
* completed before removal of the thread from the list of<br>
* reporting threads.<br>
@@ -173,7 +173,7 @@ rte_rcu_qsbr_thread_unregister(struct rte_rcu_qsbr *v, unsigned int thread_id)<br>
if (success)<br>
rte_atomic_fetch_sub_explicit(&v->num_threads,<br>
1, rte_memory_order_relaxed);<br>
- else if (!(old_bmap & (1UL << id)))<br>
+ else if (!(old_bmap & RTE_BIT64(id)))<br>
/* Someone else unregistered this thread.<br>
* Counter should not be incremented.<br>
*/<br>
@@ -234,7 +234,7 @@ rte_rcu_qsbr_dump(FILE *f, struct rte_rcu_qsbr *v)<br>
t = rte_ctz64(bmap);<br>
fprintf(f, "%u ", id + t);<br>
<br>
- bmap &= ~(1UL << t);<br>
+ bmap &= ~RTE_BIT64(t);<br>
}<br>
}<br>
<br>
@@ -261,7 +261,7 @@ rte_rcu_qsbr_dump(FILE *f, struct rte_rcu_qsbr *v)<br>
rte_atomic_load_explicit(<br>
&v->qsbr_cnt[id + t].lock_cnt,<br>
rte_memory_order_relaxed));<br>
- bmap &= ~(1UL << t);<br>
+ bmap &= ~RTE_BIT64(t);<br>
}<br>
}<br>
<br>
-- <br>
2.47.0.vfs.0.3<br>
<br>
</div>
</span></font></div>
</body>
</html>