Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jul 2021 11:11:51 +0200
From:      "Kristof Provost" <kp@FreeBSD.org>
To:        "Warner Losh" <imp@FreeBSD.org>
Cc:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   Re: git: 6edf5082bab7 - stable/12 - one-true-awk: import 20210221 (1e4bc42c53a1) which fixes a number of bugs
Message-ID:  <4AD3AB8C-A960-43BE-A89B-5D9C4CD077DD@FreeBSD.org>
In-Reply-To: <202107101712.16AHCwoE088447@gitrepo.freebsd.org>
References:  <202107101712.16AHCwoE088447@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Warner,

On 10 Jul 2021, at 19:12, Warner Losh wrote:
> The branch stable/12 has been updated by imp:
>
> URL: =

> https://cgit.FreeBSD.org/src/commit/?id=3D6edf5082bab71cf923efff9f18e38=
efe5b83b0ec
>
> commit 6edf5082bab71cf923efff9f18e38efe5b83b0ec
> Author:     Warner Losh <imp@FreeBSD.org>
> AuthorDate: 2021-07-07 23:30:35 +0000
> Commit:     Warner Losh <imp@FreeBSD.org>
> CommitDate: 2021-07-10 17:11:15 +0000
>
>     one-true-awk: import 20210221 (1e4bc42c53a1) which fixes a number =

> of bugs
>
>     Import the latest bsd-features branch of the one-true-awk =

> upstream:
>
>     o Move to bison for $YACC
>     o Set close-on-exec flag for file and pipe redirects that aren't =

> std*
>     o lots of little fixes to modernize ocde base
>     o free sval member before setting it
>     o fix a bug where a{0,3} could match aaaa
>     o pull in systime and strftime from NetBSD awk
>     o pull in fixes from {Net,Free,Open}BSD (normalized our code with =

> them)
>     o add BSD extensions and, or, xor, compl, lsheift, rshift (mostly =

> a nop)
>
>     Also revert a few of the trivial FreeBSD changes that were done =

> slightly
>     differently in the upstreaming process. Also, our PR database may =

> have
>     been mined by upstream for these fixes, and Mikolaj Golub may =

> deserve
>     credit for some of the fixes in this update.
>
>     Suggested by:           Mikolaj Golub <to.my.trociny@gmail.com>
>     PR:                     =

> 143363,143365,143368,143369,143373,143375,214782
>     Sponsored by:           Netflix
>
>     (cherry picked from commit =

> f39dd6a9784467f0db5886012b3f4b13899be6b8)

I *think* this is the relevant commit, but I=E2=80=99m not 100% sure.

Anyway, I=E2=80=99ve recently started seeing issues building pfSense for =

aarch64. I=E2=80=99ve finally narrowed it down, and replicated the proble=
m on =

base FreeBSD (stable/12, but I assume other branches are affected too).

It fails to build proctab.c. This file is generated by maketab, a tool =

built as part of the build process. In my case this tool is built for =

aarch64, which makes executing it on amd64 less successful than we=E2=80=99=
d =

like.

This only happens when building with META_MODE though. I do not =

understand the build system sufficiently to debug why. Hopefully =

you=E2=80=99ll have a better idea.

This triggers the build failure:

	% cat /usr/src/src_env.conf
	WITH_META_MODE=3Dyes
	% env SRC_ENV_CONF=3D/usr/src/src_env.conf TARGET_ARCH=3Daarch64 make -j=
 8 =

buildworld

	=E2=80=A6
	--- proctab.c ---
	*** [proctab.c] Error code 255

	make[4]: stopped in /usr/src/usr.bin/awk
	.ERROR_TARGET=3D'proctab.c'
	.ERROR_META_FILE=3D'/usr/obj/usr/src/arm64.aarch64/usr.bin/awk/proctab.c=
=2Emeta'
	.MAKE.LEVEL=3D'4'
	MAKEFILE=3D''
	.MAKE.MODE=3D'meta missing-filemon=3Dyes missing-meta=3Dyes silent=3Dyes=
 =

verbose'
	_ERROR_CMD=3D'./maketab awkgram.h > proctab.c;'
	.CURDIR=3D'/usr/src/usr.bin/awk'
	.MAKE=3D'make'
	.OBJDIR=3D'/usr/obj/usr/src/arm64.aarch64/usr.bin/awk'
	.TARGETS=3D'all'
	DESTDIR=3D'/usr/obj/usr/src/arm64.aarch64/tmp'
	LD_LIBRARY_PATH=3D''
	MACHINE=3D'arm64'
	MACHINE_ARCH=3D'aarch64'
	MAKEOBJDIRPREFIX=3D''
	MAKESYSPATH=3D'/usr/src/share/mk'
	MAKE_VERSION=3D'20200710'

