[Bug 284616] nfsd thread count auto-tune do not respect MAXNFSDCNT

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 06 Feb 2025 15:07:47 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284616

            Bug ID: 284616
           Summary: nfsd thread count auto-tune do not respect MAXNFSDCNT
           Product: Base System
           Version: 14.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: florian.millet@laposte.net

Hello everyone,

When launching nfsd without the -n parameter a function called
get_tuned_nfsdcount set the number of threads to launch at start to (number of
cpu * 8) but do not check if this result is greater than MAXNFSDCNT (which is
256).
On a processor with 72 cores it makes nfsd launch 576 threads per nfsd, if you
have multiple nfsd (with jails for example) it grows very quickly.

This problem do not appear if you manually set the number of threads through
the -n command line parameter to nfsd.

It would seem this regression appeared in commit
ae3e3df45c75ba60ec2cd2d425e4921bf2a6321d (or SVN revision 282272) nearly 10
years ago.

A patch like this one should be enough to restore this check :

diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index c1995580e142..cb506a4b1740 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -1033,6 +1033,8 @@ get_tuned_nfsdcount(void)
                tuned_nfsdcnt = DEFNFSDCNT;
        } else {
                tuned_nfsdcnt = ncpu * 8;
+               if (tuned_nfsdcnt > MAXNFSDCNT)
+                       tuned_nfsdcnt = MAXNFSDCNT;
        }
        return tuned_nfsdcnt;
 }

-- 
You are receiving this mail because:
You are the assignee for the bug.