Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1985593ybz; Sat, 18 Apr 2020 12:44:53 -0700 (PDT) X-Google-Smtp-Source: APiQypJYoCXZbnP/5IfBUzFOV9eDpoM5hiaLtgG9mqyKMU8Bha6RUKxUR7PSlL+VaMYkIS+N0LD2 X-Received: by 2002:a17:906:46da:: with SMTP id k26mr9286801ejs.106.1587239093639; Sat, 18 Apr 2020 12:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587239093; cv=none; d=google.com; s=arc-20160816; b=IpbrGZghI43SjIW6Pg+S4vZKyic9AxMW6IHtiO3tHoDnJlmusxcWJuuu1jndmuB/nC lUeLqxPlCZzvDDf0MeLD0XJorNnInuciiGPTupvGsx3VMyZgfi2uJTm3khskQh8e0fak KIweS+IB0YA+kBUkxbjXrSVEPP3HYG03muBtyrdkJbrbv2Ebyu60xkmFHOgwaGTJt373 gaTz3tAL+77ZfsxY68qgkuNWrU57lG0eT1yenYhnfR5t7iIaejVkUXIk1etyG/6Fe0Uk Czk7WHrB1tFBPwxWqqsbC9y3TGhGI/VVbYGAyYWLu1VLsW337s8iahWDaTMM2ES7u5uj 36Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=p4rEAS/O53Re2CpfxSr2/Dv5edNKCIi/n2DeEZZR7KY=; b=MoTp1K9Bto2Cgb7mBchS2/twmiI/d/ZXGrvBOBVjZO3o6NcEup8PNAJa4suE4ApKFu 2xubD0fujK/l/WwBfHE1sAkphZR34ItTmdei6WO99P8AUUEl1NmS2DpLMCH1wHAK6heF FUO0zjX4wy6uVHW6Hv7EoxRd39ldM5zoHAFr8RlAKOcj4d8hSF60olc1UTQ/cHfpL/w9 krA1VnfDhCM4wiQ1AmLQxofdlD0UzRARr+w7vBIOHvGy13SedK+AuJ6P69Hhjldeipro llP8WAEDXOPBFkxsd741FGVh0G7AY5G/DuH6qfMdWKHolh4LCW5yVh6Sgvy9r4qSCZl6 9faQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Zqa5Mu9f; 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 t16si12641587eju.94.2020.04.18.12.44.30; Sat, 18 Apr 2020 12:44:53 -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=@linux-foundation.org header.s=google header.b=Zqa5Mu9f; 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 S1728227AbgDRTmX (ORCPT + 99 others); Sat, 18 Apr 2020 15:42:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727966AbgDRTmW (ORCPT ); Sat, 18 Apr 2020 15:42:22 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A239C061A0F for ; Sat, 18 Apr 2020 12:42:22 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id r17so4649542lff.2 for ; Sat, 18 Apr 2020 12:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p4rEAS/O53Re2CpfxSr2/Dv5edNKCIi/n2DeEZZR7KY=; b=Zqa5Mu9fEAhtFeza5prrV1yWpCwrYY/kIL7e1PzuB0VaPYchsmGNPq2A2yJx0KdktA yKw2D4sAGZ7F2FEHUIRbuZqtw/gJTtLzShlshLMHwsW0bSUtv5dD1XzzxNPOvxuoXbhB B55HwDWCbOhs5ZBK+tO/PcjS/+L1qRJJ57Rxg= 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=p4rEAS/O53Re2CpfxSr2/Dv5edNKCIi/n2DeEZZR7KY=; b=DBc7ULNYBPoII7+CBpGA+CTKwHq9UbzoavzRoKkHfQg33sdrFsiHCCFgIa+/cYmM7/ v6qJtz6MkOAfqJVMFxQvXrhZkiiZYcxaHw8WZOfvO7uSKlelVz7KLLA8leZbS9jGJiA+ wkbUB1yDwKwM+Occ7mcmFl77JD034PB+7y2ahICyuHhc+TheiZmJxjO8T+sffk9d5osf aU5UMV0EicOVwis9wHM7hARe2O5Pu72KQNN4K/MZvcLTtV6yz+8i6d3C4xGnnzZIdbpY 5J6LWepNr4oi4dECnP7BSsfmGQThyDzf5/+q7an7tI4z1xWsEJRNKcNcsO7xvnBugqQ9 d+Eg== X-Gm-Message-State: AGi0PuYnxvhyV18O+2VqPrtgadYKtORqnRR7XswW3qTdKmkR8vSZCUxe 71KD05vQccCLAgq6VSVAYgqkyppQlYA= X-Received: by 2002:a19:3848:: with SMTP id d8mr5565779lfj.44.1587238940026; Sat, 18 Apr 2020 12:42:20 -0700 (PDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id x21sm1601753ljm.74.2020.04.18.12.42.18 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Apr 2020 12:42:19 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id u15so5666077ljd.3 for ; Sat, 18 Apr 2020 12:42:18 -0700 (PDT) X-Received: by 2002:a2e:7c1a:: with SMTP id x26mr5121816ljc.209.1587238938281; Sat, 18 Apr 2020 12:42:18 -0700 (PDT) MIME-Version: 1.0 References: <158654083112.1572482.8944305411228188871.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: From: Linus Torvalds Date: Sat, 18 Apr 2020 12:42:02 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86/memcpy: Introduce memcpy_mcsafe_fast To: Dan Williams Cc: Thomas Gleixner , Ingo Molnar , X86 ML , stable , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra , Tony Luck , Erwin Tsaur , Linux Kernel Mailing List , linux-nvdimm Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 17, 2020 at 5:12 PM Dan Williams wrote: > > > @@ -106,12 +108,10 @@ static __always_inline __must_check unsigned long > > memcpy_mcsafe(void *dst, const void *src, size_t cnt) > > { > > #ifdef CONFIG_X86_MCE > > - if (static_branch_unlikely(&mcsafe_key)) > > - return __memcpy_mcsafe(dst, src, cnt); > > - else > > + if (static_branch_unlikely(&mcsafe_slow_key)) > > + return memcpy_mcsafe_slow(dst, src, cnt); > > #endif > > - memcpy(dst, src, cnt); > > - return 0; > > + return memcpy_mcsafe_fast(dst, src, cnt); > > } It strikes me that I see no advantages to making this an inline function at all. Even for the good case - where it turns into just a memcpy because MCE is entirely disabled - it doesn't seem to matter. The only case that really helps is when the memcpy can be turned into a single access. Which - and I checked - does exist, with people doing r = memcpy_mcsafe(&sb_seq_count, &sb(wc)->seq_count, sizeof(uint64_t)); to read a single 64-bit field which looks aligned to me. But that code is incredible garbage anyway, since even on a broken machine, there's no actual reason to use the slow variant for that whole access that I can tell. The macs-safe copy routines do not do anything worthwhile for a single access. So my reaction remains that a lot of this is just completely wrong and incredibly mis-designed. Yes, the hardware was buggy garbage. But why should we make things worse with making the software be incomprehensibly bad too? Linus