From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706Ab3ABTDs (ORCPT ); Wed, 2 Jan 2013 14:03:48 -0500 Received: from mail-pb0-f52.google.com ([209.85.160.52]:34602 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404Ab3ABTDp (ORCPT ); Wed, 2 Jan 2013 14:03:45 -0500 Subject: Re: [PATCH] epoll: prevent missed events on EPOLL_CTL_MOD From: Eric Dumazet To: Eric Wong Cc: Linus Torvalds , Linux Kernel Mailing List , Hans Verkuil , Jiri Olsa , Jonathan Corbet , Al Viro , Davide Libenzi , Hans de Goede , Mauro Carvalho Chehab , David Miller , Andrew Morton , Andreas Voellmy , "Junchang(Jason) Wang" , Network Development , linux-fsdevel In-Reply-To: <20130102184010.GA21780@dcvr.yhbt.net> References: <20121228014503.GA5017@dcvr.yhbt.net> <1356960060-1263-1-git-send-email-normalperson@yhbt.net> <1357065750.21409.12527.camel@edumazet-glaptop> <20130101210033.GA13255@dcvr.yhbt.net> <20130101211728.GA13380@dcvr.yhbt.net> <20130101235605.GA17168@dcvr.yhbt.net> <1357148750.21409.17169.camel@edumazet-glaptop> <20130102184010.GA21780@dcvr.yhbt.net> Content-Type: text/plain; charset="UTF-8" Date: Wed, 02 Jan 2013 11:03:36 -0800 Message-ID: <1357153416.21409.17488.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2013-01-02 at 18:40 +0000, Eric Wong wrote: > Eric Dumazet wrote: > > First, thanks for working on this issue. > > No problem! > > > It seems the real problem is the epi->event.events = event->events; > > which is done without taking ep->lock > > Yes. I am hoping it is possible to do it without a lock there, > but your change is more obviously correct. > > > While a smp_mb() could reduce the race window, I believe there is still > > a race, and the following patch would close it. > > I'm not an experienced kernel hacker, can you describe where the race > would be? It would be for example in ep_send_events_proc() doing : if (epi->event.events & EPOLLONESHOT) epi->event.events &= EP_PRIVATE_BITS; And this could happen at the same time.