From owner-svn-src-head@freebsd.org Thu Dec 5 05:01:09 2019 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 55D181BAD3B; Thu, 5 Dec 2019 05:01:09 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47T3TK1YKlz3HB5; Thu, 5 Dec 2019 05:01:09 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from [172.17.133.228] (unknown [12.202.168.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 9B998EEF3; Thu, 5 Dec 2019 05:01:08 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/10.1f.0.191110 Date: Wed, 04 Dec 2019 21:00:59 -0800 Subject: Re: svn commit: r355412 - head/sys/geom From: Ravi Pokala To: Alexander Motin , , , Message-ID: <516874DA-E57F-4EAA-852B-1129A95BB998@panasas.com> Thread-Topic: svn commit: r355412 - head/sys/geom References: <201912050452.xB54qKV0080126@repo.freebsd.org> In-Reply-To: <201912050452.xB54qKV0080126@repo.freebsd.org> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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, 05 Dec 2019 05:01:09 -0000 -----Original Message----- From: on behalf of Alexander Motin Date: 2019-12-04, Wednesday at 20:52 To: , , Subject: svn commit: r355412 - head/sys/geom Author: mav Date: Thu Dec 5 04:52:19 2019 New Revision: 355412 URL: https://svnweb.freebsd.org/changeset/base/355412 Log: 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. Hi Alexander, I'm having trouble understanding this change, on a few levels. - Why did you add parentheses around the function declaration and definition? - How can that function with that name co-exist with a macro of the same name? - Isn't the "g_debugflags" test in geom_dump.c:g_trace() now redundant? - Why not simply convert geom_dump.c:g_trace() into a 'static inline' in geom.h, and not have to bother with the macro at all? What am I missing? Thanks, Ravi (rpokala@) MFC after: 2 weeks Sponsored by: iXsystems, Inc. Modified: head/sys/geom/geom.h head/sys/geom/geom_dump.c Modified: head/sys/geom/geom.h ============================================================================== --- head/sys/geom/geom.h Thu Dec 5 04:18:22 2019 (r355411) +++ head/sys/geom/geom.h Thu Dec 5 04:52:19 2019 (r355412) @@ -255,11 +255,15 @@ 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 *, ...); +void (g_trace)(int level, const char *, ...) __printflike(2, 3); # define G_T_TOPOLOGY 1 # define G_T_BIO 2 # define G_T_ACCESS 4 - +extern int g_debugflags; +#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: head/sys/geom/geom_dump.c ============================================================================== --- head/sys/geom/geom_dump.c Thu Dec 5 04:18:22 2019 (r355411) +++ head/sys/geom/geom_dump.c Thu Dec 5 04:52:19 2019 (r355412) @@ -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;