From owner-svn-src-head@freebsd.org Thu Jul 30 15:47:42 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 402233A8EA4; Thu, 30 Jul 2020 15:47:42 +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 4BHZYV14WNz4XN4; Thu, 30 Jul 2020 15:47:42 +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 0930D135E8; Thu, 30 Jul 2020 15:47:42 +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 06UFlfU3099797; Thu, 30 Jul 2020 15:47:41 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06UFlf5J099795; Thu, 30 Jul 2020 15:47:41 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <202007301547.06UFlf5J099795@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:47:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363706 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 363706 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:47:42 -0000 Author: mjg Date: Thu Jul 30 15:47:41 2020 New Revision: 363706 URL: https://svnweb.freebsd.org/changeset/base/363706 Log: vfs: short-circuit the common case NDFREE calls Almost all consumers use the NDF_ONLY_PNBUF macro, making them avoidably branch a lot in the NDFREE routine. Also note most of them should not need to call any cleanup anyway as they don't request HASBUF. Modified: head/sys/kern/vfs_lookup.c head/sys/sys/namei.h Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Thu Jul 30 15:45:11 2020 (r363705) +++ head/sys/kern/vfs_lookup.c Thu Jul 30 15:47:41 2020 (r363706) @@ -1390,18 +1390,26 @@ NDINIT_ALL(struct nameidata *ndp, u_long op, u_long fl * Free data allocated by namei(); see namei(9) for details. */ void -NDFREE(struct nameidata *ndp, const u_int flags) +NDFREE_PNBUF(struct nameidata *ndp) { + + if ((ndp->ni_cnd.cn_flags & HASBUF) != 0) { + uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf); + ndp->ni_cnd.cn_flags &= ~HASBUF; + } +} + +void +(NDFREE)(struct nameidata *ndp, const u_int flags) +{ int unlock_dvp; int unlock_vp; unlock_dvp = 0; unlock_vp = 0; - if (!(flags & NDF_NO_FREE_PNBUF) && - (ndp->ni_cnd.cn_flags & HASBUF)) { - uma_zfree(namei_zone, ndp->ni_cnd.cn_pnbuf); - ndp->ni_cnd.cn_flags &= ~HASBUF; + if (!(flags & NDF_NO_FREE_PNBUF)) { + NDFREE_PNBUF(ndp); } if (!(flags & NDF_NO_VP_UNLOCK) && (ndp->ni_cnd.cn_flags & LOCKLEAF) && ndp->ni_vp) Modified: head/sys/sys/namei.h ============================================================================== --- head/sys/sys/namei.h Thu Jul 30 15:45:11 2020 (r363705) +++ head/sys/sys/namei.h Thu Jul 30 15:47:41 2020 (r363706) @@ -210,7 +210,15 @@ void NDINIT_ALL(struct nameidata *ndp, u_long op, u_lo #define NDF_NO_FREE_PNBUF 0x00000020 #define NDF_ONLY_PNBUF (~NDF_NO_FREE_PNBUF) +void NDFREE_PNBUF(struct nameidata *); void NDFREE(struct nameidata *, const u_int); +#define NDFREE(ndp, flags) do { \ + struct nameidata *_ndp = (ndp); \ + if (__builtin_constant_p(flags) && flags == NDF_ONLY_PNBUF) \ + NDFREE_PNBUF(_ndp); \ + else \ + NDFREE(_ndp, flags); \ +} while (0) int namei(struct nameidata *ndp); int lookup(struct nameidata *ndp);