From nobody Sun Jan 09 18:14:28 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9992A1948902; Sun, 9 Jan 2022 18:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JX4q82LHfz3DNn; Sun, 9 Jan 2022 18:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3048016DD2; Sun, 9 Jan 2022 18:14:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 209IES88051470; Sun, 9 Jan 2022 18:14:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 209IESOo051469; Sun, 9 Jan 2022 18:14:28 GMT (envelope-from git) Date: Sun, 9 Jan 2022 18:14:28 GMT Message-Id: <202201091814.209IESOo051469@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: 3455c738ac23 - main - nfsd: Reduce callouts rate. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3455c738ac23f723dc516ce5acd02ed24ff9f5df Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641752068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lR78MdH5aWaqLtKr0j7vazfUbBPNcwd9JQxWe1hphBY=; b=Bc3kXZAsW9327RSrcj465yn6ZTGlRIr797W7k32g5IyqZsEZQRtkPAQP/a4qaa6TrlQ09w KI3woKL/VocRKKKzwdWb4ZO9ycGtylex7qfBBkpiSSWJP+9vhzy89gp1R5W1fTJnzp7f3W aboX2Q1K74y2g2BULFYTJ3mceLmk2dr6nqGBH+sRY+7Z9lvNvT8r8JmZ3V38wCVAlXRXrR JbN8duf/yjXAyAwIp6J4wFQo5LfkMREXOrPHyCDiFaiXTRJxp4hyxTuMootWTLyk28NO/f njnkLVRh4IHinqL5UpgTK4I7HMMJ/3EKrk2mvt90sLNBb9aXoqKSKmMRwQkOfA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641752068; a=rsa-sha256; cv=none; b=CTI0bC6Po4ZpI2kaJbq9TVcnbkJfnxj0dZsicGZiTSubetAC2qASSsElrG6vd8WJqgIf4f qN+MzqObA4+FMGmOtNlig5M2rtXPi1jHw0xAxy+mNribE3ZlwGiEG0vK6t8VZkbx1LcbGc icZCdpYiuT1w0Cmgo0qeh8ocGT5eXoEK3Wz8vCUnwYGEXvmEuxsguFKhYPlvKeC/0OKUTB 3+hd91PFnj6KjeuCkL1ItEnv3nsETY61j2QKSuRSQoRlUoHmnVSX33577zF8V77oq4MZgw 3w02WdA0uPMzvGTDZWIX/ZyMYuZtOl5RzyApdlOJZrGRxobI0u4r4/1VnJf25A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=3455c738ac23f723dc516ce5acd02ed24ff9f5df commit 3455c738ac23f723dc516ce5acd02ed24ff9f5df Author: Alexander Motin AuthorDate: 2022-01-09 18:09:29 +0000 Commit: Alexander Motin CommitDate: 2022-01-09 18:14:23 +0000 nfsd: Reduce callouts rate. Before this callouts were scheduled twice a seconds even if nfsd was never used. This reduces the rate to ~1Hz and only after nfsd first started. MFC after: 2 weeks --- sys/fs/nfs/nfs_commonport.c | 25 ------------------------- sys/fs/nfs/nfs_commonsubs.c | 1 - sys/fs/nfs/nfs_var.h | 1 - sys/fs/nfs/nfsport.h | 6 ------ sys/fs/nfsserver/nfs_nfsdport.c | 16 +++++++++++++--- 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index cd44698343d7..2bb89d8ef264 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -67,12 +67,10 @@ struct nfsstatsv1 nfsstatsv1; int nfs_numnfscbd = 0; int nfscl_debuglevel = 0; char nfsv4_callbackaddr[INET6_ADDRSTRLEN]; -struct callout newnfsd_callout; int nfsrv_lughashsize = 100; struct mtx nfsrv_dslock_mtx; struct nfsdevicehead nfsrv_devidhead; volatile int nfsrv_devidcnt = 0; -void (*nfsd_call_servertimer)(void) = NULL; void (*ncl_call_invalcaches)(struct vnode *) = NULL; vop_advlock_t *nfs_advlock_p = NULL; vop_reclaim_t *nfs_reclaim_p = NULL; @@ -399,27 +397,6 @@ newnfs_getcred(void) return (cred); } -/* - * Nfs timer routine - * Call the nfsd's timer function once/sec. - */ -void -newnfs_timer(void *arg) -{ - static time_t lasttime = 0; - /* - * Call the server timer, if set up. - * The argument indicates if it is the next second and therefore - * leases should be checked. - */ - if (lasttime != NFSD_MONOSEC) { - lasttime = NFSD_MONOSEC; - if (nfsd_call_servertimer != NULL) - (*nfsd_call_servertimer)(); - } - callout_reset(&newnfsd_callout, nfscl_ticks, newnfs_timer, NULL); -} - /* * Sleep for a short period of time unless errval == NFSERR_GRACE, where * the sleep should be for 5 seconds. @@ -895,7 +872,6 @@ nfscommon_modevent(module_t mod, int type, void *data) MTX_DEF); mtx_init(&nfsrv_dslock_mtx, "nfs4ds", NULL, MTX_DEF); TAILQ_INIT(&nfsrv_devidhead); - callout_init(&newnfsd_callout, 1); newnfs_init(); nfsd_call_nfscommon = nfssvc_nfscommon; loaded = 1; @@ -909,7 +885,6 @@ nfscommon_modevent(module_t mod, int type, void *data) } nfsd_call_nfscommon = NULL; - callout_drain(&newnfsd_callout); /* Clean out the name<-->id cache. */ nfsrv_cleanusergroup(); /* and get rid of the mutexes */ diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index d2124d1f3c0a..cdf3f4830e31 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -930,7 +930,6 @@ newnfs_init(void) * Initialize reply list and start timer */ TAILQ_INIT(&nfsd_reqq); - NFS_TIMERINIT; } /* diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index b2a44e6e16f2..d41c1853cb1f 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -431,7 +431,6 @@ int nfs_catnap(int, int, const char *); struct nfsreferral *nfsv4root_getreferral(vnode_t, vnode_t, u_int32_t); int nfsvno_pathconf(vnode_t, int, long *, struct ucred *, NFSPROC_T *); int nfsrv_atroot(vnode_t, uint64_t *); -void newnfs_timer(void *); int nfs_supportsnfsv4acls(vnode_t); /* nfs_commonacl.c */ diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index e099cf6e46f0..8ac4bc54a5f2 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -776,12 +776,6 @@ void nfsrvd_rcv(struct socket *, void *, int); #define NFSCNHASH(c, v) #define NCHNAMLEN 9999999 -/* - * These macros are defined to initialize and set the timer routine. - */ -#define NFS_TIMERINIT \ - newnfs_timer(NULL) - /* * Handle SMP stuff: */ diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 50d679397f7b..6f9e1326928e 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -60,7 +61,6 @@ extern int nfsrv_useacl; extern int newnfs_numnfsd; extern struct mount nfsv4root_mnt; extern struct nfsrv_stablefirst nfsrv_stablefirst; -extern void (*nfsd_call_servertimer)(void); extern SVCPOOL *nfsrvd_pool; extern struct nfsv4lock nfsd_suspend_lock; extern struct nfsclienthashhead *nfsclienthash; @@ -97,6 +97,7 @@ static char nfsd_master_comm[MAXCOMLEN + 1]; static struct timeval nfsd_master_start; static uint32_t nfsv4_sysid = 0; static fhandle_t zerofh; +struct callout nfsd_callout; static int nfssvc_srvcall(struct thread *, struct nfssvc_args *, struct ucred *); @@ -3530,6 +3531,14 @@ nfsd_mntinit(void) nfsv4root_mnt.mnt_lazyvnodelistsize = 0; } +static void +nfsd_timer(void *arg) +{ + + nfsrv_servertimer(); + callout_reset_sbt(&nfsd_callout, SBT_1S, SBT_1S, nfsd_timer, NULL, 0); +} + /* * Get a vnode for a file handle, without checking exports, etc. */ @@ -3771,6 +3780,7 @@ nfssvc_nfsd(struct thread *td, struct nfssvc_args *uap) nfsdarg.mdspathlen = 0; nfsdarg.mirrorcnt = 1; } + nfsd_timer(NULL); error = nfsrvd_nfsd(td, &nfsdarg); free(nfsdarg.addr, M_TEMP); free(nfsdarg.dnshost, M_TEMP); @@ -7033,6 +7043,7 @@ nfsd_modevent(module_t mod, int type, void *data) mtx_init(&nfsrv_dontlistlock_mtx, "nfs4dnl", NULL, MTX_DEF); mtx_init(&nfsrv_recalllock_mtx, "nfs4rec", NULL, MTX_DEF); lockinit(&nfsv4root_mnt.mnt_explock, PVFS, "explock", 0, 0); + callout_init(&nfsd_callout, 1); nfsrvd_initcache(); nfsd_init(); NFSD_LOCK(); @@ -7043,7 +7054,6 @@ nfsd_modevent(module_t mod, int type, void *data) vn_deleg_ops.vndeleg_recall = nfsd_recalldelegation; vn_deleg_ops.vndeleg_disable = nfsd_disabledelegation; #endif - nfsd_call_servertimer = nfsrv_servertimer; nfsd_call_nfsd = nfssvc_nfsd; loaded = 1; break; @@ -7058,8 +7068,8 @@ nfsd_modevent(module_t mod, int type, void *data) vn_deleg_ops.vndeleg_recall = NULL; vn_deleg_ops.vndeleg_disable = NULL; #endif - nfsd_call_servertimer = NULL; nfsd_call_nfsd = NULL; + callout_drain(&nfsd_callout); /* Clean out all NFSv4 state. */ nfsrv_throwawayallstate(curthread);