Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp430335pxv; Thu, 22 Jul 2021 03:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznAWDWjztLv9og29I7G29FbPu5Kbs8C2sztm4YgURpn0kGdNcAm6jt5sQSozR9++a32yS7 X-Received: by 2002:a05:6638:3048:: with SMTP id u8mr34906945jak.91.1626950930747; Thu, 22 Jul 2021 03:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626950930; cv=none; d=google.com; s=arc-20160816; b=kkHRiabL605rMygzMeKGM7LcTLxwCMV44eSjn0C5gLCH3tWN0hvQzX9R+BNLtcaeOP 5svmd8hbDsQHp4EFvW2wGDj6ImotR551zOSGSo76qs8Pnx1BRIKR4jX3gkAofoYxEY/i 8GibmTqtof1h4r2k2USEhes61fnL84hHuMaSFOOQQVTx732lWZEy0ar23nEhBGflHKXJ bP/fF6KSh6QK10cDiA8UABHFM+Pfw46rjRGj9tgD8jxngyGspJMq7p/fqfmYGO6wrfDT Wf+1NtW4NOzHqWuiKE+8m4WsOhDZRF0CFExzx3/UFDSmu6DuZTMnbQEK8x+otPjT0Pgh 95xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=UIjEw7LvBGrlUjquppZsCZAJs4MMNYvbssuJ9Tn9rvA=; b=lrYUTJvQ6McRQNvsIQ0jkl3nHBeEdBShL1wZjQj9nHJ0V29BU7bouuRp74RDu8rXcj jCfsy1646liobeV0eEsxCbugTj2TyTXli6ss3OwayFzOqitJNSNg1Cp609xbQHTn7TuV 4r5j10GmrPWu6vUO6rI++7uQi7tVJwEulW/fKB//DY0ol9V0BibgGfUUTkYgUghEyrmE VgY/j4hO7qKOwMKHu0Oso0NZVObQ0K1NyUv3Gpidodu1YI8xdUfjKlErFnJ1dRUN8+ZY KRbv8aN4AyQMsywVy7dP4nHHmGYdrP07ne8qmNScPZGLaY8EcUSHHZ0Odm+WJ0+XBpuO QAbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=BSbiykPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si25044640ioo.75.2021.07.22.03.48.38; Thu, 22 Jul 2021 03:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=BSbiykPn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbhGVKGc (ORCPT + 99 others); Thu, 22 Jul 2021 06:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230410AbhGVKGc (ORCPT ); Thu, 22 Jul 2021 06:06:32 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73EE4C061760 for ; Thu, 22 Jul 2021 03:47:06 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id gb6so7723152ejc.5 for ; Thu, 22 Jul 2021 03:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=UIjEw7LvBGrlUjquppZsCZAJs4MMNYvbssuJ9Tn9rvA=; b=BSbiykPnrXMqDFLWYOlZ+Xx9F86RQC4xFFGNJKrQva9H34djT58I60UA0c2ryP0wMY dQTMlwL7TZ+8OCgN8ZRAd5SpAQtoDzl5jb/O46f8bz9SLjuig5V0ZVlRUNdt8/szq8Jq 4kgNG3kxl2U06Reo0PMNqg4flHxCgalyEb3wE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=UIjEw7LvBGrlUjquppZsCZAJs4MMNYvbssuJ9Tn9rvA=; b=EOK9aRl2QxGqgp5772Bx/EmwTcgmSo4HrXwsXksTPWo3AW2aNaV3upTW5bBastx629 nin3PQOzutkkmihk64WxgWraxy/39VyEsm+oCE6YmwwjMFtOXgU95MJ8SvC9/eY+iRK0 yzrQcccEXjNmoPumEiIC8zRkSVZyBVlNz8yy35kXwJ2Arwx7opLiWhzfdTpUXfGMW+IR FugyYB03po4rK3hHfwTJxmw0KlkqEyVf77igDeH2fbtJ18SYDkUQJcuamB9r8zXwKdTr zzlq7CaIIk/C1YFCuCHrefMwu8Wi3sKiWxeqKEY4Gqinn//bUXciPRYdUmVtDxOSmKe9 Z+fw== X-Gm-Message-State: AOAM531TWNfnQcRyeHyRgl330p5sc5EI0Rvi9md9z5kw9Qd1H5GYYMS8 Iv9we8yZQd2v89EIefW8R2D9jA== X-Received: by 2002:a17:906:538e:: with SMTP id g14mr23577022ejo.136.1626950824915; Thu, 22 Jul 2021 03:47:04 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id gw8sm9336666ejb.44.2021.07.22.03.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jul 2021 03:47:04 -0700 (PDT) Date: Thu, 22 Jul 2021 12:47:02 +0200 From: Daniel Vetter To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Rob Clark , dri-devel , Rob Clark , "open list:DRM DRIVER FOR MSM ADRENO GPU" , David Airlie , "open list:DRM DRIVER FOR MSM ADRENO GPU" , open list , Christian =?iso-8859-1?Q?K=F6nig?= , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Sean Paul , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [Linaro-mm-sig] [PATCH] drm/msm: Add fence->wait() op Message-ID: Mail-Followup-To: Christian =?iso-8859-1?Q?K=F6nig?= , Rob Clark , dri-devel , Rob Clark , "open list:DRM DRIVER FOR MSM ADRENO GPU" , David Airlie , "open list:DRM DRIVER FOR MSM ADRENO GPU" , open list , Christian =?iso-8859-1?Q?K=F6nig?= , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Sean Paul , "open list:DMA BUFFER SHARING FRAMEWORK" References: <60ffb6f3-e932-d9af-3b90-81adf0c15250@gmail.com> <113b5858-9020-d1c1-292b-96b7f9cc717a@gmail.com> <9c1e797b-8860-d1f5-e6f2-e06380ec9012@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9c1e797b-8860-d1f5-e6f2-e06380ec9012@gmail.com> X-Operating-System: Linux phenom 5.10.0-7-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 22, 2021 at 11:28:01AM +0200, Christian K?nig wrote: > Am 22.07.21 um 11:08 schrieb Daniel Vetter: > > [SNIP] > > > As far as I know wake_up_state() tries to run the thread on the CPU it was > > > scheduled last, while wait_event_* makes the thread run on the CPU who > > > issues the wake by default. > > > > > > And yes I've also noticed this already and it was one of the reason why I > > > suggested to use a wait_queue instead of the hand wired dma_fence_wait > > > implementation. > > The first versions had used wait_queue, but iirc we had some issues with > > the callbacks and stuff and that was the reasons for hand-rolling. Or > > maybe it was the integration of the lockless fastpath for > > dma_fence_is_signalled(). > > > > > [SNIP] > > > Well it would have been nicer if we used the existing infrastructure instead > > > of re-inventing stuff for dma_fence, but that chance is long gone. > > > > > > And you don't need a dma_fence_context base class, but rather just a flag in > > > the dma_fence_ops if you want to change the behavior. > > If there's something broken we should just fix it, not force everyone to > > set a random flag. dma_fence work like special wait_queues, so if we > > differ then we should go back to that. > > Wait a second with that, this is not broken. It's just different behavior > and there are good arguments for both sides. Oh I know, but since dma_fence is meant to be a wait_queue with hw support, they really should work the same and have the same tuning. > If a wait is short you can have situations where you want to start the > thread on the original CPU. > ??? This is because you can assume that the caches on that CPU are still hot > and heating up the caches on the local CPU would take longer than an inter > CPU interrupt. > > But if the wait is long it makes more sense to run the thread on the CPU > where you noticed the wake up event. > ??? This is because you can assume that the caches are cold anyway and > starting the thread on the current CPU (most likely from an interrupt > handler) gives you the absolutely best latency. > ??? In other words you usually return from the interrupt handler and just > directly switch to the now running thread. > > I'm not sure if all drivers want the same behavior. Rob here seems to prefer > number 2, but we have used 1 for dma_fence for a rather long time now and it > could be that some people start to complain when we switch unconditionally. I think the defaults are different because usually if you wake up a wait queue, there's a 1:1 relationship between waker and waiter. Otoh if you just wake a thread it's probably some kinda of service thread, so N:1 relationship between waker and waiter. And in that case moving the waiter is a really bad idea. I think dma_fence is generally much closer to 1:1 (with the most common one irq handler -> scheduler thread for that engine), so having the "same cpu" wake behaviour really sounds like the right thing to do. And not anything that is specifically an issue with how qualcom gpus work, and hence should be msm specific. If it turns out to be the wrong thing, well I guess we'll learn something. And then maybe we have a different version of dma_fence_wait. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch