From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEFA0C433DB for ; Thu, 28 Jan 2021 13:08:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F59E64DCE for ; Thu, 28 Jan 2021 13:08:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F59E64DCE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=IznSftZ6S5cQdMxWWIzSca5bFoFbhilQv23Q1h/nLDg=; b=uNH//UH4JtrvAKAFU1X0SLiHT +apeY5bmEpJ9K/BvILenMzU8yRMtjuspx6VrxfYbKHhLDvOolkNQVqvu161ISuyJ8HClfcH1z5uPI DmtFo+1v6F1T9PzBkJr/qQvB3I5VlCkbfjH9nFCxk1jdJ+CKt6Ci6494FYXv+x078qB3Bt//YF5CF RGyk9AZKvq69YtBSvXCnTRQeg5HdesOswK+bnKgcjYb/xVke7nusfHq2I62ISWn8SvvgEFsOovJYo RUlCbCzCYmyiuv14hw2bnua7jkKE8/YJpE3H9lkVAnKEbUPNCM4CGHvj0SeaEA/PBg2rZchSFsHGT 1NCqvGCAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l570a-0005KT-Tb; Thu, 28 Jan 2021 13:06:48 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l570V-0005JH-Fe for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2021 13:06:44 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 93F0764DDD; Thu, 28 Jan 2021 13:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611839202; bh=r/Ns1W+DufnkR/AI4Ek7TWkmmUH/izqWzKydAUbFutI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TDdH+RJPhMcBwtNS7QN7GrRc2/CnjOmoJsz7k4CQe9smEI1tMazhUJ1yaQxrdk03t TN+h9R0mR1Llmr1sWO/aiBcjlpV3dQsaDgq4Sh2yn/IC+fVEJbyjDyVICx6ONwbwMj LJ+xfl3ZcV4WmCbuEeYFr6IO9wpM7HpwulQMUZmOgLzYDh5d6lcxN1vmTFrbG6W8xy Tz1AGIxJAki4vjVyt2IfiSJZYPv1lQQ43+QAjtB9UIQtFz0HMccsIyYTSvo3m5b648 cFtpRcH3piNvEkTQDKdKv0oKGJCqqLaRpSUSu1z9EjnUOJhzZB5N0OTdKFTaszY7hX utQKeErSvP90Q== From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Subject: [PATCH 1/9] arm64: assembler: add cond_yield macro Date: Thu, 28 Jan 2021 14:06:17 +0100 Message-Id: <20210128130625.54076-2-ardb@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210128130625.54076-1-ardb@kernel.org> References: <20210128130625.54076-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210128_080643_614995_ACA95805 X-CRM114-Status: GOOD ( 11.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, herbert@gondor.apana.org.au, Eric Biggers , catalin.marinas@arm.com, Dave Martin , will@kernel.org, Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a macro cond_yield that branches to a specified label when called if the TIF_NEED_RESCHED flag is set and decreasing the preempt count would make the task preemptible again, resulting in a schedule to occur. This can be used by kernel mode SIMD code that keeps a lot of state in SIMD registers, which would make chunking the input in order to perform the cond_resched() check from C code disproportionately costly. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/assembler.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index bf125c591116..5f977a7c6b43 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -745,6 +745,22 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU .Lyield_out_\@ : .endm + /* + * Check whether preempt-disabled code should yield as soon as it + * is able. This is the case if re-enabling preemption a single + * time results in a preempt count of zero, and the TIF_NEED_RESCHED + * flag is set. (Note that the latter is stored negated in the + * top word of the thread_info::preempt_count field) + */ + .macro cond_yield, lbl:req, tmp:req +#ifdef CONFIG_PREEMPTION + get_current_task \tmp + ldr \tmp, [\tmp, #TSK_TI_PREEMPT] + cmp \tmp, #PREEMPT_DISABLE_OFFSET + beq \lbl +#endif + .endm + /* * This macro emits a program property note section identifying * architecture features which require special handling, mainly for -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel