Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys/unix: Getpagesize can return wrong value for Solaris #12076

Closed
binarycrusader opened this issue Aug 8, 2015 · 6 comments
Closed

x/sys/unix: Getpagesize can return wrong value for Solaris #12076

binarycrusader opened this issue Aug 8, 2015 · 6 comments

Comments

@binarycrusader
Copy link
Contributor

Getpsagesize hardcodes the return value of 4096 for Solaris. The default pagesize on Solaris for amd64 can actually vary:

$ pagesize -a
4096
2097152
1073741824

With that said, Solaris currently defaults to 4096 for amd64, but this could change at some future point. And for other architectures (admittedly not yet supported by Go, but that are in development)
the default pagesize is definitely different, for example, SPARC where the default is currently 8192 although the default may change in the near future as current SPARC systems max out at 64 Terabytes of memory:

$ pagesize -a
8192
65536
4194304
268435456
2147483648

Issue 10180 touches on this subject, but in the context of cmd/link. A response to my inquiry on golang-dev suggested that x/sys/unix (at least) should just return whatever the POSIX interface for page size returns:

https://groups.google.com/forum/#!topic/golang-dev/ZLzxYzULzU8

As such, I'm proposing to change x/sys/unix Getpagesize to use sysconf(3C) to get the actual value (and cache it, since the value never changes after the system boots) and return that instead.

@binarycrusader
Copy link
Contributor Author

I will provide a CL soon with a proposed change for this.

@davecheney
Copy link
Contributor

I will provide a CL soon with a proposed change for this.

Please discussion your change first.

@binarycrusader
Copy link
Contributor Author

I linked to the discussion thread on golang-dev; was there a specific concern to be addressed?

@davecheney
Copy link
Contributor

I linked to the discussion thread on golang-dev; was there a specific concern to be addressed?

I am sorry, I thought this change was being proposed to the main repository.

@gopherbot
Copy link

CL https://golang.org/cl/14421 mentions this issue.

@binarycrusader
Copy link
Contributor Author

Was fixed by:

CL https://golang.org/cl/14483

@golang golang locked and limited conversation to collaborators Sep 22, 2016
stanhu pushed a commit to stanhu/go that referenced this issue Sep 14, 2020
In preparation for issues such as golang#10180, Getpagesize() needs to be
fixed to return the actual system's page size instead of assuming it's
always 4096.

This is particularly important for future platform support on Solaris.

Fixes golang#12076

Change-Id: I78205165909529215fe93ed6ba56e9c3ee1c2abb
Reviewed-on: https://go-review.googlesource.com/14483
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants