From patchwork Thu Jul 29 10:52:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12408343 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=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 C5347C4338F for ; Thu, 29 Jul 2021 10:54:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 941BC60C40 for ; Thu, 29 Jul 2021 10:54:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 941BC60C40 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2obNb0xn5EJ1zcB4hpg/gko0oqJUxkGH7MLALiF7ucU=; b=IN3S3tRltYIwr2 Pcg2v8bgq4bleWfDffXaBqD9D5FPwKnSU+RgjkoQhIkGSkBfSloasCRqYAlJA6qHkVdiOPWtq+nFp oakf7Npo2NXRV6Lkzjngipgbl7qU7oWZ+j9FkiXTy+kHTGQd4gyAZZQG/dPIk0papkaHYRlheTQBR +Ta4HexiBWjuwTzvMgX0UpiLWtHzXq4bBOeRfWiy8LKr4uUXDfGSSTSVHwLyKgMDqPw7b4n3z+IoM GigG+G2LkymHTVA59YLDu22PW5wzj30MUQd4PRf5LfUP4rwwGY1w3jFO2i93PgW3zLqC+ES1ueQ6b lDL7+62ci20zjShDP7/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m93eZ-003tNx-NQ; Thu, 29 Jul 2021 10:52:39 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m93eO-003tLm-TL for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 10:52:30 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1627555947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZNgfcOkFZLovR0RavWyLyCiO4idUfemL4FNI74bzTBg=; b=t28Hl9z4T0K7MrEKpOFWMCuB54XUp8SxhAm4+xYY66gDgZtiqxQabngppN6BC9j1jgZl7k bDCf9fbQeO0A9JTUb98kk3hgle5mMQS63hBMjtgf6TAIc3tUamMuAz1zqlMDf0hinX0T6Y /hDL4wPuf0UoUm21MSYK217oWf5dAZG32fQel8WSWNi7hfkEPm2lovi/TYWSmQMP/ZtkyI 5IFVq5uvZoFtNQkrqr7OLcv5X4D0LSd1KtxdpYGWG84Khy2waQ5Wpwdoud4l7+hit6B6eo /KPGRlqIMUJ327b9aKNCXDhPL3c9mFzqCRZGXLqKzQe+lN04j8xjy3rWf5B6Hw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1627555947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZNgfcOkFZLovR0RavWyLyCiO4idUfemL4FNI74bzTBg=; b=dU+Mz6l69i1oNUYO8/AbMrJHn30JvsP0JczbEX4iKUNo9Bv90k8EDmBbCGs1sgfAGWe95r arb3n0Vs0QBnVFCA== To: linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH] arm64/sve: Delay freeing memory in fpsimd_flush_thread() Date: Thu, 29 Jul 2021 12:52:14 +0200 Message-Id: <20210729105215.2222338-2-bigeasy@linutronix.de> In-Reply-To: <20210729105215.2222338-1-bigeasy@linutronix.de> References: <20210729105215.2222338-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_035229_165563_437879FC X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org fpsimd_flush_thread() invokes kfree() via sve_free() within a preempt disabled section which is not working on -RT. Delay freeing of memory until preemption is enabled again. Signed-off-by: Sebastian Andrzej Siewior --- arch/arm64/kernel/fpsimd.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index e57b23f952846..e098f6c67b1de 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -226,6 +226,16 @@ static void sve_free(struct task_struct *task) __sve_free(task); } +static void *sve_free_atomic(struct task_struct *task) +{ + void *sve_state = task->thread.sve_state; + + WARN_ON(test_tsk_thread_flag(task, TIF_SVE)); + + task->thread.sve_state = NULL; + return sve_state; +} + /* * TIF_SVE controls whether a task can use SVE without trapping while * in userspace, and also the way a task's FPSIMD/SVE state is stored @@ -1033,6 +1043,7 @@ void fpsimd_thread_switch(struct task_struct *next) void fpsimd_flush_thread(void) { int vl, supported_vl; + void *mem = NULL; if (!system_supports_fpsimd()) return; @@ -1045,7 +1056,7 @@ void fpsimd_flush_thread(void) if (system_supports_sve()) { clear_thread_flag(TIF_SVE); - sve_free(current); + mem = sve_free_atomic(current); /* * Reset the task vector length as required. @@ -1079,6 +1090,7 @@ void fpsimd_flush_thread(void) } put_cpu_fpsimd_context(); + kfree(mem); } /*