From patchwork Tue Jan 5 18:53:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Metcalf X-Patchwork-Id: 7958141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 29BF0BEEE5 for ; Tue, 5 Jan 2016 18:55:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B35C2025B for ; Tue, 5 Jan 2016 18:55:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5DCE32025A for ; Tue, 5 Jan 2016 18:55:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGWjn-00086t-0g; Tue, 05 Jan 2016 18:53:43 +0000 Received: from mail-am1on0678.outbound.protection.outlook.com ([2a01:111:f400:fe00::678] helo=emea01-am1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGWji-00083D-QN for linux-arm-kernel@lists.infradead.org; Tue, 05 Jan 2016 18:53:41 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=cmetcalf@ezchip.com; Received: from [10.7.0.41] (12.216.194.146) by DB4PR02MB126.eurprd02.prod.outlook.com (2a01:111:e400:289a::21) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 5 Jan 2016 18:53:11 +0000 Subject: Re: [PATCH 2/2] arm64: factor work_pending state machine to C To: Mark Rutland References: <20160105172106.GA7088@leverpostej> <1452015215-29506-2-git-send-email-mark.rutland@arm.com> From: Chris Metcalf Message-ID: <568C110F.3060503@ezchip.com> Date: Tue, 5 Jan 2016 13:53:03 -0500 User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <1452015215-29506-2-git-send-email-mark.rutland@arm.com> X-Originating-IP: [12.216.194.146] X-ClientProxiedBy: BN3PR0401CA0003.namprd04.prod.outlook.com (2a01:111:e400:51d1::13) To DB4PR02MB126.eurprd02.prod.outlook.com (2a01:111:e400:289a::21) X-Microsoft-Exchange-Diagnostics: 1; DB4PR02MB126; 2:8FqhsfwfWs3Rnf0Sj3+SiD0gnMG0WSveHtRajTcziqnjnrxpUPacpIdudUSraUpDURPfK4w5wtn66cV6G/U+DmflNni0+8Ze2YCrtsIbvQn/5LlitGhNZlQJ+qIrxPFFkwjqgOfBtCnB9m3+hw53eA==; 3:KoeqzS9n+FGjj+M40oHedHbJ6TFKCbh9T0YN4lbdVcgqBRLEF0tmyKnJlrvyrS3SfE3UpgR+j+WzbfTgCvmyt6FKdUgl6rBvaP6zS6hTWMTkVpeal2typq7rTQxGNkwH; 25:2RILfIa/9dFfF+AlyYNrGv37gJwou0dvS6iaD9QuemLaUlc73V+WoRrkkJ52l0rWxRtgNlD+5PLS6bK+ahIqAQhTn5FqASILygDVL/6/C8F+5NeUpcy/A+2mniz/rAlymGRCRJg6EO14pQhNGlz0dR6k7zrdmkjyV3owaFwwlWKv5mJVjEktpJyr5QL0/007v2LmpSU1cb6ZZUklJxpGD7JhiSrcbd9dKkY7VLRZPh4aiT6VWXVSAXZpXbNQwkuXI4C5XAOMCz8Q+WO+RX1bhA==; 20:OpdLAmsP9Jeqy/6qt93g2Wp2xTMBuqMKksKY5Uelol6DKOMuEx8h/pEzQ/pw8sUXHxTfoiuNY8EFHY0odHNRFsNIdltISg7KvL8Fsei9HxIIAiaj7fhxqoHYd98Qeg1g1njv9SFIm+B/NeWMYvV3YjBNCZxxJqyJauDGlSpkukI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR02MB126; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872)(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046); SRVR:DB4PR02MB126; BCL:0; PCL:0; RULEID:; SRVR:DB4PR02MB126; X-Microsoft-Exchange-Diagnostics: 1; DB4PR02MB126; 4:8EryrGf154qDFY3zUkqaV9cIXZ3Ms5OdiOUv48mRVtqCX308fzAXTjroKzekwnTcdxOatoGPM0l+RQuSs9q3LgfzXBeUGI+0pMzWhwpAaLlsm1R8XnE42PiesAfZg8RRbgCRJVZDV23YK2h8XMuzb4JKQ5NN7CQ0etI7rIfpZO2qDaCOAGrQY4XU3XN+8uOaaBGooxKm2LlsgvHMbEXv4VB5uK/J3QXbA6gDklj7ji4JsyjjkBMw+A1Ex0swzseq3HZSohJBDMBMsvEhHwtSL+uxeRGtgWkOMb4iC/FTYMrNysMY4lUOQpr5MnfaQkU743uQ+TEPIHbOVNK2324eO0MkVJ9b5XbAd3fi6WS/MdC5C6FiUMgHq/p6aP83EM2zNtZ5F0CQI7rt1leHVx9LBVHgoX44Xb7eFz3a71RONLVDLqpXNB8QXB14emcbmOgsY2VWudIvrYmvqDKgR1nTwQ== X-Forefront-PRVS: 0812095267 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6049001)(6009001)(377454003)(479174004)(24454002)(199003)(189002)(87266999)(80316001)(23746002)(5004730100002)(3846002)(76176999)(575784001)(77096005)(65816999)(66066001)(230700001)(40100003)(2950100001)(86362001)(54356999)(50466002)(5008740100001)(105586002)(47776003)(33656002)(50986999)(19580395003)(87976001)(122386002)(64126003)(19580405001)(189998001)(586003)(42186005)(83506001)(6116002)(106356001)(15975445007)(1096002)(101416001)(92566002)(59896002)(36756003)(4326007)(110136002)(65956001)(5001960100002)(4001350100001)(97736004)(81156007)(65806001)(3076002)(21314002)(18886065003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR02MB126; H:[10.7.0.41]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: ezchip.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; DB4PR02MB126; 23:Ug9yAWKByEmr6mr7Nh9L5mgheL7P++2N7LtAaD?= =?Windows-1252?Q?z2w7Rtg44PrjS8z03qU2MnwfjJWPus3X+kC/iJ78f+rKNjqaaeMRkuqa?= =?Windows-1252?Q?yhHcnsEP8p1nTpt4fftOi9mS1ThcFaNoAkUkDI7JSi+TzXydFQ/O4yFv?= =?Windows-1252?Q?ilAVJlrFQXSevpQbcTdrFxORuEzpag89Bnd0zVMJZqRK7ShMRLEgVKS/?= =?Windows-1252?Q?jtFw6hWkHPWqA9ZVZsRkL236bsk75+xvNcie5K5z9dmVXeVzBGVMiZ3G?= =?Windows-1252?Q?8Q8V9w4iJSxRm+bIv8NnqZTkzUyg3v66daEfjhlUQvHkuF2iPFCDGWlr?= =?Windows-1252?Q?HvnCFlr5+pE4NEARLqyFxsdYVpl3efuH3o9ZGCBYQbkkEdfyHp7OFXqI?= =?Windows-1252?Q?IxuuqQ6QDtEWu25Bbb4CH4AdTawSim9NPjvmIvcgQnyznCG2eH6XoXTC?= =?Windows-1252?Q?o0x1oTJm6stb8E643vg43Ugs8fD/Tl0cg0XYf88vAxk8sCV52Z0i/oaa?= =?Windows-1252?Q?WahvZ1JR4tpSsvSIJNS+Hw2s72ybg7MlmGxwQ5U74U5hESjHPjqAJ4QQ?= =?Windows-1252?Q?iIGVFTIFW2ED0G6PUSB8exD2LS8zQSsBo21OEV9K8cjl9UIV8qF5VQjg?= =?Windows-1252?Q?yTfabrZhbnsg556JhSVLmBrnHMgVsdkFDEVb2lPIC0Y4tw8ZLcsAjKrI?= =?Windows-1252?Q?g1iXwrriRbkbIfn2IFWDhZOjjMyPhCPKsJHDSyfQT6tdKizbzc7OgLui?= =?Windows-1252?Q?jtQXaaGZciadMgXSXNY9UOokZp3wQpo9IDGwHNCQAjpAEwpnEv49ERUj?= =?Windows-1252?Q?E0C4484zddQCb+hug/JoutMQKEXfqNrPMMiHmt6EM0aTKlipKbEYucqG?= =?Windows-1252?Q?Pm5ZdGXLNDdGXNC4ef5bAUPDmN23zD1IGHVjVQIVwEjT+pjeCk4hOaX7?= =?Windows-1252?Q?friPHRoGMpkLivU1Py2nHKpw9QvnBr735vHt5U/dWAV+ye+kEnoWcNO4?= =?Windows-1252?Q?k3Xa1KpOQVez9yKIG1CZ7hOfUw1mjTsZPzG2kuFMp9dJU8u79wO+tCbf?= =?Windows-1252?Q?+BLg7RkXgQ7Lz+oefJID3uZsclEpgQNj6LTTXxOHCShCsz6/vWfIteTW?= =?Windows-1252?Q?p83P6UUKlWMnxhX0iWqdksikGL5C7J8+H4Ka5h7smVUnk1BRwvjEuUZJ?= =?Windows-1252?Q?fb2QyNDz0mREck6nNfSILc7IRahkOL8cwPw3TNdJpVtHH30lXjCTGvjK?= =?Windows-1252?Q?n0WQ7zrVS8v5R3wGZCehvPJxnohnVSvTFAEp2/qDnTOOmOQu6i84pKtx?= =?Windows-1252?Q?uHkMV1JmJmy9s7QBPAEpR6XfN3T9fOBg4+bLJpGmXDsmq9HbXzXLcS9U?= =?Windows-1252?Q?0v+ok6zPC40v/pVgmT/FBCeP9RjWEfasjsF1XICMj9N3jNhvw+hezcD0?= =?Windows-1252?Q?19n+qd0vpFH2GHfiuUez6HYOL38N4HOawvtKGp15yk4MqmMDfIYHyQCz?= =?Windows-1252?Q?7teQ1HqXfTw6ULCanr9QZ/rWD+KW8b++yrp/UtzeXhKknUNA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB4PR02MB126; 5:jXCnlnTUQoCL/+fqW597LdglcVqhWm0LsbTzqPfRe8mtk/imiu5LZ31xD6u61w9+pE1VR0PznTm9vaptJ4F2X873EpgWlFtQKwqFGQutZbwXBIjJucolqt8BvPxCtiXbrE2Yf0CxlAxusv05QDLRWw==; 24:X+tSbrNiQqLW+uozXEUhiqDasHSRm1o0VJ07NRiL1pOykpkH5WgxitT/wApmlaDYKGSkYlOxKfCqM5ryC7NRNZp42PbgbHzsrhHo+KcoRDo= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2016 18:53:11.7951 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR02MB126 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160105_105339_355480_4EC070FC X-CRM114-Status: GOOD ( 16.49 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, luto@amacapital.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 01/05/2016 12:33 PM, Mark Rutland wrote: > Currently ret_fast_syscall, work_pending, and ret_to_user form an ad-hoc > state machine that can be difficult to reason about due to duplicated > code and a large number of branch targets. > > This patch factors the common logic out into the existing > do_notify_resume function, converting the code to C in the process, > making the code more legible. > > This patch tries to mirror the existing behaviour as closely as possible > while using the usual C control flow primitives. There should be no > functional change as a result of this patch. > > Signed-off-by: Mark Rutland > Cc: Catalin Marinas > Cc: Chris Metcalf > Cc: Will Deacon > --- > arch/arm64/kernel/entry.S | 24 +++--------------------- > arch/arm64/kernel/signal.c | 36 ++++++++++++++++++++++++++---------- > 2 files changed, 29 insertions(+), 31 deletions(-) This looks good, and also makes the task isolation change drop in very cleanly (relatively speaking). Since do_notify_resume() is called unconditionally now, we don't have to worry about fussing with the bit numbering for the TIF_xxx flags in asm/threadinfo.h, so that whole part of the patch can be dropped, and the actual change to do_notify_resume() becomes: For the moment I just added your two commits into my task-isolation tree and pushed it up, but if your changes make it into 4.5 and the task-isolation series doesn't, I will remove them and rebase on 4.5-rc1 once that's released. I've similarly staged the arch/tile enablement changes to go into 4.5 so I can drop them from the task-isolation tree as well at that point. diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 3a6c60beadca..00d0ec3a8e60 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -408,7 +409,8 @@ asmlinkage void do_notify_resume(void) local_irq_disable(); thread_flags = READ_ONCE(current_thread_info()->flags); - if (!(thread_flags & _TIF_WORK_MASK)) + if (!(thread_flags & _TIF_WORK_MASK) && + task_isolation_ready()) break; if (thread_flags & _TIF_NEED_RESCHED) { @@ -428,5 +430,7 @@ asmlinkage void do_notify_resume(void) if (thread_flags & _TIF_FOREIGN_FPSTATE) fpsimd_restore_current_state(); + + task_isolation_enter(); } }