Received: by 10.223.185.116 with SMTP id b49csp1075111wrg; Sat, 3 Mar 2018 14:52:09 -0800 (PST) X-Google-Smtp-Source: AG47ELuwFabI2Ae0g67QlcBfE4qmk2dzNFZaBdt2I5BLBmtv6a0tO8Noa1/XV0hvMP1HujwhhTK3 X-Received: by 10.98.138.66 with SMTP id y63mr10327502pfd.12.1520117529539; Sat, 03 Mar 2018 14:52:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520117529; cv=none; d=google.com; s=arc-20160816; b=u8w/zDCbgVnuGTpOJlK8Q5IW0If68502JSH5LLmdQ+g9uOWceyxgRjVHE5DB0RKPX7 jg5lVDmXFCiY3UUTb3GELbdOUh3c9SZWS3npoMuooUP2LlGD1kAjpCh+mOK9tlcLUOpW a1YxVWSwLxMGpI1si8IzECBcrbKgB+/85RdQVD8ZYoBosP9ToOVkLEeIquDb9fUfuLGd VWMmSKO7K422HiGxqHLz9xZISV6fwoYkiAbuJG/CFfKhnFtJM0jn9I3/ffKmS75b3vlB vY3cD3qyMDcaygBq1xgIUsS2kIqWnzRzbSdvbi69kT8Imps8oErhCpP82cYOgLGYVfNi 0YGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=MefqtSFTyDs6RRhoL+qoHeyo8khDB4w9EWW25UsXCs4=; b=V8ytGPL17sjV69CXDn+GuhhH8KOi7BHZC4/8SjnU7OUkh7jsPncHBMiHJjxlHwl0Jr aTTwyHtmte9kHkB49zpW1xoOZy5OofYs25XTAjJNbNJwjl1bkaeHlzjKj+oimOkTPm0p fRp6xaDdkXfo1th6I9jex7JGQF7Bce/OdFAktgF9siuJWQbXheML8sFVFITxzJf2cLNs dt+zHl5a+gJeCgeD9jaFAo7vx1U8AVHCYpmZyKEu+mJuTuXP9WuvNzNeHd0jBJ0WJWTJ Z20VqvbdfXK5HIONo4l5j1FdTv4tHctnNzze0HK0Qlw1jDeON+g67pHfLg9L/OMIXWEo 8aQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=J1mlPj1j; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si6868848plb.137.2018.03.03.14.51.55; Sat, 03 Mar 2018 14:52:09 -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=@microsoft.com header.s=selector1 header.b=J1mlPj1j; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935454AbeCCWvD (ORCPT + 99 others); Sat, 3 Mar 2018 17:51:03 -0500 Received: from mail-cys01nam02on0126.outbound.protection.outlook.com ([104.47.37.126]:64496 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935453AbeCCWlM (ORCPT ); Sat, 3 Mar 2018 17:41:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MefqtSFTyDs6RRhoL+qoHeyo8khDB4w9EWW25UsXCs4=; b=J1mlPj1jlWy/MAxBrvOmxehA42ipD85WkUDsMZg1B88gF+BomgxjNr1FJRU/Lz+KITfosVPmgqRTDx0Niur09LJ/HRoWVGMz7IsZ4q08z7cmlI8FV2QwQw+24Xpy3ClhVSFg8J/4YFc9Lp4PsmSGYDSEgi/pvvkybTDWRwBSIsk= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2SPR01MB06.namprd21.prod.outlook.com (52.132.152.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:41:09 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:41:09 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Anton Blanchard , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL for 3.18 28/63] powerpc: Avoid taking a data miss on every userspace instruction miss Thread-Topic: [PATCH AUTOSEL for 3.18 28/63] powerpc: Avoid taking a data miss on every userspace instruction miss Thread-Index: AQHTsz+l3fT1Pohk1ESjUxdbvNDI2g== Date: Sat, 3 Mar 2018 22:33:26 +0000 Message-ID: <20180303223228.27323-28-alexander.levin@microsoft.com> References: <20180303223228.27323-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223228.27323-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2SPR01MB06;7:sGaPxLfjI//hayAkdVviRed6S970Uds4PTnEKqzTROGVuSt4G4cEEmEzkE53hDcrll17uRxc9IRtRiPyJXI26EP+oleK8EqJPTwd9+xhTjHptS/7u6oQMrb2XPK5crzbeM5kMTU9lU81yjx7PZdR/Dag5lWHkMgJ1sBcmYl+QNO4+d6lEcFWTk/au+TimvJaMahmQa0xOQFGrVxv57Ha4TQzYlgTZ+OiTJtKwjMs2B7aj23v/1QYMqjzsKjFt0fa x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 5b4aaf9d-cf36-49a4-036a-08d58157dc38 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2SPR01MB06; x-ms-traffictypediagnostic: MW2SPR01MB06: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231220)(944501244)(52105095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:MW2SPR01MB06;BCL:0;PCL:0;RULEID:;SRVR:MW2SPR01MB06; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(39860400002)(39380400002)(366004)(376002)(189003)(199004)(3660700001)(575784001)(8936002)(72206003)(5660300001)(14454004)(110136005)(6512007)(4326008)(6506007)(26005)(2501003)(66066001)(86362001)(7736002)(54906003)(305945005)(25786009)(10290500003)(53936002)(6436002)(2906002)(81156014)(59450400001)(8676002)(478600001)(102836004)(106356001)(316002)(186003)(5250100002)(81166006)(6486002)(76176011)(86612001)(6666003)(2900100001)(3846002)(68736007)(97736004)(36756003)(1076002)(107886003)(2950100002)(105586002)(99286004)(6116002)(3280700002)(22452003)(10090500001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2SPR01MB06;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +4CwCtkt+aEdcyE18qumWhvMn5tRGXQWQGXGXkOyemuYvNXzEILkTDXrFBjhWd189Mt0vVzwnHYdQEHx+P/Fxj8rJSlT1jAllNNlYhWhI7lakSJgVUVUGNAQXH9D5Ny5DNqDPeCapQPzwrfvIPXB38ixumwwncY8AOoUjGfnUcs= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b4aaf9d-cf36-49a4-036a-08d58157dc38 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:33:26.6537 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2SPR01MB06 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anton Blanchard [ Upstream commit a7a9dcd882a67b68568868b988289fce5ffd8419 ] Early on in do_page_fault() we call store_updates_sp(), regardless of the type of exception. For an instruction miss this doesn't make sense, because we only use this information to detect if a data miss is the result of a stack expansion instruction or not. Worse still, it results in a data miss within every userspace instruction miss handler, because we try and load the very instruction we are about to install a pte for! A simple exec microbenchmark runs 6% faster on POWER8 with this fix: #include #include #include int main(int argc, char *argv[]) { unsigned long left =3D atol(argv[1]); char leftstr[16]; if (left-- =3D=3D 0) return 0; sprintf(leftstr, "%ld", left); execlp(argv[0], argv[0], leftstr, NULL); perror("exec failed\n"); return 0; } Pass the number of iterations on the command line (eg 10000) and time how long it takes to execute. Signed-off-by: Anton Blanchard Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/mm/fault.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c index f06b56baf0b3..9b47840be82e 100644 --- a/arch/powerpc/mm/fault.c +++ b/arch/powerpc/mm/fault.c @@ -294,7 +294,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsig= ned long address, * can result in fault, which will cause a deadlock when called with * mmap_sem held */ - if (user_mode(regs)) + if (!is_exec && user_mode(regs)) store_update_sp =3D store_updates_sp(regs); =20 if (user_mode(regs)) --=20 2.14.1