From patchwork Thu Feb 4 12:25:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 8220751 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 86E1E9F1C1 for ; Thu, 4 Feb 2016 12:25:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3F1520375 for ; Thu, 4 Feb 2016 12:25:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 907392034C for ; Thu, 4 Feb 2016 12:25:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 196656E12E; Thu, 4 Feb 2016 04:25:32 -0800 (PST) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id DA07C6E12E for ; Thu, 4 Feb 2016 04:25:30 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 04 Feb 2016 04:25:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,395,1449561600"; d="scan'208";a="740422967" Received: from tursulin-linux.isw.intel.com ([10.102.226.196]) by orsmga003.jf.intel.com with ESMTP; 04 Feb 2016 04:25:28 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Thu, 4 Feb 2016 12:25:24 +0000 Message-Id: <1454588724-34816-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH] drm/i915: Mitigate retirement starvation a bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin In execlists mode internal house keeping of the discarded requests (and so contexts and VMAs) relies solely on the retire worker, which can be prevented from running by just being unlucky when busy clients are hammering on the big lock. Prime example is the gem_close_race IGT, which due to this effect causes internal lists to grow to epic proportions, with a consequece of object VMA traversal to growing exponentially and resulting in tens of minutes test runtime. Memory use is also very high and a limiting factor on some platforms. Since we do not want to run this internal house keeping more frequently, due concerns that it may affect performance, and the scenario being statistically not very likely in real workloads, one possible workaround is to run it when new client handles are opened. This will solve the issues with this particular test case, making it complete in tens of seconds instead of tens of minutes, and will not add any run-time penalty to running clients. It can only slightly slow down new client startup, but on a realisticaly loaded system we are expecting this to be not significant. Even with heavy rendering in progress we can have perhaps up to several thousands of requests pending retirement, which, with a typical retirement cost of 80ns to 1us per request, is not significant. Signed-off-by: Tvrtko Ursulin Testcase: igt/gem_close_race/gem-close-race Cc: Chris Wilson --- drivers/gpu/drm/i915/i915_gem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index d46a0462c765..f02991d28048 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -5162,6 +5162,10 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file) if (ret) kfree(file_priv); + mutex_lock(&dev->struct_mutex); + i915_gem_retire_requests(dev); + mutex_unlock(&dev->struct_mutex); + return ret; }