Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3374680imm; Fri, 24 Aug 2018 16:07:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaV026weRDwGVdlbJCjIXSsfIu6aAEaa9WfZu25KppSRbo0AY/D7uV4nTGnmGacOmdf4HBN X-Received: by 2002:a63:f657:: with SMTP id u23-v6mr3488627pgj.258.1535152054327; Fri, 24 Aug 2018 16:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535152054; cv=none; d=google.com; s=arc-20160816; b=aVJXeLS8k9E7atzSAKvhVOIDqHfO3b8Yoe/diyFasCZfH45HpCHPHqUBV/6dnaULAF X+dcLRkQYDp2sLXCxZG9jLIHGogJmgAvpSRPZ29NO0Q+PN4NCtVrRbd3JFMiOEV/YxQm iPgmykzweQ5vzCCpHSmO3fBPPyJNVb5pnep5RdAfyJyA+K2nSASXQf/VHaAVTbnKTML8 ZrGlaGBdG37DLzZPVczyxbQ/v3T7xBUYnr47GIqRkFMU+zQgM0Bus3++5+Bhb2hCMJ2l zAUG2JIgt7BniUACGJIOtxlhDS3Q38m2GiwBSQ3GXKfIFXQvx5zgcyM0y9+85Dz7+u2V etqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=0GVilb47D6RWRir+nYTbYCjoE457CCDYFK35olFjOLU=; b=rjHJKBzFIwddUkxBLEz/LaKBYAYNo7BpBjPvbt0TbFMGZ/fibuhkih6JuJsF+bkwQ3 gPO1cQ3CFgxPIX/GhtftQBANGUi1BQHuiTfWmHyM0Wuw7A9COLMFfrb31pEuNyZIYy1U JmT9Uv6VWXsFNFsYFBGHLOxwzUC0gnhDxRh6XAn2YfZz1Mz8Nk+c+xITOgTmwYNMrIZS v4nChLoqBLvjVPZULG8Olo/+RVoz3K8JboOT0fpxk6bEWHtqS/Xo+tL1MCK2Fi8lZOuS neGEltjyEpVE3w7RkWrTqvLNiloMCO5v2Q8S+2dowP8JhhXHl0HHtR8er2KgY6iSa2hS tI0Q== 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 p2-v6si8057240pgj.391.2018.08.24.16.07.18; Fri, 24 Aug 2018 16:07:34 -0700 (PDT) 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 S1728031AbeHYCmb (ORCPT + 99 others); Fri, 24 Aug 2018 22:42:31 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:36244 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbeHYCmb (ORCPT ); Fri, 24 Aug 2018 22:42:31 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1ftL9J-0008Vs-7t; Fri, 24 Aug 2018 23:05:49 +0000 Date: Sat, 25 Aug 2018 00:05:49 +0100 From: Al Viro To: Eric Wong Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini Subject: Re: [RFC] pipe: prevent compiler reordering in pipe_poll Message-ID: <20180824230549.GP6515@ZenIV.linux.org.uk> References: <20180824225431.tpaxuck7idgnj3b7@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180824225431.tpaxuck7idgnj3b7@dcvr> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 24, 2018 at 10:54:31PM +0000, Eric Wong wrote: > The pipe_poll function does not use locks, and adding an entry > to the waitqueue is not guaranteed to happen before pipe->nrbufs > (or other fields) are read, leading to missed wakeups. > > Looking at Ruby CI build logs and backtraces, I've noticed > occasional instances where processes are stuck in select(2) or > ppoll(2) with a pipe. > > I don't have access to the systems where this is happening to > test/reproduce the problem, and haven't been able to reproduce > it locally on less-powerful hardware, either. However, it seems > like a problem based on similar comments in > fs/eventfd.c::eventfd_poll made by Paolo. You are misinterpreting those comments. That load *can't* migrate to anything earlier than taking queue lock, since that acts as an acquire barrier. READ_ONCE in eventfd_poll() is not to prevent compiler reordering - it's to prevent insane compiler doing multiple loads on possibly changing variable (ctx->count there).