From owner-svn-src-all@FreeBSD.ORG Tue Mar 4 14:46:32 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 59A6A865; Tue, 4 Mar 2014 14:46:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 394D9E2E; Tue, 4 Mar 2014 14:46:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s24EkWUY051053; Tue, 4 Mar 2014 14:46:32 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s24EkVOA051044; Tue, 4 Mar 2014 14:46:31 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201403041446.s24EkVOA051044@svn.freebsd.org> From: Gleb Smirnoff Date: Tue, 4 Mar 2014 14:46:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r262739 - in stable/10/sys: kern sys vm X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 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, 04 Mar 2014 14:46:32 -0000 Author: glebius Date: Tue Mar 4 14:46:30 2014 New Revision: 262739 URL: http://svnweb.freebsd.org/changeset/base/262739 Log: Merge r261722, r261723, r261724, r261725 from head: several minor improvements for UMA_ZPCPU_ZONE zones. Modified: stable/10/sys/kern/subr_counter.c stable/10/sys/kern/subr_pcpu.c stable/10/sys/sys/pcpu.h stable/10/sys/vm/uma.h stable/10/sys/vm/uma_core.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/subr_counter.c ============================================================================== --- stable/10/sys/kern/subr_counter.c Tue Mar 4 14:23:58 2014 (r262738) +++ stable/10/sys/kern/subr_counter.c Tue Mar 4 14:46:30 2014 (r262739) @@ -41,8 +41,6 @@ __FBSDID("$FreeBSD$"); #define IN_SUBR_COUNTER_C #include -static uma_zone_t uint64_pcpu_zone; - void counter_u64_zero(counter_u64_t c) { @@ -62,7 +60,7 @@ counter_u64_alloc(int flags) { counter_u64_t r; - r = uma_zalloc(uint64_pcpu_zone, flags); + r = uma_zalloc(pcpu_zone_64, flags); if (r != NULL) counter_u64_zero(r); @@ -73,7 +71,7 @@ void counter_u64_free(counter_u64_t c) { - uma_zfree(uint64_pcpu_zone, c); + uma_zfree(pcpu_zone_64, c); } int @@ -96,12 +94,3 @@ sysctl_handle_counter_u64(SYSCTL_HANDLER return (0); } - -static void -counter_startup(void) -{ - - uint64_pcpu_zone = uma_zcreate("uint64 pcpu", sizeof(uint64_t), - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU); -} -SYSINIT(counter, SI_SUB_KMEM, SI_ORDER_ANY, counter_startup, NULL); Modified: stable/10/sys/kern/subr_pcpu.c ============================================================================== --- stable/10/sys/kern/subr_pcpu.c Tue Mar 4 14:23:58 2014 (r262738) +++ stable/10/sys/kern/subr_pcpu.c Tue Mar 4 14:46:30 2014 (r262739) @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include static MALLOC_DEFINE(M_PCPU, "Per-cpu", "Per-cpu resource accouting."); @@ -127,6 +128,30 @@ dpcpu_startup(void *dummy __unused) SYSINIT(dpcpu, SI_SUB_KLD, SI_ORDER_FIRST, dpcpu_startup, 0); /* + * UMA_PCPU_ZONE zones, that are available for all kernel + * consumers. Right now 64 bit zone is used for counter(9) + * and pointer zone is used by flowtable. + */ + +uma_zone_t pcpu_zone_64; +uma_zone_t pcpu_zone_ptr; + +static void +pcpu_zones_startup(void) +{ + + pcpu_zone_64 = uma_zcreate("64 pcpu", sizeof(uint64_t), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU); + + if (sizeof(uint64_t) == sizeof(void *)) + pcpu_zone_ptr = pcpu_zone_64; + else + pcpu_zone_ptr = uma_zcreate("ptr pcpu", sizeof(void *), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_PCPU); +} +SYSINIT(pcpu_zones, SI_SUB_KMEM, SI_ORDER_ANY, pcpu_zones_startup, NULL); + +/* * First-fit extent based allocator for allocating space in the per-cpu * region reserved for modules. This is only intended for use by the * kernel linkers to place module linker sets. Modified: stable/10/sys/sys/pcpu.h ============================================================================== --- stable/10/sys/sys/pcpu.h Tue Mar 4 14:23:58 2014 (r262738) +++ stable/10/sys/sys/pcpu.h Tue Mar 4 14:46:30 2014 (r262739) @@ -210,6 +210,13 @@ zpcpu_get(void *base) return ((char *)(base) + sizeof(struct pcpu) * curcpu); } +static inline void * +zpcpu_get_cpu(void *base, int cpu) +{ + + return ((char *)(base) + sizeof(struct pcpu) * cpu); +} + /* * Machine dependent callouts. cpu_pcpu_init() is responsible for * initializing machine dependent fields of struct pcpu, and Modified: stable/10/sys/vm/uma.h ============================================================================== --- stable/10/sys/vm/uma.h Tue Mar 4 14:23:58 2014 (r262738) +++ stable/10/sys/vm/uma.h Tue Mar 4 14:46:30 2014 (r262739) @@ -33,8 +33,8 @@ * */ -#ifndef VM_UMA_H -#define VM_UMA_H +#ifndef _VM_UMA_H_ +#define _VM_UMA_H_ #include /* For NULL */ #include /* For M_* */ @@ -636,6 +636,12 @@ int uma_zone_exhausted(uma_zone_t zone); int uma_zone_exhausted_nolock(uma_zone_t zone); /* + * Common UMA_ZONE_PCPU zones. + */ +extern uma_zone_t pcpu_zone_64; +extern uma_zone_t pcpu_zone_ptr; + +/* * Exported statistics structures to be used by user space monitoring tools. * Statistics stream consists of a uma_stream_header, followed by a series of * alternative uma_type_header and uma_type_stat structures. @@ -683,4 +689,4 @@ struct uma_percpu_stat { uint64_t _ups_reserved[5]; /* Reserved. */ }; -#endif +#endif /* _VM_UMA_H_ */ Modified: stable/10/sys/vm/uma_core.c ============================================================================== --- stable/10/sys/vm/uma_core.c Tue Mar 4 14:23:58 2014 (r262738) +++ stable/10/sys/vm/uma_core.c Tue Mar 4 14:46:30 2014 (r262739) @@ -264,6 +264,7 @@ static uma_keg_t uma_kcreate(uma_zone_t uma_fini fini, int align, uint32_t flags); static int zone_import(uma_zone_t zone, void **bucket, int max, int flags); static void zone_release(uma_zone_t zone, void **bucket, int cnt); +static void uma_zero_item(void *item, uma_zone_t zone); void uma_print_zone(uma_zone_t); void uma_print_stats(void); @@ -2167,7 +2168,7 @@ zalloc_start: uma_dbg_alloc(zone, NULL, item); #endif if (flags & M_ZERO) - bzero(item, zone->uz_size); + uma_zero_item(item, zone); return (item); } @@ -2617,7 +2618,7 @@ zone_alloc_item(uma_zone_t zone, void *u uma_dbg_alloc(zone, NULL, item); #endif if (flags & M_ZERO) - bzero(item, zone->uz_size); + uma_zero_item(item, zone); return (item); @@ -3234,6 +3235,17 @@ uma_large_free(uma_slab_t slab) zone_free_item(slabzone, slab, NULL, SKIP_NONE); } +static void +uma_zero_item(void *item, uma_zone_t zone) +{ + + if (zone->uz_flags & UMA_ZONE_PCPU) { + for (int i = 0; i < mp_ncpus; i++) + bzero(zpcpu_get_cpu(item, i), zone->uz_size); + } else + bzero(item, zone->uz_size); +} + void uma_print_stats(void) {