Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5608110ybl; Sun, 22 Dec 2019 09:52:16 -0800 (PST) X-Google-Smtp-Source: APXvYqw5mhv8+bn7CeVBx7VK+7ACqccYUpeZmePm7qhIUmE08yXMv1Fu5QsDxJC3cPEre4pQ9YP2 X-Received: by 2002:a9d:7a4d:: with SMTP id z13mr27851051otm.148.1577037136458; Sun, 22 Dec 2019 09:52:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577037136; cv=none; d=google.com; s=arc-20160816; b=iQGF2LN5pcdp6sFzNxenyoIjIgdS536QOeutXqwCFMD5LVUyor+ot0HW8ajAYMPUZh 9LPxpGOdlN1y2dFX3ElgT4ec8dBduzA9SGPSXBa/yHw/TOPZ0fA87ZUjczrojrZrWRcc aLH2bIcRjCxE3c7Fq0ep1/4KY4TwaU+ayxwQrO36FuUdOm10HMwdHPFFtQXkHCH4XpxK /iTulCuI8juaFHYm1vtH1I3cTC0K99oKTCxWQ504K6EwGinsQZLtlESysp/9cwDriyXz ntTgv+e2lTyS6od8rLgV8iT3ecrvKrQWvpfuDpqgy3JsOFT+doOsEEbKZR0zErUmLtyr lUiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9+DFRZm1mZCG8Q4iFUUSl87IJ9WC5zykHr6alPq0ZLo=; b=IpouTP/cn0QsQk7QZJQ61jLnP0ViI+N9hINZM75CBHlOfBM3Ac6RtDUALMOl1Jj/ug EBf33nHL4f5csCfAji9PXKB/9jamZERF+T2RQZRoGBYMyJS5OJjdINimy4qOELj06KTU V94Xcxm+5ZB4+fDE47CG5gc3YE9L5icFc9ETHmK62kpQEB7l6X37sBuxe68BBfUErrc3 dk+oZRmYnbqUOsfQTGgvCotrfwuVBepSQMj1aagvV6cAREeLzxRYckv6ZWEWZqN/trgm tc+jFvoggWvUIFB84pKkq/cp2T1GZz9QnB/s0o8sfF4F2KOThaGDjP+TaA9APBLAMmcC BvDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=CQ8K6tZm; 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 v14si8686097oto.127.2019.12.22.09.52.05; Sun, 22 Dec 2019 09:52:16 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=CQ8K6tZm; 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 S1726114AbfLVRvO (ORCPT + 99 others); Sun, 22 Dec 2019 12:51:14 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:32988 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725922AbfLVRvO (ORCPT ); Sun, 22 Dec 2019 12:51:14 -0500 Received: by mail-lf1-f65.google.com with SMTP id n25so10984169lfl.0 for ; Sun, 22 Dec 2019 09:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9+DFRZm1mZCG8Q4iFUUSl87IJ9WC5zykHr6alPq0ZLo=; b=CQ8K6tZmrYw+i7cLRAX6nHHWBuA0WZCjyD1+ygJortD1DDEXd5VUtlYicd8UB1mI62 u7NC/dlgoayz6shYBUr0GxxKdDUXPS9FLAP4nfrxjjyeNFGvs0cWJ/yiwbhnGE1BHFIo ow2Mg7DSIY0wQAnnfuT4xNkYfh9ioXkz9mqrw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9+DFRZm1mZCG8Q4iFUUSl87IJ9WC5zykHr6alPq0ZLo=; b=eRGJwjVjlgqMS3MWWN/v8weaGy0FOZSeaRkiBbXzAHA/giVZKYu0tSglS6pg1KnkgY G5dkpDk36byjhaoGWgiREVkikDJ2f/+R89cWXu7m6ir29P9mnfKSnejhDS7o6mU3szuq A7GK1zIdBCiP163EdMPM1bA2hsALrxoSXdaTsVGKiR1pX2jQ3SRU8d6FYu56JHRnBYK9 DdsaF29CBiT2Fqvw9CU7ZRlOMYquzF23Co8EYMANHUCH8ZLmMvxj6FYENwsyScvhWxdN y5+3vK3mjrMkqG7RNd1ym+5pf7GXdqC5L7R9ir0s6Ct6TXdbhIpXBv5NmtPsCI8IrYCQ 6kdw== X-Gm-Message-State: APjAAAVsJWgbav524V42zNVGPfY3u+umHSPo1P3ew7mrkEbCFaxIp6Wk oa1ahUZzvqImMGvzOES1P/fAqDIlNW8= X-Received: by 2002:ac2:5388:: with SMTP id g8mr14420310lfh.43.1577037071281; Sun, 22 Dec 2019 09:51:11 -0800 (PST) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com. [209.85.167.46]) by smtp.gmail.com with ESMTPSA id c27sm6852490lfh.62.2019.12.22.09.51.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Dec 2019 09:51:10 -0800 (PST) Received: by mail-lf1-f46.google.com with SMTP id r14so10962315lfm.5 for ; Sun, 22 Dec 2019 09:51:10 -0800 (PST) X-Received: by 2002:ac2:50cc:: with SMTP id h12mr14384920lfm.29.1577037069868; Sun, 22 Dec 2019 09:51:09 -0800 (PST) MIME-Version: 1.0 References: <65b22cd4e8bb142c5b7b86bc33fb08de6f318089.1577017472.git.jstancek@redhat.com> In-Reply-To: <65b22cd4e8bb142c5b7b86bc33fb08de6f318089.1577017472.git.jstancek@redhat.com> From: Linus Torvalds Date: Sun, 22 Dec 2019 09:50:53 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] pipe: fix empty pipe check in pipe_write() To: Jan Stancek Cc: linux-fsdevel , Linux Kernel Mailing List , David Howells , Al Viro , rasibley@redhat.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 22, 2019 at 4:35 AM Jan Stancek wrote: > Problem is that after pipe_write() reacquires pipe lock, it > re-checks for empty pipe with potentially stale 'head' and > doesn't wake up read side anymore. pipe->tail can advance > beyond 'head', because there are multiple writers. Thank you. Patch is obviously correct, applied. I wonder how much that whole "cache head/tail/mask" really helps, and if we should strive to get rid of it entirely (and just make "pipe_emptuy()" and friends take a 'const struct pipe_inode_info *" argument). Oh well. I've apple your one-liner, but next time I might decide the cleverness and slight code generation advantage might not be worth it. Hopefully there won't _be_ a next time, of course ;) Linus