Further up in the build output:

	--- maketab ---
	cc -target aarch64-unknown-freebsd12.2 =

--sysroot=3D/usr/obj/usr/src/arm64.aarch64/tmp =

-B/usr/obj/usr/src/arm64.aarch64/tmp/usr/bin -O2 -pipe -fno-common   =

-DHAS_ISBLANK -I. -I/usr/src/contrib/one-true-awk -DFOPEN_MAX=3D64 -g =

-std=3Dgnu99 -Wno-format-zero-length -fstack-protector-strong =

-Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body =

-Wno-string-plus-int -Wno-unused-const-variable =

-Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality =

-Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef =

-Wno-address-of-packed-member -Wno-switch -Wno-switch-enum =

-Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments    =

/usr/src/contrib/one-true-awk/maketab.c  -o maketab

Without META_MODE maketab is built as an amd64 binary, and the entire =

build succeeds.

Best regards,
Kristof
From owner-dev-commits-src-all@freebsd.org  Sat Jul 31 12:48:40 2021
Return-Path: <owner-dev-commits-src-all@freebsd.org>
Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1])
 by mailman.nyi.freebsd.org (Postfix) with ESMTP id A9D9365BBAB;
 Sat, 31 Jul 2021 12:48:40 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (Client did not present a certificate)
 by mx1.freebsd.org (Postfix) with ESMTPS id 4GcPFz4212z4S0F;
 Sat, 31 Jul 2021 12:48:39 +0000 (UTC)
 (envelope-from kostikbel@gmail.com)
Received: from tom.home (kib@localhost [127.0.0.1])
 by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 16VCmVYo080354
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO);
 Sat, 31 Jul 2021 15:48:34 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 16VCmVYo080354
Received: (from kostik@localhost)
 by tom.home (8.16.1/8.16.1/Submit) id 16VCmV1q080353;
 Sat, 31 Jul 2021 15:48:31 +0300 (EEST)
 (envelope-from kostikbel@gmail.com)
X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com
 using -f
Date: Sat, 31 Jul 2021 15:48:31 +0300
From: Konstantin Belousov <kostikbel@gmail.com>
To: Alexander Motin <mav@freebsd.org>
Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org,
 dev-commits-src-main@freebsd.org
Subject: Re: git: 74f80bc1af2f - main - coretemp(4): Switch to
 smp_rendezvous_cpus().
Message-ID: <YQVGn7VhKstcGndr@kib.kiev.ua>
References: <202107300326.16U3QGHR070204@gitrepo.freebsd.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <202107300326.16U3QGHR070204@gitrepo.freebsd.org>
X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM,
 NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5
X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home
X-Rspamd-Queue-Id: 4GcPFz4212z4S0F
X-Spamd-Bar: ++
Authentication-Results: mx1.freebsd.org; dkim=none;
 dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com
 (policy=none); 
 spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor
 denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com
X-Spamd-Result: default: False [2.62 / 15.00]; ARC_NA(0.00)[];
 FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_TLS_ALL(0.00)[];
 FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4];
 FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[];
 MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[];
 R_SPF_SOFTFAIL(0.00)[~all:c]; NEURAL_SPAM_MEDIUM(0.99)[0.990];
 TO_DN_SOME(0.00)[]; NEURAL_SPAM_SHORT(1.00)[1.000];
 NEURAL_SPAM_LONG(0.63)[0.629]; FROM_EQ_ENVFROM(0.00)[];
 R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+];
 ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US];
 RCVD_COUNT_TWO(0.00)[2];
 MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main];
 DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]
X-BeenThere: dev-commits-src-all@freebsd.org
X-Mailman-Version: 2.1.34
Precedence: list
List-Id: Commit messages for all branches of the src repository
 <dev-commits-src-all.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/dev-commits-src-all>, 
 <mailto:dev-commits-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/dev-commits-src-all/>;
List-Post: <mailto:dev-commits-src-all@freebsd.org>
List-Help: <mailto:dev-commits-src-all-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all>, 
 <mailto:dev-commits-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 31 Jul 2021 12:48:40 -0000

