From owner-dev-commits-src-main@freebsd.org Wed Jan 13 20:59:01 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8F2EE4E858E; Wed, 13 Jan 2021 20:59:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DGKYd2ps5z3krV; Wed, 13 Jan 2021 20:59:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (unknown [IPv6:2601:648:8681:1cb0:96c:12e6:ae9f:21b7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 8C2FC2B15B; Wed, 13 Jan 2021 20:59:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: git: 11d62b6f31ab - main - linuxkpi: add kernel_fpu_begin/kernel_fpu_end To: myfreeweb , Konstantin Belousov Cc: Emmanuel Vadot , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202101121143.10CBh02x095972@gitrepo.freebsd.org> <20210113110826.46fbc900b3c375e7215a8195@bidouilliste.com> From: John Baldwin Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WE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NCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Wed, 13 Jan 2021 12:58:58 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 20:59:01 -0000 On 1/13/21 3:42 AM, myfreeweb wrote: > > > On January 13, 2021 10:08:26 AM UTC, Emmanuel Vadot wrote: >> On Tue, 12 Jan 2021 15:16:55 +0200 >> Konstantin Belousov wrote: >> >>> On Tue, Jan 12, 2021 at 11:43:00AM +0000, Emmanuel Vadot wrote: >>>> The branch main has been updated by manu: >>>> >>>> URL: https://cgit.FreeBSD.org/src/commit/?id=11d62b6f31ab4e99df6d0c6c23406b57eaa37f41 >>>> >>>> commit 11d62b6f31ab4e99df6d0c6c23406b57eaa37f41 >>>> Author: Emmanuel Vadot >>>> AuthorDate: 2021-01-12 11:02:38 +0000 >>>> Commit: Emmanuel Vadot >>>> CommitDate: 2021-01-12 11:31:00 +0000 >>>> >>>> linuxkpi: add kernel_fpu_begin/kernel_fpu_end >>>> >>>> With newer AMD GPUs (>=Navi,Renoir) there is FPU context usage in the >>>> amdgpu driver. >>>> The `kernel_fpu_begin/end` implementations in drm did not even allow nested >>>> begin-end blocks. >>> >>> Does Linux allow more then one thread to execute kernel_fpu_begin ? >> >> I actually have no idea, adding Greg to cc. > > Looks like they save the context into the current thread state, so yes? (drm doesn't need that) > > Also they seem to do something FPU_KERN_NOCTX like (??) because they disable preemption inside these blocks. > (Where does our NOCTX actually store the state?) It doesn't store at all because threads aren't allowed to sleep in a critical section, so the thread will never give up the CPU while in the FPU section. If threads can voluntarily sleep (cv_wait*, *sleep(), etc.) while using kernel_fpu_begin(), then NOCTX won't work and we will need something else. However, the code snippet from the stackoverflow URL I posted earlier looks exactly like the NOCTX case where we flush the user FPU state to the thread if the FPU state is "dirty" and then load a clean initial state for use by the FPU. It would also seem to never save the kernel FPU state anywhere by counting on avoiding context switches. So, I think you probably should just make this use NOCTX. -- John Baldwin