From patchwork Thu Sep 21 07:57:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 143438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5580287vqi; Fri, 22 Sep 2023 06:37:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEMMGks7/tmb1RKMhtgNf+0gvNHpkAYVa8yU8zSCdsGz9NVk5wO8cVS45v7rOokGsc+rtA X-Received: by 2002:a05:6a21:78a7:b0:136:e26b:6401 with SMTP id bf39-20020a056a2178a700b00136e26b6401mr9781138pzc.16.1695389845242; Fri, 22 Sep 2023 06:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695389845; cv=none; d=google.com; s=arc-20160816; b=Gx5lurPoV/Boh9kCb11qh9XtLHeeTAiVfOY85Qq0XwS0qRS9lk0mA2QH5Q/gfriWGq CDU37xzVDSs4/hRGIEBKp+MRUkKzVlWBPucyrlACELMfmdQ/wRDiYhUQSUgB6DuAs9/7 h5XiI/oZxN4hJywaxS2EKm5AbPQnlL6G/ePjfy4QbUStrK51h7L+XJhC2S5m7FLyFXFb 5/GOKpROrr8egSz47Brt0Vj5fN4ePH96fJsbnaxBUQkHIfQhaS+F8bGVHrPwb+dKIaMK xJm/luAei4m0fmQrwB2fgtpyr+bMZeD6IwMuK8D1iRD6lXFYZjnXWbpibxob3c6TygSo 49Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=08cpvcrCpdCUD29e4UfDmA8S+Uy08AnVrTRRsGrC/bY=; fh=/mmUFS5s71yRsPeN08HF9rYndG2tJREJfMy47/3Il/c=; b=S7wqmEtbaFvCk0mFZRCix9Vus1rUvX3IPj48yVLqge4YuPxnipQ5WskkgxsD5izkQM Cie8athDHNu9J+b6DXHQ+QeEDCFYtCDbLMLEe4CaJ/2qzLzRhk9R3jjJpNdWvqWy99SJ g35f+vl4PQQlF8IyDAyh9lv+ggog5B1rRBSAldWm10issJOuT2jaN2UBLUaWwOqxrEuo VWgbxRy2dWbJWuvPFb1XLqO8wGYwDa3gh57p1U3wmD1xZ7hCgBkdV+yDa6eGEYjO97Xw 3bA5f9+ML1tBV+bcklK4hXFOqtP0T9XRXGu52lHbA8P6nvQit4DoM3LhigYXT3x8MSPx n1mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=HSIHYQK5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id eb17-20020a056a004c9100b00690158afc78si3820754pfb.284.2023.09.22.06.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=HSIHYQK5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B044C82F34BB; Thu, 21 Sep 2023 14:02:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232440AbjIUVCS (ORCPT + 29 others); Thu, 21 Sep 2023 17:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231517AbjIUVBw (ORCPT ); Thu, 21 Sep 2023 17:01:52 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943DF580B1 for ; Thu, 21 Sep 2023 11:12:15 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-404fbfac998so14743435e9.3 for ; Thu, 21 Sep 2023 11:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1695319934; x=1695924734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=08cpvcrCpdCUD29e4UfDmA8S+Uy08AnVrTRRsGrC/bY=; b=HSIHYQK5bawTfqMQGWEK07nFoZMPZTh0XmGRrXdx9dibJr5ATt03wbQx7pdZTRXxbW 9fdMrlWf4VfH6IKxHV6N5C6bFDVbHDGJLhlmY+KrruiA3dbXOVIC26B19PSE7WHMsGy4 cP3I4Snm14Pid2nDj0++/MLW5LtBfKrBiNJZM8qFNnlNcWmBJ1M3sJo02nwRJVQZgIg0 dbox8VpfRu/QQc377XXSYdhvyycnICd813pKUP9GjzenCDAk2HE0W47G3XLfq6XoNiAK TVfvZcKXiUjMbAJKa0ajq2ryJx4BO6TLUFlCYuVPqWxhu32gyLWUrctQWTzBfKwKggts m6oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695319934; x=1695924734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=08cpvcrCpdCUD29e4UfDmA8S+Uy08AnVrTRRsGrC/bY=; b=RF7846pSWoY5aUfU3k5dJZXCEIc7jIJs23pOu/dmBGiHX0lvD6aWqbdYtwtAwwfxrY 1Pf8xyEqGg5jn0ZcqrmEFzl4vAqUFxKqIbX9OFV20Q1zGW4kjfZhDjvbDbb/kQOdaKHZ UNrrAOYYso6GBPxeZ4z+KcJOUbRlKP+R97Ciuf7lWtBzHaH5SCiPIPt+yiWvMSvlFza4 S/RYqxp2Hha4PeZAdG/5JzdDobIwsFUitxYhc2WzyJo1CXlst5cMRvunS4oQXuiZBhsA kJeAoBAwF16LKot7vDt2wPx3dLC6BmLKlJebehWhEDOeAp3FravtJmMJSDuNMuMhSJKo Jx/A== X-Gm-Message-State: AOJu0YxmY58AFwWJgmF7khush1p0eayzqgbD8DUaebBYGRUhdc+G7uKX 9ArQYHysnl1up+//+In8P+YNcw9W5SurWBS9NlY= X-Received: by 2002:a05:600c:21ce:b0:401:519:d2 with SMTP id x14-20020a05600c21ce00b00401051900d2mr4093726wmj.23.1695283083252; Thu, 21 Sep 2023 00:58:03 -0700 (PDT) Received: from heron.intern.cm-ag (p200300dc6f209c00529a4cfffe3dd983.dip0.t-ipconnect.de. [2003:dc:6f20:9c00:529a:4cff:fe3d:d983]) by smtp.gmail.com with ESMTPSA id v4-20020a05600c214400b003fef19bb55csm1151252wml.34.2023.09.21.00.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 00:58:03 -0700 (PDT) From: Max Kellermann To: viro@zeniv.linux.org.uk, brauner@kernel.org, howells@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Max Kellermann Subject: [PATCH 3/4] fs/pipe: remove unnecessary spinlock from pipe_write() Date: Thu, 21 Sep 2023 09:57:54 +0200 Message-Id: <20230921075755.1378787-3-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230921075755.1378787-1-max.kellermann@ionos.com> References: <20230921075755.1378787-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 21 Sep 2023 14:02:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777745102210151791 X-GMAIL-MSGID: 1777745102210151791 This reverts commit 8df441294dd3 ("pipe: Check for ring full inside of the spinlock in pipe_write()") which was obsoleted by commit c73be61cede ("pipe: Add general notification queue support") because now pipe_write() fails early with -EXDEV if there is a watch_queue. Without a watch_queue, no notifications can be posted to the pipe and mutex protection is enough, as can be seen in splice_pipe_to_pipe() which does not use the spinlock either. Signed-off-by: Max Kellermann --- fs/pipe.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 6ecaccb48738..939def02c18c 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -505,16 +505,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) * it, either the reader will consume it or it'll still * be there for the next write. */ - spin_lock_irq(&pipe->rd_wait.lock); - - head = pipe->head; - if (pipe_full(head, pipe->tail, pipe->max_usage)) { - spin_unlock_irq(&pipe->rd_wait.lock); - continue; - } - pipe->head = head + 1; - spin_unlock_irq(&pipe->rd_wait.lock); /* Insert it into the buffer array */ buf = &pipe->bufs[head & mask];