On Fri, Jul 30, 2021 at 03:26:16AM +0000, Alexander Motin wrote:
> The branch main has been updated by mav:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=74f80bc1af2ffd56ec290f610c80e46f768731a0
> 
> commit 74f80bc1af2ffd56ec290f610c80e46f768731a0
> Author:     Alexander Motin <mav@FreeBSD.org>
> AuthorDate: 2021-07-30 03:16:22 +0000
> Commit:     Alexander Motin <mav@FreeBSD.org>
> CommitDate: 2021-07-30 03:26:10 +0000
> 
>     coretemp(4): Switch to smp_rendezvous_cpus().
>     
>     Use of smp_rendezvous_cpus() instead of sched_bind() allows to not
>     block indefinitely if target CPU is running some thread with higher
>     priority, while all we need is single rdmsr/wrmsr instruction call.
>     I guess it should also be much cheaper than full thread migration.
>     
>     MFC after:      2 weeks
>     Sponsored by:   iXsystems, Inc.
> ---
>  sys/dev/coretemp/coretemp.c | 59 ++++++++++++++++++++++++++++-----------------
>  1 file changed, 37 insertions(+), 22 deletions(-)
> 
> diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c
> index 884ed6309f0e..53a2434254f6 100644
> --- a/sys/dev/coretemp/coretemp.c
> +++ b/sys/dev/coretemp/coretemp.c
> @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
>  #include <sys/module.h>
>  #include <sys/mutex.h>
>  #include <sys/proc.h>	/* for curthread */
> -#include <sys/sched.h>
> +#include <sys/smp.h>
>  #include <sys/sysctl.h>
>  #include <sys/systm.h>
>  
> @@ -310,14 +310,32 @@ coretemp_detach(device_t dev)
>  	return (0);
>  }
>  
> +struct coretemp_args {
> +	u_int		msr;
> +	uint64_t	val;
> +};
> +
> +static void
> +coretemp_rdmsr(void *arg)
> +{
> +	struct coretemp_args *args = arg;
> +
> +	args->val = rdmsr(args->msr);
> +}
> +
> +static void
> +coretemp_wrmsr(void *arg)
> +{
> +	struct coretemp_args *args = arg;
> +
> +	wrmsr(args->msr, args->val);
> +}
We have x86_msr_op().  It covers coretemp_wrmsr(), and with slight
change of the interface would also handle the functionality of
coretemp_rdmsr().

> +
>  static uint64_t
>  coretemp_get_thermal_msr(int cpu)
>  {
> -	uint64_t msr;
> -
> -	thread_lock(curthread);
> -	sched_bind(curthread, cpu);
> -	thread_unlock(curthread);
> +	struct coretemp_args args;
> +	cpuset_t cpus;
>  
>  	/*
>  	 * The digital temperature reading is located at bit 16
> @@ -329,27 +347,24 @@ coretemp_get_thermal_msr(int cpu)
>  	 * The temperature is computed by subtracting the temperature
>  	 * reading by Tj(max).
>  	 */
> -	msr = rdmsr(MSR_THERM_STATUS);
> -
> -	thread_lock(curthread);
> -	sched_unbind(curthread);
> -	thread_unlock(curthread);
> -
> -	return (msr);
> +	args.msr = MSR_THERM_STATUS;
> +	CPU_SETOF(cpu, &cpus);
> +	smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_rdmsr,
> +	    smp_no_rendezvous_barrier, &args);
> +	return (args.val);
>  }
>  
>  static void
>  coretemp_clear_thermal_msr(int cpu)
>  {
> -	thread_lock(curthread);
> -	sched_bind(curthread, cpu);
> -	thread_unlock(curthread);
> -
> -	wrmsr(MSR_THERM_STATUS, 0);
> -
> -	thread_lock(curthread);
> -	sched_unbind(curthread);
> -	thread_unlock(curthread);
> +	struct coretemp_args args;
> +	cpuset_t cpus;
> +
> +	args.msr = MSR_THERM_STATUS;
> +	args.val = 0;
> +	CPU_SETOF(cpu, &cpus);
> +	smp_rendezvous_cpus(cpus, smp_no_rendezvous_barrier, coretemp_wrmsr,
> +	    smp_no_rendezvous_barrier, &args);
>  }
>  
>  static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AD3AB8C-A960-43BE-A89B-5D9C4CD077DD>