From patchwork Fri Nov 17 16:38:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10063007 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 923676023A for ; Fri, 17 Nov 2017 16:48:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83DEC2AD35 for ; Fri, 17 Nov 2017 16:48:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78C0F2AD3E; Fri, 17 Nov 2017 16:48:56 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 2A7C62AD35 for ; Fri, 17 Nov 2017 16:48:56 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Sp8vUQTUuNuaeGfw70xJjsazhNdkCDN84yptzIBpynk=; b=Eo1w+9ILhOmyUx625BS7gjgbT/ MP+WCq2YTBwOiY9tY1zXjC1IbZCsAGGzoQ+MFmqsrIWYhAwUPumouhJjFIqdJP/Fvoh70LMcr1kIG k1yCk/d76NRRn40gqA7Ogw9YfskGno1LQFTpj0AHQiLvXJnBvc0/yZlAAeJVeV8P+ktjt0cj/MuDn MU+ZMgH5JA6XeIpcEq6+QMT1AAqsVC2r9kFsv2Ge3nmS9tHtcwwn7Q7f8akw8LOdtH4zLcay485oE HWzZKc0vvYQCxU0cf/CrH815t7PMmetGYdmnRCtmueE/zvHkCN1lQZHQp1TRrAawSpZ7eUXbY5Ey+ XYKvzFvg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eFjp0-0006Mz-Q3; Fri, 17 Nov 2017 16:48:54 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eFjfs-0000EL-Jf for linux-arm-kernel@bombadil.infradead.org; Fri, 17 Nov 2017 16:39:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uS33vkV7ieNdd17AGJXWgN1bz39HT7IsXJWg54f1AjA=; b=Vew8dG3faJR7iEk8KK1msHPTV zl8OB7sl8UTS2bh9gxy4knSBvLZ6i25eu2kUTtEc8WJf3LN42I+GXerYw+5xGT66gfC7yKuzvNVp6 K7qrIuhu6NU4zmjNA7MpzMxw4uGoOj6oV3dhhIMz2Ehw7/IoSsBb3CQ6apAfV1pmLhP+CPis1uYgg qJEKnFOS7mNyRMVJrVNWpKI+SsxAsuqo0Xer3jVEM0+aD3Ux+vaISd9rqEiyGwLGqiuTKHh8WLb7X TUBdI4jc4CKQ4LbnzjKmPLyMVTuyAhRwO2QuZMmzfSbRP+nOF0Ihp4VFG9LOnuglR8u0Xu9f5hRNk 9LLGJ+roQ==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eFjfo-00028m-36 for linux-arm-kernel@lists.infradead.org; Fri, 17 Nov 2017 16:39:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 65A8D1596; Fri, 17 Nov 2017 08:39:03 -0800 (PST) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 569213F487; Fri, 17 Nov 2017 08:39:02 -0800 (PST) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 1/4] arm64: fpsimd: Abstract out binding of task's fpsimd context to the cpu. Date: Fri, 17 Nov 2017 16:38:52 +0000 Message-Id: <1510936735-6762-2-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1510936735-6762-1-git-send-email-Dave.Martin@arm.com> References: <1510936735-6762-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171117_163924_281679_40C2C2A6 X-CRM114-Status: GOOD ( 11.74 ) 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: Marc Zyngier , Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 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 There is currently some duplicate logic to associate current's FPSIMD context with the cpu when loading FPSIMD state into the cpu regs. Subsequent patches will update that logic, so in order to ensure it only needs to be done in one place, this patch factors the relevant code out into a new function fpsimd_bind_to_cpu(). Signed-off-by: Dave Martin --- arch/arm64/kernel/fpsimd.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 143b3e7..007140b 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -992,6 +992,18 @@ void fpsimd_signal_preserve_current_state(void) } /* + * Associate current's FPSIMD context with this cpu + * Preemption must be disabled when calling this function. + */ +static void fpsimd_bind_to_cpu(void) +{ + struct fpsimd_state *st = ¤t->thread.fpsimd_state; + + __this_cpu_write(fpsimd_last_state, st); + st->cpu = smp_processor_id(); +} + +/* * Load the userland FPSIMD state of 'current' from memory, but only if the * FPSIMD state already held in the registers is /not/ the most recent FPSIMD * state of 'current' @@ -1004,11 +1016,8 @@ void fpsimd_restore_current_state(void) local_bh_disable(); if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) { - struct fpsimd_state *st = ¤t->thread.fpsimd_state; - task_fpsimd_load(); - __this_cpu_write(fpsimd_last_state, st); - st->cpu = smp_processor_id(); + fpsimd_bind_to_cpu(); } local_bh_enable(); @@ -1032,12 +1041,8 @@ void fpsimd_update_current_state(struct fpsimd_state *state) } task_fpsimd_load(); - if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) { - struct fpsimd_state *st = ¤t->thread.fpsimd_state; - - __this_cpu_write(fpsimd_last_state, st); - st->cpu = smp_processor_id(); - } + if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) + fpsimd_bind_to_cpu(); local_bh_enable(); }