From patchwork Tue Jan 24 01:25:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Bragg X-Patchwork-Id: 9533833 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B24A6042D for ; Tue, 24 Jan 2017 01:26:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BDEB28047 for ; Tue, 24 Jan 2017 01:26:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0063E280CF; Tue, 24 Jan 2017 01:26:39 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 8B60C28047 for ; Tue, 24 Jan 2017 01:26:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A1146E6A7; Tue, 24 Jan 2017 01:26:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0003E6E6A3 for ; Tue, 24 Jan 2017 01:26:36 +0000 (UTC) Received: by mail-pf0-x241.google.com with SMTP id f144so10980386pfa.2 for ; Mon, 23 Jan 2017 17:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rEv9e0tCS4iJt4FUBRt+6Ucs/haogaXi8gIV+F/ih7c=; b=msIr3HjivrrUlcAb86JqdMsMbBuhwhiJViSQIBqsvIVP3QOgx3M94rI6QSKjP3AICq 09N5jRF+KMLWORgMQkQRQBJ6bjAiXMZGTMyE7CN4E3PBHSnFgpSSkPu7xW0vYCjhLOzW qCD8KYmEyQ5gfnvOhcQTJc2R5Milw2DaoCCjKPQVB3a9bPlPLTLYtqnp/Zo88mSeda+m gU3Xx6XqXhGkijphXK83tqBbyZVLf8TgrmEwSzdKBPKy4Jnfu8Bptcrok+XfFepaKOpy 03MuA9mdUvv1ayb+cOomUM5rZIM/PnywXMqlJCjtz58E77cAqm2fn+Td2kA++Xww4Z54 Lfxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=rEv9e0tCS4iJt4FUBRt+6Ucs/haogaXi8gIV+F/ih7c=; b=rPSsCPcqU3TL6CvFIo2mNevtSpp+1x6v8Kh10QKqcc/s4Y5ZKy0sB2nB68lPZdUAiV 2rMLsKjnBLxMUHk1BYBzZt13rFY4JNI0EDQb2b3HF70AvEynGtXl0PiwzqqIz+mT6AoZ n+f4WEwOmASC+aDHZODS2tZkD4uUbpKaRZ02sez8PqxZCpYdJP8zZcqNI/Qr5uwYBlTW mlAzxYImqlcsoBBj/UlqolvD6D0Jf3QXKNs3jJNXRGhxQBpV1NqLHonh31YzuCSKMNjY dHqsD4SoxwAjEefD+2LrFT7ouHJcUkPqCDQvM41xNgqcqPY+GxLx85znNiuTqp01Zveu 4Ylw== X-Gm-Message-State: AIkVDXJZ4CbBFxjZa+idSFWelpLwL8Hq8Q6C98ktJ6HSEADUQ1vb6/TjtRismTyWVoaf4A== X-Received: by 10.98.158.210 with SMTP id f79mr35348167pfk.145.1485221196433; Mon, 23 Jan 2017 17:26:36 -0800 (PST) Received: from sixbynine.org ([207.194.157.2]) by smtp.gmail.com with ESMTPSA id s136sm552076pgc.38.2017.01.23.17.26.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jan 2017 17:26:35 -0800 (PST) From: Robert Bragg To: intel-gfx@lists.freedesktop.org Date: Mon, 23 Jan 2017 17:25:45 -0800 Message-Id: <20170124012548.12603-3-robert@sixbynine.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124012548.12603-1-robert@sixbynine.org> References: <20170124012548.12603-1-robert@sixbynine.org> Subject: [Intel-gfx] [PATCH 2/5] drm/i915/perf: avoid poll, read, EAGAIN busy loops 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-Virus-Scanned: ClamAV using ClamSMTP If the function for checking whether there is OA buffer data available (during a poll or blocking read) has false positives then we want to avoid a situation where the subsequent read() returns EAGAIN (after a more accurate check) followed by a poll() immediately reporting the same false positive POLLIN event and effectively maintaining a busy loop until there really is data. This makes sure that we clear the .pollin event status whenever we return EAGAIN to userspace which will throttle subsequent POLLIN events and repeated attempts to read to the 5ms intervals of the hrtimer callback we have. Signed-off-by: Robert Bragg Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_perf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index b0eec762b9b4..4bb7333dac45 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -1352,7 +1352,15 @@ static ssize_t i915_perf_read(struct file *file, mutex_unlock(&dev_priv->perf.lock); } - if (ret >= 0) { + /* We allow the poll checking to sometimes report false positive POLLIN + * events where we might actually report EAGAIN on read() if there's + * not really any data available. In this situation though we don't + * want to enter a busy loop between poll() reporting a POLLIN event + * and read() returning -EAGAIN. Clearing the oa.pollin state here + * effectively ensures we back off until the next hrtimer callback + * before reporting another POLLIN event. + */ + if (ret >= 0 || ret == -EAGAIN) { /* Maybe make ->pollin per-stream state if we support multiple * concurrent streams in the future. */