From nobody Sun Feb 8 12:14:02 2026 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71E3B1922DC; Fri, 7 Mar 2025 05:30:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325403; cv=fail; b=kJJVFVB+vnoX4Q4OmFyfrCiY0pBWs7WyyWJouvmLaU0Fqx9v6ONcfAmuV2btGe9J07NLj1X5Ghi39zwPcCqwRjZv1uW36FZg3aniElOCY90p1FtPUybWVPKj+/O9W4Tbt5INBoWxFwfBe33LzUNF3eshUGcYQGT6oha1Jx68r6M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325403; c=relaxed/simple; bh=RHQszQJBCkYI8rF22lGfiCrZC6wKb4h9A1ftK6cIElA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aHHBa6ZOGm07V7eZISIqLggW9zux0Axxavspc1i0NXUj/QqHUYhfcqGXeXKitPWjzM4zNorBNGVEbv3xGge8AWG16rHiHX75nfzBj1W1yPVDeoe6i8uQ/OuWhtd/1O7kOcQLkJK4SuQmGr3yGTl6f8vF3vIkvmt+jQy9ArtUCKM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Qn54MTsy; arc=fail smtp.client-ip=40.107.220.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Qn54MTsy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iGaabzeDk4IadjDXN7HFhMdwwC6yTWezGnW4H04iEPDjng8b2Ji9UMwygdPHGrCDFr04Qwsrug3FSHuOGve1PbjNv8NvQI6MldKOLC2t2FtH2vTRyJ9Vm27Jns99NECleFB1XdIZi5nfa91r2Fzrry7ceTM0Bsz65bJGVohWYvO8t39dru48sQwAi5EizILCOc6VcOb4ftR8ZROBUHCO81u47mZSU7ikdg+lLndowcivVk5PfOq8q0aN3b58mOZCvuNUmnG8z+j+QrkphjU/zDsU49Yeo9bMykXLxONfuO/q/OzU9LNmtIwrKmaD3j024lIUsSBMZlPDI/zLqF+axQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v4dq2kVhCacGMXsY+LnxsOmAOHoZ6wqtkfgmdeQqVAQ=; b=CiTWsihHwOvrqLgCg3MK1ZCYgGDJTNdWZQ1kxYpJHbvzHhzgOKIpRJ9p6jmEGSQmeIaU++hbsWmVOpjrCkmGJmuTC5jjybHCNvPSRTbq3ZeqUXVjyV1C0zvUHcNABCgkbduwCMduyxgSPo8wQ/dXBGxLoGbSdSAYDqHsT10tfVTrQM+P1VQ/kOyTZXP1tFZZrYcjMp+PMebq26wyzoVcXUHgcS4pY82fFm818GPVoEHCftM7lWWAcU38PFssvTkfpUHrJNbrYldO2RaV1Fyiit9m7vf0Er6mXgy4J4tMcC/M5/OSJTqrRYolPz69eWjSKFyGjlITeEqETpH69fIhUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v4dq2kVhCacGMXsY+LnxsOmAOHoZ6wqtkfgmdeQqVAQ=; b=Qn54MTsykmvSccaXjwkJ7nV9VJEqgMJVknW6KrybmT5j6lNzzfKx0s83KcHByMORJhEcUcEU9/mf/cPl5xIBi39uSl01b6g/wSVLamtpvgjJlilYE7gpE/SdESIqXdQt2QwejFhV8d5gEMOKEf9atGXhx8ecjhSSOVGKDvlliPo= Received: from PH8PR21CA0006.namprd21.prod.outlook.com (2603:10b6:510:2ce::18) by PH7PR12MB7236.namprd12.prod.outlook.com (2603:10b6:510:207::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.17; Fri, 7 Mar 2025 05:29:57 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:510:2ce:cafe::fe) by PH8PR21CA0006.outlook.office365.com (2603:10b6:510:2ce::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.14 via Frontend Transport; Fri, 7 Mar 2025 05:29:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8511.15 via Frontend Transport; Fri, 7 Mar 2025 05:29:57 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 6 Mar 2025 23:29:51 -0600 From: K Prateek Nayak To: Linus Torvalds , Oleg Nesterov , Alexander Viro , "Christian Brauner" , , CC: Jan Kara , "Matthew Wilcox (Oracle)" , Mateusz Guzik , Rasmus Villemoes , "Gautham R. Shenoy" , , , Swapnil Sapkal , "K Prateek Nayak" Subject: [PATCH v2 1/4] fs/pipe: Limit the slots in pipe_resize_ring() Date: Fri, 7 Mar 2025 05:29:16 +0000 Message-ID: <20250307052919.34542-2-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250307052919.34542-1-kprateek.nayak@amd.com> References: <20250307052919.34542-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|PH7PR12MB7236:EE_ X-MS-Office365-Filtering-Correlation-Id: dab82b50-eb0c-4a69-5922-08dd5d391946 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|36860700013|376014|7416014|7053199007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JnzYpyzBmyQxmY4EgcJZrdP5C6RPD6MetDbzuwAw0po1AN4ffcqwtVn/qNhy?= =?us-ascii?Q?e50xgkxDnxw8puWNb1oOESiJ/JQTtKORBD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gxI1RpRMiXcl+QwTzJ5l8kj+44uDcKSjXVrq4NvN3ZdHUKub2RcOtbec?= =?us-ascii?Q?T1LTecjAsB1QZJT/9ZXhRb0ZSl52I7LGix9wqqc1KXh3q6BeGehrcSqch5/p?= =?us-ascii?Q?7eiXJ5YJMTY8tRUNLjPIj8+vlUNADn/rTqHD41A6zJv2+0KhAJHdCWUmD2Bb?= =?us-ascii?Q?HFYxmDJI1lsZ8Kd9Tx0ITqFObcek3c41Clkjm16rvQMMwD8ax/L6jS+7OQTe?= =?us-ascii?Q?T9uxcoq3flPunmVcVG9ek4tSWe+fD9/HOA3+gnOG7yCqMRHPJYg+csYhso6p?= =?us-ascii?Q?tmCqlMKY0UabGZaYTL8dfCqlyadVFpcUBdtFmDMBW8CsjQ1aj59x85jPwRaq?= =?us-ascii?Q?j9zDtLx/kuA+z5pc/7jGfd9BOnqegYpm+d/Fhm192BOLGeDfWtzK2rSU/hR8?= =?us-ascii?Q?H+yVve/V9qu2Mvz8PliRFc2ErcuIwaR/D8X7Ua6/OcPFlOzy4a9q6zDZx1Z9?= =?us-ascii?Q?2MJYET5BzKTb/Y7Q9ZjoTFgDLsKCHc+r2TWH6XH9HWUGHrDhod6LF/2YC7LU?= =?us-ascii?Q?hsri1lUTZpGDLug=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(1800799024)(36860700013)(376014)(7416014)(7053199007);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2025 05:29:57.3319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dab82b50-eb0c-4a69-5922-08dd5d391946 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7236 Content-Type: text/plain; charset="utf-8" Limit the number of slots in pipe_resize_ring() to the maximum value representable by pipe->{head,tail}. Values beyond the max limit can lead to incorrect pipe occupancy related calculations where the pipe will never appear full. Suggested-by: Linus Torvalds Signed-off-by: K Prateek Nayak Reviewed-by: Oleg Nesterov --- Changelog: RFC v1..v2: o Use (pipe_index_t)-1u as the limit instead of BITS_PER_TYPE() hackery. (Oleg) o Added the "Suggested-by:" tag. --- fs/pipe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/pipe.c b/fs/pipe.c index 4d0799e4e719..88e81f84e3ea 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1271,6 +1271,10 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, u= nsigned int nr_slots) struct pipe_buffer *bufs; unsigned int head, tail, mask, n; =20 + /* nr_slots larger than limits of pipe->{head,tail} */ + if (unlikely(nr_slots > (pipe_index_t)-1u)) + return -EINVAL; + bufs =3D kcalloc(nr_slots, sizeof(*bufs), GFP_KERNEL_ACCOUNT | __GFP_NOWARN); if (unlikely(!bufs)) --=20 2.43.0 From nobody Sun Feb 8 12:14:02 2026 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D4C10E4; Fri, 7 Mar 2025 05:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325422; cv=fail; b=ZM+hDocIDMN2g/pIOVh5VoHasLtoRHOzuwMVLrDbarXi3wKvxFuNpPaJh2B0c+6NF6c8bRV0ULbKG2DxMRYUS9lx3vvfTaQMzv8fQIAMmYSlsRRfwe5skNRI3lwRkHwmxWJueabpSoTdjiPCTizXqhPxSE8viCq65GmmMpzroWA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325422; c=relaxed/simple; bh=xKSvsqplKs397uvJ86IP99n0l87p+1fQl/qlWBIXo3A=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WxBOWBUgYR8OIJG62q0TqkS1g84vBuUzSMKltoxQZaPFLKFOm+KUWtcDQTLIFptxjv6wmG4+EVIVvSVo9nz2cqHu1aT9S1yX6kTwxlL2xvrU+jTwYuLpK3UIMTPfdhh/U72MRtNhOHuFaPEPzjtJCoDSF+4pLqhIH95hqcQX2tc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=e5+6qiMo; arc=fail smtp.client-ip=40.107.237.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="e5+6qiMo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=caa5GJGdLgxGhE9hqfFZ3zWGd5PCaD09BJi6HpPkT8d5RkXiaqG2K0hKq/4BKaXs6Hin0C4DolK+EYu0hrVnBTGXbwxkEaPHL2UChpAFZvhoueceTryr6NGsRHZtttkZQR6ltw8fmTxJgRZZRrGVQcvMwehlgYrhwRK8iLNVqRblApBXBWfoufN4LEq5SR1NjTHW3XIqyB4TzxiHJhx0dQmzggDPPGlTMvii5nBSn4U5/2JOe4xiBcax2Rc2qCtOb2yynEjWhOyqmqb7lcsRZkmNqADWT9GUuMgsFNuuZyo4uLzJZ/+RqRJDB+VA6aU1UJdcPAvn1QX8Q9q0LvGftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iiP2qiR8gLuSVVOWR0tyRnMR1UGprbqzHrSdraYZfnI=; b=OS0sPe5vFbeFwB0+Dw7KXD44D56muJbzYGcvXFQlMTy6e7gyrxIU2bjs6miw1GtWQb+YKDSz7EQqXR+4lleHB3JKN3HS5/pA5ccA/le1KEw9Ha+AASPflp7PKepd3R+i+MLAIt9ok5ab6hrDxCbS2uIyx1R+B4m3GNQZp5ZlCEvxB7wwcE3iJnz9bdHbSBb4b0T9PZxPwTRyFpl2RZ1Q+/tLeqkX/5NvCKqk38S2M8U8CHjkzfWz8MXOKykGx6DQ+M6y/f5Zvix4cs3+isVcuw19xy9sHAn9KkH4c7BTy0kB87dOLNx39FHf2nYvubvUVB3ligRoZnEoalfpyMDxGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iiP2qiR8gLuSVVOWR0tyRnMR1UGprbqzHrSdraYZfnI=; b=e5+6qiMozXxUH2W8lzR6OyfDzYNxTQ2kIOmlQMXYlhqMSa+ONlfcwSrKhZsukzyAIQ0LxNI6m/S+aUPuyO+pD5/h3+eKJjlvpXJ+UXJKfhWRLDvVDJ7sj2sgJP7hi8O7L6/EpsAlGiJeSEfd7U8fSVuZ8EgNQa2W9Tt0BYBahqI= Received: from SJ0PR03CA0106.namprd03.prod.outlook.com (2603:10b6:a03:333::21) by PH8PR12MB6724.namprd12.prod.outlook.com (2603:10b6:510:1cf::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.19; Fri, 7 Mar 2025 05:30:14 +0000 Received: from SJ1PEPF000023D4.namprd21.prod.outlook.com (2603:10b6:a03:333:cafe::f) by SJ0PR03CA0106.outlook.office365.com (2603:10b6:a03:333::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8511.19 via Frontend Transport; Fri, 7 Mar 2025 05:30:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SJ1PEPF000023D4.mail.protection.outlook.com (10.167.244.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8549.1 via Frontend Transport; Fri, 7 Mar 2025 05:30:14 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 6 Mar 2025 23:30:09 -0600 From: K Prateek Nayak To: Linus Torvalds , Oleg Nesterov , Alexander Viro , "Christian Brauner" , , CC: Jan Kara , "Matthew Wilcox (Oracle)" , Mateusz Guzik , Rasmus Villemoes , "Gautham R. Shenoy" , , , Swapnil Sapkal , "K Prateek Nayak" Subject: [PATCH v2 2/4] kernel/watch_queue: Use pipe_buf() to retrieve the pipe buffer Date: Fri, 7 Mar 2025 05:29:17 +0000 Message-ID: <20250307052919.34542-3-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250307052919.34542-1-kprateek.nayak@amd.com> References: <20250307052919.34542-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D4:EE_|PH8PR12MB6724:EE_ X-MS-Office365-Filtering-Correlation-Id: c0ac77e8-fc05-41d9-0e82-08dd5d392356 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?wVjEC7J50k8HB/y4KkQ69VE6+AsUeAvkE6KsUusEeBq7lVeEVA3+0dalaRL4?= =?us-ascii?Q?xq4RoD4etUScpM4xwa1ItqRk6Kal19d6DIzFgzEv0u4FktSPB072wgOOwPDh?= =?us-ascii?Q?X8/FEO+OwMj84ZA8idpLXQiycmMIhPdHZeW5As3Q7inRtDPnK00OvuQ8/OHR?= =?us-ascii?Q?BJ57OuJxAPnbB8XnWuyvHd0kENA/UddC+3VHh3Gx95d1+jfnZHTxsByKdG4u?= =?us-ascii?Q?plz4k/Zx3SLq5A4oSDwn/NaOHkUbm2ZqRThYOh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?OwSCVk2Y/ogyJ+bDZ1JpNBckPFkyaIsPEZMF5HXDVtlRbWWOVTHpyBdhmYvJ?= =?us-ascii?Q?cXFdRB4d0JbxTw7FVdtRO4+kkXoajQEtqwo3FmGLubiReZF9G66p2hbfXM3M?= =?us-ascii?Q?rqpP9zB29WN1VY/gScvnJP+CbSH8QFDwCbAN1Oi50+vSJR49IZVI56z2sCve?= =?us-ascii?Q?qnyGvOc8IpHtbtCVrXzlVi1r4cc8QW42V2eEK1SlQQg28aROFIMhXmwLNY2e?= =?us-ascii?Q?j1l+BhWWAF7m4+vpJXeexjB+GjrzklJsaqBeyjq9fv3rCv7u/mmZoPZNPGTe?= =?us-ascii?Q?agn6PozFS1d9HS8GQC9xIGDcwkkFfx7R0pFaniVJTxs2SwbLUAnfTw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2025 05:30:14.2902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0ac77e8-fc05-41d9-0e82-08dd5d392356 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D4.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6724 Content-Type: text/plain; charset="utf-8" Use pipe_buf() helper to retrieve the pipe buffer in post_one_notification() replacing the open-coded the logic. Suggested-by: Oleg Nesterov Signed-off-by: K Prateek Nayak --- Changelog: RFC v1..v2: o New patch. --- kernel/watch_queue.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index 5267adeaa403..605129eb61a1 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -101,12 +101,11 @@ static bool post_one_notification(struct watch_queue = *wqueue, struct pipe_inode_info *pipe =3D wqueue->pipe; struct pipe_buffer *buf; struct page *page; - unsigned int head, tail, mask, note, offset, len; + unsigned int head, tail, note, offset, len; bool done =3D false; =20 spin_lock_irq(&pipe->rd_wait.lock); =20 - mask =3D pipe->ring_size - 1; head =3D pipe->head; tail =3D pipe->tail; if (pipe_full(head, tail, pipe->ring_size)) @@ -124,7 +123,7 @@ static bool post_one_notification(struct watch_queue *w= queue, memcpy(p + offset, n, len); kunmap_atomic(p); =20 - buf =3D &pipe->bufs[head & mask]; + buf =3D pipe_buf(pipe, head); buf->page =3D page; buf->private =3D (unsigned long)wqueue; buf->ops =3D &watch_queue_pipe_buf_ops; @@ -147,7 +146,7 @@ static bool post_one_notification(struct watch_queue *w= queue, return done; =20 lost: - buf =3D &pipe->bufs[(head - 1) & mask]; + buf =3D pipe_buf(pipe, head - 1); buf->flags |=3D PIPE_BUF_FLAG_LOSS; goto out; } --=20 2.43.0 From nobody Sun Feb 8 12:14:02 2026 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A71E18A95A; Fri, 7 Mar 2025 05:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325439; cv=fail; b=bC8m4NW6xx38gObhc6E3iq/bTj2KCSArhLO6c4wBHvlM4qUe7SE0Mqryf2ZjrXuOTF7YNwJQ4etS4MX960wO/p4qG3x9Ci/5DmDXPKajKkjvFIqdeTE5X61oaVp7OP31hD+0oU/l8K7bRJC+Tc4g3A9M4NGfwd6mVhV5wURziRs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325439; c=relaxed/simple; bh=Q73WcTB2+VlRXzqa7ev84/LZi527mPNM2QyejGvA3+4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QId27ap56DdOCntPrD5GRWs5ZNcUhc1drHc5C25afc6Dm0vF3KSf/cBkVlbeljPvAo72kGcKqN2025Iy9G5n+V9rYETdaKRA7l63oi8CbgfdYmvUhokFzR6xH4EYPSPVCKid+Bc3gGQ/C5Ot8JwFMMPzaNrwk2OCFooXDc1rGKw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=hEV8g9Sj; arc=fail smtp.client-ip=40.107.92.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="hEV8g9Sj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hUX82IsCWkEAnEMdBoImhHYIU6JyzTlNTJuEmVKoP3fVtrZTk6vycZ7iq5CV2YNJvlZT2TiqM8sj1pvCMVDTT+wOgxBJm6wYBwyxxrkabklkeJZDL8/qD8eLhkLTs/8GrUFHA1aOiNEtfQXEigN7tg4W2zhmrBm/ViGknxuAvuiFCoa5EA8ChpIX7YHb8ufqkgtizBvde+raGSvoOes+SMOxv8bBlZXNWyT6Oe0+ugyCUSepje3mSL6+KVGZufyQAuhS/941noDCUE5yfaMQGHioKHFLnN9yxxr5VMFJhTCBOxEAkPBNxwKSsm7ilE6zZA233ZDWRrwmdXZ3TtcUww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4VfVGspq/P3N40fr9urCp2EonRGH1D/vz4xu2onNWug=; b=SPCtSOyAMrU9+SzdI4bqPf4a9fNj4mVKDAden/ptkEuVhAbQ2Ac3psfVoNRsGB/phhmEO1L80TFB/XrtqYu+/ZDJ5fb4s7cPwt4Ssz73QxttR0haon2eB1lNTkWrD5+snFpoH2SIYISg3o2m3XFFE8bUL8EEMeeMkGDm2MIoTY4lOlwRnafngrujI3ENTOWGLI5dz9szcJx0YoftspTKB0dr9i88KLBucAFO7Lc9k2xvEoGVD9sLSH5qL202S+LOf1tSQm9Q2a0GIke2C9IkUXu2k48JmZ7jPZwU0IQhw9GCB5oo8Pq/qw8dD160qwkyuAFlXtv/uBwV8K79peQauA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4VfVGspq/P3N40fr9urCp2EonRGH1D/vz4xu2onNWug=; b=hEV8g9SjYpiv+G2hoDQdW/pdYyOvr1IOeuqzk8AJqOq1vmldbpX1lQhO6PBRDCjYydxJY/f2jKtx7cRtiFsSCtirVeGOXDeSqDk08fGIaNWYO1qRSiQz2EQZt19XU8kl7m9u4TFNNzlgY9ZV1fuGV7iew8aV4NdyuVEwnWsLCnM= Received: from MW4PR04CA0325.namprd04.prod.outlook.com (2603:10b6:303:82::30) by IA0PR12MB7649.namprd12.prod.outlook.com (2603:10b6:208:437::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.19; Fri, 7 Mar 2025 05:30:31 +0000 Received: from MWH0EPF000A672F.namprd04.prod.outlook.com (2603:10b6:303:82:cafe::30) by MW4PR04CA0325.outlook.office365.com (2603:10b6:303:82::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8511.19 via Frontend Transport; Fri, 7 Mar 2025 05:30:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A672F.mail.protection.outlook.com (10.167.249.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8511.15 via Frontend Transport; Fri, 7 Mar 2025 05:30:31 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 6 Mar 2025 23:30:26 -0600 From: K Prateek Nayak To: Linus Torvalds , Oleg Nesterov , Alexander Viro , "Christian Brauner" , , CC: Jan Kara , "Matthew Wilcox (Oracle)" , Mateusz Guzik , Rasmus Villemoes , "Gautham R. Shenoy" , , , Swapnil Sapkal , "K Prateek Nayak" Subject: [PATCH v2 3/4] fs/pipe: Use pipe_buf() helper to retrieve pipe buffer Date: Fri, 7 Mar 2025 05:29:18 +0000 Message-ID: <20250307052919.34542-4-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250307052919.34542-1-kprateek.nayak@amd.com> References: <20250307052919.34542-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672F:EE_|IA0PR12MB7649:EE_ X-MS-Office365-Filtering-Correlation-Id: 202d39c6-833a-4a06-4771-08dd5d392da6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JzwlEVZH8MPXplRF6mE1H7n63I4/DGIWxLJye01myOlVcjZcnRzXgPHE9aD1?= =?us-ascii?Q?VP0Vaq8NM+XlKSNBtFxN6GCTpFdGj7gDe4SGLFVWpcHwbobR7iBNo5f/eTDb?= =?us-ascii?Q?pn2yC0VXunQptVW6wc129H99+nUFQXCY/YpVPrS0EfQ3l3UkY7yHhdeI/fTm?= =?us-ascii?Q?432cBFeMNIiQSyqjg/C3+fH5YJI/3nbne7oAUr3Bofbpl6C4XQWKyKJh9A+T?= =?us-ascii?Q?OERg75JxApGHZRVPbSNcbWBubsxMZYsjlG38bHYWlYUt5RoLW3EIQOn+VRgB?= =?us-ascii?Q?F8T6ZPIdrUtky8nD9xKQyccM527xmmP0HlITUmhe9MJQg0hmNvugjs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c9AyFzxTrCP1/9kKFxyq/ELdS0R7z/?= =?us-ascii?Q?IAnBT38roppLt4jOMwgStlTc3r0VNvA+Dxk4b50/NvbrRfSrgDvHXjXcRylr?= =?us-ascii?Q?N3reMLkZiezjExSMQQgRWtwe5AD4J/pBEWqM+8aa97kD1ZoZEOMiN0t5oPQq?= =?us-ascii?Q?ZrbvvFmpNqi4F8GnRJEwXn0nLxv2rXI034OwtMCg3HtcUu/rfNJM3TCfpSUB?= =?us-ascii?Q?VzBeIzPMk2Zk+Dk43hO0kr6GCnxueZvAD3XvME/XvSamAHzKcKGI/JatavYY?= =?us-ascii?Q?GQImbykU5pzvLDg=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2025 05:30:31.5306 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 202d39c6-833a-4a06-4771-08dd5d392da6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A672F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7649 Content-Type: text/plain; charset="utf-8" Use pipe_buf() helper to retrieve the pipe buffer throughout the file replacing the open-coded the logic. Suggested-by: Oleg Nesterov Signed-off-by: K Prateek Nayak --- Changelog: RFC v1..v2: o New patch. --- fs/pipe.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 88e81f84e3ea..4d6ca0f892b1 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -274,7 +274,6 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) /* Read ->head with a barrier vs post_one_notification() */ unsigned int head =3D smp_load_acquire(&pipe->head); unsigned int tail =3D pipe->tail; - unsigned int mask =3D pipe->ring_size - 1; =20 #ifdef CONFIG_WATCH_QUEUE if (pipe->note_loss) { @@ -301,7 +300,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) #endif =20 if (!pipe_empty(head, tail)) { - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); size_t chars =3D buf->len; size_t written; int error; @@ -471,8 +470,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) was_empty =3D pipe_empty(head, pipe->tail); chars =3D total_len & (PAGE_SIZE-1); if (chars && !was_empty) { - unsigned int mask =3D pipe->ring_size - 1; - struct pipe_buffer *buf =3D &pipe->bufs[(head - 1) & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, head - 1); int offset =3D buf->offset + buf->len; =20 if ((buf->flags & PIPE_BUF_FLAG_CAN_MERGE) && @@ -503,7 +501,6 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) =20 head =3D pipe->head; if (!pipe_full(head, pipe->tail, pipe->max_usage)) { - unsigned int mask =3D pipe->ring_size - 1; struct pipe_buffer *buf; struct page *page =3D pipe->tmp_page; int copied; @@ -525,7 +522,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) pipe->head =3D head + 1; =20 /* Insert it into the buffer array */ - buf =3D &pipe->bufs[head & mask]; + buf =3D pipe_buf(pipe, head); buf->page =3D page; buf->ops =3D &anon_pipe_buf_ops; buf->offset =3D 0; --=20 2.43.0 From nobody Sun Feb 8 12:14:02 2026 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2043.outbound.protection.outlook.com [40.107.220.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC8E8157A48; Fri, 7 Mar 2025 05:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.43 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325456; cv=fail; b=eUxILQQbj/88PEwIPj4hbgX1972lB0c9QKXc9kIsLoliqbQnD5lwOQMa6hwGDb06oeYpn8USnIeB0b1wXEi61N1AfzL8jcmdnxw2QoagV/hwPc/AODUrBkLUkW3BeJaOPOoXdB2Ns0GoCdN0PIzMJqE3s9jnRBnyKKtc7GqUUao= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741325456; c=relaxed/simple; bh=A9d/q1YpQvLlyUbELP2m65tW8cqxGx7CgZxDrZDYz54=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rPeog0zpqORn/9b1Xxi9trQrEoObwLc0EIgVYR3WMuB+CP6pHhscUOw1ey5//WtWUCAuBEUXAS3UfJTdTbzA4tvJtEK2EFavv9XSqUd7a91EAnnzMpVDGouhgChzbx9tzE31RIOrvg7MUCQs9+Uvny5LwMWMld+m/0tHs+Nitps= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wZqWOEGF; arc=fail smtp.client-ip=40.107.220.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wZqWOEGF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oZ0Ifu1dT/zK+2KWEd+0Gi7zARp8dPYojFSe404ocWR3Y3OVAMaa3DF9vdLN4A4dKGWTJXWrYk4mfVOYz1KEFyMUY2B/LTfkr6dBoTvvtV/J1tDM2AUZzbxgPIE7gWBdhxrqNawCjCm0Af9IB7gO/JxSGjbV5VD9fRGFSHfRX260GqRbB6ddS74jemPWRt8sl72r5SEki5hxhiVlagYA+HG2Lh23DS8tN5OQwXkabgI3R7PVz3whuaLeixYKbT6MKMRNPPToe4suSnXQBlj4EUaYCBsDNQu4YOtKVEZFjZP5N1MVjCqfcv/a07Giycl6K+SgRjVUyO+nzwqKm1QeWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U/LEbqWXu9+405LHQ0kI8kGwEk0uesBShmGPBh9BRwk=; b=ynUE7kt4mq0qPw9YupWyTVLocVlprgo7JtDQKmqH7Zms84QtivmPpbibpSUmYp28Hv4295b1Y3Y+mtTHSliHvGRsOHhL0hnF6bYOej9uXLXCtOVDxQ5XoYw69HAMo7kZ6ff+d7cd7yRCFSHhfKlRHQbpiOeWalNo/H0mzdgb9qj3u0uLpP9R6k3DMOi5T+0maxP0fmq2NXGhe//47NQBXeSJ5gE5Hfx0sdlq8bOYJ69+DnqVUDnpYaOg4PcadskN6434gN2Eqns93ML2Xx9K+BNSWCBSm1tGNXViXSI0QZYFFSC4L3x0nr17ifYWouSVOb8lsAh9aGIumMBQQTaz1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U/LEbqWXu9+405LHQ0kI8kGwEk0uesBShmGPBh9BRwk=; b=wZqWOEGF2tD6dAJPtE/CHdjRxuMCdcr09N3FeHT6S3T5lU4oENotc8JJasYVColrfwXEipfe0Et05As5wKbvf0FF0xaQiwMW2Kz0F7BX9Y/E5Fpd0fdl5JRcXETOl1Z9XHVDg6gBkYOvIazGofTMwCAjHWCuzU26Qm9rC+i4K8U= Received: from SJ0PR03CA0183.namprd03.prod.outlook.com (2603:10b6:a03:2ef::8) by DM4PR12MB7624.namprd12.prod.outlook.com (2603:10b6:8:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8511.18; Fri, 7 Mar 2025 05:30:50 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:a03:2ef:cafe::a4) by SJ0PR03CA0183.outlook.office365.com (2603:10b6:a03:2ef::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8511.17 via Frontend Transport; Fri, 7 Mar 2025 05:30:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8511.15 via Frontend Transport; Fri, 7 Mar 2025 05:30:49 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 6 Mar 2025 23:30:44 -0600 From: K Prateek Nayak To: Linus Torvalds , Oleg Nesterov , Alexander Viro , "Christian Brauner" , , CC: Jan Kara , "Matthew Wilcox (Oracle)" , Mateusz Guzik , Rasmus Villemoes , "Gautham R. Shenoy" , , , Swapnil Sapkal , "K Prateek Nayak" Subject: [PATCH v2 4/4] fs/splice: Use pipe_buf() helper to retrieve pipe buffer Date: Fri, 7 Mar 2025 05:29:19 +0000 Message-ID: <20250307052919.34542-5-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250307052919.34542-1-kprateek.nayak@amd.com> References: <20250307052919.34542-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|DM4PR12MB7624:EE_ X-MS-Office365-Filtering-Correlation-Id: 1237710a-2928-47f8-fcbe-08dd5d393881 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sa5CPHCw+cy5F1qcj41/yZdn4U0MJ1n6hcYtuBqihPQfkQbQIvRbAHcyQsMc?= =?us-ascii?Q?ayv/7+us3Hs5Ni1hqEre19NRJTgVZEb5sKppVlS8ta+Jh+lHPrgDejItZp2V?= =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JEZhONEDfgcww+7n3B9DTo5?= =?us-ascii?Q?bgCxmu5/2NKZJ7BezMP31+ZNytdHDRlFds0aIkaAMBBtzqW/9IMvIrQvp4rL?= =?us-ascii?Q?SjSU0NI2NQ6ia1D27ynIRLSnX/p49WIM6/3owLqEUEEQ9BhzWIyFL4QTAfql?= =?us-ascii?Q?RvGnZ5GFRcgWf8juHGxzmNhs0dr+sCW86m2s/y9XCpmRhPeFVvCrzNSlvLWg?= =?us-ascii?Q?ervJQqqefWNF0H8I+bCmc8CLbMKOWYmgAhXNwS2P9Pc8ZlkCrxO3CRVG6a8G?= =?us-ascii?Q?f1Zj7kGtwP2nqLJs+6T1Tmv2zsRmcT2TNLCCienWNHN53AkA5cQZVsqqegO8?= =?us-ascii?Q?C3CDY2a7PxOV6hNPqdNdnVaBjI2VSdnt6qRAAo5Nh2onMgd2g06xc9wGjPpH?= =?us-ascii?Q?3/T8Pfo1m1sgHEoMJS3Q/EBB7vIsta0R6FEiBRAQEcf9mRpqK+TcrypO/XWF?= =?us-ascii?Q?AzKcl58efI1SshxMUDfGSy8A4OLZcD7j8jMtAbMZBZ56qBTu+5tmiA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2025 05:30:49.7321 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1237710a-2928-47f8-fcbe-08dd5d393881 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7624 Content-Type: text/plain; charset="utf-8" Use pipe_buf() helper to retrieve the pipe buffer throughout the file replacing the open-coded the logic. Suggested-by: Oleg Nesterov Signed-off-by: K Prateek Nayak --- Changelog: RFC v1..v2: o New patch. --- fs/splice.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 23fa5561b944..90d464241f15 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -200,7 +200,6 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe, unsigned int spd_pages =3D spd->nr_pages; unsigned int tail =3D pipe->tail; unsigned int head =3D pipe->head; - unsigned int mask =3D pipe->ring_size - 1; ssize_t ret =3D 0; int page_nr =3D 0; =20 @@ -214,7 +213,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe, } =20 while (!pipe_full(head, tail, pipe->max_usage)) { - struct pipe_buffer *buf =3D &pipe->bufs[head & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, head); =20 buf->page =3D spd->pages[page_nr]; buf->offset =3D spd->partial[page_nr].offset; @@ -247,7 +246,6 @@ ssize_t add_to_pipe(struct pipe_inode_info *pipe, struc= t pipe_buffer *buf) { unsigned int head =3D pipe->head; unsigned int tail =3D pipe->tail; - unsigned int mask =3D pipe->ring_size - 1; int ret; =20 if (unlikely(!pipe->readers)) { @@ -256,7 +254,7 @@ ssize_t add_to_pipe(struct pipe_inode_info *pipe, struc= t pipe_buffer *buf) } else if (pipe_full(head, tail, pipe->max_usage)) { ret =3D -EAGAIN; } else { - pipe->bufs[head & mask] =3D *buf; + *pipe_buf(pipe, head) =3D *buf; pipe->head =3D head + 1; return buf->len; } @@ -447,11 +445,10 @@ static int splice_from_pipe_feed(struct pipe_inode_in= fo *pipe, struct splice_des { unsigned int head =3D pipe->head; unsigned int tail =3D pipe->tail; - unsigned int mask =3D pipe->ring_size - 1; int ret; =20 while (!pipe_empty(head, tail)) { - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); =20 sd->len =3D buf->len; if (sd->len > sd->total_len) @@ -495,8 +492,7 @@ static int splice_from_pipe_feed(struct pipe_inode_info= *pipe, struct splice_des static inline bool eat_empty_buffer(struct pipe_inode_info *pipe) { unsigned int tail =3D pipe->tail; - unsigned int mask =3D pipe->ring_size - 1; - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); =20 if (unlikely(!buf->len)) { pipe_buf_release(pipe, buf); @@ -690,7 +686,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, st= ruct file *out, while (sd.total_len) { struct kiocb kiocb; struct iov_iter from; - unsigned int head, tail, mask; + unsigned int head, tail; size_t left; int n; =20 @@ -711,12 +707,11 @@ iter_file_splice_write(struct pipe_inode_info *pipe, = struct file *out, =20 head =3D pipe->head; tail =3D pipe->tail; - mask =3D pipe->ring_size - 1; =20 /* build the vector */ left =3D sd.total_len; for (n =3D 0; !pipe_empty(head, tail) && left && n < nbufs; tail++) { - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); size_t this_len =3D buf->len; =20 /* zero-length bvecs are not supported, skip them */ @@ -752,7 +747,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, st= ruct file *out, /* dismiss the fully eaten buffers, adjust the partial one */ tail =3D pipe->tail; while (ret) { - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); if (ret >=3D buf->len) { ret -=3D buf->len; buf->len =3D 0; @@ -809,7 +804,7 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe, = struct file *out, pipe_lock(pipe); =20 while (len > 0) { - unsigned int head, tail, mask, bc =3D 0; + unsigned int head, tail, bc =3D 0; size_t remain =3D len; =20 /* @@ -846,10 +841,9 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe,= struct file *out, =20 head =3D pipe->head; tail =3D pipe->tail; - mask =3D pipe->ring_size - 1; =20 while (!pipe_empty(head, tail)) { - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); size_t seg; =20 if (!buf->len) { @@ -894,7 +888,7 @@ ssize_t splice_to_socket(struct pipe_inode_info *pipe, = struct file *out, len -=3D ret; tail =3D pipe->tail; while (ret > 0) { - struct pipe_buffer *buf =3D &pipe->bufs[tail & mask]; + struct pipe_buffer *buf =3D pipe_buf(pipe, tail); size_t seg =3D min_t(size_t, ret, buf->len); =20 buf->offset +=3D seg; @@ -1725,7 +1719,6 @@ static int splice_pipe_to_pipe(struct pipe_inode_info= *ipipe, struct pipe_buffer *ibuf, *obuf; unsigned int i_head, o_head; unsigned int i_tail, o_tail; - unsigned int i_mask, o_mask; int ret =3D 0; bool input_wakeup =3D false; =20 @@ -1747,9 +1740,7 @@ static int splice_pipe_to_pipe(struct pipe_inode_info= *ipipe, pipe_double_lock(ipipe, opipe); =20 i_tail =3D ipipe->tail; - i_mask =3D ipipe->ring_size - 1; o_head =3D opipe->head; - o_mask =3D opipe->ring_size - 1; =20 do { size_t o_len; @@ -1792,8 +1783,8 @@ static int splice_pipe_to_pipe(struct pipe_inode_info= *ipipe, goto retry; } =20 - ibuf =3D &ipipe->bufs[i_tail & i_mask]; - obuf =3D &opipe->bufs[o_head & o_mask]; + ibuf =3D pipe_buf(ipipe, i_tail); + obuf =3D pipe_buf(opipe, o_head); =20 if (len >=3D ibuf->len) { /* @@ -1862,7 +1853,6 @@ static ssize_t link_pipe(struct pipe_inode_info *ipip= e, struct pipe_buffer *ibuf, *obuf; unsigned int i_head, o_head; unsigned int i_tail, o_tail; - unsigned int i_mask, o_mask; ssize_t ret =3D 0; =20 /* @@ -1873,9 +1863,7 @@ static ssize_t link_pipe(struct pipe_inode_info *ipip= e, pipe_double_lock(ipipe, opipe); =20 i_tail =3D ipipe->tail; - i_mask =3D ipipe->ring_size - 1; o_head =3D opipe->head; - o_mask =3D opipe->ring_size - 1; =20 do { if (!opipe->readers) { @@ -1896,8 +1884,8 @@ static ssize_t link_pipe(struct pipe_inode_info *ipip= e, pipe_full(o_head, o_tail, opipe->max_usage)) break; =20 - ibuf =3D &ipipe->bufs[i_tail & i_mask]; - obuf =3D &opipe->bufs[o_head & o_mask]; + ibuf =3D pipe_buf(ipipe, i_tail); + obuf =3D pipe_buf(opipe, o_head); =20 /* * Get a reference to this pipe buffer, --=20 2.43.0