* Re: [dpdk-dev] [PATCH v1] eal: use correct data type for slab operations
[not found] <1537803523-23347-1-git-send-email-vivek.sharma@caviumnetworks.com>
@ 2018-09-24 15:50 ` Vivek Sharma
2018-09-24 17:12 ` Dumitrescu, Cristian
2018-09-25 9:53 ` [dpdk-dev] [PATCH v2] eal: use correct data type for bitmap " Vivek Sharma
1 sibling, 1 reply; 4+ messages in thread
From: Vivek Sharma @ 2018-09-24 15:50 UTC (permalink / raw)
To: cristian.dumitrescu; +Cc: Sharma, Vivek, stable, dev
+ dev.
+cristian(Bitmap maintainer)
Please review.
Thanks!
On Monday 24 September 2018 09:08 PM, Vivek Sharma wrote:
> Currently, slab operations use unsigned long data type for 64-bit slab
> related operations. On target 'i686-native-linuxapp-gcc', unsigned long
> is 32-bit and thus, slab operations breaks on this target. Changing slab
> operations to use unsigned long long for correct functioning on all targets.
>
> Fixes: de3cfa2c9823 ("sched: initial import")
> Fixes: 693f715da45c ("remove extra parentheses in return statement")
> CC: stable@dpdk.org
>
> Signed-off-by: Vivek Sharma <vivek.sharma@caviumnetworks.com>
> ---
> lib/librte_eal/common/include/rte_bitmap.h | 14 +++++++-------
> test/test/test_bitmap.c | 18 ++++++++++++++++++
> 2 files changed, 25 insertions(+), 7 deletions(-)
>
> diff --git a/lib/librte_eal/common/include/rte_bitmap.h b/lib/librte_eal/common/include/rte_bitmap.h
> index d9facc6..7a36ce7 100644
> --- a/lib/librte_eal/common/include/rte_bitmap.h
> +++ b/lib/librte_eal/common/include/rte_bitmap.h
> @@ -88,7 +88,7 @@ __rte_bitmap_index1_inc(struct rte_bitmap *bmp)
> static inline uint64_t
> __rte_bitmap_mask1_get(struct rte_bitmap *bmp)
> {
> - return (~1lu) << bmp->offset1;
> + return (~1llu) << bmp->offset1;
> }
>
> static inline void
> @@ -317,7 +317,7 @@ rte_bitmap_get(struct rte_bitmap *bmp, uint32_t pos)
> index2 = pos >> RTE_BITMAP_SLAB_BIT_SIZE_LOG2;
> offset2 = pos & RTE_BITMAP_SLAB_BIT_MASK;
> slab2 = bmp->array2 + index2;
> - return (*slab2) & (1lu << offset2);
> + return (*slab2) & (1llu << offset2);
> }
>
> /**
> @@ -342,8 +342,8 @@ rte_bitmap_set(struct rte_bitmap *bmp, uint32_t pos)
> slab2 = bmp->array2 + index2;
> slab1 = bmp->array1 + index1;
>
> - *slab2 |= 1lu << offset2;
> - *slab1 |= 1lu << offset1;
> + *slab2 |= 1llu << offset2;
> + *slab1 |= 1llu << offset1;
> }
>
> /**
> @@ -370,7 +370,7 @@ rte_bitmap_set_slab(struct rte_bitmap *bmp, uint32_t pos, uint64_t slab)
> slab1 = bmp->array1 + index1;
>
> *slab2 |= slab;
> - *slab1 |= 1lu << offset1;
> + *slab1 |= 1llu << offset1;
> }
>
> static inline uint64_t
> @@ -408,7 +408,7 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
> slab2 = bmp->array2 + index2;
>
> /* Return if array2 slab is not all-zeros */
> - *slab2 &= ~(1lu << offset2);
> + *slab2 &= ~(1llu << offset2);
> if (*slab2){
> return;
> }
> @@ -424,7 +424,7 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
> index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2);
> offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK;
> slab1 = bmp->array1 + index1;
> - *slab1 &= ~(1lu << offset1);
> + *slab1 &= ~(1llu << offset1);
>
> return;
> }
> diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
> index c3169e9..95c5184 100644
> --- a/test/test/test_bitmap.c
> +++ b/test/test/test_bitmap.c
> @@ -101,6 +101,7 @@ test_bitmap_slab_set_get(struct rte_bitmap *bmp)
> static int
> test_bitmap_set_get_clear(struct rte_bitmap *bmp)
> {
> + uint64_t val;
> int i;
>
> rte_bitmap_reset(bmp);
> @@ -124,6 +125,23 @@ test_bitmap_set_get_clear(struct rte_bitmap *bmp)
> }
> }
>
> + rte_bitmap_reset(bmp);
> +
> + /* Alternate slab set test */
> + for (i = 0; i < MAX_BITS; i++) {
> + if (i % RTE_BITMAP_SLAB_BIT_SIZE)
> + rte_bitmap_set(bmp, i);
> + }
> +
> + for (i = 0; i < MAX_BITS; i++) {
> + val = rte_bitmap_get(bmp, i);
> + if (((i % RTE_BITMAP_SLAB_BIT_SIZE) && !val) ||
> + (!(i % RTE_BITMAP_SLAB_BIT_SIZE) && val)) {
> + printf("Failed to get set bit.\n");
> + return TEST_FAILED;
> + }
> + }
> +
> return TEST_SUCCESS;
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v1] eal: use correct data type for slab operations
2018-09-24 15:50 ` [dpdk-dev] [PATCH v1] eal: use correct data type for slab operations Vivek Sharma
@ 2018-09-24 17:12 ` Dumitrescu, Cristian
2018-10-08 15:57 ` Dumitrescu, Cristian
0 siblings, 1 reply; 4+ messages in thread
From: Dumitrescu, Cristian @ 2018-09-24 17:12 UTC (permalink / raw)
To: Vivek Sharma; +Cc: Sharma, Vivek, stable, dev
> -----Original Message-----
> From: Vivek Sharma [mailto:vivek.sharma@caviumnetworks.com]
> Sent: Monday, September 24, 2018 4:50 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: Sharma, Vivek <Vivek.Sharma@cavium.com>; stable@dpdk.org;
> dev@dpdk.org
> Subject: Re: [PATCH v1] eal: use correct data type for slab operations
>
> + dev.
> +cristian(Bitmap maintainer)
>
> Please review.
>
> Thanks!
>
> On Monday 24 September 2018 09:08 PM, Vivek Sharma wrote:
> > Currently, slab operations use unsigned long data type for 64-bit slab
> > related operations. On target 'i686-native-linuxapp-gcc', unsigned long
> > is 32-bit and thus, slab operations breaks on this target. Changing slab
> > operations to use unsigned long long for correct functioning on all targets.
> >
> > Fixes: de3cfa2c9823 ("sched: initial import")
> > Fixes: 693f715da45c ("remove extra parentheses in return statement")
> > CC: stable@dpdk.org
> >
> > Signed-off-by: Vivek Sharma <vivek.sharma@caviumnetworks.com>
> > ---
> > lib/librte_eal/common/include/rte_bitmap.h | 14 +++++++-------
> > test/test/test_bitmap.c | 18 ++++++++++++++++++
> > 2 files changed, 25 insertions(+), 7 deletions(-)
> >
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH v2] eal: use correct data type for bitmap slab operations
[not found] <1537803523-23347-1-git-send-email-vivek.sharma@caviumnetworks.com>
2018-09-24 15:50 ` [dpdk-dev] [PATCH v1] eal: use correct data type for slab operations Vivek Sharma
@ 2018-09-25 9:53 ` Vivek Sharma
1 sibling, 0 replies; 4+ messages in thread
From: Vivek Sharma @ 2018-09-25 9:53 UTC (permalink / raw)
To: dev; +Cc: stable, cristian.dumitrescu, Sharma, Vivek
Currently, slab operations use unsigned long data type for 64-bit slab
related operations. On target 'i686-native-linuxapp-gcc', unsigned long
is 32-bit and thus, slab operations breaks on this target. Changing slab
operations to use unsigned long long for correct functioning on
all targets.
Fixes: de3cfa2c9823 ("sched: initial import")
Fixes: 693f715da45c ("remove extra parentheses in return statement")
CC: stable@dpdk.org
Signed-off-by: Vivek Sharma <vivek.sharma@caviumnetworks.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
v1-->v2:
* Added Acked-by:
* check-git-log.sh fixes.
lib/librte_eal/common/include/rte_bitmap.h | 14 +++++++-------
test/test/test_bitmap.c | 18 ++++++++++++++++++
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/lib/librte_eal/common/include/rte_bitmap.h b/lib/librte_eal/common/include/rte_bitmap.h
index d9facc6..7a36ce7 100644
--- a/lib/librte_eal/common/include/rte_bitmap.h
+++ b/lib/librte_eal/common/include/rte_bitmap.h
@@ -88,7 +88,7 @@ __rte_bitmap_index1_inc(struct rte_bitmap *bmp)
static inline uint64_t
__rte_bitmap_mask1_get(struct rte_bitmap *bmp)
{
- return (~1lu) << bmp->offset1;
+ return (~1llu) << bmp->offset1;
}
static inline void
@@ -317,7 +317,7 @@ rte_bitmap_get(struct rte_bitmap *bmp, uint32_t pos)
index2 = pos >> RTE_BITMAP_SLAB_BIT_SIZE_LOG2;
offset2 = pos & RTE_BITMAP_SLAB_BIT_MASK;
slab2 = bmp->array2 + index2;
- return (*slab2) & (1lu << offset2);
+ return (*slab2) & (1llu << offset2);
}
/**
@@ -342,8 +342,8 @@ rte_bitmap_set(struct rte_bitmap *bmp, uint32_t pos)
slab2 = bmp->array2 + index2;
slab1 = bmp->array1 + index1;
- *slab2 |= 1lu << offset2;
- *slab1 |= 1lu << offset1;
+ *slab2 |= 1llu << offset2;
+ *slab1 |= 1llu << offset1;
}
/**
@@ -370,7 +370,7 @@ rte_bitmap_set_slab(struct rte_bitmap *bmp, uint32_t pos, uint64_t slab)
slab1 = bmp->array1 + index1;
*slab2 |= slab;
- *slab1 |= 1lu << offset1;
+ *slab1 |= 1llu << offset1;
}
static inline uint64_t
@@ -408,7 +408,7 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
slab2 = bmp->array2 + index2;
/* Return if array2 slab is not all-zeros */
- *slab2 &= ~(1lu << offset2);
+ *slab2 &= ~(1llu << offset2);
if (*slab2){
return;
}
@@ -424,7 +424,7 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2);
offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK;
slab1 = bmp->array1 + index1;
- *slab1 &= ~(1lu << offset1);
+ *slab1 &= ~(1llu << offset1);
return;
}
diff --git a/test/test/test_bitmap.c b/test/test/test_bitmap.c
index c3169e9..95c5184 100644
--- a/test/test/test_bitmap.c
+++ b/test/test/test_bitmap.c
@@ -101,6 +101,7 @@ test_bitmap_slab_set_get(struct rte_bitmap *bmp)
static int
test_bitmap_set_get_clear(struct rte_bitmap *bmp)
{
+ uint64_t val;
int i;
rte_bitmap_reset(bmp);
@@ -124,6 +125,23 @@ test_bitmap_set_get_clear(struct rte_bitmap *bmp)
}
}
+ rte_bitmap_reset(bmp);
+
+ /* Alternate slab set test */
+ for (i = 0; i < MAX_BITS; i++) {
+ if (i % RTE_BITMAP_SLAB_BIT_SIZE)
+ rte_bitmap_set(bmp, i);
+ }
+
+ for (i = 0; i < MAX_BITS; i++) {
+ val = rte_bitmap_get(bmp, i);
+ if (((i % RTE_BITMAP_SLAB_BIT_SIZE) && !val) ||
+ (!(i % RTE_BITMAP_SLAB_BIT_SIZE) && val)) {
+ printf("Failed to get set bit.\n");
+ return TEST_FAILED;
+ }
+ }
+
return TEST_SUCCESS;
}
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v1] eal: use correct data type for slab operations
2018-09-24 17:12 ` Dumitrescu, Cristian
@ 2018-10-08 15:57 ` Dumitrescu, Cristian
0 siblings, 0 replies; 4+ messages in thread
From: Dumitrescu, Cristian @ 2018-10-08 15:57 UTC (permalink / raw)
To: 'Vivek Sharma'
Cc: 'Sharma, Vivek', 'stable@dpdk.org',
'dev@dpdk.org'
> -----Original Message-----
> From: Dumitrescu, Cristian
> Sent: Monday, September 24, 2018 6:12 PM
> To: Vivek Sharma <vivek.sharma@caviumnetworks.com>
> Cc: Sharma, Vivek <Vivek.Sharma@cavium.com>; stable@dpdk.org;
> dev@dpdk.org
> Subject: RE: [PATCH v1] eal: use correct data type for slab operations
>
>
>
> > -----Original Message-----
> > From: Vivek Sharma [mailto:vivek.sharma@caviumnetworks.com]
> > Sent: Monday, September 24, 2018 4:50 PM
> > To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> > Cc: Sharma, Vivek <Vivek.Sharma@cavium.com>; stable@dpdk.org;
> > dev@dpdk.org
> > Subject: Re: [PATCH v1] eal: use correct data type for slab operations
> >
> > + dev.
> > +cristian(Bitmap maintainer)
> >
> > Please review.
> >
> > Thanks!
> >
> > On Monday 24 September 2018 09:08 PM, Vivek Sharma wrote:
> > > Currently, slab operations use unsigned long data type for 64-bit slab
> > > related operations. On target 'i686-native-linuxapp-gcc', unsigned long
> > > is 32-bit and thus, slab operations breaks on this target. Changing slab
> > > operations to use unsigned long long for correct functioning on all
> targets.
> > >
> > > Fixes: de3cfa2c9823 ("sched: initial import")
> > > Fixes: 693f715da45c ("remove extra parentheses in return statement")
> > > CC: stable@dpdk.org
> > >
> > > Signed-off-by: Vivek Sharma <vivek.sharma@caviumnetworks.com>
> > > ---
> > > lib/librte_eal/common/include/rte_bitmap.h | 14 +++++++-------
> > > test/test/test_bitmap.c | 18 ++++++++++++++++++
> > > 2 files changed, 25 insertions(+), 7 deletions(-)
> > >
>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Applied to next-qos tree, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-10-08 15:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1537803523-23347-1-git-send-email-vivek.sharma@caviumnetworks.com>
2018-09-24 15:50 ` [dpdk-dev] [PATCH v1] eal: use correct data type for slab operations Vivek Sharma
2018-09-24 17:12 ` Dumitrescu, Cristian
2018-10-08 15:57 ` Dumitrescu, Cristian
2018-09-25 9:53 ` [dpdk-dev] [PATCH v2] eal: use correct data type for bitmap " Vivek Sharma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).