From owner-svn-src-head@freebsd.org Tue Nov 20 15:08:08 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03B43113269C; Tue, 20 Nov 2018 15:08:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (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 42E51711AD; Tue, 20 Nov 2018 15:08:07 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id wAKF7uWY065222 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 20 Nov 2018 17:07:59 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua wAKF7uWY065222 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id wAKF7uFC065221; Tue, 20 Nov 2018 17:07:56 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 20 Nov 2018 17:07:56 +0200 From: Konstantin Belousov To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r340676 - in head/sys: kern sys Message-ID: <20181120150756.GD2378@kib.kiev.ua> References: <201811201458.wAKEwftP033152@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201811201458.wAKEwftP033152@repo.freebsd.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 42E51711AD X-Spamd-Result: default: False [-5.21 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_LONG(-1.00)[-0.998,0]; R_SPF_SOFTFAIL(0.00)[~all]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; IP_SCORE(-2.22)[ip: (-2.87), ipnet: 2001:470::/32(-4.57), asn: 6939(-3.58), country: US(-0.09)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; RCVD_TLS_LAST(0.00)[]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none] X-Rspamd-Server: mx1.freebsd.org 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: Tue, 20 Nov 2018 15:08:08 -0000 On Tue, Nov 20, 2018 at 02:58:41PM +0000, Mateusz Guzik wrote: > Author: mjg > Date: Tue Nov 20 14:58:41 2018 > New Revision: 340676 > URL: https://svnweb.freebsd.org/changeset/base/340676 > > Log: > Implement unr64 > > Important users of unr like tmpfs or pipes can get away with just > ever-increasing counters, making the overhead of managing the state > for 32 bit counters a pessimization. > > Change it to an atomic variable. This can be further sped up by making > the counts variable "allocate" ranges and store them per-cpu. > > Reviewed by: kib > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D18054 > > Modified: > head/sys/kern/subr_unit.c > head/sys/sys/systm.h > > Modified: head/sys/kern/subr_unit.c > ============================================================================== > --- head/sys/kern/subr_unit.c Tue Nov 20 14:52:43 2018 (r340675) > +++ head/sys/kern/subr_unit.c Tue Nov 20 14:58:41 2018 (r340676) > @@ -98,6 +98,19 @@ static struct mtx unitmtx; > > MTX_SYSINIT(unit, &unitmtx, "unit# allocation", MTX_DEF); > > +#ifdef UNR64_LOCKED > +uint64_t > +alloc_unr64(struct unrhdr64 *unr64) > +{ > + uint64_t item; > + > + mtx_lock(&unitmtx); > + item = unr64->counter++; > + mtx_unlock(&unitmtx); > + return (item); > +} > +#endif > + > #else /* ...USERLAND */ > > #include > > Modified: head/sys/sys/systm.h > ============================================================================== > --- head/sys/sys/systm.h Tue Nov 20 14:52:43 2018 (r340675) > +++ head/sys/sys/systm.h Tue Nov 20 14:58:41 2018 (r340676) > @@ -523,6 +523,32 @@ int alloc_unr_specific(struct unrhdr *uh, u_int item); > int alloc_unrl(struct unrhdr *uh); > void free_unr(struct unrhdr *uh, u_int item); > > +#if defined(__mips__) || defined(__powerpc__) Please note what I asked about this #ifdefs in the review. mips and powerpc machine/atomic.h should define some symbol like __ATOMIC_NO_64_OPS and this case should be handled in less arch-explicit manner. > +#define UNR64_LOCKED > +#endif > + > +struct unrhdr64 { > + uint64_t counter; > +}; > + > +static __inline void > +new_unrhdr64(struct unrhdr64 *unr64, uint64_t low) > +{ > + > + unr64->counter = low; > +} > + > +#ifdef UNR64_LOCKED > +uint64_t alloc_unr64(struct unrhdr64 *); > +#else > +static __inline uint64_t > +alloc_unr64(struct unrhdr64 *unr64) > +{ > + > + return (atomic_fetchadd_64(&unr64->counter, 1)); > +} > +#endif > + > void intr_prof_stack_use(struct thread *td, struct trapframe *frame); > > void counted_warning(unsigned *counter, const char *msg);