[PATCH v2] kexec/s390x: use mmap instead of read for slurp_file()
Dave Young
dyoung at redhat.com
Wed Oct 28 23:37:10 PDT 2015
On 10/28/15 at 10:57am, Michael Holzheu wrote:
> On Wed, 28 Oct 2015 14:46:23 +0800
> Dave Young <dyoung at redhat.com> wrote:
>
> > Hi, Michael
> >
> > > @@ -552,11 +563,18 @@ char *slurp_file(const char *filename, o
> > > if (err < 0)
> > > die("Can not seek to the begin of file %s: %s\n",
> > > filename, strerror(errno));
> > > + buf = slurp_fd(fd, filename, size, &nread, use_mmap);
> > > } else {
> > > size = stats.st_size;
> > > + if (use_mmap) {
> > > + buf = mmap(NULL, size, PROT_READ | PROT_WRITE,
> > > + MAP_PRIVATE, fd, 0);
> > > + nread = stats.st_size;
> > > + } else {
> > > + buf = slurp_fd(fd, filename, size, &nread, 0);
> > > + }
> > > }
> >
> > Drop above changes and replace below lines with an extra use_mmap argument
> > should be enough?
> >
> > - buf = slurp_fd(fd, filename, size, &nread);
> > [snip]
>
> Hmm, I don't think so.
>
> In case of non-character devices I either mmap the file directly (use_mmap=true)
> or use "slurp_fd()" (use_mmap=false). So I can't unconditionaly use slurp_fd().
How about handle these in slurp_fd only? Directly return mmapped buf in case
use_mmap=1 there. I do not understand why use_mmap=1 but you still call read
syscall to read data into the mmapped buffer..
Thanks
Dave
More information about the kexec
mailing list