From owner-svn-src-stable-12@freebsd.org Thu Dec 19 01:28:08 2019 Return-Path: Delivered-To: svn-src-stable-12@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 1040E1CD778; Thu, 19 Dec 2019 01:28:08 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) 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 47dZ536lgRz41fB; Thu, 19 Dec 2019 01:28:07 +0000 (UTC) (envelope-from mav@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 E2EE17065; Thu, 19 Dec 2019 01:28:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBJ1S7so037303; Thu, 19 Dec 2019 01:28:07 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBJ1S6cR037296; Thu, 19 Dec 2019 01:28:06 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201912190128.xBJ1S6cR037296@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Dec 2019 01:28:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r355892 - in stable/12/sys/geom: . mirror part X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys/geom: . mirror part X-SVN-Commit-Revision: 355892 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Dec 2019 01:28:08 -0000 Author: mav Date: Thu Dec 19 01:28:05 2019 New Revision: 355892 URL: https://svnweb.freebsd.org/changeset/base/355892 Log: MFC r355412, r355420: Wrap g_trace() into a macro to avoid unneeded calls. In most cases with debug disabled this function does nothing, but argument passing and the call still cost measurable time due to cache misses, etc. While there, define G_F_FOOTSHOOTING instead of numeric constants. Modified: stable/12/sys/geom/geom.h stable/12/sys/geom/geom_dump.c stable/12/sys/geom/geom_int.h stable/12/sys/geom/geom_subr.c stable/12/sys/geom/mirror/g_mirror_ctl.c stable/12/sys/geom/part/g_part.c stable/12/sys/geom/part/g_part_mbr.c stable/12/sys/geom/part/g_part_vtoc8.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/geom/geom.h ============================================================================== --- stable/12/sys/geom/geom.h Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/geom.h Thu Dec 19 01:28:05 2019 (r355892) @@ -255,11 +255,18 @@ void g_dev_physpath_changed(void); struct g_provider *g_dev_getprovider(struct cdev *dev); /* geom_dump.c */ -void g_trace(int level, const char *, ...); -# define G_T_TOPOLOGY 1 -# define G_T_BIO 2 -# define G_T_ACCESS 4 - +void (g_trace)(int level, const char *, ...) __printflike(2, 3); +#define G_T_TOPOLOGY 0x01 +#define G_T_BIO 0x02 +#define G_T_ACCESS 0x04 +extern int g_debugflags; +#define G_F_FOOTSHOOTING 0x10 +#define G_F_DISKIOCTL 0x40 +#define G_F_CTLDUMP 0x80 +#define g_trace(level, fmt, ...) do { \ + if (__predict_false(g_debugflags & (level))) \ + (g_trace)(level, fmt, ## __VA_ARGS__); \ +} while (0) /* geom_event.c */ typedef void g_event_t(void *, int flag); Modified: stable/12/sys/geom/geom_dump.c ============================================================================== --- stable/12/sys/geom/geom_dump.c Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/geom_dump.c Thu Dec 19 01:28:05 2019 (r355892) @@ -319,7 +319,7 @@ g_confxml(void *p, int flag) } void -g_trace(int level, const char *fmt, ...) +(g_trace)(int level, const char *fmt, ...) { va_list ap; Modified: stable/12/sys/geom/geom_int.h ============================================================================== --- stable/12/sys/geom/geom_int.h Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/geom_int.h Thu Dec 19 01:28:05 2019 (r355892) @@ -44,18 +44,6 @@ extern int g_collectstats; #define G_STATS_PROVIDERS 1 /* Collect I/O stats for providers */ #define G_STATS_CONSUMERS 2 /* Collect I/O stats for consumers */ -extern int g_debugflags; -/* - * 1 G_T_TOPOLOGY - * 2 G_T_BIO - * 4 G_T_ACCESS - * 8 (unused) - * 16 Allow footshooting on rank#1 providers - * 32 G_T_DETAILS - */ -#define G_F_DISKIOCTL 64 -#define G_F_CTLDUMP 128 - /* geom_dump.c */ void g_confxml(void *, int flag); void g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp); Modified: stable/12/sys/geom/geom_subr.c ============================================================================== --- stable/12/sys/geom/geom_subr.c Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/geom_subr.c Thu Dec 19 01:28:05 2019 (r355892) @@ -944,7 +944,7 @@ g_access(struct g_consumer *cp, int dcr, int dcw, int pp, pp->name); /* If foot-shooting is enabled, any open on rank#1 is OK */ - if ((g_debugflags & 16) && gp->rank == 1) + if ((g_debugflags & G_F_FOOTSHOOTING) && gp->rank == 1) ; /* If we try exclusive but already write: fail */ else if (dce > 0 && pw > 0) Modified: stable/12/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- stable/12/sys/geom/mirror/g_mirror_ctl.c Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/mirror/g_mirror_ctl.c Thu Dec 19 01:28:05 2019 (r355892) @@ -852,7 +852,7 @@ g_mirror_ctl_resize(struct gctl_req *req, struct g_cla return; } /* Deny shrinking of an opened provider */ - if ((g_debugflags & 16) == 0 && sc->sc_provider_open > 0) { + if ((g_debugflags & G_F_FOOTSHOOTING) == 0 && sc->sc_provider_open > 0) { if (sc->sc_mediasize > mediasize) { gctl_error(req, "Device %s is busy.", sc->sc_provider->name); Modified: stable/12/sys/geom/part/g_part.c ============================================================================== --- stable/12/sys/geom/part/g_part.c Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/part/g_part.c Thu Dec 19 01:28:05 2019 (r355892) @@ -1383,7 +1383,7 @@ g_part_ctl_resize(struct gctl_req *req, struct g_part_ } pp = entry->gpe_pp; - if ((g_debugflags & 16) == 0 && + if ((g_debugflags & G_F_FOOTSHOOTING) == 0 && (pp->acr > 0 || pp->acw > 0 || pp->ace > 0)) { if (entry->gpe_end - entry->gpe_start + 1 > gpp->gpp_size) { /* Deny shrinking of an opened partition. */ Modified: stable/12/sys/geom/part/g_part_mbr.c ============================================================================== --- stable/12/sys/geom/part/g_part_mbr.c Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/part/g_part_mbr.c Thu Dec 19 01:28:05 2019 (r355892) @@ -381,7 +381,7 @@ g_part_mbr_resize(struct g_part_table *basetable, return (EINVAL); /* XXX: prevent unexpected shrinking. */ pp = baseentry->gpe_pp; - if ((g_debugflags & 0x10) == 0 && size < gpp->gpp_size && + if ((g_debugflags & G_F_FOOTSHOOTING) == 0 && size < gpp->gpp_size && pp->mediasize / pp->sectorsize > size) return (EBUSY); entry = (struct g_part_mbr_entry *)baseentry; Modified: stable/12/sys/geom/part/g_part_vtoc8.c ============================================================================== --- stable/12/sys/geom/part/g_part_vtoc8.c Thu Dec 19 01:25:44 2019 (r355891) +++ stable/12/sys/geom/part/g_part_vtoc8.c Thu Dec 19 01:28:05 2019 (r355892) @@ -373,7 +373,7 @@ g_part_vtoc8_resize(struct g_part_table *basetable, return (EINVAL); /* XXX: prevent unexpected shrinking. */ pp = entry->gpe_pp; - if ((g_debugflags & 0x10) == 0 && size < gpp->gpp_size && + if ((g_debugflags & G_F_FOOTSHOOTING) == 0 && size < gpp->gpp_size && pp->mediasize / pp->sectorsize > size) return (EBUSY); entry->gpe_end = entry->gpe_start + size - 1;