Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1010871pxf; Thu, 25 Mar 2021 21:40:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlyk5vBcSmkSbLdjeda15zN58GnUnA1mrG+6ACEjlTfVslfz/B75nbdGKS7Vw562G1D3A4 X-Received: by 2002:a17:906:4117:: with SMTP id j23mr13524988ejk.10.1616733616982; Thu, 25 Mar 2021 21:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616733616; cv=none; d=google.com; s=arc-20160816; b=lioDBKPOqfKiGOwVSyHmMVH+Obd7J0q8WyWLiDTmcQYDDq7Ga8yfQFODx+artQy8qX +Hyac/NQ8rg9E7LkxeRfJYweU4aGzWGROzO5LVlw4epa8i+hyTKiXR5NbSWSbJAXPej2 ZQ64005YTzNC2r3A+4fojr04NmVR8plFjMF4WFmnTwRiWL+uzlUclfT2uUfUXumeR3At RcQn/gGoiRTsx/5R0P1z7M/LRwstydQJ2rJEmA/5Aj+7upgvah1frx28jDcfWpDMDQAE qobLn8zcULwSXkOaTNkqnHeumHI0TO56yXe3lGWbbRDk71SMW9Yinco3/S/sLj8UxXUp NKbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:mime-version :dkim-signature; bh=a9IoOzFMTgjuwvFkVPteYtTI7wNOCylyqlTUY1SfuZw=; b=NF6/rXYW/oyk/C8j9e2/ZkNybw99WWY+BAqckCgoPHkmfmnObBwZc8t/R1DUUjNHof O2A5sSY3/b1jUJuT+rXGERM8zbwAB8jObMStyMw4GllvXN2BbJqN5nKnPw8W+0zgyp38 OpY4FKCkA89Q9RFwDbiv7oGgJvEANWsAubNkIAwRCcegqRGEAxv4SYOGECEffA5pWWY1 iv6d/0RSr5P4vNQYncvCoJQgudtp0qce3AeBlNJwOL2oRoA+rYMEU2z3WgdyOWSY9DBc 0CJALP+J9A3tsdZYCTfdmEFQsTXAxGmvxU2VfWrFiGCLRb7HN8YF5kAb5o5vqbZJH5OJ M8pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FgWk9p8H; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 39si6029429edq.111.2021.03.25.21.39.53; Thu, 25 Mar 2021 21:40:16 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FgWk9p8H; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229458AbhCZEi5 (ORCPT + 99 others); Fri, 26 Mar 2021 00:38:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:37998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230304AbhCZEih (ORCPT ); Fri, 26 Mar 2021 00:38:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F37661A42 for ; Fri, 26 Mar 2021 04:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616733516; bh=uakzJgslqMTRUR4ZuQ0ajYK6JKqrawmOg9EDLLj6Hn4=; h=From:Date:Subject:To:From; b=FgWk9p8HZzum1R881d868RdocD6VtcQ4jhJsVLjpTQhyKL9BwhMi1Xu/lmCSlMW+k osY+LqNLEf3PPNoRK8JfAXR+VFGVX8ePUxmoRarCe5utDob0OPHqCMGAKySMvKF75p lk4D1VkWaHqDMejsimqBqJFiUCuXt+Py4U2Yzeoc+QtPT6JIRUa35Wsc+S0sUtUiGy TajU99e9+qukruoaaqiKWyeZN8h2yFsd6NcjPSJbSFRqTwP0CntaxoFpJynGkv0i/s 9bE96O74R5E9CHzo/UmP8jlijucHoVCT+M1cMygEGNsUhqAH4lPq7It3aouH2qz6W+ USw0F/xCn2Zdg== Received: by mail-ej1-f41.google.com with SMTP id u9so6447787ejj.7 for ; Thu, 25 Mar 2021 21:38:36 -0700 (PDT) X-Gm-Message-State: AOAM5325cBFMOi0v+ZNu68JYV0DlReU2+jugf0Q5Nw5Vq7KqJu6KeiOS EGCdwooCRkCgNf3U8rOfNBLuaeyxSGKaPfmP68zvHg== X-Received: by 2002:a17:906:7e12:: with SMTP id e18mr13718403ejr.316.1616733514967; Thu, 25 Mar 2021 21:38:34 -0700 (PDT) MIME-Version: 1.0 From: Andy Lutomirski Date: Thu, 25 Mar 2021 21:38:24 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Why does glibc use AVX-512? To: libc-alpha , "H. J. Lu" , X86 ML , LKML , "Bae, Chang Seok" , Florian Weimer , "Carlos O'Donell" , Rich Felker Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all- glibc appears to use AVX512F for memcpy by default. (Unless Prefer_ERMS is default-on, but I genuinely can't tell if this is the case. I did some searching.) The commit adding it refers to a 2016 email saying that it's 30% on KNL. Unfortunately, AVX-512 is now available in normal hardware, and the overhead from switching between normal and AVX-512 code appears to vary from bad to genuinely horrible. And, once anything has used the high parts of YMM and/or ZMM, those states tend to get stuck with XINUSE=1. I'm wondering whether glibc should stop using AVX-512 by default. Meanwhile, some of you may have noticed a little ABI break we have. On AVX-512 hardware, the size of a signal frame is unreasonably large, and this is causing problems even for existing software that doesn't use AVX-512. Do any of you have any clever ideas for how to fix it? We have some kernel patches around to try to fail more cleanly, but we still fail. I think we should seriously consider solutions in which, for new tasks, XCR0 has new giant features (e.g. AMX) and possibly even AVX-512 cleared, and programs need to explicitly request enablement. This would allow programs to opt into not saving/restoring across signals or to save/restore in buffers supplied when the feature is enabled. This has all kinds of pros and cons, and I'm not sure it's a great idea. But, in the absence of some change to the ABI, the default outcome is that, on AMX-enabled kernels on AMX-enabled hardware, the signal frame will be more than 8kB, and this will affect *every* signal regardless of whether AMX is in use. --Andy