From owner-svn-src-head@freebsd.org Thu Jul 30 15:50:52 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D9DD03A909B; Thu, 30 Jul 2020 15:50:52 +0000 (UTC) (envelope-from mjg@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BHZd85Sv0z4Xpk; Thu, 30 Jul 2020 15:50:52 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9EF35135C4; Thu, 30 Jul 2020 15:50:52 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06UFoqji001587; Thu, 30 Jul 2020 15:50:52 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06UFopxF001582; Thu, 30 Jul 2020 15:50:51 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202007301550.06UFopxF001582@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Thu, 30 Jul 2020 15:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363708 - in head/sys: kern sys tools X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys tools X-SVN-Commit-Revision: 363708 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jul 2020 15:50:52 -0000 Author: mjg Date: Thu Jul 30 15:50:51 2020 New Revision: 363708 URL: https://svnweb.freebsd.org/changeset/base/363708 Log: vfs: inline vops if there are no pre/post associated calls This removes a level of indirection from frequently used methods, most notably VOP_LOCK1 and VOP_UNLOCK1. Tested by: pho Modified: head/sys/kern/vfs_subr.c head/sys/kern/vnode_if.src head/sys/sys/vnode.h head/sys/tools/vnode_if.awk Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Thu Jul 30 15:48:56 2020 (r363707) +++ head/sys/kern/vfs_subr.c Thu Jul 30 15:50:51 2020 (r363708) @@ -5597,21 +5597,21 @@ vop_rename_pre(void *ap) #ifdef DEBUG_VFS_LOCKS void -vop_fplookup_vexec_pre(void *ap __unused) +vop_fplookup_vexec_debugpre(void *ap __unused) { VFS_SMR_ASSERT_ENTERED(); } void -vop_fplookup_vexec_post(void *ap __unused, int rc __unused) +vop_fplookup_vexec_debugpost(void *ap __unused, int rc __unused) { VFS_SMR_ASSERT_ENTERED(); } void -vop_strategy_pre(void *ap) +vop_strategy_debugpre(void *ap) { struct vop_strategy_args *a; struct buf *bp; @@ -5635,7 +5635,7 @@ vop_strategy_pre(void *ap) } void -vop_lock_pre(void *ap) +vop_lock_debugpre(void *ap) { struct vop_lock1_args *a = ap; @@ -5646,7 +5646,7 @@ vop_lock_pre(void *ap) } void -vop_lock_post(void *ap, int rc) +vop_lock_debugpost(void *ap, int rc) { struct vop_lock1_args *a = ap; @@ -5656,7 +5656,7 @@ vop_lock_post(void *ap, int rc) } void -vop_unlock_pre(void *ap) +vop_unlock_debugpre(void *ap) { struct vop_unlock_args *a = ap; @@ -5664,7 +5664,7 @@ vop_unlock_pre(void *ap) } void -vop_need_inactive_pre(void *ap) +vop_need_inactive_debugpre(void *ap) { struct vop_need_inactive_args *a = ap; @@ -5672,7 +5672,7 @@ vop_need_inactive_pre(void *ap) } void -vop_need_inactive_post(void *ap, int rc) +vop_need_inactive_debugpost(void *ap, int rc) { struct vop_need_inactive_args *a = ap; Modified: head/sys/kern/vnode_if.src ============================================================================== --- head/sys/kern/vnode_if.src Thu Jul 30 15:48:56 2020 (r363707) +++ head/sys/kern/vnode_if.src Thu Jul 30 15:50:51 2020 (r363708) @@ -147,8 +147,8 @@ vop_close { %% fplookup_vexec vp - - - -%! fplookup_vexec pre vop_fplookup_vexec_pre -%! fplookup_vexec post vop_fplookup_vexec_post +%! fplookup_vexec debugpre vop_fplookup_vexec_debugpre +%! fplookup_vexec debugpost vop_fplookup_vexec_debugpost vop_fplookup_vexec { IN struct vnode *vp; @@ -379,8 +379,8 @@ vop_inactive { IN struct thread *td; }; -%! need_inactive pre vop_need_inactive_pre -%! need_inactive post vop_need_inactive_post +%! need_inactive debugpre vop_need_inactive_debugpre +%! need_inactive debugpost vop_need_inactive_debugpost vop_need_inactive { IN struct vnode *vp; @@ -395,8 +395,8 @@ vop_reclaim { }; -%! lock1 pre vop_lock_pre -%! lock1 post vop_lock_post +%! lock1 debugpre vop_lock_debugpre +%! lock1 debugpost vop_lock_debugpost vop_lock1 { IN struct vnode *vp; @@ -406,7 +406,7 @@ vop_lock1 { }; -%! unlock pre vop_unlock_pre +%! unlock debugpre vop_unlock_debugpre vop_unlock { IN struct vnode *vp; @@ -426,7 +426,7 @@ vop_bmap { %% strategy vp L L L -%! strategy pre vop_strategy_pre +%! strategy debugpre vop_strategy_debugpre vop_strategy { IN struct vnode *vp; Modified: head/sys/sys/vnode.h ============================================================================== --- head/sys/sys/vnode.h Thu Jul 30 15:48:56 2020 (r363707) +++ head/sys/sys/vnode.h Thu Jul 30 15:50:51 2020 (r363708) @@ -869,23 +869,23 @@ void vop_symlink_post(void *a, int rc); int vop_sigdefer(struct vop_vector *vop, struct vop_generic_args *a); #ifdef DEBUG_VFS_LOCKS -void vop_fplookup_vexec_pre(void *a); -void vop_fplookup_vexec_post(void *a, int rc); -void vop_strategy_pre(void *a); -void vop_lock_pre(void *a); -void vop_lock_post(void *a, int rc); -void vop_unlock_pre(void *a); -void vop_need_inactive_pre(void *a); -void vop_need_inactive_post(void *a, int rc); +void vop_fplookup_vexec_debugpre(void *a); +void vop_fplookup_vexec_debugpost(void *a, int rc); +void vop_strategy_debugpre(void *a); +void vop_lock_debugpre(void *a); +void vop_lock_debugpost(void *a, int rc); +void vop_unlock_debugpre(void *a); +void vop_need_inactive_debugpre(void *a); +void vop_need_inactive_debugpost(void *a, int rc); #else -#define vop_fplookup_vexec_pre(x) do { } while (0) -#define vop_fplookup_vexec_post(x, y) do { } while (0) -#define vop_strategy_pre(x) do { } while (0) -#define vop_lock_pre(x) do { } while (0) -#define vop_lock_post(x, y) do { } while (0) -#define vop_unlock_pre(x) do { } while (0) -#define vop_need_inactive_pre(x) do { } while (0) -#define vop_need_inactive_post(x, y) do { } while (0) +#define vop_fplookup_vexec_debugpre(x) do { } while (0) +#define vop_fplookup_vexec_debugpost(x, y) do { } while (0) +#define vop_strategy_debugpre(x) do { } while (0) +#define vop_lock_debugpre(x) do { } while (0) +#define vop_lock_debugpost(x, y) do { } while (0) +#define vop_unlock_debugpre(x) do { } while (0) +#define vop_need_inactive_debugpre(x) do { } while (0) +#define vop_need_inactive_debugpost(x, y) do { } while (0) #endif void vop_rename_fail(struct vop_rename_args *ap); Modified: head/sys/tools/vnode_if.awk ============================================================================== --- head/sys/tools/vnode_if.awk Thu Jul 30 15:48:56 2020 (r363707) +++ head/sys/tools/vnode_if.awk Thu Jul 30 15:50:51 2020 (r363708) @@ -87,6 +87,24 @@ function add_debug_code(name, arg, pos, ind) } } +function add_debugpre(name) +{ + if (lockdata[name, "debugpre"]) { + printc("#ifdef DEBUG_VFS_LOCKS"); + printc("\t"lockdata[name, "debugpre"]"(a);"); + printc("#endif"); + } +} + +function add_debugpost(name) +{ + if (lockdata[name, "debugpost"]) { + printc("#ifdef DEBUG_VFS_LOCKS"); + printc("\t"lockdata[name, "debugpost"]"(a, rc);"); + printc("#endif"); + } +} + function add_pre(name) { if (lockdata[name, "pre"]) { @@ -101,6 +119,15 @@ function add_post(name) } } +function can_inline(name) +{ + if (lockdata[name, "pre"]) + return 0; + if (lockdata[name, "post"]) + return 0; + return 1; +} + function find_arg_with_type (type) { for (jj = 0; jj < numargs; jj++) { @@ -213,7 +240,8 @@ while ((getline < srcfile) > 0) { if ($1 ~ /^%!/) { if (NF != 4 || - ($3 != "pre" && $3 != "post")) { + ($3 != "pre" && $3 != "post" && + $3 != "debugpre" && $3 != "debugpost")) { die("Invalid %s construction", "%!"); continue; } @@ -316,7 +344,18 @@ while ((getline < srcfile) > 0) { printh("\ta.a_gen.a_desc = &" name "_desc;"); for (i = 0; i < numargs; ++i) printh("\ta.a_" args[i] " = " args[i] ";"); + if (can_inline(name)) { + printh("\n#if !defined(DEBUG_VFS_LOCKS) && !defined(INVARIANTS) && !defined(KTR)"); + printh("\tif (!SDT_PROBES_ENABLED())"); + printh("\t\treturn (" args[0]"->v_op->"name"(&a));"); + printh("\telse"); + printh("\t\treturn (" uname "_APV("args[0]"->v_op, &a));"); + printh("#else"); + } printh("\treturn (" uname "_APV("args[0]"->v_op, &a));"); + if (can_inline(name)) + printh("#endif"); + printh("}"); printh(""); @@ -364,6 +403,7 @@ while ((getline < srcfile) > 0) { printc("\t (\"Wrong a_desc in " name "(%p, %p)\", a->a_" args[0]", a));"); printc("\tVNASSERT(vop != NULL, a->a_" args[0]", (\"No "name"(%p, %p)\", a->a_" args[0]", a));") printc("\tKTR_START" ctrstr); + add_debugpre(name); add_pre(name); for (i = 0; i < numargs; ++i) add_debug_code(name, args[i], "Entry", "\t"); @@ -382,6 +422,7 @@ while ((getline < srcfile) > 0) { add_debug_code(name, args[i], "Error", "\t\t"); printc("\t}"); add_post(name); + add_debugpost(name); printc("\tKTR_STOP" ctrstr); printc("\treturn (rc);"); printc("}\n");