]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Make spl_kmem_cache size check consistent
authoryouzhongyang <youzhong@gmail.com>
Tue, 16 Jan 2024 21:30:58 +0000 (16:30 -0500)
committerGitHub <noreply@github.com>
Tue, 16 Jan 2024 21:30:58 +0000 (13:30 -0800)
On Linux x86_64, kmem cache can have size up to 4M,
however increasing spl_kmem_cache_slab_limit can lead
to crash due to the size check inconsistency.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Youzhong Yang <yyang@mathworks.com>
Closes #15757

module/os/linux/spl/spl-kmem-cache.c

index a2920c746672d16209adaf8bd4e2bb1e153c37e5..4b15081715ac1f4e3c25340fd1bbd95f650c8ddb 100644 (file)
@@ -91,7 +91,8 @@ MODULE_PARM_DESC(spl_kmem_cache_max_size, "Maximum size of slab in MB");
  * of 16K was determined to be optimal for architectures using 4K pages and
  * to also work well on architecutres using larger 64K page sizes.
  */
-static unsigned int spl_kmem_cache_slab_limit = 16384;
+static unsigned int spl_kmem_cache_slab_limit =
+    SPL_MAX_KMEM_ORDER_NR_PAGES * PAGE_SIZE;
 module_param(spl_kmem_cache_slab_limit, uint, 0644);
 MODULE_PARM_DESC(spl_kmem_cache_slab_limit,
        "Objects less than N bytes use the Linux slab");
@@ -783,7 +784,7 @@ spl_kmem_cache_create(const char *name, size_t size, size_t align,
        } else {
                unsigned long slabflags = 0;
 
-               if (size > (SPL_MAX_KMEM_ORDER_NR_PAGES * PAGE_SIZE))
+               if (size > spl_kmem_cache_slab_limit)
                        goto out;
 
 #if defined(SLAB_USERCOPY)