From owner-svn-src-head@FreeBSD.ORG Fri Aug 1 23:06:39 2014 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 52A64280; Fri, 1 Aug 2014 23:06:39 +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 407F72513; Fri, 1 Aug 2014 23:06:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s71N6cU4066264; Fri, 1 Aug 2014 23:06:38 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s71N6c1a066263; Fri, 1 Aug 2014 23:06:38 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201408012306.s71N6c1a066263@svn.freebsd.org> From: Ian Lepore Date: Fri, 1 Aug 2014 23:06:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269406 - head/sys/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 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: Fri, 01 Aug 2014 23:06:39 -0000 Author: ian Date: Fri Aug 1 23:06:38 2014 New Revision: 269406 URL: http://svnweb.freebsd.org/changeset/base/269406 Log: Use atomic_load/store_64() in the arm implementation of counter(9), and remove the XXX comments about non-atomic access to the counters. Modified: head/sys/arm/include/counter.h Modified: head/sys/arm/include/counter.h ============================================================================== --- head/sys/arm/include/counter.h Fri Aug 1 22:56:41 2014 (r269405) +++ head/sys/arm/include/counter.h Fri Aug 1 23:06:38 2014 (r269406) @@ -30,6 +30,7 @@ #define __MACHINE_COUNTER_H__ #include +#include #ifdef INVARIANTS #include #endif @@ -38,12 +39,13 @@ #define counter_exit() critical_exit() #ifdef IN_SUBR_COUNTER_C -/* XXXKIB non-atomic 64bit read */ + static inline uint64_t counter_u64_read_one(uint64_t *p, int cpu) { - return (*(uint64_t *)((char *)p + sizeof(struct pcpu) * cpu)); + return (atomic_load_64((uint64_t *)((char *)p + sizeof(struct pcpu) * + cpu))); } static inline uint64_t @@ -59,13 +61,12 @@ counter_u64_fetch_inline(uint64_t *p) return (r); } -/* XXXKIB non-atomic 64bit store, might interrupt increment */ static void counter_u64_zero_one_cpu(void *arg) { - *((uint64_t *)((char *)arg + sizeof(struct pcpu) * - PCPU_GET(cpuid))) = 0; + atomic_store_64((uint64_t *)((char *)arg + sizeof(struct pcpu) * + PCPU_GET(cpuid)), 0); } static inline void @@ -79,7 +80,7 @@ counter_u64_zero_inline(counter_u64_t c) #define counter_u64_add_protected(c, inc) do { \ CRITICAL_ASSERT(curthread); \ - *(uint64_t *)zpcpu_get(c) += (inc); \ + atomic_add_64((uint64_t *)zpcpu_get(c), (inc)); \ } while (0) static inline void