From patchwork Tue Feb 24 21:25:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 5875551 Return-Path: X-Original-To: patchwork-linux-fsdevel@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 60F649F169 for ; Tue, 24 Feb 2015 21:26:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 931F42024F for ; Tue, 24 Feb 2015 21:26:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68E2F2024D for ; Tue, 24 Feb 2015 21:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752972AbbBXVZr (ORCPT ); Tue, 24 Feb 2015 16:25:47 -0500 Received: from prod-mail-xrelay02.akamai.com ([72.246.2.14]:37412 "EHLO prod-mail-xrelay02.akamai.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752943AbbBXVZq (ORCPT ); Tue, 24 Feb 2015 16:25:46 -0500 Received: from prod-mail-xrelay02.akamai.com (localhost [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id 40AD1284FB; Tue, 24 Feb 2015 21:25:45 +0000 (GMT) Received: from prod-mail-relay07.akamai.com (prod-mail-relay07.akamai.com [172.17.121.112]) by prod-mail-xrelay02.akamai.com (Postfix) with ESMTP id 27F5C284F1; Tue, 24 Feb 2015 21:25:45 +0000 (GMT) Received: from localhost (bos-lpjec.kendall.corp.akamai.com [172.28.13.37]) by prod-mail-relay07.akamai.com (Postfix) with ESMTP id 223F880066; Tue, 24 Feb 2015 21:25:45 +0000 (GMT) To: peterz@infradead.org, mingo@redhat.com, viro@zeniv.linux.org.uk Cc: akpm@linux-foundation.org, normalperson@yhbt.net, davidel@xmailserver.org, mtk.manpages@gmail.com, luto@amacapital.net, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org Message-Id: In-Reply-To: References: From: Jason Baron Subject: [PATCH v3 2/3] epoll: restrict wakeups to the overflow list Date: Tue, 24 Feb 2015 21:25:45 +0000 (GMT) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 During ep_scan_ready_list(), when the ep->mtx is dropped, we queue new events to the ep->ovflist. However, instead of just issuing wakeup for these newly encountered events, we instead proceed to issue wakeups even if nothing new is being propagated. Normally, this simply results in unnecessary calls to wakeup. However, now that we want to add wakeup queues that have 'state', this results in unnecessary state transitions. That is, with the current default behavior of always waking up all threads, the extra calls to wakeup do not affect things adversely (besides the extra call overheads). However, we wish to add policies that are stateful (for example rotating wakeups among epoll sets), and these unnecessary wakeups cause unwanted transitions. Signed-off-by: Jason Baron --- fs/eventpoll.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index d77f944..da84712 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -594,7 +594,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, struct list_head *, void *), void *priv, int depth, bool ep_locked) { - int error, pwake = 0; + int error, pwake = 0, newly_ready = 0; unsigned long flags; struct epitem *epi, *nepi; LIST_HEAD(txlist); @@ -634,6 +634,13 @@ static int ep_scan_ready_list(struct eventpoll *ep, for (nepi = ep->ovflist; (epi = nepi) != NULL; nepi = epi->next, epi->next = EP_UNACTIVE_PTR) { /* + * We only need to perform wakeups if new events have arrived + * while the ep->lock was dropped. We should have already + * issued the wakeups for an existing events. + */ + if (!newly_ready) + newly_ready = 1; + /* * We need to check if the item is already in the list. * During the "sproc" callback execution time, items are * queued into ->ovflist but the "txlist" might already @@ -657,7 +664,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, list_splice(&txlist, &ep->rdllist); __pm_relax(ep->ws); - if (!list_empty(&ep->rdllist)) { + if (newly_ready) { /* * Wake up (if active) both the eventpoll wait list and * the ->poll() wait list (delayed after we release the lock).