All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Prefer posix_madvise() over madvise()
@ 2010-09-11 11:51 Andreas Färber
  2010-09-11 12:11 ` [Qemu-devel] " Blue Swirl
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2010-09-11 11:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Blue Swirl, Andreas Färber

From: Andreas Färber <afaerber@opensolaris.org>

vl.c has a Sun-specific hack to supply a prototype for madvise(),
but the call site has apparently moved to arch_init.c.
The underlying issue is that madvise() is not a POSIX function,
therefore Solaris' _POSIX_C_SOURCE suppresses the prototype.

Haiku doesn't implement madvise() at all.

Where functionality equivalent to that of madvise() is provided,
use the POSIX function posix_madvise().
http://www.opengroup.org/onlinepubs/9699919799/functions/posix_madvise.html

Remaining madvise() users:
exec.c: limited to __linux__ and/or MADV_MERGEABLE (no POSIX equivalent)
kvm-all.c: limited to MADV_DONTFORK (no POSIX equivalent),
           otherwise runtime error if !kvm_has_sync_mmu()
hw/virtio-balloon.c: limited to __linux__

Signed-off-by: Andreas Färber <afaerber@opensolaris.org>
Cc: Blue Swirl <blauwirbel@gmail.com>
---
 arch_init.c |    2 +-
 vl.c        |    3 ---
 2 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index e468c0c..fa39557 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -396,7 +396,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
 #ifndef _WIN32
             if (ch == 0 &&
                 (!kvm_enabled() || kvm_has_sync_mmu())) {
-                madvise(host, TARGET_PAGE_SIZE, MADV_DONTNEED);
+                posix_madvise(host, TARGET_PAGE_SIZE, POSIX_MADV_DONTNEED);
             }
 #endif
         } else if (flags & RAM_SAVE_FLAG_PAGE) {
diff --git a/vl.c b/vl.c
index 3f45aa9..d352d18 100644
--- a/vl.c
+++ b/vl.c
@@ -80,9 +80,6 @@
 #include <net/if.h>
 #include <syslog.h>
 #include <stropts.h>
-/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for
-   discussion about Solaris header problems */
-extern int madvise(caddr_t, size_t, int);
 #endif
 #endif
 #endif
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: [PATCH] Prefer posix_madvise() over madvise()
  2010-09-11 11:51 [Qemu-devel] [PATCH] Prefer posix_madvise() over madvise() Andreas Färber
@ 2010-09-11 12:11 ` Blue Swirl
  2010-09-11 17:13   ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Blue Swirl @ 2010-09-11 12:11 UTC (permalink / raw)
  To: Andreas Färber; +Cc: qemu-devel, Andreas Färber

On Sat, Sep 11, 2010 at 11:51 AM, Andreas Färber <andreas.faerber@web.de> wrote:
> From: Andreas Färber <afaerber@opensolaris.org>
>
> vl.c has a Sun-specific hack to supply a prototype for madvise(),
> but the call site has apparently moved to arch_init.c.
> The underlying issue is that madvise() is not a POSIX function,
> therefore Solaris' _POSIX_C_SOURCE suppresses the prototype.
>
> Haiku doesn't implement madvise() at all.

OpenBSD doesn't implement posix_madvise(). How about adding probing to
configure and wrapping the stuff found as qemu_madvise()?

>
> Where functionality equivalent to that of madvise() is provided,
> use the POSIX function posix_madvise().
> http://www.opengroup.org/onlinepubs/9699919799/functions/posix_madvise.html
>
> Remaining madvise() users:
> exec.c: limited to __linux__ and/or MADV_MERGEABLE (no POSIX equivalent)
> kvm-all.c: limited to MADV_DONTFORK (no POSIX equivalent),
>           otherwise runtime error if !kvm_has_sync_mmu()
> hw/virtio-balloon.c: limited to __linux__
>
> Signed-off-by: Andreas Färber <afaerber@opensolaris.org>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> ---
>  arch_init.c |    2 +-
>  vl.c        |    3 ---
>  2 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/arch_init.c b/arch_init.c
> index e468c0c..fa39557 100644
> --- a/arch_init.c
> +++ b/arch_init.c
> @@ -396,7 +396,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)
>  #ifndef _WIN32
>             if (ch == 0 &&
>                 (!kvm_enabled() || kvm_has_sync_mmu())) {
> -                madvise(host, TARGET_PAGE_SIZE, MADV_DONTNEED);
> +                posix_madvise(host, TARGET_PAGE_SIZE, POSIX_MADV_DONTNEED);
>             }
>  #endif
>         } else if (flags & RAM_SAVE_FLAG_PAGE) {
> diff --git a/vl.c b/vl.c
> index 3f45aa9..d352d18 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -80,9 +80,6 @@
>  #include <net/if.h>
>  #include <syslog.h>
>  #include <stropts.h>
> -/* See MySQL bug #7156 (http://bugs.mysql.com/bug.php?id=7156) for
> -   discussion about Solaris header problems */
> -extern int madvise(caddr_t, size_t, int);
>  #endif
>  #endif
>  #endif
> --
> 1.7.2.2
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Re: [PATCH] Prefer posix_madvise() over madvise()
  2010-09-11 12:11 ` [Qemu-devel] " Blue Swirl
@ 2010-09-11 17:13   ` Andreas Färber
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Färber @ 2010-09-11 17:13 UTC (permalink / raw)
  To: Blue Swirl; +Cc: QEMU Developers

Am 11.09.2010 um 14:11 schrieb Blue Swirl:

> On Sat, Sep 11, 2010 at 11:51 AM, Andreas Färber <andreas.faerber@web.de 
> > wrote:
>> From: Andreas Färber <afaerber@opensolaris.org>
>>
>> vl.c has a Sun-specific hack to supply a prototype for madvise(),
>> but the call site has apparently moved to arch_init.c.
>> The underlying issue is that madvise() is not a POSIX function,
>> therefore Solaris' _POSIX_C_SOURCE suppresses the prototype.
>>
>> Haiku doesn't implement madvise() at all.
>
> OpenBSD doesn't implement posix_madvise(). How about adding probing to
> configure and wrapping the stuff found as qemu_madvise()?

Done in "Introduce qemu_madvise()". Should've been "[PATCH v2]".

Andreas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-09-11 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-11 11:51 [Qemu-devel] [PATCH] Prefer posix_madvise() over madvise() Andreas Färber
2010-09-11 12:11 ` [Qemu-devel] " Blue Swirl
2010-09-11 17:13   ` Andreas Färber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.