Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40921

Large allocations Use MMAP_NORESERVE (but not large_pages)

    XMLWordPrintable

Details

    • Can result in unexpected behaviour
    • Hide
      Large memory allocations use MAP_NORESERVE where available (Linux and Illumos) to ensure that large memory mappings (e.g. 8TiB on default innodb_buffer_pool_size_max) do not result in memory actually being reserved (which it is by default on Illumos). --large-page memory behaviour isn't changed.
      Show
      Large memory allocations use MAP_NORESERVE where available (Linux and Illumos) to ensure that large memory mappings (e.g. 8TiB on default innodb_buffer_pool_size_max) do not result in memory actually being reserved (which it is by default on Illumos). --large-page memory behaviour isn't changed.

    Description

      From fiddaman - https://jira.mariadb.org/browse/MDEV-38671?focusedCommentId=336602&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-336602

      Having just upgraded mariadb on a system running illumos, this change has bitten me:

      2026-08-04 12:21:11 0 [ERROR] InnoDB: Cannot map innodb_buffer_pool_size_max=8388608m
       2026-08-04 12:21:11 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
      

      On Linux a `PROT_NONE` anonymous mapping costs nothing, but on illumos any anonymous mapping without `MAP_NORESERVE` reserves swap at map time regardless of protection (https://man.omnios.org/man4/swap).
      I fixed it by explicitly adding smaller limits to `my.cnf` for am also planning to apply the following patch:

      --- a~/mysys/my_largepage.c     1970-01-01 00:00:00
      +++ a/mysys/my_largepage.c      1970-01-01 00:00:00
      @@ -492,7 +492,11 @@ char *my_large_virtual_alloc(size_t *size)
         ptr= mmap(NULL, *size, PROT_READ | PROT_WRITE,
                   MAP_PRIVATE | OS_MAP_ANON, -1, 0);
       # else
      -  ptr= mmap(NULL, *size, PROT_NONE, MAP_PRIVATE | OS_MAP_ANON, -1, 0);
      +  ptr= mmap(NULL, *size, PROT_NONE, MAP_PRIVATE | OS_MAP_ANON
      +#  ifdef __illumos__
      +            | MAP_NORESERVE
      +#  endif /* __illumos__ */
      +            , -1, 0);
       # endif
         if (ptr == MAP_FAILED)
           ptr= NULL;
      

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              danblack Daniel Black
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 2h 10m
                  2h 10m

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.