From owner-freebsd-arm@freebsd.org Thu Feb 9 03:22:54 2017 Return-Path: Delivered-To: freebsd-arm@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 9C0DDCD7048 for ; Thu, 9 Feb 2017 03:22:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wr0-x232.google.com (mail-wr0-x232.google.com [IPv6:2a00:1450:400c:c0c::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3CDAABE7 for ; Thu, 9 Feb 2017 03:22:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wr0-x232.google.com with SMTP id o16so73889022wra.1 for ; Wed, 08 Feb 2017 19:22:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/jime3F92ULKOnwSXXzwJj2/Yk+7ZM6ygbDdqg0WzG8=; b=MEURP+gOVj+udmwI4wvmTe6i7auq4ZdRkwfCEII3elq82nPPZbgVUgaGOkkfOaX40m zZ0xQu7AmD0OQnqitnIXHwk8jt7gEfSfBuTn41qwK6UAgiHnvJROpZuU4ToUBGAcFGNA nhee7qMdxCTKg4tWK8Kk56vkGrK7KnqmS3GpNsEN7Hyvgiv9YioULk8qdp1x+LuBD72x Bg2PWHsH5GX702s4S1QsLxzqf2NNDozV26owTc85EjFz90LXkcCJV6rRrGIYHK1A+03I NjMx8csMwvqx6owft0kOuK6ZDeYDAqpWc2DTGmFOKGrbwVFalrN9LdFnZxGDWkvijSTA Ha7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/jime3F92ULKOnwSXXzwJj2/Yk+7ZM6ygbDdqg0WzG8=; b=lb41czD0HfsAGuhni7YCdIDBz0YbopTS1uJO33khfbIAr0t5TBUdkiuQzb35hCx1qT HFaY5Lcgms0C2kvd/M2/uZgt1VhTpPIB7N34TPDt+9IhAMlIHGYNiEHFy9sPKwJDw7NA sm9N0TCYCtSt5kVm9EP+ex3dJ/vp6iMiqFe5DQRPBdSZdWuDCGyts6sKVOFnB6OugzMm peg89dkX1cLavc0skE5jisulUovN8+oMmzVknFFiO3sK3pbAt534LLDrMtyY9uFshljb tbHl0/84oGnh/px5kK6xTsCV7Gfb688G1MGp5JMZn0vmrnJxERuvFsigy4+FDhkLop4v dlMA== X-Gm-Message-State: AMke39kV2QqJqFNvcvkrYO1kMOvhSHE7JP305401O3TEMZY0+VCMeNUCfXDUl4yrd/gSE/AHB5gLex7CvUQrDA== X-Received: by 10.223.169.112 with SMTP id u103mr620282wrc.166.1486610571348; Wed, 08 Feb 2017 19:22:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.82.162 with HTTP; Wed, 8 Feb 2017 19:22:50 -0800 (PST) In-Reply-To: <59508065.2X8Qo0R8aR@pc-alex> References: <2478341.4YUvIvO0Dr@pc-alex> <20170202160159.GN2092@kib.kiev.ua> <59508065.2X8Qo0R8aR@pc-alex> From: Adrian Chadd Date: Wed, 8 Feb 2017 19:22:50 -0800 Message-ID: Subject: Re: Counter API To: Alexandre Martins Cc: Konstantin Belousov , Freebsd arm Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Feb 2017 03:22:54 -0000 On 3 February 2017 at 05:03, Alexandre Martins wrote: > Hi Kontantin. > > Your patch compille and run great in a 32 bit environment. I don't have a= 64 > bit one to check. > > Thank you for your support. hm! Should this be committed to -head? -adrian > > Best regards > > Alexandre > > Le jeudi 2 f=C3=A9vrier 2017, 18:01:59 Konstantin Belousov a =C3=A9crit : >> On Thu, Feb 02, 2017 at 04:38:08PM +0100, Alexandre Martins wrote: >> > Hi all, >> > >> > Our companie is curently tracking performance issue with our ARM produ= ct. >> > >> > We have seen that counter API was migrated from intrinsic to atomic. >> > >> > https://svnweb.freebsd.org/base?view=3Drevision&revision=3D269406 >> > >> > But there is still the calls to critical_enter/leave in the macro >> > counter_enter/leave. >> > >> > Is that needed ? Can we remove that ? >> >> Try this. I did not even compiled the patch. >> >> diff --git a/sys/arm/include/counter.h b/sys/arm/include/counter.h >> index c4da91f7a14..950516e1616 100644 >> --- a/sys/arm/include/counter.h >> +++ b/sys/arm/include/counter.h >> @@ -31,12 +31,9 @@ >> >> #include >> #include >> -#ifdef INVARIANTS >> -#include >> -#endif >> >> -#define counter_enter() critical_enter() >> -#define counter_exit() critical_exit() >> +#define counter_enter() do {} while (0) >> +#define counter_exit() do {} while (0) >> >> #ifdef IN_SUBR_COUNTER_C >> >> @@ -55,7 +52,7 @@ counter_u64_fetch_inline(uint64_t *p) >> int i; >> >> r =3D 0; >> - for (i =3D 0; i < mp_ncpus; i++) >> + CPU_FOREACH(i) >> r +=3D counter_u64_read_one((uint64_t *)p, i); >> >> return (r); >> @@ -78,18 +75,13 @@ counter_u64_zero_inline(counter_u64_t c) >> } >> #endif >> >> -#define counter_u64_add_protected(c, inc) do { \ >> - CRITICAL_ASSERT(curthread); \ >> - atomic_add_64((uint64_t *)zpcpu_get(c), (inc)); \ >> -} while (0) >> +#define counter_u64_add_protected(c, inc) counter_u64_add(c,= inc) >> >> static inline void >> counter_u64_add(counter_u64_t c, int64_t inc) >> { >> >> - counter_enter(); >> - counter_u64_add_protected(c, inc); >> - counter_exit(); >> + atomic_add_64((uint64_t *)zpcpu_get(c), inc); >> } >> >> #endif /* ! __MACHINE_COUNTER_H__ */ >> diff --git a/sys/arm64/include/counter.h b/sys/arm64/include/counter.h >> index 9d56cce3d3d..cfa521f9b73 100644 >> --- a/sys/arm64/include/counter.h >> +++ b/sys/arm64/include/counter.h >> @@ -30,12 +30,10 @@ >> #define _MACHINE_COUNTER_H_ >> >> #include >> -#ifdef INVARIANTS >> -#include >> -#endif >> +#include >> >> -#define counter_enter() critical_enter() >> -#define counter_exit() critical_exit() >> +#define counter_enter() do {} while (0) >> +#define counter_exit() do {} while (0) >> >> #ifdef IN_SUBR_COUNTER_C >> static inline uint64_t >> @@ -52,13 +50,12 @@ counter_u64_fetch_inline(uint64_t *p) >> int i; >> >> r =3D 0; >> - for (i =3D 0; i < mp_ncpus; i++) >> + CPU_FOREACH(i) >> r +=3D counter_u64_read_one((uint64_t *)p, i); >> >> return (r); >> } >> >> -/* XXXKIB might interrupt increment */ >> static void >> counter_u64_zero_one_cpu(void *arg) >> { >> @@ -76,18 +73,13 @@ counter_u64_zero_inline(counter_u64_t c) >> } >> #endif >> >> -#define counter_u64_add_protected(c, inc) do { \ >> - CRITICAL_ASSERT(curthread); \ >> - *(uint64_t *)zpcpu_get(c) +=3D (inc); \ >> -} while (0) >> +#define counter_u64_add_protected(c, inc) counter_u64_add(c,= inc) >> >> static inline void >> counter_u64_add(counter_u64_t c, int64_t inc) >> { >> >> - counter_enter(); >> - counter_u64_add_protected(c, inc); >> - counter_exit(); >> + atomic_add_64((uint64_t *)zpcpu_get(c), inc); >> } >> >> #endif /* ! _MACHINE_COUNTER_H_ */ > > -- > Alexandre Martins > STORMSHIELD >