nfsd_cache_size_limit() takes the square root of the low-memory page count and then shifts the result by the page size in KB. The shift belongs under the root. A host with 64 KB pages has a page count 16 times smaller than a 4 KB host with the same memory, so its root is 4 times smaller and its shift 16 times larger, and the limit comes out 4 times larger. With 8 GB of low memory the limit is 92672 entries on 4 KB pages and 370688 on 64 KB pages. Take the root of the byte count instead. The result matches the table above the function on every page size. Low memory on a 32-bit host is under 1 GB, so the byte count fits in an unsigned long. Fixes: 0338dd157282 ("nfsd: dynamically allocate DRC entries") Suggested-by: NeilBrown Reviewed-by: NeilBrown Link: https://patch.msgid.link/20260921-duplicate-reply-cache-v6-1-db5e13fd9944@kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfscache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 80364b91331a..b43b276a92b3 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -73,7 +73,7 @@ nfsd_cache_size_limit(void) unsigned int limit; unsigned long low_pages = totalram_pages() - totalhigh_pages(); - limit = (16 * int_sqrt(low_pages)) << (PAGE_SHIFT-10); + limit = int_sqrt(low_pages << PAGE_SHIFT); return min_t(unsigned int, limit, 256*1024); } -- 2.56.0