From: Eric Wong Subject: Re: epoll: possible bug from wakeup_source activation Date: Tue, 12 Mar 2013 00:44:45 +0000 Message-ID: <20130312004445.GA5151@dcvr.yhbt.net> References: <20130307112639.GA25130@dcvr.yhbt.net> <20130308013027.GA31830@dcvr.yhbt.net> <20130308204944.GA27379@dcvr.yhbt.net> <20130309071037.GA13360@dcvr.yhbt.net> <20130312001722.GB973@dcvr.yhbt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: NeilBrown , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Davide Libenzi , Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton To: Arve =?utf-8?B?SGrDuG5uZXbDpWc=?= Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Arve Hj=C3=B8nnev=C3=A5g wrote: > On Mon, Mar 11, 2013 at 5:17 PM, Eric Wong wr= ote: > > Arve Hj=C3=B8nnev=C3=A5g wrote: > >> On Fri, Mar 8, 2013 at 11:10 PM, Eric Wong = wrote: > >> > Arve Hj=C3=B8nnev=C3=A5g wrote: > >> >> On Fri, Mar 8, 2013 at 12:49 PM, Eric Wong wrote: > >> >> > What happens if ep_modify calls ep_destroy_wakeup_source > >> >> > while __pm_stay_awake is running on the same epi->ws? > >> >> > >> >> Yes, that looks like a problem. I think calling > >> >> ep_destroy_wakeup_source with ep->lock held should fix that. It= is not > >> >> clear how useful changing EPOLLWAKEUP in ep_modify is, so > >> >> alternatively we could remove that feature and instead only all= ow it > >> >> to be set in ep_insert. > >> > > >> > ep->lock would work, but ep->lock is already a source of heavy > >> > contention in my multithreaded+epoll webservers. > >> > >> This should not have any significant impact on that since you woul= d be > >> adding a lock to a code path that is, as far as I know, unused. > >> > >> > Perhaps RCU can be used? I've no experience with RCU, but I've = been > >> > meaning to get acquainted with RCU. > >> > >> That adds code to the common path however. The wakeup_source is no= t > >> touch without holding one of the locks so holding both locks befor= e > >> deleting it seems like a simpler solution. > > > > True. However, I've been looking into eliminating ep->lock in more > > places (maybe entirely)[1]. > > > > I don't think the current overhead of RCU in epoll is significant, > > either. > > > > > > [1] I'll be testing Mathieu's wait-free concurrent queue soon: > > http://mid.gmane.org/20130311213602.GB9829@Krystal >=20 > OK, but is there any way you could use the same locking scheme for th= e > wakeup_source and the queue? Probably, yes. I think I can just use ep->mtx and ignore the mutex included with wfcq_head, need to protect the rbtree while dequeueing.