Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1887221ybv; Thu, 6 Feb 2020 11:38:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxFtACMneVf/nOwzFzAOrNQ/67xZw1vwuyR+2ScZxMjAO3bxA1wyUpNtbDF9bcDax4YhXSD X-Received: by 2002:aca:fd4c:: with SMTP id b73mr8366642oii.33.1581017903770; Thu, 06 Feb 2020 11:38:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581017903; cv=none; d=google.com; s=arc-20160816; b=XoudsQ2pt+xO6TwbuccQgcSnT/UrCpJcts6CCfnQuLoTYb4A+J0Et34m8DHbzg6dEN ba1wOFGwdU2R2jFQzRvFHWCQB5cqMdDyNKMJHQ5UoyxAUP15AElq6R4ZH7qVktCUrQD6 rhp25NGuXDlYuikaRD3okn/yZsNkTeAhTLsebiVVdMf2othOeYr1rp9DtoJXU+Xm4Eof msCyngXlL3mQxlvm3tikFcysqHXuqkJTJfyPmFpEP1urdQhIF+hvEMWzu3YRJ5muNa9z 8YdbQ2r6u+wwzSEYDoEYFn8i96R/eV1tWh3pCR1C1SLKInICrIYdCs2zy3KyXA6J9cXm mQ5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding :dkim-signature; bh=rKTvlvWyi8MG0YmfjREezL+sDnmmMkY4ULQZDe7XKuE=; b=GEifOVpjJceAg6mPbS65lAJJCHAnjzpMSk4BcEsSQ6W1w5+y4ufYI/8QNkFaD/WnRa iQrb+7b9t2gp6PekIl0CBOTrgNKaJka3UzyfMvGMI9gvbVDsuR2tq41DR3hTSIEemozT 0yQun3paOxt3/2ArWB9NLysQcvQh1h15JN+J9OhG7q4OIV5uuVpdbPIrv9+Kwyk73U+M mi1u/W9JZU5sFoSqNT7Y0rWWglOlK2uCMpIzio524flpjloTV8tDKlTnd1Hmk4lozPBo 0ABgFdyo3UHqVCPVtsQQPL/hf9giDNiADJU80AGSNmZZyAE4Pq4IeDgP7nz1oVFXlWMQ mTVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=Luey5zHo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22si288153otq.94.2020.02.06.11.38.12; Thu, 06 Feb 2020 11:38:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=Luey5zHo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727916AbgBFThK (ORCPT + 99 others); Thu, 6 Feb 2020 14:37:10 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35900 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727773AbgBFThJ (ORCPT ); Thu, 6 Feb 2020 14:37:09 -0500 Received: by mail-pl1-f193.google.com with SMTP id a6so2750835plm.3 for ; Thu, 06 Feb 2020 11:37:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=rKTvlvWyi8MG0YmfjREezL+sDnmmMkY4ULQZDe7XKuE=; b=Luey5zHoxj6esRIvL6Pt376gxqW6K6LoCYn2YfW/AUsKavFVKAQb4yZv5jrrN1oaO/ xvmWXthtMLcI+EIgAZOXD4vNmSw/P1SR1h1HD8faleytiWTezXxggiK3i+pUZL/B37eP pF7DVuYKz1MhmKp2/PUl0z7AgQmWH6d+mlDF1lYYqPpmAE4O4mbTShNCdiIr/nj8ZNvW q/9d5ignoX4uEL6osYOGS+foEU2Xfx63a/Fs6zSWH2Wd/aZ3OscMYT0JFmF3AFdFO6GB bavwPuOP5r+u5lVNiC4ovGmHOhZ0R1j6LgvxXjkkE5BjMxj+O72CBnxBhDdmA1tneaGS +XpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=rKTvlvWyi8MG0YmfjREezL+sDnmmMkY4ULQZDe7XKuE=; b=dB00TET4SNFxk93l03A+V+Ym3fAMIcv5Wida3yKBacnytOv6z8qwtrvfJ/cidKcX3e 4cV6a8/qGW4bgv+V4zP368PZiaNPH8QdiKKGgyRB/QxunWZUA0Jc96u1/sg8qXHGGH9i mI80iOtEwQJfQ7/Kvpz11UzsQyLduDBKiPNiPvl+KeMJePL4MaQF/l6Fw+zqOoQcK4bs wLkm4mqxDjOXbuVfsPZJGW++sIfrz03lh57pnZwNNwsbRuTFJ06EnXL4/yVvdRX0e1AI vG4KrWcsfpTHFFvM913EfyKAs7XSy8JO/sT2g3XTaez2QX7pdpxE9CAlqsVTm3dRYAEG KpWw== X-Gm-Message-State: APjAAAX4QboGmd3pYi0ApeLJq73HXuvNmZbxgL4DF5s1tC+fZRlur+QD eMtxI8ZCxDzkR6NjpWbk5X86QA== X-Received: by 2002:a17:90a:be06:: with SMTP id a6mr6452821pjs.73.1581017829153; Thu, 06 Feb 2020 11:37:09 -0800 (PST) Received: from ?IPv6:2600:1010:b01f:241b:9d8d:a655:f13f:191f? ([2600:1010:b01f:241b:9d8d:a655:f13f:191f]) by smtp.gmail.com with ESMTPSA id k1sm195149pfg.66.2020.02.06.11.37.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Feb 2020 11:37:08 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] x86/split_lock: Avoid runtime reads of the TEST_CTRL MSR Date: Thu, 6 Feb 2020 11:37:04 -0800 Message-Id: <6735A646-3817-4030-B9B9-11492BB1B8F0@amacapital.net> References: <20200206164614.GA20622@agluck-desk2.amr.corp.intel.com> Cc: Andy Lutomirski , Sean Christopherson , Thomas Gleixner , Mark D Rustad , Arvind Sankar , Peter Zijlstra , Ingo Molnar , "Yu, Fenghua" , Ingo Molnar , Borislav Petkov , H Peter Anvin , "Raj, Ashok" , "Shankar, Ravi V" , linux-kernel , x86 , Xiaoyao Li In-Reply-To: <20200206164614.GA20622@agluck-desk2.amr.corp.intel.com> To: "Luck, Tony" X-Mailer: iPhone Mail (17C54) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Feb 6, 2020, at 8:46 AM, Luck, Tony wrote: >=20 > =EF=BB=BFOn Wed, Feb 05, 2020 at 05:18:23PM -0800, Andy Lutomirski wrote: >>> On Wed, Feb 5, 2020 at 4:49 PM Luck, Tony wrote: >>>=20 >>> In a context switch from a task that is detecting split locks >>> to one that is not (or vice versa) we need to update the TEST_CTRL >>> MSR. Currently this is done with the common sequence: >>> read the MSR >>> flip the bit >>> write the MSR >>> in order to avoid changing the value of any reserved bits in the MSR. >>>=20 >>> Cache the value of the TEST_CTRL MSR when we read it during initializati= on >>> so we can avoid an expensive RDMSR instruction during context switch. >>=20 >> If something else that is per-cpu-ish gets added to the MSR in the >> future, I will personally make fun of you for not making this percpu. >=20 > Xiaoyao Li has posted a version using a percpu cache value: >=20 > https://lore.kernel.org/r/20200206070412.17400-4-xiaoyao.li@intel.com >=20 > So take that if it makes you happier. My patch only used the > cached value to store the state of the reserved bits in the MSR > and assumed those are the same for all cores. >=20 > Xiaoyao Li's version updates with what was most recently written > on each thread (but doesn't, and can't, make use of that because we > know that the other thread on the core may have changed the actual > value in the MSR). >=20 > If more bits are implemented that need to be set at run time, we > are likely up the proverbial creek. I'll see if I can find out if > there are plans for that. >=20 I suppose that this whole thing is a giant mess, especially since at least o= ne bit there is per-physical-core. Sigh. So I don=E2=80=99t have a strong preference.=