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>
next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart2440787.jo5CHQqg38 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Hi Kontantin. Your patch compille and run great in a 32 bit environment. I don't have= a 64=20 bit one to check. Thank you for your support. Best regards Alexandre Le jeudi 2 f=E9vrier 2017, 18:01:59 Konstantin Belousov a =E9crit : > On Thu, Feb 02, 2017 at 04:38:08PM +0100, Alexandre Martins wrote: > > Hi all, > >=20 > > Our companie is curently tracking performance issue with our ARM pr= oduct. > >=20 > > We have seen that counter API was migrated from intrinsic to atomic= . > >=20 > > https://svnweb.freebsd.org/base?view=3Drevision&revision=3D269406 > >=20 > > But there is still the calls to critical_enter/leave in the macro > > counter_enter/leave. > >=20 > > Is that needed ? Can we remove that ? >=20 > Try this. I did not even compiled the patch. >=20 > 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 @@ >=20 > #include <sys/pcpu.h> > #include <machine/atomic.h> > -#ifdef INVARIANTS > -#include <sys/proc.h> > -#endif >=20 > -#define=09counter_enter()=09critical_enter() > -#define=09counter_exit()=09critical_exit() > +#define=09counter_enter()=09do {} while (0) > +#define=09counter_exit()=09do {} while (0) >=20 > #ifdef IN_SUBR_COUNTER_C >=20 > @@ -55,7 +52,7 @@ counter_u64_fetch_inline(uint64_t *p) > =09int i; >=20 > =09r =3D 0; > -=09for (i =3D 0; i < mp_ncpus; i++) > +=09CPU_FOREACH(i) > =09=09r +=3D counter_u64_read_one((uint64_t *)p, i); >=20 > =09return (r); > @@ -78,18 +75,13 @@ counter_u64_zero_inline(counter_u64_t c) > } > #endif >=20 > -#define=09counter_u64_add_protected(c, inc)=09do {=09\ > -=09CRITICAL_ASSERT(curthread);=09=09=09\ > -=09atomic_add_64((uint64_t *)zpcpu_get(c), (inc));=09\ > -} while (0) > +#define=09counter_u64_add_protected(c, inc)=09counter_u64_add(c, inc= ) >=20 > static inline void > counter_u64_add(counter_u64_t c, int64_t inc) > { >=20 > -=09counter_enter(); > -=09counter_u64_add_protected(c, inc); > -=09counter_exit(); > +=09atomic_add_64((uint64_t *)zpcpu_get(c), inc); > } >=20 > #endif=09/* ! __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=09_MACHINE_COUNTER_H_ >=20 > #include <sys/pcpu.h> > -#ifdef INVARIANTS > -#include <sys/proc.h> > -#endif > +#include <machine/atomic.h> >=20 > -#define=09counter_enter()=09critical_enter() > -#define=09counter_exit()=09critical_exit() > +#define=09counter_enter()=09do {} while (0) > +#define=09counter_exit()=09do {} while (0) >=20 > #ifdef IN_SUBR_COUNTER_C > static inline uint64_t > @@ -52,13 +50,12 @@ counter_u64_fetch_inline(uint64_t *p) > =09int i; >=20 > =09r =3D 0; > -=09for (i =3D 0; i < mp_ncpus; i++) > +=09CPU_FOREACH(i) > =09=09r +=3D counter_u64_read_one((uint64_t *)p, i); >=20 > =09return (r); > } >=20 > -/* 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 >=20 > -#define=09counter_u64_add_protected(c, inc)=09do {=09\ > -=09CRITICAL_ASSERT(curthread);=09=09=09\ > -=09*(uint64_t *)zpcpu_get(c) +=3D (inc);=09=09\ > -} while (0) > +#define=09counter_u64_add_protected(c, inc)=09counter_u64_add(c, inc= ) >=20 > static inline void > counter_u64_add(counter_u64_t c, int64_t inc) > { >=20 > -=09counter_enter(); > -=09counter_u64_add_protected(c, inc); > -=09counter_exit(); > +=09atomic_add_64((uint64_t *)zpcpu_get(c), inc); > } >=20 > #endif=09/* ! _MACHINE_COUNTER_H_ */ =2D-=20 Alexandre Martins STORMSHIELD --nextPart2440787.jo5CHQqg38 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCCCOUw ggSGMIICbqADAgECAgUA28zw7TANBgkqhkiG9w0BAQsFADBIMQswCQYDVQQGEwJGUjEUMBIGA1UE CgwLU1RPUk1TSElFTEQxIzAhBgNVBAMMGlN0b3Jtc2hpZWxkIFJvb3QgQXV0aG9yaXR5MB4XDTE0 MDkwNDE1MDcxMFoXDTI0MDkwMTE1MDcxMFowSTELMAkGA1UEBhMCRlIxFDASBgNVBAoMC1NUT1JN U0hJRUxEMSQwIgYDVQQDDBtTdG9ybXNoaWVsZCBVc2VycyBBdXRob3JpdHkwggEiMA0GCSqGSIb3 DQEBAQUAA4IBDwAwggEKAoIBAQDChwWgC/6VWKL7jgWI3eA2sVvRdOwuHcXsRAAXVWdlMC0ygg7u 45E78GhAnpdl8QbIu7x/Q2zOq6KttspwDEIjkoMLTZngLLlGjYJZPfuSoC6hl9R7vRd5f8Fhu3v0 xQ/7vzKYz4C836IGCrk31gmrPO0H0fxkyxCMfhoTTzue3oXW1IsmQwCrOPOu2Y82QANDhbifWLjI WJetnj58YRKR82KBs3Flbqxtp0mi9+IswMvCCRSoT+ORB73Cl6URt7Qm7BcD+qnkJ9uwlUC94dIl T2hX4ybY/w/ssA17Ew418fgyRCWQXzgjZgZ/XUcw2WP9dIggA7P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xexyr0xyT3IpYQ dmyMSHRT18Z/ZaBlQdyfnS2PYkPHJAHl4iqB4SnQlh3rwFdKTJMgCz413cDxQHytgRPGTiXOhyV7 aS3ANJFha6ZHA8HU9sTslY8ZXSUu94iD3t2kcF3gBb432UKALwryKqnrwzFX68pFpqO5QAjEHaF6 6p1agMb2b3HlQGZrME5wSO6rsZJPYvJEyvrwHxCxjSTkOdPw6GriWGTMrVMU0fVrfptMS1gxggIT MIICDwIBATBSMEkxCzAJBgNVBAYTAkZSMRQwEgYDVQQKDAtTVE9STVNISUVMRDEkMCIGA1UEAwwb U3Rvcm1zaGllbGQgVXNlcnMgQXV0aG9yaXR5AgUAhSjLuzANBglghkgBZQMEAgEFAKCBkzAYBgkq hkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNzAyMDMxMzAzNTZaMCgGCSqG SIb3DQEJDzEbMBkwCwYJYIZIAWUDBAECMAoGCCqGSIb3DQMHMC8GCSqGSIb3DQEJBDEiBCC4ICES r/F4vY5/oDKYnT4L50GYuba2eqmJUHgEV46eRDANBgkqhkiG9w0BAQEFAASCAQBfZnvu+JMW1RME I4rq13tafGAUaueWd+kBamDuu+Y6u50bDxTtumz8LVBPknzK266fqM9cGtFx6kmSVqMU8CLn7eV+ uauwwiPIo9dAlnm7YdZaxNLymh8iVRB4983rX0Fa9LkZbEY52HgzoSI0Xg/H+35u9uPv0jY+btL3 pGvxFHIoTQm4sl+AxOnrJw4gZj5NE9vQ5IsGjY/fO9k6d6Yul4HZU/hBJB1sRr5ZTlhdss7EjnCX nAbhrtl87RKZPrq3o3OhR3Tb2GNz5b4URbfrMQiVw5QG17ghZziYnyBt5rAzfjhU4rkD4g844LtT Rjetmc00lll/GrSbr6yQ101SAAAAAAAA --nextPart2440787.jo5CHQqg38--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?59508065.2X8Qo0R8aR>