Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9904459ybi; Wed, 10 Jul 2019 19:37:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmZXD8CSDtfFWV9HfMZHFk6MX8SXNnh1CFgwxZfuc/o1f2b+v1Oxnf2FBpeJd1V7O+G++2 X-Received: by 2002:a17:90b:28f:: with SMTP id az15mr1919579pjb.18.1562812669182; Wed, 10 Jul 2019 19:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562812669; cv=none; d=google.com; s=arc-20160816; b=VrKM5sEql7OsRi/4Q8JLdPa5CoR97MEzsaOdWWb4uk+53slDd2JVdqI06i2HVVRli6 rqcUk3RkpBhYcJUQiIc8XLgW+w7ZYE7BK0JQUrpD5OTo6w5XwPwRBqhbULoPykPe/Wz9 H2b/uceApSQzEqMQY4y39Ntpehp5U3MSZKKAWv6MbckSSecyuLs5k0olCA8MPpr60icT eRTQmMGxAnT6AjTpOmNyB1TQ+Q8QBmjrKL3xrlsqEP/aPm4nvH+pAlUgiBzyK1NLw5be DwCkApqGcixJqLZTeg9JbrLfE098eNPkH+g4wZGRw0azmW+Ur7EJnHoXiXoe1RplCzVh 4w2w== 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=C1FC0kkhG8SE4KxZI9/vd1vvZYlqKizf2ehICOMyQFw=; b=zoUuQJz/Kz1/iCaF8Mvdnl1N2ayPN8BgP0VXOkUpPRT+lQ+w9vFIh8qGKHmFfja/rS qBzuC0VmnkMaIGuAXWoNk46fh2ZRJsI6V0GTCrslI39VB86VjoBfb+U2yLvWAT+sIIRA rdJKxXTEB+ZaF0TujInjTDrw14QTK9y0XjpSQP8ohXWmVVrdnG9aGVfUM1MZq+Vvfi9K WdlV78okpgly4y/u+q8Uu0glzMgpo+zr2IihFFjUJNDKGfKDlnBfn5yxKT9ewj/qWdpV LLKbzclJX8vNVhJnrnenNyq0Oixfx9/1XTyu/O+wzHF2mJHREPp/5lP+A1B0LL9h+juZ mDkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gZuX85ZC; 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 t14si3754639pgm.395.2019.07.10.19.37.33; Wed, 10 Jul 2019 19:37:49 -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=gZuX85ZC; 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 S1727906AbfGKCfy (ORCPT + 99 others); Wed, 10 Jul 2019 22:35:54 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:32836 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727622AbfGKCfx (ORCPT ); Wed, 10 Jul 2019 22:35:53 -0400 Received: by mail-io1-f66.google.com with SMTP id z3so9293106iog.0 for ; Wed, 10 Jul 2019 19:35:53 -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=C1FC0kkhG8SE4KxZI9/vd1vvZYlqKizf2ehICOMyQFw=; b=gZuX85ZCmj/43wOQW8QDrAr8gsP1kGWGDwQXP7ruMAHyiaKt3g7NjtaA+MEVdHmPOT wKDPWmEBpa83TiEvIwO+ugF++ClLRUvAzQLBP51kB4e6VSC6Snkjk3d4n8a6/wkm9/Ra D7155hJwNevtJn/VruKCuIazOesSrERBBV8vHwGFFkNSHxznLmqbfHO6yEdsHe98bC30 T7PKRJ7+sCT5Xa2XQQwi9kRh5LcipaXeyRjPVyu6OVHm/E8NeQJY6UH3Mv4YtROKhPbf uYVC+T7pV39I8wXcfcxdqZB0y5IdoQR5bzuyil6Rc7DsmYrELvsBAixhWonuRgUpjKBt FjYg== 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=C1FC0kkhG8SE4KxZI9/vd1vvZYlqKizf2ehICOMyQFw=; b=j0B6FEsYI36XbLw44pMNqXHcvb1lxIHlpPZEpeGXugSOebT6wAEwOyJwJN7BfNruNp WWHHbaby6fDLSpDctL2w+2mzfdDF5h9JsQCyA5RkOoXZHwi2au9cODgQy75YKHXgaD7k dRHwdTRiRxGsKsbGMwLUamT/FFokKlvDDIqfqV2uZiL7muu+9RbA+c0X+F+lDabzkn4d s1eWehx4hZJMlI+88t+Y8nw3Y0r9/Y9+peaAV36OXmpSYF29MojpUCCw/5FJTL/+A5Od UTZJwv5mDIFruTFKGqL0NitU1b4DoHrmSmE6M3CUut1ZDM56e7ZMgZ1m6BhikTmqk7Kx nKYg== X-Gm-Message-State: APjAAAWskIrnFeBRbSwzJvFA7y5/7USX0IqyeGvHADxxK68f5mttg1wr 3p6lKjRQHP6aFdQ1UMsJyur06+6xtGIGLlFQiDk= X-Received: by 2002:a5d:8e08:: with SMTP id e8mr1665361iod.139.1562812552660; Wed, 10 Jul 2019 19:35:52 -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: From: Chia-I Wu Date: Wed, 10 Jul 2019 19:35:41 -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 11:46 AM Chia-I Wu wrote: > > 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. It was virtio_gpu_dequeue_ctrl_func who wanted to grab the lock to handle the responses. I sent a patch for it https://patchwork.freedesktop.org/series/63529/ > > > > > > cheers, > > Gerd > >