Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 03 Feb 2017 14:03:56 +0100
From:      Alexandre Martins <alexandre.martins@stormshield.eu>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Freebsd arm <freebsd-arm@freebsd.org>
Subject:   Re: Counter API
Message-ID:  <59508065.2X8Qo0R8aR@pc-alex>
In-Reply-To: <20170202160159.GN2092@kib.kiev.ua>
References:  <2478341.4YUvIvO0Dr@pc-alex> <20170202160159.GN2092@kib.kiev.ua>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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.

Best regards

Alexandre

Le jeudi 2 fvrier 2017, 18:01:59 Konstantin Belousov a crit :
> 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 product.
> > 
> > We have seen that counter API was migrated from intrinsic to atomic.
> > 
> > https://svnweb.freebsd.org/base?view=revision&revision=269406
> > 
> > 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 <sys/pcpu.h>
>  #include <machine/atomic.h>
> -#ifdef INVARIANTS
> -#include <sys/proc.h>
> -#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 = 0;
> -	for (i = 0; i < mp_ncpus; i++)
> +	CPU_FOREACH(i)
>  		r += 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 <sys/pcpu.h>
> -#ifdef INVARIANTS
> -#include <sys/proc.h>
> -#endif
> +#include <machine/atomic.h>
> 
> -#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 = 0;
> -	for (i = 0; i < mp_ncpus; i++)
> +	CPU_FOREACH(i)
>  		r += 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) += (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


[-- Attachment #2 --]
0	*H
010
	`He0	*H
00n0
	*H
0H10	UFR10U
STORMSHIELD1#0!UStormshield Root Authority0
140904150710Z
240901150710Z0I10	UFR10U
STORMSHIELD1$0"UStormshield Users Authority0"0
	*H
0
‡X6[t.DUge0-2;h@eȻClΫpB#M,FY=.{ya{2πߢ
7	<d~O;ޅԋ&C8ُ6@CXX>|abqenmI,	O—&'۰@%OhW&
{52D%_8#f]G0ct y\v0t0Uml||uu4[ׁ0U#0BgDaP0U00U0	`HB0
	*H
N9-؞>m-K!M-7zD6IZʾr>q?u
?xr6_'NջZ7]V\5Y&))m@~^Qdp/H3ͦ`o⬋U,z,0Bdp!C2K8.r>0-1!C%3U2ϠMg~3͟wͲAZ&vF/BA$_ڀV!
s7)=-nP>qH~g/Rs,PAJVm#QXJo
*/󞁃V|sĿj~y߽j
3]v3ƌqe`Y|HB3lC!^J2$4A`Z+(7b{e˄wʈ<L=6[3`>IQFaiܝ ?:_yԊ
/`0W0?(˻0
	*H
0I10	UFR10U
STORMSHIELD1$0"UStormshield Users Authority0
160901151108Z
170901151108Z0p10	UFR10U
STORMSHIELD10UAlexandre MARTINS1/0-	*H
	 alexandre.martins@stormshield.eu0"0
	*H
0
~
{x~;#3BgXC[rSVuv#>aL0w}""v`B)Db8qHkH\dqB6rd|:%Ze[wi3)$! hXε<صVO}#
EjJegk0%L퉬Q'b}3"*(_T-
w?gR	H,\aWO4Ǘ
Y3TR(Wn7Sv1n8xIan	00UD0IM_W]A$v#<0U#0ml||uu4[ׁ0	U00U0	`HB0U%0++0JUC0A0?=;9https://pki.netasq.com/auth/certificaterevocationlist.crl0U 
00U 0+U$0" alexandre.martins@stormshield.eu0
	*H
5hhN
̛U9œ2+Ejr@|f{`J2X!ȳ.ڤ|^*$"vlHtSeeAܟ-bC$*)ЖWJL >5@|N%·%{i-4akG앏]%.ݤp]7B/
*1WE@zZoq@fk0NpHObD$9jXḓSk~LKX100R0I10	UFR10U
STORMSHIELD1$0"UStormshield Users Authority(˻0
	`He0	*H
	1	*H
0	*H
	1
170203130356Z0(	*H
	100	`He0
*H
0/	*H
	1"  !x2>AzPxWD0
	*H
_f{#{Z|`jwj`:l-PO|ۮ\qIV"~#ȣ@yaZ"Ux_AZlF9x3"4^~n6>nkr(M	_' f>M;:w.SA$lFYNX]Ďp|>sGtcsE1Ô׸!g8 m3~8T8SF74YMR
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?59508065.2X8Qo0R8aR>