From patchwork Wed Sep 26 07:17:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 10615343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2CA9214BD for ; Wed, 26 Sep 2018 07:17:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17F5F2A9F3 for ; Wed, 26 Sep 2018 07:17:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C0512AA02; Wed, 26 Sep 2018 07:17:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2F232A9CC for ; Wed, 26 Sep 2018 07:17:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 52B4D6E37A; Wed, 26 Sep 2018 07:17:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 821316E37A for ; Wed, 26 Sep 2018 07:17:10 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id z16-v6so1047805wmi.3 for ; Wed, 26 Sep 2018 00:17:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Xb3CYlgsB4xWMHdg804HXeQAaum/mEnSpfsRg+nw9Ow=; b=JIF9qJAQBlemeeAy59FAnmCv0lL2RMxazZc3eNhGGTdeMV4mamR2+5UJB3n9/9/fL7 3M/OC84NNYs4Y/LkHugIjYldIqZqfY50GhG+jmFCiX0nGU/EyqTQUdL8S4pRX7fB873e 5aHMmfyDcLGaYNjWRIEHVrGmU8JF+UAyoND2nBzQRQ1TvwV5lCObqOmA2O//IgJhq6QE 2NBDGTNk5S2OXUOT0ekVpJl47fBic8xD5ZEm6+6Fg3h7PU0yuzI/27EpuoqEZjifS0+0 bCbmPRZng8as46Hc9NuBV6Zya/n+M0vX5hTTJCzmwEQHrh8/IGdBJGdEJb+mnwUo76QW Xr6w== X-Gm-Message-State: ABuFfoh+v7JvnA5/i3Vc5nwoGECW9tpjzCSbByiBQGv8LNL9RsvXD+pP uZ4CGiZ+tf4UGnrcp3diktZd9H8MdULfoA== X-Google-Smtp-Source: ACcGV619C6mTP/7L4A8LKom24qyIpE5U9+fA/JvCS+AfugjNMBU2DGKMFGp6ER1ONptdXx/wxzaRIw== X-Received: by 2002:a1c:55c2:: with SMTP id j185-v6mr3236443wmb.104.1537946228521; Wed, 26 Sep 2018 00:17:08 -0700 (PDT) Received: from omlet.es (nat-240.udc.es. [193.144.61.240]) by smtp.gmail.com with ESMTPSA id y12-v6sm3559747wrq.33.2018.09.26.00.17.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 00:17:07 -0700 (PDT) From: Jason Ekstrand X-Google-Original-From: Jason Ekstrand To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/syncobj: Don't leak fences when WAIT_FOR_SUBMIT is set Date: Wed, 26 Sep 2018 02:17:03 -0500 Message-Id: <20180926071703.15257-1-jason.ekstrand@intel.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jason Ekstrand , stable@vger.kernel.org, Jason Ekstrand MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We attempt to get fences earlier in the hopes that everything will already have fences and no callbacks will be needed. If we do succeed in getting a fence, getting one a second time will result in a duplicate ref with no unref. This is causing memory leaks in Vulkan applications that create a lot of fences; playing for a few hours can, apparently, bring down the system. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899 Signed-off-by: Jason Ekstrand Cc: stable@vger.kernel.org Reviewed-by: Chris Wilson Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
--- drivers/gpu/drm/drm_syncobj.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c index adb3cb27d31e..759278fef35a 100644 --- a/drivers/gpu/drm/drm_syncobj.c +++ b/drivers/gpu/drm/drm_syncobj.c @@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj, { int ret; + WARN_ON(*fence); + *fence = drm_syncobj_fence_get(syncobj); if (*fence) return 1; @@ -743,6 +745,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs, if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { for (i = 0; i < count; ++i) { + if (entries[i].fence) + continue; + drm_syncobj_fence_get_or_add_callback(syncobjs[i], &entries[i].fence, &entries[i].syncobj_cb,