Unnecessary limitation on munmap?

Ken Brown kbrown@cornell.edu
Sat Dec 21 21:42:14 GMT 2024


I'm wondering why munmap insists on operating with chunks of size 64k 
instead of pages of size 4k.  In other words, what would go wrong if we 
did the following:

--- a/winsup/cygwin/mm/mmap.cc
+++ b/winsup/cygwin/mm/mmap.cc
@@ -1143,7 +1143,7 @@ munmap (void *addr, size_t len)
        set_errno (EINVAL);
        return -1;
      }
-  const size_t pagesize = wincap.allocation_granularity ();
+  const size_t pagesize = wincap.page_size ();
    if (((uintptr_t) addr % pagesize) || !len)
      {
        set_errno (EINVAL);

I'm currently testing a build with this patch, and so far I haven't seen 
any problems.  But maybe I don't know what to test.

Ken


More information about the Cygwin-developers mailing list