<div dir="ltr">Kamil,<div><br></div><div>I just resubmitted 4 patches with appropriate commit messages.</div><div><br></div><div>Given 32-bit's maximum of 4GB of RAM, I am doubtful that it</div><div>would be practical to map over half of that to video memory.</div><div>At least from an integrated GPU's perspective.</div><div></div><div><br></div><div>Jake Freeland</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 28, 2022 at 10:42 AM Kamil Konieczny <<a href="mailto:kamil.konieczny@linux.intel.com" target="_blank">kamil.konieczny@linux.intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Jake,<br>
<br>
On 2022-09-28 at 10:19:04 -0500, Jake Freeland wrote:<br>
> I cannot find any relevant documentation for both Linux and FreeBSD<br>
> that mentions an mmap flag that supports large file allocation on<br>
> 32-bit architectures.<br>
> <br>
> Commit message:<br>
> The mmap64() function exists to point 32-bit architectures to an mmap<br>
> interface with the capability to address a 64-bit memory address space.<br>
> As 32-bit machines are replaced by 64-bit, there is no longer a need to<br>
> keep mmap64() around. This is especially apparent in operating systems<br>
> like FreeBSD that exclude the mmap64() function altogether. This patch<br>
> replaces all instances of mmap64() with mmap().<br>
> <br>
> Jake Freeland<br>
<br>
Commit message looks ok, please repost patch with this.<br>
<br>
For the _LARGEFILE64_SOURCE, it looks like it is enough to define<br>
_FILE_OFFSET_BITS on 32-bit platform during compile, see:<br>
<br>
<a href="https://stackoverflow.com/questions/59453555/is-there-any-difference-between-mmap-vs-mmap64" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/59453555/is-there-any-difference-between-mmap-vs-mmap64</a><br>
<br>
The question is: are there any igt users of 32-bit platform with<br>
GPU memory size bigger then 2GB ?<br>
<br>
Regards,<br>
Kamil<br>
<br>
> <br>
> On Wed, Sep 28, 2022 at 7:45 AM Petri Latvala <<a href="mailto:petri.latvala@intel.com" target="_blank">petri.latvala@intel.com</a>><br>
> wrote:<br>
> <br>
> > On Wed, Sep 28, 2022 at 02:33:14PM +0200, Kamil Konieczny wrote:<br>
> > > Hi Jake,<br>
> > ><br>
> > > this patch is missing commit message. Please put here short<br>
> > > description of change and why you do it. Change looks resonable<br>
> > > as on 64-bit systems both functions are the same.<br>
> > ><br>
> > > On 2022-09-18 at 17:15:35 -0500, Jake Freeland wrote:<br>
> > > > Signed-off-by: Jake Freeland <<a href="mailto:jfree@freebsd.org" target="_blank">jfree@freebsd.org</a>><br>
> > ><br>
> > > Adding Petri on cc as I do not know if anyone compiles this on<br>
> > > 32-bit platforms.<br>
> ><br>
> > Aren't you supposed to use mmap() with _LARGEFILE_something even on<br>
> > 32-bit builds, instead of mmap64?<br>
> ><br>
> ><br>
> > --<br>
> > Petri Latvala<br>
> ><br>
> ><br>
> ><br>
> > ><br>
> > > Regards,<br>
> > > Kamil<br>
> > ><br>
> > > > ---<br>
> > > > lib/i915/gem_mman.c | 4 ++--<br>
> > > > lib/igt_vgem.c | 2 +-<br>
> > > > tests/i915/gem_mmap_gtt.c | 22 +++++++++++-----------<br>
> > > > tests/i915/gem_mmap_offset.c | 14 +++++++-------<br>
> > > > 4 files changed, 21 insertions(+), 21 deletions(-)<br>
> > > ><br>
> > > > diff --git a/lib/i915/gem_mman.c b/lib/i915/gem_mman.c<br>
> > > > index aa9ac6f3..0b41ba70 100644<br>
> > > > --- a/lib/i915/gem_mman.c<br>
> > > > +++ b/lib/i915/gem_mman.c<br>
> > > > @@ -118,7 +118,7 @@ void *__gem_mmap__gtt(int fd, uint32_t handle,<br>
> > uint64_t size, unsigned prot)<br>
> > > > if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg))<br>
> > > > return NULL;<br>
> > > ><br>
> > > > - ptr = mmap64(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);<br>
> > > > + ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset);<br>
> > > > if (ptr == MAP_FAILED)<br>
> > > > ptr = NULL;<br>
> > > > else<br>
> > > > @@ -331,7 +331,7 @@ void *__gem_mmap_offset(int fd, uint32_t handle,<br>
> > uint64_t offset, uint64_t size,<br>
> > > > if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &arg))<br>
> > > > return NULL;<br>
> > > ><br>
> > > > - ptr = mmap64(0, size, prot, MAP_SHARED, fd, arg.offset + offset);<br>
> > > > + ptr = mmap(0, size, prot, MAP_SHARED, fd, arg.offset + offset);<br>
> > > ><br>
> > > > if (ptr == MAP_FAILED)<br>
> > > > ptr = NULL;<br>
> > > > diff --git a/lib/igt_vgem.c b/lib/igt_vgem.c<br>
> > > > index 7f933b23..468383c7 100644<br>
> > > > --- a/lib/igt_vgem.c<br>
> > > > +++ b/lib/igt_vgem.c<br>
> > > > @@ -76,7 +76,7 @@ void *__vgem_mmap(int fd, struct vgem_bo *bo,<br>
> > unsigned prot)<br>
> > > > if (drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg))<br>
> > > > return NULL;<br>
> > > ><br>
> > > > - ptr = mmap64(0, bo->size, prot, MAP_SHARED, fd, arg.offset);<br>
> > > > + ptr = mmap(0, bo->size, prot, MAP_SHARED, fd, arg.offset);<br>
> > > > if (ptr == MAP_FAILED)<br>
> > > > return NULL;<br>
> > > ><br>
> > > > diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c<br>
> > > > index 4f05eb18..683eaf16 100644<br>
> > > > --- a/tests/i915/gem_mmap_gtt.c<br>
> > > > +++ b/tests/i915/gem_mmap_gtt.c<br>
> > > > @@ -113,11 +113,11 @@ test_access(int fd)<br>
> > > > mmap_arg.handle = handle;<br>
> > > > do_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg);<br>
> > > ><br>
> > > > - igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > + igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > MAP_SHARED, fd, mmap_arg.offset));<br>
> > > ><br>
> > > > /* Check that the same offset on the other fd doesn't work. */<br>
> > > > - igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > + igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > MAP_SHARED, fd2, mmap_arg.offset) == MAP_FAILED);<br>
> > > > igt_assert(errno == EACCES);<br>
> > > ><br>
> > > > @@ -128,7 +128,7 @@ test_access(int fd)<br>
> > > ><br>
> > > > /* Recheck that it works after flink. */<br>
> > > > /* Check that the same offset on the other fd doesn't work. */<br>
> > > > - igt_assert(mmap64(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > + igt_assert(mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > MAP_SHARED, fd2, mmap_arg.offset));<br>
> > > > }<br>
> > > ><br>
> > > > @@ -159,11 +159,11 @@ test_short(int fd)<br>
> > > > for (pages = 1; pages <= OBJECT_SIZE / PAGE_SIZE; pages <<= 1) {<br>
> > > > uint8_t *r, *w;<br>
> > > ><br>
> > > > - w = mmap64(0, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > + w = mmap(0, pages * PAGE_SIZE, PROT_READ | PROT_WRITE,<br>
> > > > MAP_SHARED, fd, mmap_arg.offset);<br>
> > > > igt_assert(w != MAP_FAILED);<br>
> > > ><br>
> > > > - r = mmap64(0, pages * PAGE_SIZE, PROT_READ,<br>
> > > > + r = mmap(0, pages * PAGE_SIZE, PROT_READ,<br>
> > > > MAP_SHARED, fd, mmap_arg.offset);<br>
> > > > igt_assert(r != MAP_FAILED);<br>
> > > ><br>
> > > > @@ -384,13 +384,13 @@ test_isolation(int i915)<br>
> > > ><br>
> > > > close(B);<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > igt_assert(ptr != MAP_FAILED);<br>
> > > > munmap(ptr, 4096);<br>
> > > ><br>
> > > > close(A);<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > igt_assert(ptr == MAP_FAILED);<br>
> > > > }<br>
> > > ><br>
> > > > @@ -400,7 +400,7 @@ test_close_race(int i915)<br>
> > > > const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);<br>
> > > > _Atomic uint32_t *handles;<br>
> > > ><br>
> > > > - handles = mmap64(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1,<br>
> > 0);<br>
> > > > + handles = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> > > > igt_assert(handles != MAP_FAILED);<br>
> > > ><br>
> > > > igt_fork(child, ncpus + 1) {<br>
> > > > @@ -418,7 +418,7 @@ test_close_race(int i915)<br>
> > > > &mmap_arg) != -1) {<br>
> > > > void *ptr;<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096,<br>
> > > > + ptr = mmap(0, 4096,<br>
> > > > PROT_WRITE, MAP_SHARED, i915,<br>
> > > > mmap_arg.offset);<br>
> > > > if (ptr != MAP_FAILED) {<br>
> > > > @@ -444,7 +444,7 @@ test_flink_race(int i915)<br>
> > > > const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);<br>
> > > > _Atomic uint32_t *handles;<br>
> > > ><br>
> > > > - handles = mmap64(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1,<br>
> > 0);<br>
> > > > + handles = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> > > > igt_assert(handles != MAP_FAILED);<br>
> > > ><br>
> > > > igt_fork(child, ncpus + 1) {<br>
> > > > @@ -469,7 +469,7 @@ test_flink_race(int i915)<br>
> > > > &mmap_arg) != -1) {<br>
> > > > void *ptr;<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096,<br>
> > > > + ptr = mmap(0, 4096,<br>
> > > > PROT_WRITE, MAP_SHARED, fd,<br>
> > > > mmap_arg.offset);<br>
> > > > if (ptr != MAP_FAILED) {<br>
> > > > diff --git a/tests/i915/gem_mmap_offset.c<br>
> > b/tests/i915/gem_mmap_offset.c<br>
> > > > index 5781b2fb..0933ed94 100644<br>
> > > > --- a/tests/i915/gem_mmap_offset.c<br>
> > > > +++ b/tests/i915/gem_mmap_offset.c<br>
> > > > @@ -66,7 +66,7 @@ __mmap_offset(int i915, uint32_t handle, uint64_t<br>
> > offset, uint64_t size,<br>
> > > > if (mmap_offset_ioctl(i915, &arg))<br>
> > > > return NULL;<br>
> > > ><br>
> > > > - ptr = mmap64(0, size, prot, MAP_SHARED, i915, arg.offset + offset);<br>
> > > > + ptr = mmap(0, size, prot, MAP_SHARED, i915, arg.offset + offset);<br>
> > > > if (ptr == MAP_FAILED)<br>
> > > > ptr = NULL;<br>
> > > > else<br>
> > > > @@ -214,12 +214,12 @@ static void isolation(int i915)<br>
> > > > t->name, B, b, offset_b);<br>
> > > ><br>
> > > > errno = 0;<br>
> > > > - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, i915,<br>
> > offset_a);<br>
> > > > + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, i915, offset_a);<br>
> > > > igt_assert(ptr == MAP_FAILED);<br>
> > > > igt_assert_eq(errno, EACCES);<br>
> > > ><br>
> > > > errno = 0;<br>
> > > > - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, i915,<br>
> > offset_b);<br>
> > > > + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, i915, offset_b);<br>
> > > > igt_assert(ptr == MAP_FAILED);<br>
> > > > igt_assert_eq(errno, EACCES);<br>
> > > ><br>
> > > > @@ -237,13 +237,13 @@ static void isolation(int i915)<br>
> > > ><br>
> > > > close(B);<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > igt_assert(ptr != MAP_FAILED);<br>
> > > > munmap(ptr, 4096);<br>
> > > ><br>
> > > > close(A);<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > + ptr = mmap(0, 4096, PROT_READ, MAP_SHARED, A, offset_a);<br>
> > > > igt_assert(ptr == MAP_FAILED);<br>
> > > > }<br>
> > > > }<br>
> > > > @@ -401,7 +401,7 @@ static void close_race(int i915, int timeout)<br>
> > > > _Atomic uint32_t *handles;<br>
> > > > size_t len = ALIGN((ncpus + 1) * sizeof(uint32_t), 4096);<br>
> > > ><br>
> > > > - handles = mmap64(0, len, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> > > > + handles = mmap(0, len, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);<br>
> > > > igt_assert(handles != MAP_FAILED);<br>
> > > ><br>
> > > > igt_fork(child, ncpus + 1) {<br>
> > > > @@ -420,7 +420,7 @@ static void close_race(int i915, int timeout)<br>
> > > > &mmap_arg) != -1) {<br>
> > > > void *ptr;<br>
> > > ><br>
> > > > - ptr = mmap64(0, 4096,<br>
> > > > + ptr = mmap(0, 4096,<br>
> > > > PROT_WRITE, MAP_SHARED, i915,<br>
> > > > mmap_arg.offset);<br>
> > > > if (ptr != MAP_FAILED) {<br>
> > > > --<br>
> > > > 2.37.3<br>
> > > ><br>
> ><br>
</blockquote></div>