Linux – Persistent changes to /proc/sys/sunrpc/tcp_slot_table_entries

linuxmodprobesysctludev

I'm trying to make a persistent change to sunrpc.tcp_slot_table_entries on a Linux CentOS 5.5. This value has been found important for the performance of our NFS clients, and must be set before the NFS mounts are done.

Simply putting the value in /etc/sysctl.conf doesn't work because /etc/rc.d/rc.sysinit (which does the sysctl -p) is executed before the sunrpc module is loaded.

Same problem with RHEL 4:

I tried to:

  • put install sunrpc /sbin/modprobe -q --ignore-install sunrpc;/sbin/sysctl -w sunrpc.tcp_slot_table_entries=64 in /etc/modprobe.conf (and in /etc/modprobe.d/sunrpc)
  • put SUBSYSTEM=="module" ACTION=="add" DEVPATH=="*/sunrpc" RUN+="/sbin/sysctl -w sunrpc.tcp_slot_table_entries=64" (maybe it has to be changed for CentOS 5)
    in /etc/udev/rules.d/23-sunrpc.rules
    but to no avail.

And I'd prefer not to modify /etc/init.d/netfs (from initscripts package).

So, have you succeeded in doing it properly on a CentOS 5, and if so, how ?

Edit:
found in /etc/modprobe.d/modprobe.conf.dist:

install sunrpc /sbin/modprobe --first-time --ignore-install sunrpc && { /bin/mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs > /dev/null 2>&1 || :; }

That's maybe why my own addition to modprobe wasn't taken into account. But I'm not sure if I should modify directly that file, as it may be overwritten by module-init-tools updates …

Best Answer

Finally I created an almost dummy init script, inserted at S15 (see in /etc/rc3.d/), as the module is loaded in S14 (nfslock) and used in S25 (netfs).

/etc/init.d/sunrpc_tuning:

#!/bin/sh
#
# sunrpc_tuning       Tunes /proc/sys/sunrpc (launched after lockd)
#
# chkconfig: 345 15 85
# description: set values to sunrpc after module is loaded
# probe: true

case "$1" in
   start)
      echo "Setting sunrpc.tcp_slot_table_entries ..."
      /sbin/sysctl -w sunrpc.tcp_slot_table_entries=128
      ;;
   *) ;;
esac

Then: chkconfig --add sunrpc_tuning