qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Re: [Qemu-commits] [COMMIT 3086844] Instead of	writing a zero page, madvise it away
Date: Mon, 22 Jun 2009 20:12:08 +0300	[thread overview]
Message-ID: <4A3FBB68.3000708@redhat.com> (raw)
In-Reply-To: <4A3FB829.10203@us.ibm.com>

On 06/22/2009 07:58 PM, Anthony Liguori wrote:
>> Note that the patch contains a small bug -- the kernel is allowed to 
>> ignore the advise according to the manual page, so it's better to 
>> memset() the memory before dropping it.
>
>
> Hrm, that's not quite how I interpreted the man page.
>
> "This call
>  does not influence the semantics of the application (except in the case
>  of  MADV_DONTNEED),  but  may influence its performance.  The kernel is
>  free to ignore the advice."
>
> MADV_DONTNEED is called out as changing the application semantics.  
> Specifically, I think the kernel has to zero-fill even if it choose to 
> ignore the advice.
>
> I limited the guard to Linux specifically because I was unsure about 
> that behavior but it would be good to clarify if anyone knows how.

This is not posix (there is a POSIX_MADV_DONTNEED which appears to be 
non-destructive (and a better complement to the other advices)), so the 
only references are the manual page and the code.  I don't see Linux 
ever avoiding brake brake brake the kernel certainly can ignore the advice:

static long madvise_dontneed(struct vm_area_struct * vma,
                  struct vm_area_struct ** prev,
                  unsigned long start, unsigned long end)
{
     *prev = vma;
     if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
         return -EINVAL;

     if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
         struct zap_details details = {
             .nonlinear_vma = vma,
             .last_index = ULONG_MAX,
         };
         zap_page_range(vma, start, end - start, &details);
     } else
         zap_page_range(vma, start, end - start, NULL);
     return 0;
}

it won't do it silently, but we don't check the return code either.  
Let's take the safe path on this and zero the page.

-- 
error compiling committee.c: too many arguments to function

  reply	other threads:[~2009-06-22 17:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200906221549.n5MFn3Qd015389@d03av02.boulder.ibm.com>
2009-06-22 16:12 ` [Qemu-devel] Re: [Qemu-commits] [COMMIT 3086844] Instead of writing a zero page, madvise it away Avi Kivity
2009-06-22 16:25   ` Anthony Liguori
2009-06-22 16:38     ` Avi Kivity
2009-06-22 16:58       ` Anthony Liguori
2009-06-22 17:12         ` Avi Kivity [this message]
2009-06-22 17:03       ` Anthony Liguori
2009-06-22 17:20         ` Avi Kivity
2009-06-22 17:37           ` Anthony Liguori
2009-06-22 18:01             ` Avi Kivity
2009-06-22 17:44           ` Anthony Liguori
2009-06-22 18:04             ` Avi Kivity
2009-06-22 19:38         ` Paul Brook
2009-06-22 19:49           ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A3FBB68.3000708@redhat.com \
    --to=avi@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).