Skip to contentSkip to conversation

perf tools: Fix copyfile_offset update of output offset

PATCH In review Jiri Olsa 3 participants 3 messages Jan 9, 2018 – Jan 17, 2018 perf events

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 perf tools: Fix copyfile_offset update of output offset

We need to increase output offset in each iteration, not decrease it as we currently do.

I guess we were lucky to finish in most cases in first iteration, so the bug never showed. However it shows a lot when working with big (~4GB) size data.

---
 tools/perf/util/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/util.c +1 -1
index a789f952b3e9..443892dabedb 100644
@@ -210,7 +210,7 @@ static int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64
 
 		size -= ret;
 		off_in += ret;
-		off_out -= ret;
+		off_out += ret;
 	}
 	munmap(ptr, off_in + size);
 
Signature · 1 line
2.13.6
#1 lore raw

Em Tue, Jan 09, 2018 at 02:39:23PM +0100, Jiri Olsa escreveu:

Quoted 6 lines

We need to increase output offset in each iteration, not decrease it as we currently do.

I guess we were lucky to finish in most cases in first iteration, so the bug never showed. However it shows a lot when working with big (~4GB) size data.

Try adding these in the future:

Fixes 9c9f5a2f1944 ("perf tools: Introduce copyfile_offset() function")

Probably there are people tracking those to apply to older kernels :-)

- Arnaldo

Quoted 21 lines
---
 tools/perf/util/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/util.c +1 -1
index a789f952b3e9..443892dabedb 100644
@@ -210,7 +210,7 @@ static int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64
 
 		size -= ret;
 		off_in += ret;
-		off_out -= ret;
+		off_out += ret;
 	}
 	munmap(ptr, off_in + size);
 
Signature · 1 line
2.13.6
#2 lore raw
In reply to Jiri Olsa
perf tools: Fix copyfile_offset update of output offset
Commit-ID:  fa1195ccc0af2d121abe0fe266a1caee8c265eea
Gitweb:     https://git.kernel.org/tip/fa1195ccc0af2d121abe0fe266a1caee8c265eea
Author:     Jiri Olsa <[email protected]>
AuthorDate: Tue, 9 Jan 2018 14:39:23 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Jan 2018 16:57:16 -0300

perf tools: Fix copyfile_offset update of output offset

We need to increase output offset in each iteration, not decrease it as we currently do.

I guess we were lucky to finish in most cases in first iteration, so the bug never showed. However it shows a lot when working with big (~4GB) size data.

Cc Alexander Shishkin <[email protected]>
Cc Andi Kleen <[email protected]>
Cc David Ahern <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Fixes 9c9f5a2f1944 ("perf tools: Introduce copyfile_offset() function")
---
 tools/perf/util/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/util.c +1 -1
index a789f95..443892d 100644
@@ -210,7 +210,7 @@ static int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64
 
 		size -= ret;
 		off_in += ret;
-		off_out -= ret;
+		off_out += ret;
 	}
 	munmap(ptr, off_in + size);