Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3694548imu; Mon, 28 Jan 2019 09:10:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN7BrzsNlF1FLA5ENPrtml8j/d7O/8SdUKKkKtOEGpyyQ7sj/iRDI/NzvpxMcdVq/4R8Jfht X-Received: by 2002:a63:77ce:: with SMTP id s197mr20436887pgc.89.1548695440944; Mon, 28 Jan 2019 09:10:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695440; cv=none; d=google.com; s=arc-20160816; b=XlfxYo3HSr79+nwkRNTBc1z84QNYDD3qfLYhJSw+hFCMpRwtQuvaoQfTYTsyYCTrZg DhkkbBoh2fTftdsp0CjhjqOUrMhZfwgC1GNhR82iG/iwnlsGAUH5dEruUi5X3/NOi0uK VrueiorlvJDdCWVSvVqOk2Iwh1eHxhKKbf+qwWm8Yixu17WG4cM1p7jZ0yVq9EYa2Hhj QAkixxpcwo+XlD6hdLt7H2QQZLzgaCa/9Lv8EyCGdjsobKwJNho0m5uw+/W14jVmvEFw cKavl9aDWajhj89XZHTahRnF6WLguh5EwHlKsYR0o5eV202/Xy82o5ZbtE0oLa0tKmFL 74BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0dinGmI0trwgRaeb75pdjIq89CGzZ9MiHCjgI60wyZE=; b=yGxdFeBQ6qDWu+g5s8OIO18VXhh6pVISP8J8ufX9HM2DgYYw6ztTHmoxtzehkeV4m0 4x1JQUIO5MjxzX2JfR+1ghU2lcg+6YBlychkJv+VIciw1R/wMK9k8We0fTLrbuW15RG9 vWpD9ck6T8ru212/NYqyFXO2M/wzOzebGB819fz6sbq1HK/Xc8GtpHGAdPAiIPJo5o9p twnipue6Ry0KSEBHBQuehfjcWuUobW9nyveKtuKaFzZwsLS39Q6Ze9E2FF3W783lhIAc MwuB2aCmKK+s/snyWaKOV1zxqW+X5ua1+GChfZQ7/EpGh5iSduxwd3zJffp6sNjgF/84 tF0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ukdxcYSE; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si18635051plo.108.2019.01.28.09.10.25; Mon, 28 Jan 2019 09:10:40 -0800 (PST) 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=@kernel.org header.s=default header.b=ukdxcYSE; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733019AbfA1QLw (ORCPT + 99 others); Mon, 28 Jan 2019 11:11:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:39266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733026AbfA1QLu (ORCPT ); Mon, 28 Jan 2019 11:11:50 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3AF7121848; Mon, 28 Jan 2019 16:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691909; bh=3s81iF9vciymf2w4xPReymvYVpe3eQAc3UABl2EwJ94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ukdxcYSEVB7Gmo/vdEdCwwmSKUTyxNy0Xp5IvuhikUJ4e+BMeHfYoDVYT/tZHPxmZ MoxCB1PVjKOjCsC+zJBJkAD4VL40oZmYADJEO7i+MJDwXVly3FhZ5X9GnZPtme917+ tUjbtxXvVxGWFm/+ZRDF55vGZfHJTsZa95drMFRc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Davidlohr Bueso , Davidlohr Bueso , Al Viro , Jason Baron , Andrew Morton , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 255/258] fs/epoll: drop ovflist branch prediction Date: Mon, 28 Jan 2019 10:59:21 -0500 Message-Id: <20190128155924.51521-255-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Davidlohr Bueso [ Upstream commit 76699a67f3041ff4c7af6d6ee9be2bfbf1ffb671 ] The ep->ovflist is a secondary ready-list to temporarily store events that might occur when doing sproc without holding the ep->wq.lock. This accounts for every time we check for ready events and also send events back to userspace; both callbacks, particularly the latter because of copy_to_user, can account for a non-trivial time. As such, the unlikely() check to see if the pointer is being used, seems both misleading and sub-optimal. In fact, we go to an awful lot of trouble to sync both lists, and populating the ovflist is far from an uncommon scenario. For example, profiling a concurrent epoll_wait(2) benchmark, with CONFIG_PROFILE_ANNOTATED_BRANCHES shows that for a two threads a 33% incorrect rate was seen; and when incrementally increasing the number of epoll instances (which is used, for example for multiple queuing load balancing models), up to a 90% incorrect rate was seen. Similarly, by deleting the prediction, 3% throughput boost was seen across incremental threads. Link: http://lkml.kernel.org/r/20181108051006.18751-4-dave@stgolabs.net Signed-off-by: Davidlohr Bueso Reviewed-by: Andrew Morton Cc: Al Viro Cc: Jason Baron Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/eventpoll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 42bbe6824b4b..58f48ea0db23 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1154,7 +1154,7 @@ static int ep_poll_callback(wait_queue_entry_t *wait, unsigned mode, int sync, v * semantics). All the events that happen during that period of time are * chained in ep->ovflist and requeued later on. */ - if (unlikely(ep->ovflist != EP_UNACTIVE_PTR)) { + if (ep->ovflist != EP_UNACTIVE_PTR) { if (epi->next == EP_UNACTIVE_PTR) { epi->next = ep->ovflist; ep->ovflist = epi; -- 2.19.1