Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6585827rwr; Tue, 2 May 2023 02:33:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ69edQ07cLosi/3nbRqcJj55FC8T7CJann08d64pfyav6zBWf4hrhd67Zht0bXeujnBBViG X-Received: by 2002:a05:6a00:10c6:b0:63b:5609:3bb5 with SMTP id d6-20020a056a0010c600b0063b56093bb5mr25504226pfu.18.1683020003618; Tue, 02 May 2023 02:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683020003; cv=none; d=google.com; s=arc-20160816; b=0VBWpaNkV44F7tW5byAg3edQ/AQukPawgZVa3Jz1fihCSpqQNgQgeuMfqh81PFotGI cNg90IxD2ur4OmRs9Xu2mM+wU9URHILkNA02VMbrUQOBJzfp8DKUXvPlzzrdPdQwnenq X4Wq5TE+MZTh5hJayRzdS4VlsKnWJfOyaFZYqa3sva27larbOnc4y0pZK3Dowgkja7Xq hz4+9qeShQY7Il8VpNRjX5EJC2y2EkkbAwY+7vNMI4rybMAENXwhq2eWt2TLUUf0bZMK r4jthK3QWjw4l1ek7RRvAXZD64jHdudaWvlSxbsI5/qP4S+y6LXr+nsw6OQgpDQtEirG aMdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tATDJ3YwN0YIFuJkuZXPFoYmDT3Hka4KTY7vGtll+HE=; b=KX2WdVOxT5iIFIoVBb7ViyH/imNleBTBDK8XEvXeoei62ELA9nUlur8zG7mth/KXzB e2pK/bf9Rw4N2DyRsgHqsVj6Hkuwl8xFPcI/kx9c1BmAhhPjzviUJP3srez5zzwz7Uky LHeJB2nsVKPFZgXJBba1iieOKyFgn9RHCjaM3yYFWlB0QsZZFoH0WLH9vh2J9qH6HC2O 1rA6db1eV+xAuRivErJQdxCro8ALKam2Skf2Qfub2SbSeMqHregTpybTqZI55TW31Ojm rvLw9i6Chrd6HwxiYBCzYcYZY2j5JRY5xZAqEUM/n/1WhIySWzGKyvBVCX+nEYjoETXA 2hdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@basnieuwenhuizen.nl header.s=google header.b=T3DU+8fI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a63e703000000b0050c164c8e99si30099611pgi.436.2023.05.02.02.33.11; Tue, 02 May 2023 02:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@basnieuwenhuizen.nl header.s=google header.b=T3DU+8fI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233507AbjEBJa2 (ORCPT + 99 others); Tue, 2 May 2023 05:30:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233341AbjEBJa1 (ORCPT ); Tue, 2 May 2023 05:30:27 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABBB649FD for ; Tue, 2 May 2023 02:30:24 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-b9a2b7852e6so559528276.0 for ; Tue, 02 May 2023 02:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basnieuwenhuizen.nl; s=google; t=1683019824; x=1685611824; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tATDJ3YwN0YIFuJkuZXPFoYmDT3Hka4KTY7vGtll+HE=; b=T3DU+8fIpXH7t9tYeLnAWEXQvAUb9dY3sS+DJBJM7A4zHOTrz2W9fg+oTF7EvryXGV ihUyAsloKLOgp9s3eqaOxiRzzAfu3ilIu7sS5lcRXkUcz6OAepnSevgFBzP8YNIIp+z8 U/XD0xHhRaj4ZhYy/CQMX/0ZSwJsWpDEJfWhw/r5FT/agH11xFCvRTpkNzlIhx43iCRE 0vp0q3NVq8UGLvv2WFP4QAA+/ksvTutm15aFaVAmZCIp+MhXS3R6FtE0XRBS6XXqqNre wa1+ZfFWlmCiCnikziBlzdMrQgTjoQTLMclgrak5o+WpiwliL99WSZKT9DZrqf8atmrq L7xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683019824; x=1685611824; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tATDJ3YwN0YIFuJkuZXPFoYmDT3Hka4KTY7vGtll+HE=; b=LmHW91voA5zT721BY50gqVmhleT3rqBqPu3aTflTYSIV5wRynq4y2Ub/GTAbdVKN/p Zv3lRpaATUZH3zE8wHz736sHwNokrJyRrQh1Caj8S9PPSmhUVj2Ycd66VW5uIlQuLibJ 48TIEo1KCbO6WY8jTTdCq/ppMvv0hutdKy7GA9wsU92ZUaBY7hYPJrfBq0i8Wt8OgImM 7qRRGRvZjJBK8AdoUGVl1aLQMGTuuPvgtelXmKz0rUYHV9zaZGyYa1YonNj8C0Op6vom t4569mkiwFj0NZiBRYbhxXnwK+jpRtR4tdUgEMeZ2ybnsf6MgWLyVxuqicYSB0ypDVyS 93xQ== X-Gm-Message-State: AC+VfDxc8hOxiXXSfs0c65ZjZWkQoh38IfpQOgCeZWkcUFA8de95XzDt ho9+SG6HqwfODssKjsKics53Rf0sKhJmscCWt1kjxw== X-Received: by 2002:a25:ab04:0:b0:b9a:39e5:2f4d with SMTP id u4-20020a25ab04000000b00b9a39e52f4dmr2114758ybi.2.1683019823822; Tue, 02 May 2023 02:30:23 -0700 (PDT) MIME-Version: 1.0 References: <20230501185747.33519-1-andrealmeid@igalia.com> <6ab2ff76-4518-6fac-071e-5d0d5adc4fcd@igalia.com> In-Reply-To: From: Bas Nieuwenhuizen Date: Tue, 2 May 2023 11:30:05 +0200 Message-ID: Subject: Re: [RFC PATCH 0/1] Add AMDGPU_INFO_GUILTY_APP ioctl To: =?UTF-8?Q?Timur_Krist=C3=B3f?= Cc: =?UTF-8?Q?Christian_K=C3=B6nig?= , =?UTF-8?Q?Andr=C3=A9_Almeida?= , Alex Deucher , dri-devel , amd-gfx list , linux-kernel@vger.kernel.org, "Pelloux-Prayer, Pierre-Eric" , =?UTF-8?B?TWFyZWsgT2zFocOhaw==?= , michel.daenzer@mailbox.org, Samuel Pitoiset , kernel-dev@igalia.com, "Deucher, Alexander" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 2, 2023 at 11:12=E2=80=AFAM Timur Krist=C3=B3f wrote: > > Hi Christian, > > Christian K=C3=B6nig ezt =C3=ADrta (id=C5=91po= nt: 2023. m=C3=A1j. 2., Ke 9:59): >> >> Am 02.05.23 um 03:26 schrieb Andr=C3=A9 Almeida: >> > Em 01/05/2023 16:24, Alex Deucher escreveu: >> >> On Mon, May 1, 2023 at 2:58=E2=80=AFPM Andr=C3=A9 Almeida >> >> wrote: >> >>> >> >>> I know that devcoredump is also used for this kind of information, >> >>> but I believe >> >>> that using an IOCTL is better for interfacing Mesa + Linux rather >> >>> than parsing >> >>> a file that its contents are subjected to be changed. >> >> >> >> Can you elaborate a bit on that? Isn't the whole point of devcoredum= p >> >> to store this sort of information? >> >> >> > >> > I think that devcoredump is something that you could use to submit to >> > a bug report as it is, and then people can read/parse as they want, >> > not as an interface to be read by Mesa... I'm not sure that it's >> > something that I would call an API. But I might be wrong, if you know >> > something that uses that as an API please share. >> > >> > Anyway, relying on that for Mesa would mean that we would need to >> > ensure stability for the file content and format, making it less >> > flexible to modify in the future and probe to bugs, while the IOCTL is >> > well defined and extensible. Maybe the dump from Mesa + devcoredump >> > could be complementary information to a bug report. >> >> Neither using an IOCTL nor devcoredump is a good approach for this since >> the values read from the hw register are completely unreliable. They >> could not be available because of GFXOFF or they could be overwritten or >> not even updated by the CP in the first place because of a hang etc.... >> >> If you want to track progress inside an IB what you do instead is to >> insert intermediate fence write commands into the IB. E.g. something >> like write value X to location Y when this executes. >> >> This way you can not only track how far the IB processed, but also in >> which stages of processing we where when the hang occurred. E.g. End of >> Pipe, End of Shaders, specific shader stages etc... > > > Currently our biggest challenge in the userspace driver is debugging "ran= dom" GPU hangs. We have many dozens of bug reports from users which are lik= e: "play the game for X hours and it will eventually hang the GPU". With th= e currently available tools, it is impossible for us to tackle these issues= . Andr=C3=A9's proposal would be a step in improving this situation. > > We already do something like what you suggest, but there are multiple pro= blems with that approach: > > 1. we can only submit 1 command buffer at a time because we won't know wh= ich IB hanged > 2. we can't use chaining because we don't know where in the IB it hanged > 3. it needs userspace to insert (a lot of) extra commands such as extra s= ynchronization and memory writes > 4. It doesn't work when GPU recovery is enabled because the information i= s already gone when we detect the hang > > Consequences: > > A. It has a huge perf impact, so we can't enable it always > B. Thanks to the extra synchronization, some issues can't be reproduced w= hen this kind of debugging is enabled > C. We have to ask users to disable GPU recovery to collect logs for us I think the problem is that the hang debugging in radv combines too many things. The information here can be gotten easily by adding a breadcrumb at the start of the cmdbuffer to store the IB address (or even just cmdbuffer CPU pointer) in the trace buffer. That should be approximately zero overhead and would give us the same info as this. I tried to remove (1/2) at some point because with a breadcrumb like the above I don't think it is necessary, but I think Samuel was against it at the time? As for all the other synchronization that is for figuring out which part of the IB hung (e.g. without barriers the IB processing might have moved past the hanging shader already), and I don't think this kernel mechanism changes that. So if we want to make this low overhead we can do this already without new kernel support, we just need to rework radv a bit. > > In my opinion, the correct solution to those problems would be if the ker= nel could give userspace the necessary information about a GPU hang before = a GPU reset. To avoid the massive peformance cost, it would be best if we c= ould know which IB hung and what were the commands being executed when it h= ung (perhaps pointers to the VA of the commands), along with which shaders = were in flight (perhaps pointers to the VA of the shader binaries). > > If such an interface could be created, that would mean we could easily qu= ery this information and create useful logs of GPU hangs without much users= pace overhead and without requiring the user to disable GPU resets etc. > > If it's not possible to do this, we'd appreciate some suggestions on how = to properly solve this without the massive performance cost and without req= uiring the user to disable GPU recovery. > > Side note, it is also extremely difficult to even determine whether the p= roblem is in userspace or the kernel. While kernel developers usually dismi= ss all GPU hangs as userspace problems, we've seen many issues where the pr= oblem was in the kernel (eg. bugs where wrong voltages were set, etc.) - an= y idea for tackling those kind of issues is also welcome. > > Thanks & best regards, > Timur