* [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.
[not found] <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcas5p4.samsung.com>
@ 2018-08-02 10:31 ` Maninder Singh
2018-08-02 13:08 ` Eric Dumazet
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p1>
0 siblings, 2 replies; 5+ messages in thread
From: Maninder Singh @ 2018-08-02 10:31 UTC (permalink / raw)
To: davem, shuahkh
Cc: netdev, linux-api, linux-kernel, edumazet, pankaj.m, a.sahrawat,
Maninder Singh, Vaneet Narang
FILE_SZ is defined as (1UL << 35), it will overflow
for 32 bit system and logic will break.
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
---
tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
index e8c5dff..1d6ca12 100644
--- a/tools/testing/selftests/net/tcp_mmap.c
+++ b/tools/testing/selftests/net/tcp_mmap.c
@@ -85,7 +85,7 @@
#define MSG_ZEROCOPY 0x4000000
#endif
-#define FILE_SZ (1UL << 35)
+#define FILE_SZ (1ULL << 35)
static int cfg_family = AF_INET6;
static socklen_t cfg_alen = sizeof(struct sockaddr_in6);
static int cfg_port = 8787;
@@ -134,7 +134,7 @@ void hash_zone(void *zone, unsigned int length)
void *child_thread(void *arg)
{
- unsigned long total_mmap = 0, total = 0;
+ unsigned long long total_mmap = 0, total = 0;
struct tcp_zerocopy_receive zc;
unsigned long delta_usec;
int flags = MAP_SHARED;
@@ -316,7 +316,7 @@ int main(int argc, char *argv[])
{
struct sockaddr_storage listenaddr, addr;
unsigned int max_pacing_rate = 0;
- unsigned long total = 0;
+ unsigned long long total = 0;
char *host = NULL;
int fd, c, on = 1;
char *buffer;
@@ -431,7 +431,7 @@ int main(int argc, char *argv[])
zflg = 0;
}
while (total < FILE_SZ) {
- long wr = FILE_SZ - total;
+ unsigned long long wr = FILE_SZ - total;
if (wr > chunk_size)
wr = chunk_size;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.
2018-08-02 10:31 ` [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture Maninder Singh
@ 2018-08-02 13:08 ` Eric Dumazet
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p1>
1 sibling, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2018-08-02 13:08 UTC (permalink / raw)
To: Maninder Singh, davem, shuahkh
Cc: netdev, linux-api, linux-kernel, edumazet, pankaj.m, a.sahrawat,
Vaneet Narang
On 08/02/2018 03:31 AM, Maninder Singh wrote:
> FILE_SZ is defined as (1UL << 35), it will overflow
> for 32 bit system and logic will break.
>
> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
> ---
> tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
> index e8c5dff..1d6ca12 100644
> --- a/tools/testing/selftests/net/tcp_mmap.c
> +++ b/tools/testing/selftests/net/tcp_mmap.c
> @@ -85,7 +85,7 @@
> #define MSG_ZEROCOPY 0x4000000
> #endif
>
> -#define FILE_SZ (1UL << 35)
> +#define FILE_SZ (1ULL << 35)
> static int cfg_family = AF_INET6;
> static socklen_t cfg_alen = sizeof(struct sockaddr_in6);
> static int cfg_port = 8787;
> @@ -134,7 +134,7 @@ void hash_zone(void *zone, unsigned int length)
>
> void *child_thread(void *arg)
> {
> - unsigned long total_mmap = 0, total = 0;
> + unsigned long long total_mmap = 0, total = 0;
> struct tcp_zerocopy_receive zc;
> unsigned long delta_usec;
> int flags = MAP_SHARED;
> @@ -316,7 +316,7 @@ int main(int argc, char *argv[])
> {
> struct sockaddr_storage listenaddr, addr;
> unsigned int max_pacing_rate = 0;
> - unsigned long total = 0;
> + unsigned long long total = 0;
> char *host = NULL;
> int fd, c, on = 1;
> char *buffer;
> @@ -431,7 +431,7 @@ int main(int argc, char *argv[])
> zflg = 0;
> }
> while (total < FILE_SZ) {
> - long wr = FILE_SZ - total;
> + unsigned long long wr = FILE_SZ - total;
>
> if (wr > chunk_size)
> wr = chunk_size;
>
What about using more conventional size_t instead of "unsigned long long" ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p1>
@ 2018-08-03 3:31 ` Maninder Singh
2018-08-03 11:12 ` David Laight
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p4>
0 siblings, 2 replies; 5+ messages in thread
From: Maninder Singh @ 2018-08-03 3:31 UTC (permalink / raw)
To: Eric Dumazet, davem, shuahkh
Cc: netdev, linux-api, linux-kernel, edumazet, PANKAJ MISHRA,
AMIT SAHRAWAT, Vaneet Narang
Hi,
>On 08/02/2018 03:31 AM, Maninder Singh wrote:
>> FILE_SZ is defined as (1UL << 35), it will overflow
>> for 32 bit system and logic will break.
>>
>> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
>> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
>> ---
>> tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
>> index e8c5dff..1d6ca12 100644
>> --- a/tools/testing/selftests/net/tcp_mmap.c
>> +++ b/tools/testing/selftests/net/tcp_mmap.c
>> @@ -85,7 +85,7 @@
>> #define MSG_ZEROCOPY 0x4000000
>> #endif
>>
>> -#define FILE_SZ (1UL << 35)
>> +#define FILE_SZ (1ULL << 35)
...
...
>> @@ -431,7 +431,7 @@ int main(int argc, char *argv[])
>> zflg = 0;
>> }
>> while (total < FILE_SZ) {
>> - long wr = FILE_SZ - total;
>> + unsigned long long wr = FILE_SZ - total;
>>
>> if (wr > chunk_size)
>> wr = chunk_size;
>>
>
>What about using more conventional size_t instead of "unsigned long long" ?
size_t is also equivalent to unsigned long and it will not hold value of (1 << 35) for 32 bit system.
So we can do two things.
(1) reduce FILE SIZE to (1 << 30), so that UL (size_t) can hold this value.
It will not show any perofrmance boost with ZEROCOPY. (checked on x86_64)
(2) use unsigned long long to work with both 32 and 64 bit system.
It will show performance boost with ZEROCOPY.(checked on x86_64)
What do you think?
Thanks and regards,
Maninder Singh
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.
2018-08-03 3:31 ` Maninder Singh
@ 2018-08-03 11:12 ` David Laight
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p4>
1 sibling, 0 replies; 5+ messages in thread
From: David Laight @ 2018-08-03 11:12 UTC (permalink / raw)
To: 'maninder1.s@samsung.com', Eric Dumazet, davem, shuahkh
Cc: netdev, linux-api, linux-kernel, edumazet, PANKAJ MISHRA,
AMIT SAHRAWAT, Vaneet Narang
From: Maninder Singh
> Sent: 03 August 2018 04:32
> >On 08/02/2018 03:31 AM, Maninder Singh wrote:
> >> FILE_SZ is defined as (1UL << 35), it will overflow
> >> for 32 bit system and logic will break.
> >>
> >> Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
> >> Signed-off-by: Vaneet Narang <v.narang@samsung.com>
> >> ---
> >> tools/testing/selftests/net/tcp_mmap.c | 8 ++++----
> >> 1 file changed, 4 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tools/testing/selftests/net/tcp_mmap.c b/tools/testing/selftests/net/tcp_mmap.c
> >> index e8c5dff..1d6ca12 100644
> >> --- a/tools/testing/selftests/net/tcp_mmap.c
> >> +++ b/tools/testing/selftests/net/tcp_mmap.c
> >> @@ -85,7 +85,7 @@
> >> #define MSG_ZEROCOPY 0x4000000
> >> #endif
> >>
> >> -#define FILE_SZ (1UL << 35)
> >> +#define FILE_SZ (1ULL << 35)
>
> ...
> ...
> >> @@ -431,7 +431,7 @@ int main(int argc, char *argv[])
> >> zflg = 0;
> >> }
> >> while (total < FILE_SZ) {
> >> - long wr = FILE_SZ - total;
> >> + unsigned long long wr = FILE_SZ - total;
> >>
> >> if (wr > chunk_size)
> >> wr = chunk_size;
> >>
> >
> >What about using more conventional size_t instead of "unsigned long long" ?
>
> size_t is also equivalent to unsigned long and it will not hold value of (1 << 35) for 32 bit system.
> So we can do two things.
Wouldn't the 'correct' type be off_t ?
In any case, IIRC, you have to do really horrid things in Linux to
access files larger than 2G on 32bit systems.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture.
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p4>
@ 2018-08-10 6:03 ` Maninder Singh
0 siblings, 0 replies; 5+ messages in thread
From: Maninder Singh @ 2018-08-10 6:03 UTC (permalink / raw)
To: David Laight, Eric Dumazet, davem
Cc: shuahkh, netdev, linux-api, linux-kernel, edumazet,
PANKAJ MISHRA, AMIT SAHRAWAT, Vaneet Narang
>> >
>> >What about using more conventional size_t instead of "unsigned long long" ?
>>
>> size_t is also equivalent to unsigned long and it will not hold value of (1 << 35) for 32 bit system.
>> So we can do two things.
>
>Wouldn't the 'correct' type be off_t ?
>In any case, IIRC, you have to do really horrid things in Linux to
>access files larger than 2G on 32bit systems.
>
> David
Any inputs.
Thanks,
Maninder Singh
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-08-10 8:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcas5p4.samsung.com>
2018-08-02 10:31 ` [PATCH 1/1] selftest/net: fix FILE_SIZE for 32 bit architecture Maninder Singh
2018-08-02 13:08 ` Eric Dumazet
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p1>
2018-08-03 3:31 ` Maninder Singh
2018-08-03 11:12 ` David Laight
[not found] ` <CGME20180802103616epcas5p48ec1e2ea3568b11683aa7b55254dffb0@epcms5p4>
2018-08-10 6:03 ` Maninder Singh
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).