[dpdk-dev,v3] Fix two compile issues with i686 platform

Message ID 20141208025952.GA24461@localhost.localdomain (mailing list archive)
State Not Applicable, archived
Headers

Commit Message

Neil Horman Dec. 8, 2014, 2:59 a.m. UTC
On Mon, Dec 08, 2014 at 02:46:51AM +0000, Qiu, Michael wrote:
> On 12/5/2014 11:25 PM, Neil Horman wrote:
> > On Fri, Dec 05, 2014 at 03:02:33PM +0000, Bruce Richardson wrote:
> >> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
> >>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
> >>>> On 2014/12/4 17:12, Michael Qiu wrote:
> >>>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
> >>>>> is always false due to limited range of data type [-Werror=type-limits]
> >>>>>     || (hugepage_sz == RTE_PGSIZE_16G)) {
> >>>>>     ^
> >>>>> cc1: all warnings being treated as errors
> >>>>>
> >>>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
> >>>>> conversion from "long long" to "void *" may lose significant bits
> >>>>>    RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
> >>>>>
> >>>>> This was introuduced by commit b77b5639:
> >>>>>         mem: add huge page sizes for IBM Power
> >>>>>
> >>>>> The root cause is that size_t and uintptr_t are 32-bit in i686
> >>>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
> >>>>>
> >>>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
> >>>>> this issue.
> >>>>>
> >>>>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> >>>>> ---
> >>>>>  v3 ---> v2
> >>>>> 	Change RTE_PGSIZE_16G from ULL to UL
> >>>>> 	to keep all entries consistent
> >>>>>
> >>>>>  V2 ---> v1
> >>>>> 	Change two type entries to one, and
> >>>>> 	leave RTE_PGSIZE_16G only valid for
> >>>>> 	64-bit platform
> >>>>>
> >>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent of
> >>> architecutre.  While a system can't have a hugepage size that exceeds its
> >>> virtual address limit, theres no need to do per-architecture special casing of
> >>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
> >>> everytime you want to check a page size, just convert the size_t to a uint64_t
> >>> and you can allow all of the enumerated page types on all architecutres, and
> >>> save yourself some ifdeffing in the process.
> >>>
> >>> Neil
> >> While I get your point, I find it distasteful to use a uint64_t for memory sizes,
> >> when there is the size_t type defined for that particular purpose.
> >> However, I suppose that reducing the number of #ifdefs compared to using the
> >> "correct" datatypes for objects is a more practical optino - however distastful
> >> I find it.
> > size_t isn't defined for memory sizes in the sense that we're using them here.
> > size_t is meant to address the need for a type to describe object sizes on a
> > particular system, and it itself is sized accordingly (32 bits on a 32 bit arch,
> > 64 on 64), so that you can safely store a size that the system in question might
> > maximally allocate/return.  In this situation we are describing memory sizes
> > that might occur no a plurality of arches, and so size_t is inappropriate
> > because it as a type is not sized for anything other than the arch it is being
> > built for.  The pragmatic benefits of ennumerating page sizes in a single
> > canonical location far outweigh the desire to use a misappropriated type to
> > describe them.
> 
> Neil,
> 
> This patch fix two compile issues, and we need to do *dpdk testing
> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
> 
> I've get you mind and your concern. But we should take care of changing
> the type of "hugepage_sz", because lots of places using it.
> 
> Would you mind if we consider this as hot fix, and we can post a better
> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
> 
Honestly, no.  Because intels testing schedule shouldn't drive the inclusion of
upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
asking for a proper fix for a very straightforward problem.  I've attached the
proper fix below.

Regards
Neil
  

Comments

Michael Qiu Dec. 8, 2014, 3:37 a.m. UTC | #1
On 12/8/2014 11:00 AM, Neil Horman wrote:
> On Mon, Dec 08, 2014 at 02:46:51AM +0000, Qiu, Michael wrote:
>> On 12/5/2014 11:25 PM, Neil Horman wrote:
>>> On Fri, Dec 05, 2014 at 03:02:33PM +0000, Bruce Richardson wrote:
>>>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
>>>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
>>>>>> On 2014/12/4 17:12, Michael Qiu wrote:
>>>>>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
>>>>>>> is always false due to limited range of data type [-Werror=type-limits]
>>>>>>>     || (hugepage_sz == RTE_PGSIZE_16G)) {
>>>>>>>     ^
>>>>>>> cc1: all warnings being treated as errors
>>>>>>>
>>>>>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
>>>>>>> conversion from "long long" to "void *" may lose significant bits
>>>>>>>    RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
>>>>>>>
>>>>>>> This was introuduced by commit b77b5639:
>>>>>>>         mem: add huge page sizes for IBM Power
>>>>>>>
>>>>>>> The root cause is that size_t and uintptr_t are 32-bit in i686
>>>>>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
>>>>>>>
>>>>>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
>>>>>>> this issue.
>>>>>>>
>>>>>>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
>>>>>>> ---
>>>>>>>  v3 ---> v2
>>>>>>> 	Change RTE_PGSIZE_16G from ULL to UL
>>>>>>> 	to keep all entries consistent
>>>>>>>
>>>>>>>  V2 ---> v1
>>>>>>> 	Change two type entries to one, and
>>>>>>> 	leave RTE_PGSIZE_16G only valid for
>>>>>>> 	64-bit platform
>>>>>>>
>>>>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent of
>>>>> architecutre.  While a system can't have a hugepage size that exceeds its
>>>>> virtual address limit, theres no need to do per-architecture special casing of
>>>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
>>>>> everytime you want to check a page size, just convert the size_t to a uint64_t
>>>>> and you can allow all of the enumerated page types on all architecutres, and
>>>>> save yourself some ifdeffing in the process.
>>>>>
>>>>> Neil
>>>> While I get your point, I find it distasteful to use a uint64_t for memory sizes,
>>>> when there is the size_t type defined for that particular purpose.
>>>> However, I suppose that reducing the number of #ifdefs compared to using the
>>>> "correct" datatypes for objects is a more practical optino - however distastful
>>>> I find it.
>>> size_t isn't defined for memory sizes in the sense that we're using them here.
>>> size_t is meant to address the need for a type to describe object sizes on a
>>> particular system, and it itself is sized accordingly (32 bits on a 32 bit arch,
>>> 64 on 64), so that you can safely store a size that the system in question might
>>> maximally allocate/return.  In this situation we are describing memory sizes
>>> that might occur no a plurality of arches, and so size_t is inappropriate
>>> because it as a type is not sized for anything other than the arch it is being
>>> built for.  The pragmatic benefits of ennumerating page sizes in a single
>>> canonical location far outweigh the desire to use a misappropriated type to
>>> describe them.
>> Neil,
>>
>> This patch fix two compile issues, and we need to do *dpdk testing
>> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
>>
>> I've get you mind and your concern. But we should take care of changing
>> the type of "hugepage_sz", because lots of places using it.
>>
>> Would you mind if we consider this as hot fix, and we can post a better
>> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
>>
> Honestly, no.  Because intels testing schedule shouldn't drive the inclusion of
> upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
> asking for a proper fix for a very straightforward problem.  I've attached the
> proper fix below.
>
> Regards
> Neil

We test dpdk upstream now as 1,8 rc2 and rc3 released :)

