From owner-svn-src-head@freebsd.org Tue Mar 15 19:05:57 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1916EAD1029; Tue, 15 Mar 2016 19:05:57 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (glebi.us [96.95.210.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id DEBFE1DD0; Tue, 15 Mar 2016 19:05:56 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id u2FJ5nnD069882 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Mar 2016 12:05:49 -0700 (PDT) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id u2FJ5nUs069881; Tue, 15 Mar 2016 12:05:49 -0700 (PDT) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 15 Mar 2016 12:05:49 -0700 From: Gleb Smirnoff To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r296880 - in head: share/man/man9 sys/kern sys/sys Message-ID: <20160315190549.GT1328@FreeBSD.org> References: <201603150005.u2F050ps086390@repo.freebsd.org> <56E7BEB3.7020301@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56E7BEB3.7020301@selasky.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 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: Tue, 15 Mar 2016 19:05:57 -0000 Hans, On Tue, Mar 15, 2016 at 08:50:11AM +0100, Hans Petter Selasky wrote: H> > Modified: head/sys/sys/sysctl.h H> > ============================================================================== H> > --- head/sys/sys/sysctl.h Mon Mar 14 23:49:16 2016 (r296879) H> > +++ head/sys/sys/sysctl.h Tue Mar 15 00:05:00 2016 (r296880) H> > @@ -204,6 +204,7 @@ int sysctl_handle_long(SYSCTL_HANDLER_AR H> > int sysctl_handle_string(SYSCTL_HANDLER_ARGS); H> > int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); H> > int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS); H> > +int sysctl_handle_counter_u64_array(SYSCTL_HANDLER_ARGS); H> > H> > int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS); H> > int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS); H> > @@ -648,6 +649,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e H> > __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \ H> > }) H> > H> > +/* Oid for an array of counter(9)s. The pointer and length must be non zero. */ H> > +#define SYSCTL_COUNTER_U64_ARRAY(parent, nbr, name, access, ptr, len, descr) \ H> > + SYSCTL_OID(parent, nbr, name, \ H> > + CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ H> > + (ptr), (len), sysctl_handle_counter_u64_array, "S", descr); \ H> > + CTASSERT(((access) & CTLTYPE) == 0 || \ H> > + ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) H> > + H> H> Gleb: I suggest you follow the example of the other static SYSCTLs, and H> extend the CTASSERT to also cover the size of the array: I agree. H> CTASSERT(((access) & CTLTYPE) == 0 || \ H> (((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE && \ H> (sizeof(*(ptr)) == 8 * (len)))) Hardcoding 8 is definitely wrong here. If you come up with correct assert, feel free to commit it. I failed to imagine one quickly. H> > +#define SYSCTL_ADD_COUNTER_U64_ARRAY(ctx, parent, nbr, name, access, \ H> > + ptr, len, descr) \ H> > +({ \ H> > + counter_u64_t *__ptr = (ptr); \ H> > + CTASSERT(((access) & CTLTYPE) == 0 || \ H> > + ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ H> H> Same here possibly. Maybe extend the CTASSERT() to also cover the size H> of the array? Would limit the "len" to a constant argument though. Of course limiting len to constant for a dynamic oid is something we don't want. -- Totus tuus, Glebius.