From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8EEEFA034C; Tue, 10 May 2022 00:39:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F691410EE; Tue, 10 May 2022 00:39:40 +0200 (CEST) Received: from tentoumushi.denkimushi.com (tentoumushi.denkimushi.com [81.187.253.217]) by mails.dpdk.org (Postfix) with ESMTP id D996540DDA for ; Tue, 10 May 2022 00:39:32 +0200 (CEST) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denkimushi.com; s=dkim; t=1652135964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0JswECi8eu3WpjPatjVixE2SezbO1nDWOiYPFayv4ZQ=; b=bu1KkExn2A8sHVjKGgVU+mwLyFmh3gqZnaEONrPnFMpFKF/pI3H0qLd3hVSs1LvOv6I/30 6vDWriINYu4dPxJQYT6cCU/u2o9bvaSCajfoYEB1aaVRXPpixIE/Jnx5P7tQDZSFunYcY2 WEaW2iPBQvVv/WGiJc6FAvww6LT09hg= Content-Transfer-Encoding: quoted-printable From: Dunk MIME-Version: 1.0 (1.0) Subject: Re: [PATCH v6] lib/eal/ppc fix compilation for musl Date: Mon, 9 May 2022 23:39:22 +0100 Message-Id: <9C68FD6F-1208-4C37-A6EE-57DCC40EDBBD@denkimushi.com> References: Cc: dev , David Christensen In-Reply-To: To: David Marchand ARC-Seal: i=1; s=dkim; d=denkimushi.com; t=1652135964; a=rsa-sha256; cv=none; b=YtPjmNKUwKgCAtoGQWDnQEDxihu2/amA5yKwzRqz1FiM42frPdEqoYu75ApJ1YKtcQROBj WmOiKsKxZT2zEH3zq6Zk1vsuQnJxpG6S1pUjm9zKKSbWTZISjUSqzPIg56/sC4hv7TuS0Z u8bh8QfePfkQC2LpUcGhtjGKXSYFyUQ= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=dunk@denkimushi.com smtp.mailfrom=dunk@denkimushi.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=denkimushi.com; s=dkim; t=1652135964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0JswECi8eu3WpjPatjVixE2SezbO1nDWOiYPFayv4ZQ=; b=J1co55dYVrO/0Ws/cwoYZm2TGWS7vDDGa/djhLac6M+8g/kdB6dqn5XfMljcTiY15S9kPU E97piYY9VYqn9KaeS8XO91UKP3MDpQTy8OFChHXFVtoLnSf+jIUOfL8SR2jgeh3Y5G/412 n6WNmq8iJjxBEv3Ct2AXVA/vRIWhTFY= X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > On 9 May 2022, at 13:06, David Marchand wrote:= >=20 > =EF=BB=BFOn Sat, May 7, 2022 at 11:16 PM Duncan Bellamy wrote: >>=20 >> musl lacks __ppc_get_timebase() but has __builtin_ppc_get_timebase() >>=20 >> the __ppc_get_timebase_freq() is taken from: >> https://git.alpinelinux.org/aports/commit/?id=3D06b03f70fb94972286c0c9f62= 78df89e53903833 >>=20 >> Signed-off-by: Duncan Bellamy >=20 > - A patch title does not need lib/ prefix. > Here, "eal/ppc: " is enough. >=20 >=20 > - Code in lib/eal/linux won't be used for FreeBSD/Windows. > On the other hand, arch-specific code (here, lib/eal/ppc/) can be used > for the various OS. > Besides, as far as I can see in the Linux kernel sources, powerpc is > the only architecture that exports a "timebase" entry in > /proc/cpuinfo. > So, I see no reason to put any code out of lib/eal/ppc. >=20 >=20 > - In the end, unless I missed some point, the patch could probably > look like (untested): >=20 > diff --git a/lib/eal/ppc/include/rte_cycles.h b/lib/eal/ppc/include/rte_cy= cles.h > index 5585f9273c..666fc9b0bf 100644 > --- a/lib/eal/ppc/include/rte_cycles.h > +++ b/lib/eal/ppc/include/rte_cycles.h > @@ -10,7 +10,10 @@ > extern "C" { > #endif >=20 > +#include > +#ifdef __GLIBC__ > #include > +#endif >=20 > #include "generic/rte_cycles.h" >=20 > @@ -26,7 +29,11 @@ extern "C" { > static inline uint64_t > rte_rdtsc(void) > { > +#ifdef __GLIBC__ > return __ppc_get_timebase(); > +#else > + return __builtin_ppc_get_timebase(); > +#endif > } >=20 > static inline uint64_t > diff --git a/lib/eal/ppc/rte_cycles.c b/lib/eal/ppc/rte_cycles.c > index 3180adb0ff..99d36b2f7e 100644 > --- a/lib/eal/ppc/rte_cycles.c > +++ b/lib/eal/ppc/rte_cycles.c > @@ -2,12 +2,50 @@ > * Copyright (C) IBM Corporation 2019. > */ >=20 > +#include > +#ifdef __GLIBC__ > #include > +#elif RTE_EXEC_ENV_LINUX > +#include > +#include > +#endif >=20 > #include "eal_private.h" >=20 > uint64_t > get_tsc_freq_arch(void) > { > +#ifdef __GLIBC__ > return __ppc_get_timebase_freq(); > +#elif RTE_EXEC_ENV_LINUX > + static unsigned long base; > + char buf[512]; > + ssize_t nr; > + FILE *f; > + > + if (base !=3D 0) > + goto out; > + > + f =3D fopen("/proc/cpuinfo", "rb"); > + if (f =3D=3D NULL) > + goto out; > + > + while (fgets(buf, sizeof(buf), f) !=3D NULL) { > + char *ret =3D strstr(buf, "timebase"); > + > + if (ret =3D=3D NULL) > + continue; > + ret +=3D sizeof("timebase") - 1; > + ret =3D strchr(ret, ':'); > + if (ret =3D=3D NULL) > + continue; > + base =3D strtoul(ret + 1, NULL, 10); > + break; > + } > + fclose(f); > +out: > + return (uint64_t) base; > +#else > + return 0; > +#endif > } >=20 >=20 > --=20 > David Marchand >=20 Thanks, that looks the same thing. Will run through alpine CI and change co= mmit title=