From owner-freebsd-emulation@freebsd.org Wed Mar 4 18:49:16 2020 Return-Path: Delivered-To: freebsd-emulation@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 8F7D4275C79 for ; Wed, 4 Mar 2020 18:49:16 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 48XjbH5QJYz4SlS for ; Wed, 4 Mar 2020 18:49:15 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by mailman.nyi.freebsd.org (Postfix) id A982F275C65; Wed, 4 Mar 2020 18:49:15 +0000 (UTC) Delivered-To: emulation@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 A9205275C64 for ; Wed, 4 Mar 2020 18:49:15 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48XjbG5jF8z4Sjv for ; Wed, 4 Mar 2020 18:49:14 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by freefall.freebsd.org (Postfix) id 700C11A1B3; Wed, 4 Mar 2020 18:49:14 +0000 (UTC) Delivered-To: vbox@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id 5B1011A140; Wed, 4 Mar 2020 18:49:14 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48XjbF28bzz4Sg1; Wed, 4 Mar 2020 18:49:13 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by mail-qk1-f193.google.com with SMTP id j7so2449536qkd.5; Wed, 04 Mar 2020 10:49:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7/JKXD33FfO7O2i4fd06ltBtMN47rKz8oO0ClBGerbA=; b=Qq1xtd1IhHE85+JBYjiMCiwIXXviTQhRIxVBXokmvzpsrDgHyb3eg6eP1+cJLTr912 yVK7zmHnERTx+tngocfMFKsGbS0olDLzyQWMrGMCeXHKrnFMC1LhKvXvlt0P7piMnStL e4vmQrme9zjXCSkFbtCZtnXLVOViA27a/z0OiCGK9hok38/DbNOI2+G3GkRnBVMnywGr icyW3UD9G23vYElHzC5/jjeMAlK9V2ZGBwbbHYwFn+u9KFvzCNZCZCcQ2l9rruWOiiO/ pFdEGW0SZZOihvLx97aVGbaEd523jJ7/aUBowiZarbbfzVULwncCVAtJ7X+guOy54MPJ +Z4g== X-Gm-Message-State: ANhLgQ0ZO67sb7QTZ+3/wJIMm9tpH1lWaoTDXV4roAlzHaJJxBUX/x9r hxGcaBXxfkBzyHrQ2mP+QuOKl9WsbCM= X-Google-Smtp-Source: ADFU+vtX38GQD2oGx8aUhOHmNa1kvl3SFqkQdWNoHG7oHGSuQB801JY5JgxiC2QSqEo+soKTbbD1Kg== X-Received: by 2002:a05:620a:4f7:: with SMTP id b23mr4476794qkh.258.1583347751338; Wed, 04 Mar 2020 10:49:11 -0800 (PST) Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com. [209.85.219.51]) by smtp.gmail.com with ESMTPSA id h9sm14526890qtq.61.2020.03.04.10.49.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Mar 2020 10:49:11 -0800 (PST) Received: by mail-qv1-f51.google.com with SMTP id u10so1268675qvi.2; Wed, 04 Mar 2020 10:49:11 -0800 (PST) X-Received: by 2002:a05:6214:8b:: with SMTP id n11mr3309011qvr.72.1583347750710; Wed, 04 Mar 2020 10:49:10 -0800 (PST) MIME-Version: 1.0 References: <202002281832.01SIWaEL071685@repo.freebsd.org> <5767791583138727@sas1-c7aad230fe87.qloud-c.yandex.net> <3d54ebc3-a511-a239-136d-c0f638a69351@FreeBSD.org> <20200304182801.GA95422@spindle.one-eyed-alien.net> In-Reply-To: <20200304182801.GA95422@spindle.one-eyed-alien.net> From: Ryan Libby Date: Wed, 4 Mar 2020 10:48:59 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r358439 - head/sys/amd64/include To: Brooks Davis Cc: Guido Falsi , "Alexander V. Chernikov" , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , vbox@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48XjbF28bzz4Sg1 X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-5.72 / 15.00]; NEURAL_HAM_MEDIUM(-0.72)[-0.723,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-Mailman-Approved-At: Thu, 05 Mar 2020 10:34:48 +0000 X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2020 18:49:16 -0000 On Wed, Mar 4, 2020 at 10:28 AM Brooks Davis wrote: > > On Wed, Mar 04, 2020 at 12:27:08PM +0100, Guido Falsi wrote: > > On 02/03/20 18:13, Ryan Libby wrote: > > > On Mon, Mar 2, 2020 at 12:45 AM Alexander V. Chernikov wrote: > > >> > > >> 28.02.2020, 18:32, "Ryan Libby" : > > >>> Author: rlibby > > >>> Date: Fri Feb 28 18:32:36 2020 > > >>> New Revision: 358439 > > >>> URL: https://svnweb.freebsd.org/changeset/base/358439 > > >>> > > >>> Log: > > >>> amd64 atomic.h: minor codegen optimization in flag access > > >>> > > >>> Previously the pattern to extract status flags from inline assembly > > >>> blocks was to use setcc in the block to write the flag to a register. > > >>> This was suboptimal in a few ways: > > >>> - It would lead to code like: sete %cl; test %cl; jne, i.e. a flag > > >>> would just be loaded into a register and then reloaded to a flag. > > >>> - The setcc would force the block to use an additional register. > > >>> - If the client code didn't care for the flag value then the setcc > > >>> would be entirely pointless but could not be eliminated by the > > >>> optimizer. > > >>> > > >>> A more modern inline asm construct (since gcc 6 and clang 9) allows for > > >> This effectively restricts kernel builds by all older compilers. > > >> Is there any chance of making it conditional depending on the compiler version/features? > > > > > > Yes, it is possible to test for __GCC_ASM_FLAG_OUTPUTS__. It is more > > > maintenance effort going forward. If building current with an old cross > > > compiler is an important scenario, we can either revert this and the > > > following revision or work up a patch to make it conditional. I'll see > > > what that might look like. > > > > > > > Actually this causes emulators/virtualbox-ose port to fail to build: > > > > In file included from /usr/src/sys/sys/systm.h:44: > > /usr/include/machine/atomic.h:230:1: error: invalid output constraint > > '=@cce' in asm > > ATOMIC_CMPSET(char); > > ^ > > /usr/include/machine/atomic.h:205:4: note: expanded from macro > > 'ATOMIC_CMPSET' > > : "=@cce" (res), /* 0 */ \ > > ^ > > /usr/include/machine/atomic.h:230:1: error: invalid output constraint > > '=@cce' in asm > > > > (and so on) > > > > > > the virtualbox-ose port is forced to use an older clang version due to > > crashes when compiled with newer ones. > > > > Not sure whose responsibility is to fix this. > > I suspect that now that we don't care about gcc 4.2.1, we should > restructure machine/atomic.h to use __atomic compiler builtins in nearly > all cases. We could then conditionalize small sets of mircooptimized > assembly versions based on the availability of compiler features if they > add any value. > > On CheriBSD we've switched the RISC-V to use the C versions and are > overdue to do the same to MIPS. Reworking things to make this the > default would decrease our maintenance burden and it seems unlikely that > most of our platforms would benefit from handcode assembly (given the > general level of optimization in our lower-tier platforms). > > -- Brooks There's further discussion on that topic in the original review (D23869) and in D23661.