From owner-svn-src-head@FreeBSD.ORG Wed Jan 21 20:12:36 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 794DE15D; Wed, 21 Jan 2015 20:12:36 +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)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6556A8A0; Wed, 21 Jan 2015 20:12:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0LKCapp005879; Wed, 21 Jan 2015 20:12:36 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0LKCZAd005877; Wed, 21 Jan 2015 20:12:36 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201501212012.t0LKCZAd005877@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Wed, 21 Jan 2015 20:12:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r277512 - in head/sys/arm: arm include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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: Wed, 21 Jan 2015 20:12:36 -0000 Author: ian Date: Wed Jan 21 20:12:35 2015 New Revision: 277512 URL: https://svnweb.freebsd.org/changeset/base/277512 Log: Micro-optimize the new arm inline bus_space implementation by grouping all the data the inline functions access together at the start of the bus_space struct. The start-of part isn't so important, it's the grouping-together that's the point: now all the most-accessed data should be in one cache line. Suggested by: cognet Modified: head/sys/arm/arm/bus_space_base.c head/sys/arm/include/bus.h Modified: head/sys/arm/arm/bus_space_base.c ============================================================================== --- head/sys/arm/arm/bus_space_base.c Wed Jan 21 20:08:24 2015 (r277511) +++ head/sys/arm/arm/bus_space_base.c Wed Jan 21 20:12:35 2015 (r277512) @@ -150,7 +150,7 @@ static struct bus_space arm_base_bus_spa .bs_wr_2_s = generic_bs_wr_2, .bs_wr_4_s = generic_bs_wr_4, .bs_wr_8_s = BS_UNIMPLEMENTED, -}; +} __aligned(CACHE_LINE_SIZE); #ifdef FDT bus_space_tag_t fdtbus_bs_tag = &arm_base_bus_space; Modified: head/sys/arm/include/bus.h ============================================================================== --- head/sys/arm/include/bus.h Wed Jan 21 20:08:24 2015 (r277511) +++ head/sys/arm/include/bus.h Wed Jan 21 20:12:35 2015 (r277512) @@ -79,9 +79,27 @@ #define BUS_SPACE_MAP_LINEAR 0x02 #define BUS_SPACE_MAP_PREFETCHABLE 0x04 +/* + * Bus space for ARM. + * + * The functions used most often are grouped together at the beginning to ensure + * that all the data fits into a single cache line. The inline implementations + * of single read/write access these values a lot. + */ struct bus_space { - /* cookie */ - void *bs_privdata; + /* Read/write single and barrier: the most commonly used functions. */ + uint8_t (*bs_r_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t); + uint32_t (*bs_r_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t); + void (*bs_w_1)(bus_space_tag_t, bus_space_handle_t, + bus_size_t, uint8_t); + void (*bs_w_4)(bus_space_tag_t, bus_space_handle_t, + bus_size_t, uint32_t); + void (*bs_barrier)(bus_space_tag_t, bus_space_handle_t, + bus_size_t, bus_size_t, int); + + /* Backlink to parent (if copied), and implementation private data. */ + struct bus_space *bs_parent; + void *bs_privdata; /* mapping/unmapping */ int (*bs_map) (bus_space_tag_t, bus_addr_t, bus_size_t, @@ -97,15 +115,8 @@ struct bus_space { void (*bs_free) (bus_space_tag_t, bus_space_handle_t, bus_size_t); - /* get kernel virtual address */ - /* barrier */ - void (*bs_barrier) (bus_space_tag_t, bus_space_handle_t, - bus_size_t, bus_size_t, int); - - /* read (single) */ - uint8_t (*bs_r_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t); + /* Read single, the less commonly used functions. */ uint16_t (*bs_r_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t); - uint32_t (*bs_r_4) (bus_space_tag_t, bus_space_handle_t, bus_size_t); uint64_t (*bs_r_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t); /* read multiple */ @@ -128,13 +139,9 @@ struct bus_space { void (*bs_rr_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t, uint64_t *, bus_size_t); - /* write (single) */ - void (*bs_w_1) (bus_space_tag_t, bus_space_handle_t, - bus_size_t, uint8_t); + /* Write single, the less commonly used functions. */ void (*bs_w_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t, uint16_t); - void (*bs_w_4) (bus_space_tag_t, bus_space_handle_t, - bus_size_t, uint32_t); void (*bs_w_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t, uint64_t);