I know that what you mean. but lots of please using "hugepage_sz" do you
confirm it will not affect other issue?

On other hand, we use 32 bit address in 32 bit platform for better
performance(some of places also use uintptr_t for address check and
alignment).

And it should not acceptable in 32 bit platform to use 64-bit platform
specification affairs(like RTE_PGSIZE_16G).

Thanks,
Michael

>
>
> diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
> index 412b432..31a391c 100644
> --- a/lib/librte_eal/common/eal_common_memory.c
> +++ b/lib/librte_eal/common/eal_common_memory.c
> @@ -96,7 +96,7 @@ rte_dump_physmem_layout(FILE *f)
>  
>  		fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
>  		       "virt:%p, socket_id:%"PRId32", "
> -		       "hugepage_sz:%zu, nchannel:%"PRIx32", "
> +		       "hugepage_sz:%llu, nchannel:%"PRIx32", "
>  		       "nrank:%"PRIx32"\n", i,
>  		       mcfg->memseg[i].phys_addr,
>  		       mcfg->memseg[i].len,
> diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
> index aac6abf..e2ecb0d 100644
> --- a/lib/librte_eal/common/eal_internal_cfg.h
> +++ b/lib/librte_eal/common/eal_internal_cfg.h
> @@ -49,7 +49,7 @@
>   * mount points of hugepages
>   */
>  struct hugepage_info {
> -	size_t hugepage_sz;   /**< size of a huge page */
> +	uint64_t hugepage_sz;   /**< size of a huge page */
>  	const char *hugedir;    /**< dir where hugetlbfs is mounted */
>  	uint32_t num_pages[RTE_MAX_NUMA_NODES];
>  				/**< number of hugepages of that size on each socket */
> diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
> index 1990833..7f8103f 100644
> --- a/lib/librte_eal/common/include/rte_memory.h
> +++ b/lib/librte_eal/common/include/rte_memory.h
> @@ -92,7 +92,7 @@ struct rte_memseg {
>  	phys_addr_t ioremap_addr; /**< Real physical address inside the VM */
>  #endif
>  	size_t len;               /**< Length of the segment. */
> -	size_t hugepage_sz;       /**< The pagesize of underlying memory */
> +	uint64_t hugepage_sz;       /**< The pagesize of underlying memory */
>  	int32_t socket_id;          /**< NUMA socket ID. */
>  	uint32_t nchannel;          /**< Number of channels. */
>  	uint32_t nrank;             /**< Number of ranks. */
> diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
> index 7d47bff..3006e81 100644
> --- a/lib/librte_eal/common/include/rte_memzone.h
> +++ b/lib/librte_eal/common/include/rte_memzone.h
> @@ -83,7 +83,7 @@ struct rte_memzone {
>  #endif
>  	size_t len;                       /**< Length of the memzone. */
>  
> -	size_t hugepage_sz;               /**< The page size of underlying memory */
> +	uint64_t hugepage_sz;               /**< The page size of underlying memory */
>  
>  	int32_t socket_id;                /**< NUMA socket ID. */
>  
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index e6cb919..bae2507 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -300,7 +300,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl,
>  #endif
>  
>  	for (i = 0; i < hpi->num_pages[0]; i++) {
> -		size_t hugepage_sz = hpi->hugepage_sz;
> +		uint64_t hugepage_sz = hpi->hugepage_sz;
>  
>  		if (orig) {
>  			hugepg_tbl[i].file_id = i;
>
  
Michael Qiu Dec. 8, 2014, 4:57 a.m. UTC | #2
On 12/8/2014 11:39 AM, Qiu, Michael wrote:
> On 12/8/2014 11:00 AM, Neil Horman wrote:
>> On Mon, Dec 08, 2014 at 02:46:51AM +0000, Qiu, Michael wrote:
>>> On 12/5/2014 11:25 PM, Neil Horman wrote:
>>>> On Fri, Dec 05, 2014 at 03:02:33PM +0000, Bruce Richardson wrote:
>>>>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
>>>>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
>>>>>>> On 2014/12/4 17:12, Michael Qiu wrote:
>>>>>>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
>>>>>>>> is always false due to limited range of data type [-Werror=type-limits]
>>>>>>>>     || (hugepage_sz == RTE_PGSIZE_16G)) {
>>>>>>>>     ^
>>>>>>>> cc1: all warnings being treated as errors
>>>>>>>>
>>>>>>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
>>>>>>>> conversion from "long long" to "void *" may lose significant bits
>>>>>>>>    RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
>>>>>>>>
>>>>>>>> This was introuduced by commit b77b5639:
>>>>>>>>         mem: add huge page sizes for IBM Power
>>>>>>>>
>>>>>>>> The root cause is that size_t and uintptr_t are 32-bit in i686
>>>>>>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
>>>>>>>>
>>>>>>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
>>>>>>>> this issue.
>>>>>>>>
>>>>>>>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
>>>>>>>> ---
>>>>>>>>  v3 ---> v2
>>>>>>>> 	Change RTE_PGSIZE_16G from ULL to UL
>>>>>>>> 	to keep all entries consistent
>>>>>>>>
>>>>>>>>  V2 ---> v1
>>>>>>>> 	Change two type entries to one, and
>>>>>>>> 	leave RTE_PGSIZE_16G only valid for
>>>>>>>> 	64-bit platform
>>>>>>>>
>>>>>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent of
>>>>>> architecutre.  While a system can't have a hugepage size that exceeds its
>>>>>> virtual address limit, theres no need to do per-architecture special casing of
>>>>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
>>>>>> everytime you want to check a page size, just convert the size_t to a uint64_t
>>>>>> and you can allow all of the enumerated page types on all architecutres, and
>>>>>> save yourself some ifdeffing in the process.
>>>>>>
>>>>>> Neil
>>>>> While I get your point, I find it distasteful to use a uint64_t for memory sizes,
>>>>> when there is the size_t type defined for that particular purpose.
>>>>> However, I suppose that reducing the number of #ifdefs compared to using the
>>>>> "correct" datatypes for objects is a more practical optino - however distastful
>>>>> I find it.
>>>> size_t isn't defined for memory sizes in the sense that we're using them here.
>>>> size_t is meant to address the need for a type to describe object sizes on a
>>>> particular system, and it itself is sized accordingly (32 bits on a 32 bit arch,
>>>> 64 on 64), so that you can safely store a size that the system in question might
>>>> maximally allocate/return.  In this situation we are describing memory sizes
>>>> that might occur no a plurality of arches, and so size_t is inappropriate
>>>> because it as a type is not sized for anything other than the arch it is being
>>>> built for.  The pragmatic benefits of ennumerating page sizes in a single
>>>> canonical location far outweigh the desire to use a misappropriated type to
>>>> describe them.
>>> Neil,
>>>
>>> This patch fix two compile issues, and we need to do *dpdk testing
>>> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
>>>
>>> I've get you mind and your concern. But we should take care of changing
>>> the type of "hugepage_sz", because lots of places using it.
>>>
>>> Would you mind if we consider this as hot fix, and we can post a better
>>> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
>>>
>> Honestly, no.  Because intels testing schedule shouldn't drive the inclusion of
>> upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
>> asking for a proper fix for a very straightforward problem.  I've attached the
>> proper fix below.
>>
>> Regards
>> Neil
> We test dpdk upstream now as 1,8 rc2 and rc3 released :)
>
> I know that what you mean. but lots of please using "hugepage_sz" do you

Sorry, please/places
> confirm it will not affect other issue?
>
> On other hand, we use 32 bit address in 32 bit platform for better
> performance(some of places also use uintptr_t for address check and
> alignment).
>
> And it should not acceptable in 32 bit platform to use 64-bit platform
> specification affairs(like RTE_PGSIZE_16G).
>
> Thanks,
> Michael
>
>>
>> diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
>> index 412b432..31a391c 100644
>> --- a/lib/librte_eal/common/eal_common_memory.c
>> +++ b/lib/librte_eal/common/eal_common_memory.c
>> @@ -96,7 +96,7 @@ rte_dump_physmem_layout(FILE *f)
>>  
>>  		fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
>>  		       "virt:%p, socket_id:%"PRId32", "
>> -		       "hugepage_sz:%zu, nchannel:%"PRIx32", "
>> +		       "hugepage_sz:%llu, nchannel:%"PRIx32", "
>>  		       "nrank:%"PRIx32"\n", i,
>>  		       mcfg->memseg[i].phys_addr,
>>  		       mcfg->memseg[i].len,
>> diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
>> index aac6abf..e2ecb0d 100644
>> --- a/lib/librte_eal/common/eal_internal_cfg.h
>> +++ b/lib/librte_eal/common/eal_internal_cfg.h
>> @@ -49,7 +49,7 @@
>>   * mount points of hugepages
>>   */
>>  struct hugepage_info {
>> -	size_t hugepage_sz;   /**< size of a huge page */
>> +	uint64_t hugepage_sz;   /**< size of a huge page */
>>  	const char *hugedir;    /**< dir where hugetlbfs is mounted */
>>  	uint32_t num_pages[RTE_MAX_NUMA_NODES];
>>  				/**< number of hugepages of that size on each socket */
>> diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
>> index 1990833..7f8103f 100644
>> --- a/lib/librte_eal/common/include/rte_memory.h
>> +++ b/lib/librte_eal/common/include/rte_memory.h
>> @@ -92,7 +92,7 @@ struct rte_memseg {
>>  	phys_addr_t ioremap_addr; /**< Real physical address inside the VM */
>>  #endif
>>  	size_t len;               /**< Length of the segment. */
>> -	size_t hugepage_sz;       /**< The pagesize of underlying memory */
>> +	uint64_t hugepage_sz;       /**< The pagesize of underlying memory */
>>  	int32_t socket_id;          /**< NUMA socket ID. */
>>  	uint32_t nchannel;          /**< Number of channels. */
>>  	uint32_t nrank;             /**< Number of ranks. */
>> diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
>> index 7d47bff..3006e81 100644
>> --- a/lib/librte_eal/common/include/rte_memzone.h
>> +++ b/lib/librte_eal/common/include/rte_memzone.h
>> @@ -83,7 +83,7 @@ struct rte_memzone {
>>  #endif
>>  	size_t len;                       /**< Length of the memzone. */
>>  
>> -	size_t hugepage_sz;               /**< The page size of underlying memory */
>> +	uint64_t hugepage_sz;               /**< The page size of underlying memory */
>>  
>>  	int32_t socket_id;                /**< NUMA socket ID. */
>>  
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
>> index e6cb919..bae2507 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
>> @@ -300,7 +300,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl,
>>  #endif
>>  
>>  	for (i = 0; i < hpi->num_pages[0]; i++) {
>> -		size_t hugepage_sz = hpi->hugepage_sz;
>> +		uint64_t hugepage_sz = hpi->hugepage_sz;
>>  
>>  		if (orig) {
>>  			hugepg_tbl[i].file_id = i;
>>
>
  
Neil Horman Dec. 8, 2014, 11:37 a.m. UTC | #3
On Mon, Dec 08, 2014 at 03:37:19AM +0000, Qiu, Michael wrote:
> On 12/8/2014 11:00 AM, Neil Horman wrote:
> > On Mon, Dec 08, 2014 at 02:46:51AM +0000, Qiu, Michael wrote:
> >> On 12/5/2014 11:25 PM, Neil Horman wrote:
> >>> On Fri, Dec 05, 2014 at 03:02:33PM +0000, Bruce Richardson wrote:
> >>>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
> >>>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
> >>>>>> On 2014/12/4 17:12, Michael Qiu wrote:
> >>>>>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
> >>>>>>> is always false due to limited range of data type [-Werror=type-limits]
> >>>>>>>     || (hugepage_sz == RTE_PGSIZE_16G)) {
> >>>>>>>     ^
> >>>>>>> cc1: all warnings being treated as errors
> >>>>>>>
> >>>>>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
> >>>>>>> conversion from "long long" to "void *" may lose significant bits
> >>>>>>>    RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
> >>>>>>>
> >>>>>>> This was introuduced by commit b77b5639:
> >>>>>>>         mem: add huge page sizes for IBM Power
> >>>>>>>
> >>>>>>> The root cause is that size_t and uintptr_t are 32-bit in i686
> >>>>>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
> >>>>>>>
> >>>>>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
> >>>>>>> this issue.
> >>>>>>>
> >>>>>>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> >>>>>>> ---
> >>>>>>>  v3 ---> v2
> >>>>>>> 	Change RTE_PGSIZE_16G from ULL to UL
> >>>>>>> 	to keep all entries consistent
> >>>>>>>
> >>>>>>>  V2 ---> v1
> >>>>>>> 	Change two type entries to one, and
> >>>>>>> 	leave RTE_PGSIZE_16G only valid for
> >>>>>>> 	64-bit platform
> >>>>>>>
> >>>>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent of
> >>>>> architecutre.  While a system can't have a hugepage size that exceeds its
> >>>>> virtual address limit, theres no need to do per-architecture special casing of
> >>>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
> >>>>> everytime you want to check a page size, just convert the size_t to a uint64_t
> >>>>> and you can allow all of the enumerated page types on all architecutres, and
> >>>>> save yourself some ifdeffing in the process.
> >>>>>
> >>>>> Neil
> >>>> While I get your point, I find it distasteful to use a uint64_t for memory sizes,
> >>>> when there is the size_t type defined for that particular purpose.
> >>>> However, I suppose that reducing the number of #ifdefs compared to using the
> >>>> "correct" datatypes for objects is a more practical optino - however distastful
> >>>> I find it.
> >>> size_t isn't defined for memory sizes in the sense that we're using them here.
> >>> size_t is meant to address the need for a type to describe object sizes on a
> >>> particular system, and it itself is sized accordingly (32 bits on a 32 bit arch,
> >>> 64 on 64), so that you can safely store a size that the system in question might
> >>> maximally allocate/return.  In this situation we are describing memory sizes
> >>> that might occur no a plurality of arches, and so size_t is inappropriate
> >>> because it as a type is not sized for anything other than the arch it is being
> >>> built for.  The pragmatic benefits of ennumerating page sizes in a single
> >>> canonical location far outweigh the desire to use a misappropriated type to
> >>> describe them.
> >> Neil,
> >>
> >> This patch fix two compile issues, and we need to do *dpdk testing
> >> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
> >>
> >> I've get you mind and your concern. But we should take care of changing
> >> the type of "hugepage_sz", because lots of places using it.
> >>
> >> Would you mind if we consider this as hot fix, and we can post a better
> >> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
> >>
> > Honestly, no.  Because intels testing schedule shouldn't drive the inclusion of
> > upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
> > asking for a proper fix for a very straightforward problem.  I've attached the
> > proper fix below.
> >
> > Regards
> > Neil
> 
> We test dpdk upstream now as 1,8 rc2 and rc3 released :)
> 
Yes, I don't take issue with you testing dpdk, on the contrary, I appreciate it.
What I take issue with is that you are asserting that the blockage of your
testing is reason to ignore a proper fix an issue, rather than some substandard
one.

> I know that what you mean. but lots of please using "hugepage_sz" do you
> confirm it will not affect other issue?
> 
5.  There are 5 placees that use hugepage_sz, as the patch below indicates.
Thats no alot.

Also, I take issue with the assertion that this patch creates no additional
problems.  I'm sure it creates no additional problems that your patch wouldn't
also create, arguably less.  If we were really being pragmatic here, I would
point out that this problem was caused by the fact that support for an entire
new architecture was integrated during the -rc phase of a release, which seems
extreemely risky to me, and as such, the most appropriate thing to do would be
to back support for ppc out until after the 1.8 release when it could be
properly tested.  Instead we are slamming in hacked up fixes that throw arch
specific ifdefs througout the code.

> On other hand, we use 32 bit address in 32 bit platform for better
> performance(some of places also use uintptr_t for address check and
> alignment).
> 
This has nothing to do with address bus size.

> And it should not acceptable in 32 bit platform to use 64-bit platform
> specification affairs(like RTE_PGSIZE_16G).
> 
Ok, so add a single arch specific runtime check during hugepage mapping to exit
on the 16G size use on 32 bit systems.  Thats a fair and reasonable thing to do,
though I think the hugepage remap is already ifdeffed for 54 bit arches only.

Neil
  
Thomas Monjalon Dec. 8, 2014, 11:50 a.m. UTC | #4
2014-12-08 06:37, Neil Horman:
> On Mon, Dec 08, 2014 at 03:37:19AM +0000, Qiu, Michael wrote:
> > On 12/8/2014 11:00 AM, Neil Horman wrote:
> > > On Mon, Dec 08, 2014 at 02:46:51AM +0000, Qiu, Michael wrote:
> > >> On 12/5/2014 11:25 PM, Neil Horman wrote:
> > >>> On Fri, Dec 05, 2014 at 03:02:33PM +0000, Bruce Richardson wrote:
> > >>>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
> > >>>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
> > >>>>>> On 2014/12/4 17:12, Michael Qiu wrote:
> > >>>>>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
> > >>>>>>> is always false due to limited range of data type [-Werror=type-limits]
> > >>>>>>>     || (hugepage_sz == RTE_PGSIZE_16G)) {
> > >>>>>>>     ^
> > >>>>>>> cc1: all warnings being treated as errors
> > >>>>>>>
> > >>>>>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
> > >>>>>>> conversion from "long long" to "void *" may lose significant bits
> > >>>>>>>    RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
> > >>>>>>>
> > >>>>>>> This was introuduced by commit b77b5639:
> > >>>>>>>         mem: add huge page sizes for IBM Power
> > >>>>>>>
> > >>>>>>> The root cause is that size_t and uintptr_t are 32-bit in i686
> > >>>>>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
> > >>>>>>>
> > >>>>>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
> > >>>>>>> this issue.
> > >>>>>>>
> > >>>>>>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> > >>>>>>> ---
> > >>>>>>>  v3 ---> v2
> > >>>>>>> 	Change RTE_PGSIZE_16G from ULL to UL
> > >>>>>>> 	to keep all entries consistent
> > >>>>>>>
> > >>>>>>>  V2 ---> v1
> > >>>>>>> 	Change two type entries to one, and
> > >>>>>>> 	leave RTE_PGSIZE_16G only valid for
> > >>>>>>> 	64-bit platform
> > >>>>>>>
> > >>>>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent of
> > >>>>> architecutre.  While a system can't have a hugepage size that exceeds its
> > >>>>> virtual address limit, theres no need to do per-architecture special casing of
> > >>>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
> > >>>>> everytime you want to check a page size, just convert the size_t to a uint64_t
> > >>>>> and you can allow all of the enumerated page types on all architecutres, and
> > >>>>> save yourself some ifdeffing in the process.
> > >>>>>
> > >>>>> Neil
> > >>>> While I get your point, I find it distasteful to use a uint64_t for memory sizes,
> > >>>> when there is the size_t type defined for that particular purpose.
> > >>>> However, I suppose that reducing the number of #ifdefs compared to using the
> > >>>> "correct" datatypes for objects is a more practical optino - however distastful
> > >>>> I find it.
> > >>> size_t isn't defined for memory sizes in the sense that we're using them here.
> > >>> size_t is meant to address the need for a type to describe object sizes on a
> > >>> particular system, and it itself is sized accordingly (32 bits on a 32 bit arch,
> > >>> 64 on 64), so that you can safely store a size that the system in question might
> > >>> maximally allocate/return.  In this situation we are describing memory sizes
> > >>> that might occur no a plurality of arches, and so size_t is inappropriate
> > >>> because it as a type is not sized for anything other than the arch it is being
> > >>> built for.  The pragmatic benefits of ennumerating page sizes in a single
> > >>> canonical location far outweigh the desire to use a misappropriated type to
> > >>> describe them.
> > >> Neil,
> > >>
> > >> This patch fix two compile issues, and we need to do *dpdk testing
> > >> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
> > >>
> > >> I've get you mind and your concern. But we should take care of changing
> > >> the type of "hugepage_sz", because lots of places using it.
> > >>
> > >> Would you mind if we consider this as hot fix, and we can post a better
> > >> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
> > >>
> > > Honestly, no.  Because intels testing schedule shouldn't drive the inclusion of
> > > upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
> > > asking for a proper fix for a very straightforward problem.  I've attached the
> > > proper fix below.
> > >
> > > Regards
> > > Neil
> > 
> > We test dpdk upstream now as 1,8 rc2 and rc3 released :)
> > 
> Yes, I don't take issue with you testing dpdk, on the contrary, I appreciate it.
> What I take issue with is that you are asserting that the blockage of your
> testing is reason to ignore a proper fix an issue, rather than some substandard
> one.

I agree. Neil's patch seems a lot better.

> > I know that what you mean. but lots of please using "hugepage_sz" do you
> > confirm it will not affect other issue?
> > 
> 5.  There are 5 placees that use hugepage_sz, as the patch below indicates.
> Thats no alot.
> 
> Also, I take issue with the assertion that this patch creates no additional
> problems.  I'm sure it creates no additional problems that your patch wouldn't
> also create, arguably less.  If we were really being pragmatic here, I would
> point out that this problem was caused by the fact that support for an entire
> new architecture was integrated during the -rc phase of a release, which seems
> extreemely risky to me,

No, it was integrated between -rc1 and -rc2. But -rc1 was not really a release
candidate. It was a first step after mbuf rework. This tag was requested for
validation but it was a bad idea. We won't create such wrong tag anymore.
</digress>
PPC was integrated before the real RC phase.

> and as such, the most appropriate thing to do would be
> to back support for ppc out until after the 1.8 release when it could be
> properly tested.  Instead we are slamming in hacked up fixes that throw arch
> specific ifdefs througout the code.

I think we can fix it (without ugly ifdefs) and avoid going back.
Thanks for your help.
  
Michael Qiu Dec. 8, 2014, 2:59 p.m. UTC | #5
On 2014/12/8 19:38, Neil Horman wrote:
> On Mon, Dec 08, 2014 at 03:37:19AM +0000, Qiu, Michael wrote:
>> On 12/8/2014 11:00 AM, Neil Horman wrote:
>>> On Mon, Dec 08, 2014 at 02:46:51AM +0000, Qiu, Michael wrote:
>>>> On 12/5/2014 11:25 PM, Neil Horman wrote:
>>>>> On Fri, Dec 05, 2014 at 03:02:33PM +0000, Bruce Richardson wrote:
>>>>>> On Fri, Dec 05, 2014 at 09:22:05AM -0500, Neil Horman wrote:
>>>>>>> On Fri, Dec 05, 2014 at 04:31:47PM +0800, Chao Zhu wrote:
>>>>>>>> On 2014/12/4 17:12, Michael Qiu wrote:
>>>>>>>>> lib/librte_eal/linuxapp/eal/eal_memory.c:324:4: error: comparison
>>>>>>>>> is always false due to limited range of data type [-Werror=type-limits]
>>>>>>>>>     || (hugepage_sz == RTE_PGSIZE_16G)) {
>>>>>>>>>     ^
>>>>>>>>> cc1: all warnings being treated as errors
>>>>>>>>>
>>>>>>>>> lib/librte_eal/linuxapp/eal/eal.c(461): error #2259: non-pointer
>>>>>>>>> conversion from "long long" to "void *" may lose significant bits
>>>>>>>>>    RTE_PTR_ALIGN_CEIL((uintptr_t)addr, RTE_PGSIZE_16M);
>>>>>>>>>
>>>>>>>>> This was introuduced by commit b77b5639:
>>>>>>>>>         mem: add huge page sizes for IBM Power
>>>>>>>>>
>>>>>>>>> The root cause is that size_t and uintptr_t are 32-bit in i686
>>>>>>>>> platform, but RTE_PGSIZE_16M and RTE_PGSIZE_16G are always 64-bit.
>>>>>>>>>
>>>>>>>>> Define RTE_PGSIZE_16G only in 64 bit platform to avoid
>>>>>>>>> this issue.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
>>>>>>>>> ---
>>>>>>>>>  v3 ---> v2
>>>>>>>>> 	Change RTE_PGSIZE_16G from ULL to UL
>>>>>>>>> 	to keep all entries consistent
>>>>>>>>>
>>>>>>>>>  V2 ---> v1
>>>>>>>>> 	Change two type entries to one, and
>>>>>>>>> 	leave RTE_PGSIZE_16G only valid for
>>>>>>>>> 	64-bit platform
>>>>>>>>>
>>>>>>> NACK, this is the wrong way to fix this problem.  Pagesizes are independent of
>>>>>>> architecutre.  While a system can't have a hugepage size that exceeds its
>>>>>>> virtual address limit, theres no need to do per-architecture special casing of
>>>>>>> page sizes here.  Instead of littering the code with ifdef RTE_ARCH_64
>>>>>>> everytime you want to check a page size, just convert the size_t to a uint64_t
>>>>>>> and you can allow all of the enumerated page types on all architecutres, and
>>>>>>> save yourself some ifdeffing in the process.
>>>>>>>
>>>>>>> Neil
>>>>>> While I get your point, I find it distasteful to use a uint64_t for memory sizes,
>>>>>> when there is the size_t type defined for that particular purpose.
>>>>>> However, I suppose that reducing the number of #ifdefs compared to using the
>>>>>> "correct" datatypes for objects is a more practical optino - however distastful
>>>>>> I find it.
>>>>> size_t isn't defined for memory sizes in the sense that we're using them here.
>>>>> size_t is meant to address the need for a type to describe object sizes on a
>>>>> particular system, and it itself is sized accordingly (32 bits on a 32 bit arch,
>>>>> 64 on 64), so that you can safely store a size that the system in question might
>>>>> maximally allocate/return.  In this situation we are describing memory sizes
>>>>> that might occur no a plurality of arches, and so size_t is inappropriate
>>>>> because it as a type is not sized for anything other than the arch it is being
>>>>> built for.  The pragmatic benefits of ennumerating page sizes in a single
>>>>> canonical location far outweigh the desire to use a misappropriated type to
>>>>> describe them.
>>>> Neil,
>>>>
>>>> This patch fix two compile issues, and we need to do *dpdk testing
>>>> affairs*,  if it is blocked in build stage, we can do *nothing* for testing.
>>>>
>>>> I've get you mind and your concern. But we should take care of changing
>>>> the type of "hugepage_sz", because lots of places using it.
>>>>
>>>> Would you mind if we consider this as hot fix, and we can post a better
>>>> fix later(like in dpdk 2.0)? Otherwise all test cycle are blocked.
>>>>
>>> Honestly, no.  Because intels testing schedule shouldn't drive the inclusion of
>>> upstream fixes.  Also, I'm not asking for a major redesign of anything, I'm
>>> asking for a proper fix for a very straightforward problem.  I've attached the
>>> proper fix below.
>>>
>>> Regards
>>> Neil
>> We test dpdk upstream now as 1,8 rc2 and rc3 released :)
>>
> Yes, I don't take issue with you testing dpdk, on the contrary, I appreciate it.
> What I take issue with is that you are asserting that the blockage of your
> testing is reason to ignore a proper fix an issue, rather than some substandard
> one.

Agree :)

>> I know that what you mean. but lots of please using "hugepage_sz" do you
>> confirm it will not affect other issue?
>>
> 5.  There are 5 placees that use hugepage_sz, as the patch below indicates.
> Thats no alot.
>
> Also, I take issue with the assertion that this patch creates no additional
> problems.  I'm sure it creates no additional problems that your patch wouldn't
> also create, arguably less.  If we were really being pragmatic here, I would
> point out that this problem was caused by the fact that support for an entire
> new architecture was integrated during the -rc phase of a release, which seems
> extreemely risky to me, and as such, the most appropriate thing to do would be
> to back support for ppc out until after the 1.8 release when it could be
> properly tested.  Instead we are slamming in hacked up fixes that throw arch
> specific ifdefs througout the code.
>
>> On other hand, we use 32 bit address in 32 bit platform for better
>> performance(some of places also use uintptr_t for address check and
>> alignment).
>>
> This has nothing to do with address bus size.

Actually, it does, this is one of what I'm fixed. But it also introduced
by support Power Arch.

Other places I have not check yet.

Anyway, I will verify your solution, and to see any potential issues.

Thanks
Michael
>> And it should not acceptable in 32 bit platform to use 64-bit platform
>> specification affairs(like RTE_PGSIZE_16G).
>>
> Ok, so add a single arch specific runtime check during hugepage mapping to exit
> on the 16G size use on 32 bit systems.  Thats a fair and reasonable thing to do,
> though I think the hugepage remap is already ifdeffed for 54 bit arches only.
>
> Neil
>
>
  

Patch

diff --git a/lib/librte_eal/common/eal_common_memory.c b/lib/librte_eal/common/eal_common_memory.c
index 412b432..31a391c 100644
--- a/lib/librte_eal/common/eal_common_memory.c
+++ b/lib/librte_eal/common/eal_common_memory.c
@@ -96,7 +96,7 @@  rte_dump_physmem_layout(FILE *f)
 
 		fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
 		       "virt:%p, socket_id:%"PRId32", "
-		       "hugepage_sz:%zu, nchannel:%"PRIx32", "
+		       "hugepage_sz:%llu, nchannel:%"PRIx32", "
 		       "nrank:%"PRIx32"\n", i,
 		       mcfg->memseg[i].phys_addr,
 		       mcfg->memseg[i].len,
diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h
index aac6abf..e2ecb0d 100644
--- a/lib/librte_eal/common/eal_internal_cfg.h
+++ b/lib/librte_eal/common/eal_internal_cfg.h
@@ -49,7 +49,7 @@ 
  * mount points of hugepages
  */
 struct hugepage_info {
-	size_t hugepage_sz;   /**< size of a huge page */
+	uint64_t hugepage_sz;   /**< size of a huge page */
 	const char *hugedir;    /**< dir where hugetlbfs is mounted */
 	uint32_t num_pages[RTE_MAX_NUMA_NODES];
 				/**< number of hugepages of that size on each socket */
diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index 1990833..7f8103f 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -92,7 +92,7 @@  struct rte_memseg {
 	phys_addr_t ioremap_addr; /**< Real physical address inside the VM */
 #endif
 	size_t len;               /**< Length of the segment. */
-	size_t hugepage_sz;       /**< The pagesize of underlying memory */
+	uint64_t hugepage_sz;       /**< The pagesize of underlying memory */
 	int32_t socket_id;          /**< NUMA socket ID. */
 	uint32_t nchannel;          /**< Number of channels. */
 	uint32_t nrank;             /**< Number of ranks. */
diff --git a/lib/librte_eal/common/include/rte_memzone.h b/lib/librte_eal/common/include/rte_memzone.h
index 7d47bff..3006e81 100644
--- a/lib/librte_eal/common/include/rte_memzone.h
+++ b/lib/librte_eal/common/include/rte_memzone.h
@@ -83,7 +83,7 @@  struct rte_memzone {
 #endif
 	size_t len;                       /**< Length of the memzone. */
 
-	size_t hugepage_sz;               /**< The page size of underlying memory */
+	uint64_t hugepage_sz;               /**< The page size of underlying memory */
 
 	int32_t socket_id;                /**< NUMA socket ID. */
 
diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c
index e6cb919..bae2507 100644
--- a/lib/librte_eal/linuxapp/eal/eal_memory.c
+++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -300,7 +300,7 @@  map_all_hugepages(struct hugepage_file *hugepg_tbl,
 #endif
 
 	for (i = 0; i < hpi->num_pages[0]; i++) {
-		size_t hugepage_sz = hpi->hugepage_sz;
+		uint64_t hugepage_sz = hpi->hugepage_sz;
 
 		if (orig) {
 			hugepg_tbl[i].file_id = i;