Date: Thu, 30 Jul 2020 15:47:41 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363706 - in head/sys: kern sys Message-ID: <202007301547.06UFlf5J099795@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007301547.06UFlf5J099795>