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=-16.0 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, USER_AGENT_SANE_1 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 8CE95C4338F for ; Thu, 29 Jul 2021 14:01:13 +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 5E4E760238 for ; Thu, 29 Jul 2021 14:01:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5E4E760238 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=npAk0lnCqZjktjABAB5jXpfO4YweFBOv4UB/+HZMAPw=; b=3Y9FCJJ5pHS7na K5m8qIgesUIlq04W3DFaSWPnCkur8GxWxa3MYyWgLMu4h6Uda9mIUMUrE+ctg0fqles1lm/UAic+j 211dWLc1AAVRXu/tcef6izki3xBVH4SpacYR7awS4zSeN2bqejVRERUNLpMZus0MW45udkEYc5isM V6f1C+4i671eDDgTdJpwJMIGgi7Uaeu8+Oa/xwDqrQ5uPjSE1u1aYemoVHJv3pBcExkKLeMmYVYLO 4CNWKswYzKBM9iPv5kqK9dtcozk5VxLy+BRhk8DrLR8TjTZcgkNCVzYd5fKEkCzrmp4GWKhfXEQFW SL5pXlpBuvknFWSETmHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m96Zg-004Qz3-Fg; Thu, 29 Jul 2021 13:59:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m96Zc-004Qxm-2E for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 13:59:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0FB2D6D; Thu, 29 Jul 2021 06:59:42 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 262793F70D; Thu, 29 Jul 2021 06:59:41 -0700 (PDT) Date: Thu, 29 Jul 2021 14:58:20 +0100 From: Dave Martin To: Sebastian Andrzej Siewior Cc: linux-arm-kernel@lists.infradead.org, Mark Brown , Catalin Marinas , Will Deacon , Thomas Gleixner Subject: Re: [PATCH] arm64/sve: Delay freeing memory in fpsimd_flush_thread() Message-ID: <20210729135819.GM1724@arm.com> References: <20210729105215.2222338-1-bigeasy@linutronix.de> <20210729105215.2222338-2-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210729105215.2222338-2-bigeasy@linutronix.de> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_065944_196505_0D60F549 X-CRM114-Status: GOOD ( 22.14 ) 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: , 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 On Thu, Jul 29, 2021 at 12:52:14PM +0200, Sebastian Andrzej Siewior wrote: > 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. I'll leave this for Mark Brown to comment on, but it looks reasonable to me. Cheers ---Dave > > 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); > } > > /* > -- > 2.32.0 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel