From patchwork Thu May 5 16:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 12839779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AD1F9C433F5 for ; Thu, 5 May 2022 16:33:49 +0000 (UTC) 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=DioUzQqJBqM9gSWmKRf/jUfIcfoT2kvx4ZkpNRCztrM=; b=z5MyOv7kWZEWDJ p7f5oI56JVu36BHQd2nXgNbu+u+Uaqvx97vxYuOEVj5fCeGFwUt+bPqoA9QNHaDJHsjEKaG38JMyP AYnMSSqRXowEMhb+HEkq58NbuhwUTL2GY2jC5Smz0qiH7AAA9QqeutwLw6HIdK+xzwx4QJR5ws4VI LW3I4kDQUXp83gQdCTY3B1IGtswDBjp4wSIUZlY4Ufm5jZXDavPz5Wyxxr08Y2LOcMEtta2Oifdcl q+dj1ZSsphWZvYeG8NIZtb3lZR3SNML/26U7LU/uOpb2VhjPGhlkgjr61CJm9Xc2jCPfqllGBaLN0 PFcTGW5WoiidKpdgKfng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmePJ-00GsMy-Ff; Thu, 05 May 2022 16:32:49 +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 1nmeOs-00Gs8v-3y for linux-arm-kernel@lists.infradead.org; Thu, 05 May 2022 16:32:24 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1651768333; 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=UhvugnrnSVEkgaTr6vuGdh+1uO5Ehoz84DBvH9ORve8=; b=PZFj7i9Ulvdr4aGFnlBRyKAAPZm70H6UgKaL2HxcnsLqwttlVKT6I2AjRCd3DNWW6mm7lK x3bMMG3PMWQovnj5rXAnPk9nrYBgA0fw4I8HgK3Ex8EcWtNl3JEZ7K4YK9UXMb9SqPIjwY oG1aAd+U3dB+IoeSarzq9EqqKUaJCIuDvJWcGBnr6GFeVt+YtTPdPN/Wa7GC1YAKEMe7ra 9HgMK5VFkRyw5TRB+aRn8iHOV1roshPhbVWlnBZFGR0F0iJ40QjMsXbsMurwP8ynYjy5Rk 4VFQ2K3KZZ/u5jmdW/lponTuRHtbpWbzPy3CV+bYJ7QWo94GPh9xFnrGlf+/gw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1651768333; 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=UhvugnrnSVEkgaTr6vuGdh+1uO5Ehoz84DBvH9ORve8=; b=3c4ySyon0VMhDIYu04AVi+cZD8babqI6cESs+L77rihRfNPcAILV22DXIZFtlCsShHUBhl tEaIIxc61D6dFcCw== To: linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH 1/3] arm64/sve: Delay freeing memory in fpsimd_flush_thread() Date: Thu, 5 May 2022 18:32:05 +0200 Message-Id: <20220505163207.85751-2-bigeasy@linutronix.de> In-Reply-To: <20220505163207.85751-1-bigeasy@linutronix.de> References: <20220505163207.85751-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220505_093222_321683_BC9877A2 X-CRM114-Status: GOOD ( 10.11 ) 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()+sme_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 Reviewed-by: Mark Brown --- arch/arm64/kernel/fpsimd.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 95a733d3b2538..475939beb0167 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1562,6 +1562,9 @@ static void fpsimd_flush_thread_vl(enum vec_type type) void fpsimd_flush_thread(void) { + void *sve_state = NULL; + void *za_state = NULL; + if (!system_supports_fpsimd()) return; @@ -1573,18 +1576,28 @@ void fpsimd_flush_thread(void) if (system_supports_sve()) { clear_thread_flag(TIF_SVE); - sve_free(current); + + /* Defer kfree() while in atomic context */ + sve_state = current->thread.sve_state; + current->thread.sve_state = NULL; + fpsimd_flush_thread_vl(ARM64_VEC_SVE); } if (system_supports_sme()) { clear_thread_flag(TIF_SME); - sme_free(current); + + /* Defer kfree() while in atomic context */ + za_state = current->thread.za_state; + current->thread.za_state = NULL; + fpsimd_flush_thread_vl(ARM64_VEC_SME); current->thread.svcr = 0; } put_cpu_fpsimd_context(); + kfree(sve_state); + kfree(za_state); } /*