Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1758681pxf; Fri, 26 Mar 2021 14:16:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgHJNhuEWT5/DVljp/ToEVDTsekISZ2fwqknPp7pDCUw3ssewSlBsUPbDjwSRN1L1zuevt X-Received: by 2002:a17:906:311a:: with SMTP id 26mr17249947ejx.395.1616793385560; Fri, 26 Mar 2021 14:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616793385; cv=none; d=google.com; s=arc-20160816; b=0+hEXxkdK69O+aMxjLNAi0nk0RA6XJs6TxVKbgqU1O+tCcx+xM2UDh7KDgojyl0JCs mDCxPgl6+aQS9PNbi9xhJ+C1eZgG7wyW372yHCIEVsXXolyvI47lCb+7XzHCw7SLwIjq okOVsN7+qQA1C96t4Z2/gMPFGUVBJMUj1m3H76QlnzVup/9kDh83uLIyvqf6fVyQ6OCe uEOSfcyOPgLuHML8wLzW+vO+OkGikFOLkYWJXSRQw/hYrHpcIhOjbSOMb1Tu/gNfC84d jr4/Pfy8QjKsNBwtp6sFVOcr5zVVF4iE7DkdsXq4MNVOAQsuLDoRRKpYG8GGw2heeVll /lxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:in-reply-to:date:references:subject:cc:to:from; bh=LNIu6gkWVERqws9Qoj6zZvuAdgsSDsB1lwSQy+XsPFI=; b=PlxaellKYg5ew/QLgOCdDlTT58cfKzMXYNihar29aawQ30brGGVb8IzJwtRpc7CSu8 agMIDZD/NohERctF08R0xEhVcnG/N5RtXaJWc7g0S4nb4sHQgrYdiP7FbiHT2iL4QC0k jg2+TtZdHJ+TF4UMuWJVKzKoHSLANNPdMjRLsoIIAovkCCYlhy/b2WW+ngvuCPQJ/eer LBcsebItqs03VF0aypoVj4YMJE7wPSL0CqFnb0Qb8WgVyijZ1/QjgrOsnwBfSOsFSuG6 s6T2iO/ypVBjPoXACqDtAxqkMhelX7wUIQbz3tyRmnuU7mhrl5cF3xLWbgGrySLo4Q6G 38wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ko14si7376200ejc.419.2021.03.26.14.16.03; Fri, 26 Mar 2021 14:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbhCZVMA convert rfc822-to-8bit (ORCPT + 99 others); Fri, 26 Mar 2021 17:12:00 -0400 Received: from albireo.enyo.de ([37.24.231.21]:56226 "EHLO albireo.enyo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbhCZVLn (ORCPT ); Fri, 26 Mar 2021 17:11:43 -0400 Received: from [172.17.203.2] (port=60777 helo=deneb.enyo.de) by albireo.enyo.de ([172.17.140.2]) with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1lPtk0-0004H1-VB; Fri, 26 Mar 2021 21:11:36 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1lPtk0-0000FD-K4; Fri, 26 Mar 2021 22:11:36 +0100 From: Florian Weimer To: Andy Lutomirski Cc: "H. J. Lu" , X86 ML , LKML , "Bae\, Chang Seok" , "Carlos O'Donell" , Rich Felker , libc-alpha Subject: Re: Why does glibc use AVX-512? References: <87a6qqi064.fsf@mid.deneb.enyo.de> <87blb5d7zx.fsf@mid.deneb.enyo.de> <877dltd569.fsf@mid.deneb.enyo.de> Date: Fri, 26 Mar 2021 22:11:36 +0100 In-Reply-To: (Andy Lutomirski's message of "Fri, 26 Mar 2021 13:48:01 -0700") Message-ID: <87pmzlboxj.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andy Lutomirski: > On Fri, Mar 26, 2021 at 1:35 PM Florian Weimer wrote: >> >> * Andy Lutomirski: >> >> > On Fri, Mar 26, 2021 at 12:34 PM Florian Weimer wrote: >> >> x86: Sporadic failures in tst-cpu-features-cpuinfo >> >> >> > >> > It's worth noting that recent microcode updates have make RTM >> > considerably less likely to actually work on many parts. It's >> > possible you should just disable it. :( >> >> Sorry, I'm not sure who should disable it. >> >> Let me sum up the situation: >> >> We have a request for a performance enhancement in glibc, so that >> applications can use it on server parts where RTM actually works. >> >> For CPUs that support AVX-512, we may be able to meet that with a >> change that uses the new 256-bit registers, t avoid the %xmm >> transition penalty. (This is the easy case, hopefully—there shouldn't >> be any frequency issues associated with that, and if the kernel >> doesn't optimize the context switch today, that's a nonissue as well.) > > I would make sure that the transition penalty actually works the way > you think it does. My general experience with the transition > penalties is that the CPU is rather more aggressive about penalizing > you than makes sense. Do you mean the frequency/thermal budget? I mean the immense slowdown you get if you use %xmm registers after their %ymm counterparts (doesn't have to be %zmm, that issue is present starting with AVX) and you have not issued VZEROALL or VZEROUPPER between the two uses. It's a bit like EMMS, I gues, only that you don't get corruption, just really poor performance. >> For CPUs that do not support AVX-512 but support RTM (and AVX2), we >> need a dynamic run-time check whether the string function is invoked >> in a transaction. In that case, we need to use VZEROALL instead of >> VZEROUPPER. (It's apparently too costly to issue VZEROALL >> unconditionally.) > > So VZEROALL works in a transaction and VZEROUPPER doesn't? That's bizarre. Apparently yes. >> All this needs to work transparently without user intervention. We >> cannot require firmware upgrades to fix the incorrect RTM reporting >> issue (the bug I referenced). I think we can require software updates >> which tell glibc when to use RTM-enabled string functions if the >> dynamic selection does not work (either for performance reasons, or >> because of the RTM reporting bug). >> >> I want to avoid a situation where one in eight processes fail to work >> correctly because the CPUID checks ran on CPU 0, where RTM is reported >> as available, and then we trap when executing XTEST on other CPUs. > > What kind of system has that problem? It's a standard laptop after a suspend/resume cycle. It's either a kernel or firmware bug. > If RTM reports as available, then it should work in the sense of not > trapping. (There is no guarantee that transactions will *ever* > complete, and that part is no joke.) XTEST doesn't abort transactions, but it traps without RTM support. If CPU0 has RTM support and we enable XTEST use in glibc based on that (because the startup code runs on CPU0), then the XTEST instruction must not trap when running on other CPUs. Currently, we do not use RTM for anything in glibc by default, even if it is available according to CPUID. (There are ways to opt in, unless the CPU is on the disallow list due to the early Haswell bug.) I'm worried that if we start executing XTEST on all CPUs that indicate RTM support, we will see lots of weird issues, along the lines of bug 27398.