Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp38121imu; Thu, 3 Jan 2019 13:33:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN46+47v/ujG5lS61dJ/wTTa0uOL/TmvpzdzrmoD+KqcuB3G0iDduhFXS2GUBlXetbXJQx2Z X-Received: by 2002:a17:902:2868:: with SMTP id e95mr48665363plb.317.1546551220020; Thu, 03 Jan 2019 13:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546551219; cv=none; d=google.com; s=arc-20160816; b=N3Sin3EVl1qTJrRUpwkKlTU5nbnzwO3+SOYqSndkCG5Zbh8lBjV2wD+EySxGCLGQRq thrgfZyT/grZDgLsVmS0WF9KgC9GAlCdyMZfKItn5YtLQ1ICR0e/7UIMjt36/ATmfEwX Mlh8zPjrzoGiUbcRWXl3cBn/qGH6N7ODCQ7k2oUFZIzrBYAw/XZ1S2aXE0b7TQp0VL63 9K5z7oJCqXtfVxSTnaLb7NosSXzhswAJ/UoYmb6q22GG/LD8UolFdSEBmmnuu1/2RfuS OEKLBiucKD/d52CutVchRwRkcyKY+Lsdni3xmUCvnAQhqg2GZqAS4RbkRIfzMQdomzSw H68Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from; bh=GS8WYZ9DBlPIt8sKL2j9VodK43NRZ4UpjJ4JTrFs8wY=; b=ZzzXaPuZWPQr1vIqg2BV2m8mk+JOpCb7bNI6nmt51SE8hh1aQlMi/k2gNEXm9M/Dc2 uhKV8UI3mgsmTceBkmKHqbMPPTZIViEyHWkl0ORu6+YghHgUKg/ZMwKr9xxUaseK+rQ6 RauTAIX58faS0nnXYtWf4bAwAomD3pWJBFilVF7kBp2DZb5Zg7zA5G2lED6zNPo/B/Zb 5zdpM9o5pX3xO4Z5ij9RWdV+MMZOlTsNnQ9c72xy8WiR+obBWPXG1SELGEbUa9CZ4FIo Sk7eHelndAF6QCJ1Q3hfNdx8JeS5l5KU56xSDhzRElsZD2rpdpUzeU0RTxmeSJdFoBMO j8PA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si40062683pgz.180.2019.01.03.13.33.25; Thu, 03 Jan 2019 13:33:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729698AbfACPBP (ORCPT + 99 others); Thu, 3 Jan 2019 10:01:15 -0500 Received: from mx2.suse.de ([195.135.220.15]:33102 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727066AbfACPBO (ORCPT ); Thu, 3 Jan 2019 10:01:14 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 563A6AC8D; Thu, 3 Jan 2019 15:01:12 +0000 (UTC) From: Roman Penyaev Cc: Roman Penyaev , Davidlohr Bueso , Jason Baron , Al Viro , "Paul E. McKenney" , Linus Torvalds , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/4] use rwlock in order to reduce ep_poll_callback() contention Date: Thu, 3 Jan 2019 16:01:00 +0100 Message-Id: <20190103150104.17128-1-rpenyaev@suse.de> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The last patch targets the contention problem in ep_poll_callback(), which can be very well reproduced by generating events (write to pipe or eventfd) from many threads, while consumer thread does polling. The following are some microbenchmark results based on the test [1] which starts threads which generate N events each. The test ends when all events are successfully fetched by the poller thread: spinlock ======== threads events/ms run-time ms 8 6402 12495 16 7045 22709 32 7395 43268 rwlock + xchg ============= threads events/ms run-time ms 8 10038 7969 16 12178 13138 32 13223 24199 According to the results bandwidth of delivered events is significantly increased, thus execution time is reduced. This series is based on linux-next/akpm. v2: o I was wrong saying that ep_poll_callback() can't be called concurrently for the same epi: several wait queues can be attached to the single epoll item, thus several event sources can signal in parallel. To cover this case lockless element addition has to detect that the same @epi is not yet in the list. This is done by extra cmpxchg() operation. o unify awaking of wakeup source calling ep_pm_stay_awake_rcu(epi) in all the cases from ep_poll_callback() path. o more explicit comments [1] https://github.com/rouming/test-tools/blob/master/stress-epoll.c Roman Penyaev (4): epoll: make sure all elements in ready list are in FIFO order epoll: loosen irq safety in ep_poll_callback() epoll: unify awaking of wakeup source on ep_poll_callback() path epoll: use rwlock in order to reduce ep_poll_callback() contention fs/eventpoll.c | 178 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 133 insertions(+), 45 deletions(-) Signed-off-by: Roman Penyaev Cc: Davidlohr Bueso Cc: Jason Baron Cc: Al Viro Cc: "Paul E. McKenney" Cc: Linus Torvalds Cc: Andrew Morton Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org -- 2.19.1