* [linux-next] splice call weird results
@ 2014-05-27 9:13 Cyrill Gorcunov
2014-05-27 10:20 ` Kirill A. Shutemov
0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2014-05-27 9:13 UTC (permalink / raw)
To: LKML; +Cc: Andrew Morton, Pavel Emelyanov, kirill.shutemov
Hi! While been trying to run criu on linux-next (due to recent Kirill's patch related
to /proc/pid/clear_refs with THP enabled) I noticed that it fails dumping programs when
moves data from memory pages into an image file. So I wrote pretty idiotic test and
run it on current fedora 20 kernel and then on linux-next.
fedora-20 output
----------------
[cyrill@moon criu] ~/pipe
Opened pipe-test.SQBcJa
vmspliced 8192 bytes
spliced 4096 bytes
linux-next
----------
[root@fc criu]# ~/pipe
Opened pipe-test.9nZSW7
vmspliced 8192 bytes
spliced 8192 bytes
In test I fill pipe with 8K data then splice 4K of it into a file (the test
is below). Is it intended, or I did some silly mistake?
---
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/uio.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
static char buf[8 << 20];
int main(int argc, char *argv[])
{
char *tmpname, t[64] = "pipe-test.XXXXXX";
int _pipe[2], fd, ret = 0;
struct iovec iov[] = {
[0] = {
.iov_base = &buf[0],
.iov_len = 4096,
},
[1] = {
.iov_base = &buf[4096],
.iov_len = 4096,
},
};
if (pipe(_pipe)) {
perror("Can't create pipe");
exit(1);
}
memset(buf, 0x1, sizeof(buf));
tmpname = mktemp(t);
fd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC);
if (fd < 0) {
perror("Can't open temp file");
close(_pipe[0]);
close(_pipe[1]);
exit(1);
}
printf("Opened %s\n", tmpname);
ret = vmsplice(_pipe[1], iov, ARRAY_SIZE(iov), SPLICE_F_GIFT);
printf("vmspliced %li bytes\n", (long)ret);
ret = splice(_pipe[0], NULL, fd, NULL, iov[0].iov_len, SPLICE_F_MOVE);
printf("spliced %li bytes\n", (long)ret);
out:
close(_pipe[0]);
close(_pipe[1]);
close(fd);
unlink(tmpname);
return ret;
}
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [linux-next] splice call weird results
2014-05-27 9:13 [linux-next] splice call weird results Cyrill Gorcunov
@ 2014-05-27 10:20 ` Kirill A. Shutemov
2014-05-27 10:27 ` Cyrill Gorcunov
0 siblings, 1 reply; 5+ messages in thread
From: Kirill A. Shutemov @ 2014-05-27 10:20 UTC (permalink / raw)
To: Cyrill Gorcunov, Al Viro
Cc: LKML, Andrew Morton, Pavel Emelyanov, kirill.shutemov
Cyrill Gorcunov wrote:
> Hi! While been trying to run criu on linux-next (due to recent Kirill's patch related
> to /proc/pid/clear_refs with THP enabled) I noticed that it fails dumping programs when
> moves data from memory pages into an image file. So I wrote pretty idiotic test and
> run it on current fedora 20 kernel and then on linux-next.
>
+Al. He reworked splice code in linux-next.
> fedora-20 output
> ----------------
> [cyrill@moon criu] ~/pipe
> Opened pipe-test.SQBcJa
> vmspliced 8192 bytes
> spliced 4096 bytes
>
> linux-next
> ----------
> [root@fc criu]# ~/pipe
> Opened pipe-test.9nZSW7
> vmspliced 8192 bytes
> spliced 8192 bytes
>
> In test I fill pipe with 8K data then splice 4K of it into a file (the test
> is below). Is it intended, or I did some silly mistake?
> ---
> #define _GNU_SOURCE
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <string.h>
> #include <fcntl.h>
>
> #include <sys/uio.h>
>
> #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
>
> static char buf[8 << 20];
>
> int main(int argc, char *argv[])
> {
> char *tmpname, t[64] = "pipe-test.XXXXXX";
> int _pipe[2], fd, ret = 0;
>
> struct iovec iov[] = {
> [0] = {
> .iov_base = &buf[0],
> .iov_len = 4096,
> },
>
> [1] = {
> .iov_base = &buf[4096],
> .iov_len = 4096,
> },
> };
>
> if (pipe(_pipe)) {
> perror("Can't create pipe");
> exit(1);
> }
>
> memset(buf, 0x1, sizeof(buf));
> tmpname = mktemp(t);
>
> fd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC);
> if (fd < 0) {
> perror("Can't open temp file");
> close(_pipe[0]);
> close(_pipe[1]);
> exit(1);
> }
> printf("Opened %s\n", tmpname);
>
> ret = vmsplice(_pipe[1], iov, ARRAY_SIZE(iov), SPLICE_F_GIFT);
> printf("vmspliced %li bytes\n", (long)ret);
>
> ret = splice(_pipe[0], NULL, fd, NULL, iov[0].iov_len, SPLICE_F_MOVE);
> printf("spliced %li bytes\n", (long)ret);
>
> out:
> close(_pipe[0]);
> close(_pipe[1]);
> close(fd);
> unlink(tmpname);
> return ret;
> }
--
Kirill A. Shutemov
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [linux-next] splice call weird results
2014-05-27 10:20 ` Kirill A. Shutemov
@ 2014-05-27 10:27 ` Cyrill Gorcunov
2014-05-27 17:20 ` Cong Wang
0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2014-05-27 10:27 UTC (permalink / raw)
To: Kirill A. Shutemov; +Cc: Al Viro, LKML, Andrew Morton, Pavel Emelyanov
On Tue, May 27, 2014 at 01:20:13PM +0300, Kirill A. Shutemov wrote:
> Cyrill Gorcunov wrote:
> > Hi! While been trying to run criu on linux-next (due to recent Kirill's patch related
> > to /proc/pid/clear_refs with THP enabled) I noticed that it fails dumping programs when
> > moves data from memory pages into an image file. So I wrote pretty idiotic test and
> > run it on current fedora 20 kernel and then on linux-next.
> >
>
> +Al. He reworked splice code in linux-next.
Thanks Kirill. Al, it looks like iter_file_splice_write no longer honor @len while
building kiocb vector but pushes as much as it can.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-next] splice call weird results
2014-05-27 10:27 ` Cyrill Gorcunov
@ 2014-05-27 17:20 ` Cong Wang
2014-05-27 17:51 ` Cyrill Gorcunov
0 siblings, 1 reply; 5+ messages in thread
From: Cong Wang @ 2014-05-27 17:20 UTC (permalink / raw)
To: Cyrill Gorcunov
Cc: Kirill A. Shutemov, Al Viro, LKML, Andrew Morton, Pavel Emelyanov
On Tue, May 27, 2014 at 3:27 AM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> On Tue, May 27, 2014 at 01:20:13PM +0300, Kirill A. Shutemov wrote:
>> Cyrill Gorcunov wrote:
>> > Hi! While been trying to run criu on linux-next (due to recent Kirill's patch related
>> > to /proc/pid/clear_refs with THP enabled) I noticed that it fails dumping programs when
>> > moves data from memory pages into an image file. So I wrote pretty idiotic test and
>> > run it on current fedora 20 kernel and then on linux-next.
>> >
>>
>> +Al. He reworked splice code in linux-next.
>
> Thanks Kirill. Al, it looks like iter_file_splice_write no longer honor @len while
> building kiocb vector but pushes as much as it can.
I guess this should fix your problem:
https://lkml.org/lkml/2014/5/27/353
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [linux-next] splice call weird results
2014-05-27 17:20 ` Cong Wang
@ 2014-05-27 17:51 ` Cyrill Gorcunov
0 siblings, 0 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2014-05-27 17:51 UTC (permalink / raw)
To: Cong Wang
Cc: Kirill A. Shutemov, Al Viro, LKML, Andrew Morton, Pavel Emelyanov
On Tue, May 27, 2014 at 10:20:46AM -0700, Cong Wang wrote:
> On Tue, May 27, 2014 at 3:27 AM, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> > On Tue, May 27, 2014 at 01:20:13PM +0300, Kirill A. Shutemov wrote:
> >> Cyrill Gorcunov wrote:
> >> > Hi! While been trying to run criu on linux-next (due to recent Kirill's patch related
> >> > to /proc/pid/clear_refs with THP enabled) I noticed that it fails dumping programs when
> >> > moves data from memory pages into an image file. So I wrote pretty idiotic test and
> >> > run it on current fedora 20 kernel and then on linux-next.
> >> >
> >>
> >> +Al. He reworked splice code in linux-next.
> >
> > Thanks Kirill. Al, it looks like iter_file_splice_write no longer honor @len while
> > building kiocb vector but pushes as much as it can.
>
>
> I guess this should fix your problem:
> https://lkml.org/lkml/2014/5/27/353
Thanks, but i doubt, the problem I notice is rather in iter_file_splice_write.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-27 17:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-27 9:13 [linux-next] splice call weird results Cyrill Gorcunov
2014-05-27 10:20 ` Kirill A. Shutemov
2014-05-27 10:27 ` Cyrill Gorcunov
2014-05-27 17:20 ` Cong Wang
2014-05-27 17:51 ` Cyrill Gorcunov
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).