From owner-svn-src-all@freebsd.org Tue Mar 15 07:47:36 2016 Return-Path: Delivered-To: svn-src-all@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 32F91AD154F; Tue, 15 Mar 2016 07:47:36 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F166F758; Tue, 15 Mar 2016 07:47:35 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (unknown [62.141.129.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 2B7E61FE024; Tue, 15 Mar 2016 08:47:24 +0100 (CET) Subject: Re: svn commit: r296880 - in head: share/man/man9 sys/kern sys/sys To: Gleb Smirnoff , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201603150005.u2F050ps086390@repo.freebsd.org> From: Hans Petter Selasky Message-ID: <56E7BEB3.7020301@selasky.org> Date: Tue, 15 Mar 2016 08:50:11 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <201603150005.u2F050ps086390@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2016 07:47:36 -0000 On 03/15/16 01:05, Gleb Smirnoff wrote: > Author: glebius > Date: Tue Mar 15 00:05:00 2016 > New Revision: 296880 > URL: https://svnweb.freebsd.org/changeset/base/296880 > > Log: > Provide sysctl(9) macro to deal with array of counter(9). > > Modified: > head/share/man/man9/counter.9 > head/sys/kern/subr_counter.c > head/sys/sys/sysctl.h > > Modified: head/sys/sys/sysctl.h > ============================================================================== > --- head/sys/sys/sysctl.h Mon Mar 14 23:49:16 2016 (r296879) > +++ head/sys/sys/sysctl.h Tue Mar 15 00:05:00 2016 (r296880) > @@ -204,6 +204,7 @@ int sysctl_handle_long(SYSCTL_HANDLER_AR > int sysctl_handle_string(SYSCTL_HANDLER_ARGS); > int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); > int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS); > +int sysctl_handle_counter_u64_array(SYSCTL_HANDLER_ARGS); > > int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS); > int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS); > @@ -648,6 +649,26 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e > __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \ > }) > > +/* Oid for an array of counter(9)s. The pointer and length must be non zero. */ > +#define SYSCTL_COUNTER_U64_ARRAY(parent, nbr, name, access, ptr, len, descr) \ > + SYSCTL_OID(parent, nbr, name, \ > + CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ > + (ptr), (len), sysctl_handle_counter_u64_array, "S", descr); \ > + CTASSERT(((access) & CTLTYPE) == 0 || \ > + ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) > + Gleb: I suggest you follow the example of the other static SYSCTLs, and extend the CTASSERT to also cover the size of the array: CTASSERT(((access) & CTLTYPE) == 0 || \ (((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE && \ (sizeof(*(ptr)) == 8 * (len)))) > +#define SYSCTL_ADD_COUNTER_U64_ARRAY(ctx, parent, nbr, name, access, \ > + ptr, len, descr) \ > +({ \ > + counter_u64_t *__ptr = (ptr); \ > + CTASSERT(((access) & CTLTYPE) == 0 || \ > + ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ Same here possibly. Maybe extend the CTASSERT() to also cover the size of the array? Would limit the "len" to a constant argument though. > + sysctl_add_oid(ctx, parent, nbr, name, \ > + CTLTYPE_OPAQUE | CTLFLAG_MPSAFE | (access), \ > + __ptr, len, sysctl_handle_counter_u64_array, "S", \ > + __DESCR(descr)); \ > +}) > + > /* Oid for an opaque object. Specified by a pointer and a length. */ > #define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ --HPS