From patchwork Sun Apr 1 11:11:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 10319117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B04260375 for ; Sun, 1 Apr 2018 11:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02C8028F13 for ; Sun, 1 Apr 2018 11:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAFEC28F40; Sun, 1 Apr 2018 11:11:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A682228F13 for ; Sun, 1 Apr 2018 11:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yfSki9oMsMnBxrv7QhRGvF3dM7MQlNz1J2+YpME9+KQ=; b=R8JhlygCTghB/D FqOuJw9YgIjAALvimyuLeHXsXFuBAO5tUKQIu0tkCBu9+Hrkod2JtJv0AC/G0nWjKlMaYl88jzipw FkzhvpL1HeCgxVpnyZ3R5VJ5TALm1b2pFM82klAbaB7XTuSD+dpghkffurUYoFj4tiyLUH/lMg08+ zXeW7KQEdjGvx6x0PsTs/bXz0MjRXQMwP6t5v82e8R3Nj0KNq4ZJS44NHeTEG+Euuu8OqPYlZuCDI HcoiVea9fsZ8RlqefzOITQyp55JtdkH2fUt9+SFkllOhuPg3t2ULNz7Q0BdX4eush3UfTII+H1ion MdQLwihmGjwdrPeE+RwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2ato-0006tj-9o; Sun, 01 Apr 2018 11:11:48 +0000 Received: from mail-by2nam01on0059.outbound.protection.outlook.com ([104.47.34.59] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f2atk-0006re-02 for linux-arm-kernel@lists.infradead.org; Sun, 01 Apr 2018 11:11:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BV2GhEvoUROtxfAuqxRMjqT9v/uccWPAzf2Drdg8M5A=; b=f+rQbizp6mM99H4hWSqG6Uip7xpLydlPJ5xAzVZxbW4Bnksljh38+zI5o2L/HcbjQdUsZ0PtPUjgBH/q/GLmjP6d6EPew3T1peY7Fqm7HXhN3/R0c54T91E1La9vhDhRIHAOO9yV+AreGGnDOTyLNh6LPQWDeOEeXB43Yjld1uc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (50.233.148.156) by BN6PR07MB2898.namprd07.prod.outlook.com (10.173.28.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.10; Sun, 1 Apr 2018 11:11:24 +0000 Date: Sun, 1 Apr 2018 14:11:08 +0300 From: Yury Norov To: Will Deacon Subject: Re: [PATCH 2/2] smp: introduce kick_active_cpus_sync() Message-ID: <20180401111108.mudkiewzn33sifvk@yury-thinkpad> References: <20180325175004.28162-1-ynorov@caviumnetworks.com> <20180325175004.28162-3-ynorov@caviumnetworks.com> <20180327102116.GA2464@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180327102116.GA2464@arm.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: HE1PR06CA0153.eurprd06.prod.outlook.com (10.170.251.40) To BN6PR07MB2898.namprd07.prod.outlook.com (10.173.28.144) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99217bb9-48dd-4732-1945-08d597c14f30 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BN6PR07MB2898; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB2898; 3:J8MKOyn+m6Z4zrABdM3qSKsvjnO8XwzGC0osa1c/FJvSTrdzBuDRxJg3mJxgt3VXZ2loWrX6IFj2ktoQN2IXSAWnYR7FvWYriKbN3BE4Z9k25FoVMe3OtZJtLs5/Y1EvU2O0QwOVsJzZtxN7YiKtXbAieFGftMMBz+mcB1VtQLOxZ5NWZezrsCMyX/psrpbPj1B/VcEHLuIhrD+k+F5GzBZc0yuRwLv1tTX3MKVcsWzIFM7sawUQoSm945YNLj/o; 25:6lVTz/jiHQoDRPAx7vKP13Xnwett5r0K5F8I6IS6yZZlb2NIhfpcdGdCzkqEYEy8ofTzYXo7BIMMBmibiAk41/cLjNuKlJmUyK9AyT4FzhwFaVQW6oGJhXpcZVyNhWGQyXYFIIj8saH2lL6OHU99sxEEDpPmhJa9D/x0otNhTM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EZW7Sdrh02lhsjM2I=; 4:Ie1q306T/jLujr0bD7xK6BTn9dJfE15HHDUCNzSYl/sKFO2IsNdX1QsMJ91EpKDB782RLhZqV+5zdPWxCtVNOb/Bu8Hmedc22KlQdo/AmROqZuB81qcPmGu4AViWlTWs9U65knQNQ80z2asOsSvEEb9p9N+szldx6hm3aGvV4GZOn1fxVshdCxGyNAeidQJHwuS6tF10s94KSUsDJFfgQ2oYfP4yM56UIeAH0/G6z4QMJX8e1zCq4awO51603ZnjQQkxo7vJe0gSTAM3xA3ekQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231221)(944501327)(52105095)(93006095)(10201501046)(3002001)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011); SRVR:BN6PR07MB2898; BCL:0; PCL:0; RULEID:; SRVR:BN6PR07MB2898; X-Forefront-PRVS: 06290ECA9D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(7916004)(396003)(39380400002)(366004)(39850400004)(376002)(346002)(199004)(189003)(486005)(476003)(6496006)(33716001)(5660300001)(446003)(8936002)(575784001)(956004)(11346002)(7736002)(33896004)(52116002)(305945005)(6246003)(97736004)(6486002)(76176011)(50466002)(2906002)(6306002)(478600001)(1076002)(316002)(7416002)(59450400001)(486005)(16586007)(9686003)(81156014)(81166006)(25786009)(229853002)(3846002)(23726003)(186003)(16526019)(42882007)(4326008)(386003)(54906003)(6666003)(6116002)(58126008)(8676002)(26005)(6916009)(72206003)(106356001)(68736007)(66066001)(47776003)(76506005)(105586002)(53936002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB2898; H:localhost; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB2898; 23:1aMho3eJACJO6n1cWPb0ZPJQGD/nXxmPpm7Fy0m78?= =?us-ascii?Q?JWV5PsNAaK8AvIucQL0CRkc2ZjSYdAwR4BKIj5JTt2dE5nb1uCxDmvwdcYGV?= =?us-ascii?Q?NUy62XugNqX4uUZz0cCOuVz+tNJM1FZpIojadZPU/kAnuOA+0K70uyNh/ZrO?= =?us-ascii?Q?sqYgJ+2r5Sk5DyKyI/X73xILW37uoFl8w6O/7vkK9NXm4WjzZ/DwPhqJvbvF?= =?us-ascii?Q?mp8zap4QqOoefnN6XrCcpifITZRQXQmiqIeKNy3aj2Ah7w7Drn+tuGn0pNI3?= =?us-ascii?Q?jizr/gEiJgxNaBNRI9rKLiAIXHRdxR+L6xgJ0BEo84tXAZqAnAdNc+N+IjA8?= =?us-ascii?Q?BehHpjDRyfJNgw1FL5W1kf6kRsBR6AXsp2TLCAxQLvI2CCA0dynkndDJ5n8p?= =?us-ascii?Q?TU8b0wUG89HcBaW6lG25uX8G++GKvPJAITmOiBipR/Sw8slULXz+85wrLE2S?= =?us-ascii?Q?RSVEo4E4loNnyS+kNsuWsTr4UJ5al8psUx/0fJdpkePzXmBskMlJbAhp+wlm?= =?us-ascii?Q?p6Qlw8RF5ivVSV3jNykhICPpbLfoY9nCegj85d686E+GI1EvQ+F93E5SdZCG?= =?us-ascii?Q?3Yhzd9BXQuos0D+FM/Nmzs8TAL3jMhv57SMTtp0DpcGdopqLT4ttwXwkM80P?= =?us-ascii?Q?Jr1NNlacqF/GvA3ibzKbCRT5QlpimDt8ifKs7tzXqdaQECEnhYX+oJrguZqy?= =?us-ascii?Q?Y0VHWZavcov7RKDZ1OeasMxEF02BpCSlD0WQmcEA7eGLl4SnDt5B0SHzKXPK?= =?us-ascii?Q?iMM/Pwh/lLP28tj58VJ0v1BE2ANt/PqgnmX+M2B4sJX3rwT9Hi+E7QDV/2lR?= =?us-asc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Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2018 11:11:24.5238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99217bb9-48dd-4732-1945-08d597c14f30 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2898 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180401_041144_055054_3B4D74D7 X-CRM114-Status: GOOD ( 22.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Benjamin Herrenschmidt , Chris Metcalf , Catalin Marinas , kvm-ppc@vger.kernel.org, Russell King - ARM Linux , Steven Rostedt , linux-kernel@vger.kernel.org, Pekka Enberg , linux-mm@kvack.org, Mathieu Desnoyers , Michael Ellerman , Andrew Morton , David Rientjes , Paul Mackerras , Christopher Lameter , "Paul E. McKenney" , linuxppc-dev@lists.ozlabs.org, Joonsoo Kim , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Mar 27, 2018 at 11:21:17AM +0100, Will Deacon wrote: > On Sun, Mar 25, 2018 at 08:50:04PM +0300, Yury Norov wrote: > > kick_all_cpus_sync() forces all CPUs to sync caches by sending broadcast IPI. > > If CPU is in extended quiescent state (idle task or nohz_full userspace), this > > work may be done at the exit of this state. Delaying synchronization helps to > > save power if CPU is in idle state and decrease latency for real-time tasks. > > > > This patch introduces kick_active_cpus_sync() and uses it in mm/slab and arm64 > > code to delay syncronization. > > > > For task isolation (https://lkml.org/lkml/2017/11/3/589), IPI to the CPU running > > isolated task would be fatal, as it breaks isolation. The approach with delaying > > of synchronization work helps to maintain isolated state. > > > > I've tested it with test from task isolation series on ThunderX2 for more than > > 10 hours (10k giga-ticks) without breaking isolation. > > > > Signed-off-by: Yury Norov > > --- > > arch/arm64/kernel/insn.c | 2 +- > > include/linux/smp.h | 2 ++ > > kernel/smp.c | 24 ++++++++++++++++++++++++ > > mm/slab.c | 2 +- > > 4 files changed, 28 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c > > index 2718a77da165..9d7c492e920e 100644 > > --- a/arch/arm64/kernel/insn.c > > +++ b/arch/arm64/kernel/insn.c > > @@ -291,7 +291,7 @@ int __kprobes aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt) > > * synchronization. > > */ > > ret = aarch64_insn_patch_text_nosync(addrs[0], insns[0]); > > - kick_all_cpus_sync(); > > + kick_active_cpus_sync(); > > return ret; > > } > > } > > I think this means that runtime modifications to the kernel text might not > be picked up by CPUs coming out of idle. Shouldn't we add an ISB on that > path to avoid executing stale instructions? > > Will commit 153ae9d5667e7baab4d48c48e8ec30fbcbd86f1e Author: Yury Norov Date: Sat Mar 31 15:05:23 2018 +0300 Hi Will, Paul, On my system there are 3 paths that go thru rcu_dynticks_eqs_exit(), and so require isb(). First path starts at gic_handle_irq() on secondary_start_kernel stack. gic_handle_irq() already issues isb(), and so we can do nothing. Second path starts at el0_svc entry; and third path is the exit from do_idle() on secondary_start_kernel stack. For do_idle() path there is arch_cpu_idle_exit() hook that is not used by arm64 at now, so I picked it. And for el0_svc, I've introduced isb_if_eqs macro and call it at the beginning of el0_svc_naked. I've tested it on ThunderX2 machine, and it works for me. Below is my call traces and patch for them. If you OK with it, I think I'm ready to submit v2 (but maybe split this patch for better readability). Yury [ 585.412095] Call trace: [ 585.412097] [] dump_backtrace+0x0/0x380 [ 585.412099] [] show_stack+0x14/0x20 [ 585.412101] [] dump_stack+0x98/0xbc [ 585.412104] [] rcu_dynticks_eqs_exit+0x68/0x70 [ 585.412105] [] rcu_irq_enter+0x48/0x50 [ 585.412106] [] irq_enter+0xc/0x70 [ 585.412108] [] __handle_domain_irq+0x3c/0x120 [ 585.412109] [] gic_handle_irq+0xc4/0x180 [ 585.412110] Exception stack(0xfffffc001130fe20 to 0xfffffc001130ff60) [ 585.412112] fe20: 00000000000000a0 0000000000000000 0000000000000001 0000000000000000 [ 585.412113] fe40: 0000028f6f0b0000 0000000000000020 0013cd6f53963b31 0000000000000000 [ 585.412144] fe60: 0000000000000002 fffffc001130fed0 0000000000000b80 0000000000003400 [ 585.412146] fe80: 0000000000000000 0000000000000001 0000000000000000 00000000000001db [ 585.412147] fea0: fffffc0008247a78 000003ff86dc61f8 0000000000000014 fffffc0008fc0000 [ 585.412149] fec0: fffffc00090143e8 fffffc0009014000 fffffc0008fc94a0 0000000000000000 [ 585.412150] fee0: 0000000000000000 fffffe8f46bb1700 0000000000000000 0000000000000000 [ 585.412152] ff00: 0000000000000000 fffffc001130ff60 fffffc0008085034 fffffc001130ff60 [ 585.412153] ff20: fffffc0008085038 0000000000400149 fffffc0009014000 fffffc0008fc94a0 [ 585.412155] ff40: ffffffffffffffff 0000000000000000 fffffc001130ff60 fffffc0008085038 [ 585.412156] [] el1_irq+0xb0/0x124 [ 585.412158] [] arch_cpu_idle+0x10/0x18 [ 585.412159] [] do_idle+0x10c/0x1d8 [ 585.412160] [] cpu_startup_entry+0x24/0x28 [ 585.412162] [] secondary_start_kernel+0x15c/0x1a0 [ 585.412164] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.14.0-isolation-160735-g59b71c1-dirty #18 [ 585.412058] Call trace: [ 585.412060] [] dump_backtrace+0x0/0x380 [ 585.412062] [] show_stack+0x14/0x20 [ 585.412064] [] dump_stack+0x98/0xbc [ 585.412066] [] rcu_dynticks_eqs_exit+0x68/0x70 [ 585.412068] [] rcu_eqs_exit.isra.23+0x64/0x80 [ 585.412069] [] rcu_user_exit+0xc/0x18 [ 585.412071] [] __context_tracking_exit.part.2+0x74/0x98 [ 585.412072] [] context_tracking_exit.part.3+0x40/0x50 [ 585.412074] [] context_tracking_user_exit+0x30/0x38 [ 585.412075] Exception stack(0xfffffc00385afec0 to 0xfffffc00385b0000) [ 585.412076] fec0: 00000000000000b1 000002aacd702420 0000000000000200 00000000000001f4 [ 585.412078] fee0: 0000000000000000 0000000000000008 000002aabec9af17 ffffffffffffffff [ 585.412079] ff00: 0000000000000016 ffffffffffffffff 000003ffe7619470 0000000000000057 [ 585.412081] ff20: a3d70a3d70a3d70b 000000000000016d 2ce33e6c02ce33e7 00000000000001db [ 585.412082] ff40: 000002aabec7d260 000003ff86dc61f8 0000000000000014 00000000000001f4 [ 585.412083] ff60: 0000000000000000 000002aabecab000 000002aacd6e2830 0000000000000001 [ 585.412085] ff80: 000002aacd6e2830 000002aabec58380 0000000000000054 000002aabebccf50 [ 585.412086] ffa0: 0000000000000054 000003ffe7619540 000002aabebcf538 000003ffe7619540 [ 585.412088] ffc0: 000003ff86dc6410 0000000060000000 00000000000000b1 0000000000000016 [ 585.412089] ffe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 [ 585.412091] [] el0_svc_naked+0xc/0x3c [ 585.446067] CPU: 68 PID: 0 Comm: swapper/68 Not tainted 4.14.0-isolation-160735-g59b71c1-dirty #18 [ 585.412038] Call trace: [ 585.412041] [] dump_backtrace+0x0/0x380 [ 585.412042] [] show_stack+0x14/0x20 [ 585.412045] [] dump_stack+0x98/0xbc [ 585.412047] [] rcu_dynticks_eqs_exit+0x68/0x70 [ 585.412049] [] rcu_eqs_exit.isra.23+0x64/0x80 [ 585.412050] [] rcu_idle_exit+0x18/0x28 [ 585.412052] [] do_idle+0x118/0x1d8 [ 585.412053] [] cpu_startup_entry+0x24/0x28 [ 585.412055] [] secondary_start_kernel+0x15c/0x1a0 [ 585.412057] CPU: 22 PID: 4315 Comm: nginx Not tainted 4.14.0-isolation-160735-g59b71c1-dirty #18 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index e1c59d4008a8..efa5060a2f1c 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -35,22 +35,29 @@ #include /* - * Context tracking subsystem. Used to instrument transitions - * between user and kernel mode. + * Save/restore needed during syscalls. Restore syscall arguments from + * the values already saved on stack during kernel_entry. */ - .macro ct_user_exit, syscall = 0 -#ifdef CONFIG_CONTEXT_TRACKING - bl context_tracking_user_exit - .if \syscall == 1 - /* - * Save/restore needed during syscalls. Restore syscall arguments from - * the values already saved on stack during kernel_entry. - */ + .macro __restore_syscall_args ldp x0, x1, [sp] ldp x2, x3, [sp, #S_X2] ldp x4, x5, [sp, #S_X4] ldp x6, x7, [sp, #S_X6] - .endif + .endm + + .macro el0_svc_restore_syscall_args +#if !defined(CONFIG_TINY_RCU) || defined(CONFIG_CONTEXT_TRACKING) + __restore_syscall_args +#endif + .endm + +/* + * Context tracking subsystem. Used to instrument transitions + * between user and kernel mode. + */ + .macro ct_user_exit +#ifdef CONFIG_CONTEXT_TRACKING + bl context_tracking_user_exit #endif .endm @@ -433,6 +440,20 @@ __bad_stack: ASM_BUG() .endm +/* + * Flush I-cache if CPU is in extended quiescent state + */ + .macro isb_if_eqs +#ifndef CONFIG_TINY_RCU + bl rcu_is_watching + tst w0, #0xff + b.ne 1f + /* Pairs with aarch64_insn_patch_text for EQS CPUs. */ + isb +1: +#endif + .endm + el0_sync_invalid: inv_entry 0, BAD_SYNC ENDPROC(el0_sync_invalid) @@ -840,8 +861,10 @@ el0_svc: mov wsc_nr, #__NR_syscalls el0_svc_naked: // compat entry point stp x0, xscno, [sp, #S_ORIG_X0] // save the original x0 and syscall number + isb_if_eqs enable_dbg_and_irq - ct_user_exit 1 + ct_user_exit + el0_svc_restore_syscall_args ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks tst x16, #_TIF_SYSCALL_WORK @@ -874,10 +897,7 @@ __sys_trace: mov x1, sp // pointer to regs cmp wscno, wsc_nr // check upper syscall limit b.hs __ni_sys_trace - ldp x0, x1, [sp] // restore the syscall args - ldp x2, x3, [sp, #S_X2] - ldp x4, x5, [sp, #S_X4] - ldp x6, x7, [sp, #S_X6] + __restore_syscall_args ldr x16, [stbl, xscno, lsl #3] // address in the syscall table blr x16 // call sys_* routine diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 2dc0f8482210..f11afd2aa33a 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -88,6 +88,12 @@ void arch_cpu_idle(void) trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id()); } +void arch_cpu_idle_exit(void) +{ + if (!rcu_is_watching()) + isb(); +} + #ifdef CONFIG_HOTPLUG_CPU void arch_cpu_idle_dead(void) {