Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2473054ybi; Thu, 4 Jul 2019 11:53:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkVGyrv4iWDfagLL7UJZ8gdoF6W8MSE61OrMgF0r8M/D3NtAW4pwIbUt9+EgHGcXGPiWgq X-Received: by 2002:a17:90a:b312:: with SMTP id d18mr1016991pjr.35.1562266397487; Thu, 04 Jul 2019 11:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562266397; cv=none; d=google.com; s=arc-20160816; b=H5ykFU82Ls4fIaoOm8eQR+el+E9ndbaWQ9Ng6J+ntAMKN4ZIqFjJSVSBc04nPCgBkQ 1kb0E432wCaVGSg7OQKv9hFKsjXGMtOS3Jlb/1fNEW2gX0r682p+OBKwpDXjBv8a8vi0 7OLN24Abe7Q1JwQED36zfaTjUmZ9J/aI2EpIZlg8lJuEwNscbqNqQ9dITo7GUceGva3A 4EOdpwI/tW9Nwhnk2ogaZx3/J6t8wIu2wmp7V3VVpPJ2nXhpvLrDL9cMYzZMD1K5hjse y9l33DfjDFBpVRlsGDwLW10AXokiW9CcYo9bvRH8FmthqSoRHEWW5sHEpJq+y+Do/Ld7 9OMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/EL1KLCRFQKW2ACCFaTqozaezf7EHz4hHVM/un1EcE4=; b=edSCj384UzFYmydLNMygZ0WX7RsBJIYNAlZVx7O/nzWcqkRMXSIZkVSthhSMOfizk3 JJVJbxi0bAwzqgdFEVvZVdHUeSr/OnE6w0lEiQXzmuq3WWxp2wp7mlGMEUWfdm35tHN3 GqkR49PsAl7Rayn1zoVssuaeb8vLCLkQAuamke6gm3n88UfzjrwU272FiQM6MsIL4w9s d/mSkI9XulkmwgoQ/3idBsfzaCiWPWEur6bPOoffUEh4Zr6vgcs7VSdo2eLZ8rWFkJgc UwN73zghTKdw1kd9VVaLYLNc4muPILN0bzHavJNh0FPntQi3SOadngS7Llzd4l3yOC6b 61rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t5F5YNcu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si5532155pll.374.2019.07.04.11.53.02; Thu, 04 Jul 2019 11:53:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t5F5YNcu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727209AbfGDSqZ (ORCPT + 99 others); Thu, 4 Jul 2019 14:46:25 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:40608 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbfGDSqY (ORCPT ); Thu, 4 Jul 2019 14:46:24 -0400 Received: by mail-io1-f66.google.com with SMTP id h6so6287184iom.7 for ; Thu, 04 Jul 2019 11:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/EL1KLCRFQKW2ACCFaTqozaezf7EHz4hHVM/un1EcE4=; b=t5F5YNcug6hMseo0CGrmu4jtrScYyR5ptz8hoGQXZ2nAYmqEbnWUkptDsisVRn+DlR CwihM32a+oNgurJg0qF/nDO/Z7Use2bWSvL/B+Rs/djchh2zDLEkloovdGI54dEmg7Z7 0ZcLtk9dxbf4JWb2t6EWq1MMcGyaVhvNZG3gucduuo5SYzlm2Ej4EDjeXGg2fUYsONWY wVSxZ+NiAJAy8IT861ZE5CZnGHPrrz8tDjXqwYFHsv145C6cr2YShpRTl8W7KSNlzkUK tR5Qy2gVPZtMNqRb6vSFgLcjAmVZ/dcSvndnrTJdKezTc/nvPEShNL2J6I+hSa2Pwbck a/OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/EL1KLCRFQKW2ACCFaTqozaezf7EHz4hHVM/un1EcE4=; b=IRRjzU67w2NGGTmHT2GuE0rHpfPfGumkOxCos3V6Ln9vKHLUZC1LqMVgvs/elvdmPb Nsn1j2HVqUEfEA6FUbmjOf5f4xUy+QvLv/jMeWBKXn4Xs86ux6NqUsD6bxaSD42R9Zey /kXjfIkU1XutCSEaHN910ww6QozgSxQzSnWxd6PxaCJAAQx3lnIvwfprWKPKUm+ztcX/ iNRKgm8FSutekzmgd/RH5Om0CO6Q/ZPf9zrFHWvdGcPusJ3zTzgakbGunK/gASF33ZZ/ 1OapQ+lmZsmr67yHmPQ4ATVb/3tyNgL+c94hX782vJQV2ulOyiBqZpe3yBCl9C/zoWBj 5iNQ== X-Gm-Message-State: APjAAAWmMQSO8QeW2VSC/YwzKotQIiORbE4e+q/spc8SG5sqDT+ss7uv NgSr/0gSbbrKZ64QJDjZIPKqWgLQisz6mPfXQ9I= X-Received: by 2002:a05:6602:104:: with SMTP id s4mr39068278iot.200.1562265983623; Thu, 04 Jul 2019 11:46:23 -0700 (PDT) MIME-Version: 1.0 References: <20190702141903.1131-1-kraxel@redhat.com> <20190702141903.1131-9-kraxel@redhat.com> <20190704112534.v7icsuverf7wrbjq@sirius.home.kraxel.org> In-Reply-To: <20190704112534.v7icsuverf7wrbjq@sirius.home.kraxel.org> From: Chia-I Wu Date: Thu, 4 Jul 2019 11:46:12 -0700 Message-ID: Subject: Re: [PATCH v6 08/18] drm/virtio: rework virtio_gpu_execbuffer_ioctl fencing To: Gerd Hoffmann Cc: ML dri-devel , Gurchetan Singh , David Airlie , Daniel Vetter , "open list:VIRTIO GPU DRIVER" , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 4, 2019 at 4:25 AM Gerd Hoffmann wrote: > > Hi, > > > > if (fence) > > > virtio_gpu_fence_emit(vgdev, hdr, fence); > > > + if (vbuf->objs) { > > > + virtio_gpu_array_add_fence(vbuf->objs, &fence->f); > > > + virtio_gpu_array_unlock_resv(vbuf->objs); > > > + } > > This is with the spinlock held. Maybe we should move the > > virtio_gpu_array_unlock_resv call out of the critical section. > > That would bring back the race ... Right... > > > I am actually more concerned about virtio_gpu_array_add_fence, but it > > is also harder to move. Should we add a kref to the object array? > > Yep, refcounting would be the other way to fix the race. > > > This bothers me because I recently ran into a CPU-bound game with very > > bad lock contention here. > > Hmm. Any clue where this comes from? Multiple threads competing for > virtio buffers I guess? Maybe we should have larger virtqueues? The game was single-threaded. I guess it was the game and Xorg competing for virtio buffers. That was also on an older kernel without explicit fences. The userspace had to create dummy resources frequently to do VIRTIO_IOCTL_RESOURCE_WAIT. I think this is fine for now as far as I am concerned. I can look into this more closely after this series lands. > > cheers, > Gerd >