public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Fix madvise on systems with page size != 4096
@ 2014-04-25  6:15 Ian Lance Taylor
  2014-04-27 23:03 ` [gofrontend-dev] " Michael Hudson-Doyle
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2014-04-25  6:15 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

This patch from Anton Blanchard fixes libgo to adjust to the system page
size when calling madvise.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.9 branch.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 953 bytes --]

diff -r 3a53301d24d7 libgo/runtime/mheap.c
--- a/libgo/runtime/mheap.c	Tue Apr 22 16:43:35 2014 -0700
+++ b/libgo/runtime/mheap.c	Thu Apr 24 21:18:35 2014 -0700
@@ -387,7 +387,7 @@
 static uintptr
 scavengelist(MSpan *list, uint64 now, uint64 limit)
 {
-	uintptr released, sumreleased;
+	uintptr released, sumreleased, start, end, pagesize;
 	MSpan *s;
 
 	if(runtime_MSpanList_IsEmpty(list))
@@ -400,7 +400,17 @@
 			mstats.heap_released += released;
 			sumreleased += released;
 			s->npreleased = s->npages;
-			runtime_SysUnused((void*)(s->start << PageShift), s->npages << PageShift);
+
+			start = s->start << PageShift;
+			end = start + (s->npages << PageShift);
+
+			// Round start up and end down to ensure we
+			// are acting on entire pages.
+			pagesize = getpagesize();
+			start = ROUND(start, pagesize);
+			end &= ~(pagesize - 1);
+			if(end > start)
+				runtime_SysUnused((void*)start, end - start);
 		}
 	}
 	return sumreleased;

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

* Re: [gofrontend-dev] libgo patch committed: Fix madvise on systems with page size != 4096
  2014-04-25  6:15 libgo patch committed: Fix madvise on systems with page size != 4096 Ian Lance Taylor
@ 2014-04-27 23:03 ` Michael Hudson-Doyle
  2014-04-27 23:38   ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Hudson-Doyle @ 2014-04-27 23:03 UTC (permalink / raw)
  To: Ian Lance Taylor, gcc-patches, gofrontend-dev

"'Ian Lance Taylor <iant@google.com>' via gofrontend-dev"
<gofrontend-dev@googlegroups.com> writes:

> This patch from Anton Blanchard fixes libgo to adjust to the system page
> size when calling madvise.  Bootstrapped and ran Go testsuite on
> x86_64-unknown-linux-gnu.  Committed to mainline and 4.9 branch.

Hi, I think this patch will make my Canonical colleagues very happy (and
me when I get around to building a 64k page arm64 kernel...).  It looks
to me like this is also a problem in the gc runtime library though --
should the patch be sent there too?  (Apologies if it already has and I
missed it, I did look though).

Cheers,
mwh

> Ian
>
> -- 
> You received this message because you are subscribed to the Google Groups "gofrontend-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gofrontend-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> diff -r 3a53301d24d7 libgo/runtime/mheap.c
> --- a/libgo/runtime/mheap.c	Tue Apr 22 16:43:35 2014 -0700
> +++ b/libgo/runtime/mheap.c	Thu Apr 24 21:18:35 2014 -0700
> @@ -387,7 +387,7 @@
>  static uintptr
>  scavengelist(MSpan *list, uint64 now, uint64 limit)
>  {
> -	uintptr released, sumreleased;
> +	uintptr released, sumreleased, start, end, pagesize;
>  	MSpan *s;
>  
>  	if(runtime_MSpanList_IsEmpty(list))
> @@ -400,7 +400,17 @@
>  			mstats.heap_released += released;
>  			sumreleased += released;
>  			s->npreleased = s->npages;
> -			runtime_SysUnused((void*)(s->start << PageShift), s->npages << PageShift);
> +
> +			start = s->start << PageShift;
> +			end = start + (s->npages << PageShift);
> +
> +			// Round start up and end down to ensure we
> +			// are acting on entire pages.
> +			pagesize = getpagesize();
> +			start = ROUND(start, pagesize);
> +			end &= ~(pagesize - 1);
> +			if(end > start)
> +				runtime_SysUnused((void*)start, end - start);
>  		}
>  	}
>  	return sumreleased;

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

* Re: [gofrontend-dev] libgo patch committed: Fix madvise on systems with page size != 4096
  2014-04-27 23:03 ` [gofrontend-dev] " Michael Hudson-Doyle
@ 2014-04-27 23:38   ` Ian Lance Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2014-04-27 23:38 UTC (permalink / raw)
  To: Michael Hudson-Doyle; +Cc: gcc-patches, gofrontend-dev

On Sun, Apr 27, 2014 at 2:45 PM, Michael Hudson-Doyle
<michael.hudson@linaro.org> wrote:
> "'Ian Lance Taylor <iant@google.com>' via gofrontend-dev"
> <gofrontend-dev@googlegroups.com> writes:
>
>> This patch from Anton Blanchard fixes libgo to adjust to the system page
>> size when calling madvise.  Bootstrapped and ran Go testsuite on
>> x86_64-unknown-linux-gnu.  Committed to mainline and 4.9 branch.
>
> Hi, I think this patch will make my Canonical colleagues very happy (and
> me when I get around to building a 64k page arm64 kernel...).  It looks
> to me like this is also a problem in the gc runtime library though --
> should the patch be sent there too?  (Apologies if it already has and I
> missed it, I did look though).

It's a potential problem in the gc runtime library, but I think it's
not a real problem at this point, since gc only runs on systems with
4k pages anyhow.

Ian

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

end of thread, other threads:[~2014-04-27 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25  6:15 libgo patch committed: Fix madvise on systems with page size != 4096 Ian Lance Taylor
2014-04-27 23:03 ` [gofrontend-dev] " Michael Hudson-Doyle
2014-04-27 23:38   ` Ian Lance Taylor

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 read-only IMAP folder(s) and NNTP newsgroup(s).