[Openais] [Corosync] Patch to improve BSD support
Steven Dake
sdake at redhat.com
Wed Jun 17 22:49:01 PDT 2009
merged
thanks
-steve
On Wed, 2009-06-17 at 11:25 +0200, Jérôme Flesch wrote:
> This patch adds a call to madvise(..., MADV_NOSYNC) after each call to
> mmap() . MADV_NOSYNC is an option specific to BSD systems specifying to
> the system to not write data on the disk unless it's really needed.
>
> It doesn't seem really required to make Corosync works on FreeBSD
> (performances look the same with or without), but the man page of
> madvise() on FreeBSD says it should be done when using mmap() to create
> shared memory.
>
> plain text document attachment (patch-bsd-madvise)
> diff --git a/exec/coroipcs.c b/exec/coroipcs.c
> index 9f7769e..645e1a5 100644
> --- exec/coroipcs.c
> +++ exec/coroipcs.c
> @@ -188,6 +188,9 @@ memory_map (
> if (addr != addr_orig) {
> return (-1);
> }
> +#ifdef COROSYNC_BSD
> + madvise(addr, bytes, MADV_NOSYNC);
> +#endif
>
> res = close (fd);
> if (res) {
> @@ -227,10 +230,16 @@ circular_memory_map (
> if (addr != addr_orig) {
> return (-1);
> }
> +#ifdef COROSYNC_BSD
> + madvise(addr_orig, bytes, MADV_NOSYNC);
> +#endif
>
> addr = mmap (((char *)addr_orig) + bytes,
> bytes, PROT_READ | PROT_WRITE,
> MAP_FIXED | MAP_SHARED, fd, 0);
> +#ifdef COROSYNC_BSD
> + madvise(((char *)addr_orig) + bytes, bytes, MADV_NOSYNC);
> +#endif
>
> res = close (fd);
> if (res) {
> diff --git a/lib/coroipcc.c b/lib/coroipcc.c
> index c30fad7..c5b0d71 100644
> --- lib/coroipcc.c
> +++ lib/coroipcc.c
> @@ -294,10 +294,16 @@ circular_memory_map (char *path, const char *file, void **buf, size_t bytes)
> if (addr != addr_orig) {
> return (-1);
> }
> +#ifdef COROSYNC_BSD
> + madvise(addr_orig, bytes, MADV_NOSYNC);
> +#endif
>
> addr = mmap (((char *)addr_orig) + bytes,
> bytes, PROT_READ | PROT_WRITE,
> MAP_FIXED | MAP_SHARED, fd, 0);
> +#ifdef COROSYNC_BSD
> + madvise(((char *)addr_orig) + bytes, bytes, MADV_NOSYNC);
> +#endif
>
> res = close (fd);
> if (res) {
> @@ -360,6 +366,9 @@ memory_map (char *path, const char *file, void **buf, size_t bytes)
> if (addr != addr_orig) {
> return (-1);
> }
> +#ifdef COROSYNC_BSD
> + madvise(addr_orig, bytes, MADV_NOSYNC);
> +#endif
>
> res = close (fd);
> if (res) {
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais
More information about the Openais
mailing list