From patchwork Fri Feb 9 14:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EF2EC4828F for ; Fri, 9 Feb 2024 14:29:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5FFB6B0089; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A9AFC6B008C; Fri, 9 Feb 2024 09:29:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89DA36B0088; Fri, 9 Feb 2024 09:29:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 797346B0085 for ; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 426831A1097 for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) X-FDA: 81772497702.05.BDE5BF8 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf13.hostedemail.com (Postfix) with ESMTP id DFCC420019 for ; Fri, 9 Feb 2024 14:29:06 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=LzdQ56ug; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf13.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488947; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Xp/CDCIv8x19lL1UbiGyRLdd/wr0PppohAnD3gAfH/c=; b=nElGouck55XqwtrT4KeVmMZdAQPM/vSAw34c44zhqFLJIpOMyQGpIGZKqYD6KdyxVcS/Ak 4BuJg89qrFUfqmYSZ1TNCp/0lhIRQMcJkCTia64VOkYcrSf+Y1hSLexHYRzdzVeuRiA9av PiBmw1jS2RoSXdl2cZqX8nrP9/7tqGE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=LzdQ56ug; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf13.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488947; a=rsa-sha256; cv=none; b=1RoyKyU+AKONMpkJV3Bd3hkDKAEjAuD1vtdm00kWH+IaB5Ooh2vzyMV6mw75cOFCQbNwhA tGT2kd1XCHEN9QL9Jf+NfZxtjtfhEwedxgpRxR2jo8dPNUyAeUcOYXjXhcHbaqKG+XZ7z3 JRlarvzp2n8Tbx0yXCKnZZhbfvecg2o= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142904euoutp01bc019a533662469c4e95e3f0c45a72e9~yOCX82mxB2559825598euoutp01O for ; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142904euoutp01bc019a533662469c4e95e3f0c45a72e9~yOCX82mxB2559825598euoutp01O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488944; bh=Xp/CDCIv8x19lL1UbiGyRLdd/wr0PppohAnD3gAfH/c=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=LzdQ56uglyxjaJchOqqToC0c03bgWaOs+RPDfGhHNU9nsIH+BF6X887k+qb9pBDBM MQgLLEY70ciK0e/b+vB/b4SQGZiKoMEKA77+j6Pyunniki1dNFeugxTTAy4Eml3nR+ bF64C58U7sasaiGtG9I6zpBtSo2oSuhVUIoRNCMk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142904eucas1p21b3aca7b96105d3b5578a9ff3ae31d1f~yOCXp-XiZ0208902089eucas1p2U; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id E8.2E.09552.0B636C56; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240209142903eucas1p17f73779c6b38276cd7cefbe0a40f355e~yOCXQxwuN0937209372eucas1p1W; Fri, 9 Feb 2024 14:29:03 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240209142903eusmtrp2f9b51616ff70cd7034716594c79ec1a4~yOCXQJcRl2110121101eusmtrp2Y; Fri, 9 Feb 2024 14:29:03 +0000 (GMT) X-AuditID: cbfec7f5-83dff70000002550-89-65c636b0a566 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 06.6F.09146.FA636C56; Fri, 9 Feb 2024 14:29:03 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142903eusmtip1cba34f5186d87344c625af1f3f3dac53~yOCXDXR-x2720027200eusmtip1v; Fri, 9 Feb 2024 14:29:03 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:03 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:03 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , Daniel Gomez Subject: [RFC PATCH 1/9] splice: don't check for uptodate if partially uptodate is impl Thread-Topic: [RFC PATCH 1/9] splice: don't check for uptodate if partially uptodate is impl Thread-Index: AQHaW2RTk/uEtIw1W0yBH2EezPFdkg== Date: Fri, 9 Feb 2024 14:29:02 +0000 Message-ID: <20240209142901.126894-2-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02SaUwTURSFfTPT6VBtGAqRJ66AK9IKwehEjZGocRKMQYMmGBeqjHVpETpU kERFAVEkFQluhUBVEFAitioqm9pioRbDDyOCUZZaRFFBioBaBWkHE/59991z7zk3eQQqauT5 EAdi4hlljFTuhwuwCtOvJvHdZSYmSK0RUHnlZTj1xWgH1Eu1A6csWdcRqsuuxqjcyykIVV1j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XVxmV5eIt7Xzx1eb lR/8/jPYv1heifkQ+5zVaq/fR/4p8BYrtGqRPa7EUpyRaKjFXFScCAAnnUg83AMAAA== X-CMS-MailID: 20240209142903eucas1p17f73779c6b38276cd7cefbe0a40f355e X-Msg-Generator: CA X-RootMTR: 20240209142903eucas1p17f73779c6b38276cd7cefbe0a40f355e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142903eucas1p17f73779c6b38276cd7cefbe0a40f355e References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: DFCC420019 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: a48xia85hityi4a7rh1c6dr3xqfipgd5 X-HE-Tag: 1707488946-864800 X-HE-Meta: U2FsdGVkX1/qRC6UwvNDt6tWvhK4MYkbUNXkCTcaN46MFBMITkL9svmHju+DVPUPbeckP/jVDepgEpxu086tl9M5/hcIdRz9DjY8sAoX0vuJFyb1V9SXryQFpTJoVR8jo2YPkQcaPDOxzFqEKMamr+Pk+d7AjEouqNLEbz7yhhaDBGrjIcMa+tv3ulCFt4m1ovRTkZp6D4HxAtIcL4WDyZSKbOugJf5pW1GkLwKY2+4AqpS74H1zZd4rDb77PPSq+B6IjQ5pM1Rt9zPEbRmPthTOWblvP3DaSVi3GaAYvUCZBASMioJmpvSCHpomnA9g/5Qfxvy4TSRNtplG5NG0bf9MwGoOwf+UqQZmGdfhaZHBEoBfhhCg5kE7JzIE15o7OO7jr/m9gPZD1r3qAXluOGE8F/RaiZlWIgbtO5S37KxqemdaOKV5fMUqihsDHulvXDL4KYwEaBTAKKteRRdkTwiey057h9em07gzB7P5dRi/nt+QZbXBoOTRPi3Ct6G1UqMNtBeW+SJzCAM8WIr8xlTmx9uc+KX8tYYKV9gHgOTKbfexITvmO/4KkEN8zXG5Ewm0dQZ1VjH5vHFp83bk/3Xh2diGcDFNlUyJseCjjJgwdmcGRpv0pi+U/sgT6QVZk2mOzKS/sT3ZTF4fcNhv8/p24tdFc5A0Kie0WVgFTS61ZfeMqt3bDHDX8pGtZ5HCG5qAeCSQyY+wIBBm48mxDnw3cKoZbZleO6BtxwZeEn+fAVfYB2SCO3KHU/JV+pgsHa+icERCwgHZvUttq5dpd6AJpDMyJ1NAFL56n7x25v3ONIe3zyORiUnebmA0M8u10yeGu8OcT1HO0P01SkFHYOELEkWarYsgXtTRRhncVlx82j9rPk/vNZJW5V1vXl48NlygPLF/ha81jHQTJfRL0NyBLp5+4wcLHbpDaK1DFHC/hUWbTOVw2VGheSo/BaYzY8IZ/NqMGy9N9Vqx0Mx yAt2mBgy 2X7CTqu4+Q6UN1ZZebQFd4b9r8P2x4Ys5+MBawlP+bO2cuMARLhQiV5JN/pxm6bBxzW98+4Kx9BGFGpnUKeEGnFoNvDawhCaQwrmY1j/W5z59Ipu0qTZ3BvKVkqhD2L/tKI6k6sjVkq/FCZFLyrQ92uK5Yja9ZReea0yy X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Pankaj Raghav When huge_page=always is set in tmpfs, it will zero out the whole page even if only a small part of it is written, and it updates the uptodate flag of the whole huge page. Once the per-block uptodate tracking is implemented for tmpfs hugepages, pipe_buf_confirm only needs to check the range it needs to splice to be uptodate and not the whole folio as we don't set uptodate flag for partial writes. Signed-off-by: Pankaj Raghav Signed-off-by: Daniel Gomez --- Other option here is to have a separate implementation of page_cache_pipe_buf_ops for tmpfs instead of changing the page_cache_pipe_buf_confirm. fs/splice.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 218e24b1ac40..e6ac57795590 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -120,7 +120,9 @@ static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe, struct pipe_buffer *buf) { struct folio *folio = page_folio(buf->page); + const struct address_space_operations *ops; int err; + off_t off = folio_page_idx(folio, buf->page) * PAGE_SIZE + buf->offset; if (!folio_test_uptodate(folio)) { folio_lock(folio); @@ -134,12 +136,21 @@ static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe, goto error; } + ops = folio->mapping->a_ops; /* * Uh oh, read-error from disk. */ - if (!folio_test_uptodate(folio)) { - err = -EIO; - goto error; + if (!ops->is_partially_uptodate) { + if (!folio_test_uptodate(folio)) { + err = -EIO; + goto error; + } + } else { + if (!ops->is_partially_uptodate(folio, off, + buf->len)) { + err = -EIO; + goto error; + } } /* Folio is ok after all, we are done */ From patchwork Fri Feb 9 14:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F7E9C48297 for ; Fri, 9 Feb 2024 14:29:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DAAF6B0096; Fri, 9 Feb 2024 09:29:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 062426B0095; Fri, 9 Feb 2024 09:29:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5E066B0088; Fri, 9 Feb 2024 09:29:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9B3A96B0085 for ; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6E588C0905 for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) X-FDA: 81772497702.05.A53FDB3 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf12.hostedemail.com (Postfix) with ESMTP id DD99340023 for ; Fri, 9 Feb 2024 14:29:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Pb7wORK5; spf=pass (imf12.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488947; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CVr+BSsSvYqyUxoK+Z2ICaYEZFi6sZ1CmkC1b8DH1ws=; b=SGDkOrNVnK1Che6NU/d+du5GWwYwXRCKog4FDC8mjhxLf028xNq6hxUJ3UaO0tLxx2TAij 9iIZjBbijbSvN/OapXvMHPMplx+sce4QTtR7uJMWilyNqUsKpYVZGvRZXO6AY/gWFmdqHY Bdj6TLyVP0WBOLefO4mHNoyzolpzqzs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488947; a=rsa-sha256; cv=none; b=coJWkBrGGeMAgi330BcfBGENurf7Cetf3VZ+jf7yThfNYe9DuLsuXidULRRMuVSFtXA20i IGtGOhv+xgqgkBh/h9bqOrMOoUyNSbWftukKh7PC7Wv9ucREkAezu9copkNRBpkuudykns 1Q1xdS+vWIN2a/IFYeoMwmofnBYt444= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Pb7wORK5; spf=pass (imf12.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142905euoutp01ef5ee83ca9d06d23b1847668e7dacb99~yOCYvslgc2699226992euoutp01t for ; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142905euoutp01ef5ee83ca9d06d23b1847668e7dacb99~yOCYvslgc2699226992euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488945; bh=CVr+BSsSvYqyUxoK+Z2ICaYEZFi6sZ1CmkC1b8DH1ws=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=Pb7wORK50Qp+0MacIA0fkdKvzFt9bF4rsGSIhRPNRlT0NZm2ww6wtDMVP4Pd5chC7 I5mWfcqo2MrXuaJZKPqJG5CxmvzRturYToAAG4Q1z+8C9hwqNzrnL7oFcLbjPd0/fC Y8ygeYk3rQ5RfOmWXecirDYjuqC317lWLAdiHFgA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142905eucas1p2574b31587e71bdc31a2993449e51ba90~yOCYaW4Yr0060200602eucas1p26; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id B9.F5.09814.0B636C56; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240209142904eucas1p20a388be8e43b756b84b5a586d5a88f18~yOCX8K7xm2346823468eucas1p2R; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240209142904eusmtrp22b43289d14a97adda5bf8a1bb0345841~yOCX7eDvn2106521065eusmtrp2p; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) X-AuditID: cbfec7f4-711ff70000002656-34-65c636b071cb Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 67.6F.09146.0B636C56; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240209142904eusmtip20cf00b0cf7880a505516226c14ba4db4~yOCXvA7qt0292502925eusmtip2c; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:03 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:03 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , "Daniel Gomez" Subject: [RFC PATCH 2/9] shmem: add per-block uptodate tracking for hugepages Thread-Topic: [RFC PATCH 2/9] shmem: add per-block uptodate tracking for hugepages Thread-Index: AQHaW2RT4T3ZrPeWjkOR05yD13efEQ== Date: Fri, 9 Feb 2024 14:29:02 +0000 Message-ID: <20240209142901.126894-3-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDKsWRmVeSWpSXmKPExsWy7djP87obzI6lGjx/ZW4xZ/0aNovXhz8x Wpzt+81mcXrCIiaLp5/6WCxmT29mstiz9ySLxeVdc9gs7q35z2pxY8JTRovzf4+zWvz+MYfN gcdj56y77B4LNpV6bF6h5bFpVSebx6ZPk9g9Tsz4zeJxZsERdo/Pm+Q8Nj15yxTAGcVlk5Ka k1mWWqRvl8CV0br+N3vBB+eKC0/nMzUwbjfvYuTgkBAwkfjclNTFyMUhJLCCUaJv7VZ2COcL o8SLhtlQzmdGiZ+nrzLDdPStsYaIL2eU2HtuNyNc0ceXv5ghnNOMErs/vmHpYuSEGHzojgiI zSagKbHv5CawsSICzxklWnd/BHOYBW4zS8xpn8UIUiUs4C8xf8UlJhBbRCBEovP2eShbT2Lf z3XsIDaLgIrEgqX3mUFsXgEriedr74LZnALWEvMerWcDsRkFZCUerfwFVs8sIC5x68l8sDkS AoISi2bvYYawxST+7XrIBmHrSJy9/oQRwjaQ2Lp0HwuErSjRcewmG8QcPYkbU6dA2doSyxa+ hrpBUOLkzCcsIM9ICPRxSVx7eowNEmAuEuc6OCDmCEu8Or6FHcKWkfi/cz7TBEbtWUjOm4Vk xSwkK2YhWbGAkWUVo3hqaXFuemqxUV5quV5xYm5xaV66XnJ+7iZGYII7/e/4lx2My1991DvE yMTBeIhRgoNZSYQ3ZMmRVCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8qinyqUIC6YklqdmpqQWp RTBZJg5OqQamlZrvfb687S/omfZp+oWYROanaW4f3BVuP62cNpHzc9QjxV0qB+LepUo18JQE yS8Q3eziu+n30Q9l7tGSNhmisXZpqicXTl+zqSz0+UdGkR3cTvP2rsnbyJ8RprqtfnWEXzbr WxWF9ONHZvbPEVk0m2vP5I5L/RduC/xZXMrFyGX8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fPk3bZgd/r0FMobJT 7+XuhjneZ1ZdUTZ4WvTtzaL0FTtE2i6eEFu2tEPxQlXulwWLPl19evPln+2RK+oCIkLlDK+x M64uSAj9V/7n4vyqaE5elaQik6u2Cjx7k+f5NkT9/Lbu0LH+2U0OXLcn/OBfxXzCptRTiTl9 27ybP6K76wwtX6v13L1kKR4kdPqOyMHvct+8nl9caPH1rZfoYZ+KpeI8yQ8nJCxYeEhg0SXW jltWfVHhGf5LiyUst04WnrS2dqq8iNWh/A9Pnr2XO62jfcTUrs/UOZ/pwmnZmBszm07ZRTwJ dtOR49/2+mliieDyU5c9l0ZOeqym/8ndMv/S3Dzu1FtKLMUZiYZazEXFiQBXdoA03AMAAA== X-CMS-MailID: 20240209142904eucas1p20a388be8e43b756b84b5a586d5a88f18 X-Msg-Generator: CA X-RootMTR: 20240209142904eucas1p20a388be8e43b756b84b5a586d5a88f18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142904eucas1p20a388be8e43b756b84b5a586d5a88f18 References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: DD99340023 X-Rspam-User: X-Stat-Signature: oinxntmi7k9onw5gpxhab81i96yz8hgi X-Rspamd-Server: rspam03 X-HE-Tag: 1707488946-100296 X-HE-Meta: U2FsdGVkX1879PVFtKyaQNBIQGzUagcCaiQqZtzLCYVUXmUJwNKW7408MnM64aXmW9zmnHo3g/5meDx1oyAqfe6/L5bagIVA0jV54RT+ZsFywW6WBif1TZP8xrRvYS/YVGpHaZP/BMTTQwiAUQufJuWZZJ7g9jwPvFom64bEHgOfx9Gx/HfJcWwa+InjtkBwRqnsESFf2iiAodu9Q84yeQkpgJ9ZNAs4PyzThK+W0DL6M/cM09iNTTxH0cO0i8UxuBAu2Ga+prcrC7J5w1yAntb43jfvsGAw+zCMH50GA87ZObxE5iToj47edZvvbbJUeo12T46qFPtezOF4k67v6dz3JrIbuGa6xHTr4zzXm1YFGXEJV9aP+/leEU3PmdmnuudCQVWzuRJNWlC6WI3dbGAhvPb7aChzu9CPgjMPcEVCnbfs5gnMg3y86+zc8T5rnqYtbtVCtkfEc6jI7Z+hGIjm2Nv/kF940Rxac8xIsDwTRxw0DN0GCPQWBvE1dZ9nkHsUvl4u0+2jIYOlY1kiB1a0sWphQZZseH3z6aTqtMI5sLDuFvOvaB+EThryX6l4irjbCbL1po0nw6cjyBCIzIqkgydem1zw6jXb0CwvcgoL5u6wsBWNrIxAiqEaofbJWhhJtx+/mrSAk5u6Vo8tTWZDEdkbDXa4K+GdFjkiOtEYVzcfLoFQU2RktaOOMOaMp9CRx3JlgPRto7mtxzOHnToje8+Db33dcxL0SE1XjHL1LJe+3/9fHiBsAvHp0kQ1u9vaMI74LZeJ5nNNw3tbKI5lMew6RY/HbH83Pdi4h67vqzUGuzpuzs3uvgubPfFuXPwrAn5x0r0LlanE/1B1+QKOE7Q1vKLmvSCWnatDqisXrzCJpI5unP7cqmSMvyii3a4EHWyRPd71aryoTC6NP9yUw5ZxD6ty5U2Y8MJkXXEGS+ugN5aaTRwwik2FfriyTriA7p/PbTTzbtsPRLz 6uQ8CmxD Zt07qV6JFNIGEs1QG5U+gn8yBG+V0lINckHYtf/WJL8wQi4wAVkTtkDROrmEnadn28faxU8le3fo6rW9wxeBbxokLAkR01kExjOFoS7FulCBZNt2OC2u1nCE2T0lGAcbZqgOey+WHbtviRmV25iO2CEeKwKcP6S0QOpex X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Based on iomap per-block dirty and uptodate state track, add support for shmem_folio_state struct to track the uptodate state per-block for large folios (hugepages). Signed-off-by: Daniel Gomez --- mm/shmem.c | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 189 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index d7c84ff62186..5980d7b94f65 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -131,6 +131,124 @@ struct shmem_options { #define SHMEM_SEEN_QUOTA 32 }; +/* + * Structure allocated for each folio to track per-block uptodate state. + * + * Like buffered-io iomap_folio_state struct but only for uptodate. + */ +struct shmem_folio_state { + spinlock_t state_lock; + unsigned long state[]; +}; + +static inline bool sfs_is_fully_uptodate(struct folio *folio) +{ + struct inode *inode = folio->mapping->host; + struct shmem_folio_state *sfs = folio->private; + + return bitmap_full(sfs->state, i_blocks_per_folio(inode, folio)); +} + +static inline bool sfs_is_block_uptodate(struct shmem_folio_state *sfs, + unsigned int block) +{ + return test_bit(block, sfs->state); +} + +/** + * sfs_get_last_block_uptodate - find the index of the last uptodate block + * within a specified range + * @folio: The folio + * @first: The starting block of the range to search + * @last: The ending block of the range to search + * + * Returns the index of the last uptodate block within the specified range. If + * a non uptodate block is found at the start, it returns UINT_MAX. + */ +static unsigned int sfs_get_last_block_uptodate(struct folio *folio, + unsigned int first, + unsigned int last) +{ + struct inode *inode = folio->mapping->host; + struct shmem_folio_state *sfs = folio->private; + unsigned int nr_blocks = i_blocks_per_folio(inode, folio); + unsigned int aux = find_next_zero_bit(sfs->state, nr_blocks, first); + + /* + * Exceed the range of possible last block and return UINT_MAX if a non + * uptodate block is found at the beginning of the scan. + */ + if (aux == first) + return UINT_MAX; + + return min_t(unsigned int, aux - 1, last); +} + +static void sfs_set_range_uptodate(struct folio *folio, + struct shmem_folio_state *sfs, size_t off, + size_t len) +{ + struct inode *inode = folio->mapping->host; + unsigned int first_blk = off >> inode->i_blkbits; + unsigned int last_blk = (off + len - 1) >> inode->i_blkbits; + unsigned int nr_blks = last_blk - first_blk + 1; + unsigned long flags; + + spin_lock_irqsave(&sfs->state_lock, flags); + bitmap_set(sfs->state, first_blk, nr_blks); + if (sfs_is_fully_uptodate(folio)) + folio_mark_uptodate(folio); + spin_unlock_irqrestore(&sfs->state_lock, flags); +} + +static struct shmem_folio_state *sfs_alloc(struct inode *inode, + struct folio *folio) +{ + struct shmem_folio_state *sfs = folio->private; + unsigned int nr_blocks = i_blocks_per_folio(inode, folio); + gfp_t gfp = GFP_KERNEL; + + if (sfs || nr_blocks <= 1) + return sfs; + + /* + * sfs->state tracks uptodate flag when the block size is smaller + * than the folio size. + */ + sfs = kzalloc(struct_size(sfs, state, BITS_TO_LONGS(nr_blocks)), gfp); + if (!sfs) + return sfs; + + spin_lock_init(&sfs->state_lock); + if (folio_test_uptodate(folio)) + bitmap_set(sfs->state, 0, nr_blocks); + folio_attach_private(folio, sfs); + + return sfs; +} + +static void sfs_free(struct folio *folio, bool force) +{ + if (!folio_test_private(folio)) + return; + + if (!force) + WARN_ON_ONCE(sfs_is_fully_uptodate(folio) != + folio_test_uptodate(folio)); + + kfree(folio_detach_private(folio)); +} + +static void shmem_set_range_uptodate(struct folio *folio, size_t off, + size_t len) +{ + struct shmem_folio_state *sfs = folio->private; + + if (sfs) + sfs_set_range_uptodate(folio, sfs, off, len); + else + folio_mark_uptodate(folio); +} #ifdef CONFIG_TMPFS static unsigned long shmem_default_max_blocks(void) { @@ -1487,7 +1605,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) } folio_zero_range(folio, 0, folio_size(folio)); flush_dcache_folio(folio); - folio_mark_uptodate(folio); + shmem_set_range_uptodate(folio, 0, folio_size(folio)); } swap = folio_alloc_swap(folio); @@ -1769,13 +1887,16 @@ static int shmem_replace_folio(struct folio **foliop, gfp_t gfp, if (!new) return -ENOMEM; + if (folio_get_private(old)) + folio_attach_private(new, folio_detach_private(old)); + folio_get(new); folio_copy(new, old); flush_dcache_folio(new); __folio_set_locked(new); __folio_set_swapbacked(new); - folio_mark_uptodate(new); + shmem_set_range_uptodate(new, 0, folio_size(new)); new->swap = entry; folio_set_swapcache(new); @@ -2060,6 +2181,12 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, alloced: alloced = true; + + if (!sfs_alloc(inode, folio) && folio_test_large(folio)) { + error = -ENOMEM; + goto unlock; + } + if (folio_test_pmd_mappable(folio) && DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE) < folio_next_index(folio) - 1) { @@ -2101,7 +2228,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, for (i = 0; i < n; i++) clear_highpage(folio_page(folio, i)); flush_dcache_folio(folio); - folio_mark_uptodate(folio); + shmem_set_range_uptodate(folio, 0, folio_size(folio)); } /* Perhaps the file has been truncated since we checked */ @@ -2746,8 +2873,8 @@ shmem_write_end(struct file *file, struct address_space *mapping, folio_zero_segments(folio, 0, from, from + copied, folio_size(folio)); } - folio_mark_uptodate(folio); } + shmem_set_range_uptodate(folio, 0, folio_size(folio)); folio_mark_dirty(folio); folio_unlock(folio); folio_put(folio); @@ -2755,6 +2882,59 @@ shmem_write_end(struct file *file, struct address_space *mapping, return copied; } +static void shmem_invalidate_folio(struct folio *folio, size_t offset, + size_t len) +{ + /* + * If we're invalidating the entire folio, clear the dirty state + * from it and release it to avoid unnecessary buildup of the LRU. + */ + if (offset == 0 && len == folio_size(folio)) { + WARN_ON_ONCE(folio_test_writeback(folio)); + folio_cancel_dirty(folio); + sfs_free(folio, true); + } +} + +static bool shmem_release_folio(struct folio *folio, gfp_t gfp_flags) +{ + if (folio_test_dirty(folio) && !sfs_is_fully_uptodate(folio)) + return false; + + sfs_free(folio, false); + return true; +} + +/* + * shmem_is_partially_uptodate checks whether blocks within a folio are + * uptodate or not. + * + * Returns true if all blocks which correspond to the specified part + * of the folio are uptodate. + */ +static bool shmem_is_partially_uptodate(struct folio *folio, size_t from, + size_t count) +{ + struct shmem_folio_state *sfs = folio->private; + struct inode *inode = folio->mapping->host; + unsigned int first, last; + + if (!sfs) + return false; + + /* Caller's range may extend past the end of this folio */ + count = min(folio_size(folio) - from, count); + + /* First and last blocks in range within folio */ + first = from >> inode->i_blkbits; + last = (from + count - 1) >> inode->i_blkbits; + + if (sfs_get_last_block_uptodate(folio, first, last) != last) + return false; + + return true; +} + static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to) { struct file *file = iocb->ki_filp; @@ -3506,7 +3686,7 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, inode->i_mapping->a_ops = &shmem_aops; inode->i_op = &shmem_symlink_inode_operations; memcpy(folio_address(folio), symname, len); - folio_mark_uptodate(folio); + shmem_set_range_uptodate(folio, 0, folio_size(folio)); folio_mark_dirty(folio); folio_unlock(folio); folio_put(folio); @@ -4476,7 +4656,10 @@ const struct address_space_operations shmem_aops = { #ifdef CONFIG_MIGRATION .migrate_folio = migrate_folio, #endif - .error_remove_folio = shmem_error_remove_folio, + .error_remove_folio = shmem_error_remove_folio, + .invalidate_folio = shmem_invalidate_folio, + .release_folio = shmem_release_folio, + .is_partially_uptodate = shmem_is_partially_uptodate, }; EXPORT_SYMBOL(shmem_aops); From patchwork Fri Feb 9 14:29:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551414 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87D19C4829D for ; Fri, 9 Feb 2024 14:29:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EBBE6B008A; Fri, 9 Feb 2024 09:29:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BDEF6B0088; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE5886B0093; Fri, 9 Feb 2024 09:29:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9F3AA6B0087 for ; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 74C9E1210BE for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) X-FDA: 81772497702.02.0CDF227 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf05.hostedemail.com (Postfix) with ESMTP id 6B31510000E for ; Fri, 9 Feb 2024 14:29:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=iNLm28Q5; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf05.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488948; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5EX9mww1Yf0rOpRLklIYKmjmJtYHS5jxFy+jU2z9Pew=; b=wlIfd2BgKxoVNWp3Oni67A76pLKTYWFVpKfmHj2gZQMPuMxqPm6V8PoPeOXN7Z4Gnp2Hj+ 4HAQOR3gVjbHw71vtQMO6Menx3sVWghj6zYETlrl9P5QaISmL3ya7wiXNBDz0Q42HqYc17 WTPoo9lFHmZi8u14if0kqjRXHB66DNo= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=iNLm28Q5; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf05.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488948; a=rsa-sha256; cv=none; b=bhiu8bUOX8448q2mEadwz2WRNEls+WwDJEDpLtmvr+VcTNXxxXXBNg5Ybxtf8vU5/oAKcT TEW2Mx08zEsLfmsENTXeQdXKrEtHsb2kK33pOz9Xt0c65jxlMxjlBUH3lNWOWtu/4iGRhh mo1WDs4p7TgxiloXRnky1jyU5MTU1os= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142905euoutp0140e3fb5e22791c18770833777b982c57~yOCZS00cg2778527785euoutp01c for ; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142905euoutp0140e3fb5e22791c18770833777b982c57~yOCZS00cg2778527785euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488946; bh=5EX9mww1Yf0rOpRLklIYKmjmJtYHS5jxFy+jU2z9Pew=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=iNLm28Q52eLnCOfv8G9K1mU0dX3bnVJ7nTJpdf1iOu6zrWSahXzu798GPGN2uutw3 dH9S2x4Fe0vbb3SYya8z7xMMwS4Tf9T4HQ5lzJx9Z0blo8q3MI7YDC/s9JKhNpAGMI ea1TZ65+ON5c7yQwpys2kl8OdcvYvuKc4Kq8T3Io= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142905eucas1p2901cf7d34b6c0b8739cc8cd9c806d0b4~yOCY8xfYl2314723147eucas1p2o; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id DA.F5.09814.1B636C56; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eucas1p2df56a08287a84a5fa004142100926bb4~yOCYgKpDC0208802088eucas1p2M; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240209142905eusmtrp2d681160c1113aac64263cd808d288845~yOCYfYvDM2110121101eusmtrp2a; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) X-AuditID: cbfec7f4-711ff70000002656-39-65c636b16a2a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 48.6F.09146.0B636C56; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240209142904eusmtip2518107333d642b9a564504242782a9dc~yOCYU-zq50196001960eusmtip2M; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:04 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:04 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , "Daniel Gomez" Subject: [RFC PATCH 3/9] shmem: move folio zero operation to write_begin() Thread-Topic: [RFC PATCH 3/9] shmem: move folio zero operation to write_begin() Thread-Index: AQHaW2RUQo5uE9Fs4EG+AkzmtoGKGQ== Date: Fri, 9 Feb 2024 14:29:02 +0000 Message-ID: <20240209142901.126894-4-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPKsWRmVeSWpSXmKPExsWy7djP87obzY6lGly5o2gxZ/0aNovXhz8x Wpzt+81mcXrCIiaLp5/6WCxmT29mstiz9ySLxeVdc9gs7q35z2pxY8JTRovzf4+zWvz+MYfN gcdj56y77B4LNpV6bF6h5bFpVSebx6ZPk9g9Tsz4zeJxZsERdo/Pm+Q8Nj15yxTAGcVlk5Ka k1mWWqRvl8CVsfSyVcFzwYrPJ76yNDDe5+ti5OSQEDCRePJ1I3MXIxeHkMAKRomZP5YzQjhf GCWadt5jhXA+M0q8PzSRGaalZ9UzFojEckaJjmV7meGqlt/5CJU5zSgxbfFDhMlHF/5lB+ln E9CU2HdyEztIQkTgOaNE6+6PYA6zwG1miTntsxhBqoQFvCROfp4BZosIBEq877vAAmHrSXT8 /cYGYrMIqEgsWHof7CpeASuJ5t5VYDangLXEvEfrwWoYBWQlHq38BbaZWUBc4taT+UwQXwhK LJq9B+ojMYl/ux6yQdg6EmevP2GEsA0kti7dxwJhK0p0HLvJBjFHT+LG1ClQtrbEsoWvoW4Q lDg58wnY/xICTVwSexZPYIVodpHoPL4eapmwxKvjW9ghbBmJ/zvnM01g1J6F5L5ZSHbMQrJj FpIdCxhZVjGKp5YW56anFhvlpZbrFSfmFpfmpesl5+duYgSmudP/jn/Zwbj81Ue9Q4xMHIyH GCU4mJVEeEOWHEkV4k1JrKxKLcqPLyrNSS0+xCjNwaIkzquaIp8qJJCeWJKanZpakFoEk2Xi 4JRqYIrKZW6esourctYD9YZejp5G53R3z3zPX2FTL81h6CsKz9T6kudiZjSh/++pFyZLNoYf 32dV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T7EaAoMo4nMUqLJ+cBUmVcSb2hmYGpoYmZpYGppZqwkzutZ 0JEoJJCeWJKanZpakFoE08fEwSnVwJTw4+6k1eH5h6bWmDgtytWcdWPGlTNdFq7ak/4w/v5R +23y9H7OtMbX/6Kezgn56JGQmeRn1Gj57EfHe+UVDpv5xe5sPdQ68YboZDmXq5PyxF7kF+5+ /+fqpaTwG0Y/Ny299Ub7Plfy80Y/Zl+lL7lSMZU3lTZfiXpSWTj/4vqZTZNSbhRw3F3Vmcee GbjgKbfrYdZvy6bH7pXI+dXRnLH+3a41jno/Hc8unLdda/JJjeajDBJb1KoZU7c3P5mic6vw QsfERTZNvkc2fbD859j6IfpNoOC/MJNgl09lr/8XV2y3mmYWUMyuWPO7WjRZ+lKmkDdr3ptd l49Ou5zYVuUrF2IvyJ9QJNp/4F95iroSS3FGoqEWc1FxIgDA8rDp3QMAAA== X-CMS-MailID: 20240209142905eucas1p2df56a08287a84a5fa004142100926bb4 X-Msg-Generator: CA X-RootMTR: 20240209142905eucas1p2df56a08287a84a5fa004142100926bb4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142905eucas1p2df56a08287a84a5fa004142100926bb4 References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6B31510000E X-Stat-Signature: wnde1qh58f3pz8ogrbsywz1z1nrj1u3r X-HE-Tag: 1707488948-147150 X-HE-Meta: U2FsdGVkX1878NKHaxkfuVeSKC9ZxWArFvQz2hJFq/Xd6nGTjfdNM2Yu45fD4L4iBKdL2UlIuEAh9lfvHe+3bD2n82YyhNiIH6vQGrfRbG1b8Y/FRFubYXtnTn11C86x00x1cJDg32XwZWfrQEihlKeSm/yvBpledT9dACUqrrxY9Vnj0qQy+hjWYZMnoNmeH6dF/LpbN3Ivowe+5r+pUIVFzdVeyNKu7GFERuTBVjCWvWD9N8G1nh6cwSj3LESF726Z67wgeK1AyPyaoi4Z4BanVB5V7MTT0ID7dhM+liV/5RF/X90JsGb2RXTyj/g4zPGUdq57ulL7lc5vHpW3X+qhPQ0JB6UvS8aQ3QDa9X7icvLqVUujkgcONlaZAlQSP1j+zNxvJDMvZ3ezKwDVeK/HbfZZlwFND/2rWuC7YvQN4K3bCHmWiV7V3IZhoLyQMs2RG9WK1Xb4mnWkcCwaVjBoee5LjaxQoHcHxpkZ1KCEhH+C/tE3m5+6xoceTIKSQp/YIBPYmEJ/9dHDEqNLZiBM9It637dyQtI1QxwvSHn1ZiqlfFmViAWZa6dhA0GEucZO5q/oiqUiySrLvnTGB8V/PspdqbKp6PRjTmMUqod5tzWhr5VGvPmpLJW27VKtEUgiw8v748eL2WERszaeMHbzB3sX/9drCWLPvsAAJuh7FNYSfAYd546pbbDI4UBQEY1G7fbdBV96+yVvvk5+2Yb6YrmDITQjyzvotuLZ/xXGgtqqcQa7LI6uQ3IKeR5w1aSN+itBh6tynsSINIBfjchWicimbqsQ3rC00YV2GWy9WDz738s6qVRfh9yEA50HqgTIFgW95SItd/WgxI0B772RiOs7+BPP0oCLPaOUdXWHGZ8Xv9gZ6IpMtaarTj/EtmjPxTrQx426DaTzpjiUdPfViXOWLtbh0fbHAT9jilUC1t527jfP4ZCauyAzoc1Wcd0zs7cgNJ8k4hc/WBy cJXWO/Cj lNcwDC7xgJo7V5bZ+zrA4RrwlpCr0Vt/VmhkKMgSScKHh0INMkyFBfn1nH5Cp0G0ZF4sTzMN8i+NW1WCb4VejW2dnNJbAJZvS8kmV+fFyc+5X0stfewvxv8KFBpTQ1ZJO3K5N274e/J44PZ8tIFgXr7gWaci4HXh9ts7PMYRVVVsnyNARBSSbUvbLcppzLTm+c4Whyt5RfW38auKWJejnd/Lgog== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Simplify zero out operation by moving it from write_end() to the write_begin(). If a large folio does not have any block uptodate when we first get it, zero it out entirely. Signed-off-by: Daniel Gomez --- mm/shmem.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5980d7b94f65..3bddf7a89c18 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -149,6 +149,14 @@ static inline bool sfs_is_fully_uptodate(struct folio *folio) return bitmap_full(sfs->state, i_blocks_per_folio(inode, folio)); } +static inline bool sfs_is_any_uptodate(struct folio *folio) +{ + struct inode *inode = folio->mapping->host; + struct shmem_folio_state *sfs = folio->private; + + return !bitmap_empty(sfs->state, i_blocks_per_folio(inode, folio)); +} + static inline bool sfs_is_block_uptodate(struct shmem_folio_state *sfs, unsigned int block) { @@ -239,6 +247,15 @@ static void sfs_free(struct folio *folio, bool force) kfree(folio_detach_private(folio)); } +static inline bool shmem_is_any_uptodate(struct folio *folio) +{ + struct shmem_folio_state *sfs = folio->private; + + if (folio_test_large(folio) && sfs) + return sfs_is_any_uptodate(folio); + return folio_test_uptodate(folio); +} + static void shmem_set_range_uptodate(struct folio *folio, size_t off, size_t len) { @@ -2845,6 +2862,9 @@ shmem_write_begin(struct file *file, struct address_space *mapping, if (ret) return ret; + if (!shmem_is_any_uptodate(folio)) + folio_zero_range(folio, 0, folio_size(folio)); + *pagep = folio_file_page(folio, index); if (PageHWPoison(*pagep)) { folio_unlock(folio); @@ -2867,13 +2887,6 @@ shmem_write_end(struct file *file, struct address_space *mapping, if (pos + copied > inode->i_size) i_size_write(inode, pos + copied); - if (!folio_test_uptodate(folio)) { - if (copied < folio_size(folio)) { - size_t from = offset_in_folio(folio, pos); - folio_zero_segments(folio, 0, from, - from + copied, folio_size(folio)); - } - } shmem_set_range_uptodate(folio, 0, folio_size(folio)); folio_mark_dirty(folio); folio_unlock(folio); From patchwork Fri Feb 9 14:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551417 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E90AC48297 for ; Fri, 9 Feb 2024 14:29:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 011B56B0092; Fri, 9 Feb 2024 09:29:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E415E6B0095; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B2276B0098; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EE47D6B008A for ; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C641BC0905 for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) X-FDA: 81772497702.28.E52BB84 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf18.hostedemail.com (Postfix) with ESMTP id B7F221C001A for ; Fri, 9 Feb 2024 14:29:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=YapIIPGe; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf18.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488949; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yzLVEVoC51q0kiEHcn5lFzpeprpnxNh9RSZm3CgLznw=; b=bpsuTPJpyf2R1nd2HgvjFUYkSRM+Zprypufx7zracHb+VLfXbLER1TdwuRzCGjJ+gDcHj/ IH55736dnWf22dA6xkSikNq4SltpCEBcoSBW5hwl9lOta7dt/EHBn30mBrwOn7fKkMA8XC kcEPycCJZfxiMvfr2om8VkJW7c0JGec= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=YapIIPGe; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf18.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488949; a=rsa-sha256; cv=none; b=ZIghC/UqGV2RDpBghzjBsNQYKr9BtPdcbRY5vKQMt2rdWW5HWhd0FgEqEXIyKsZqLyf+oy XU5+1sHLItlZiWm/6mYDy0n9JxsmjHZxzX0Pl90E06vxBCdtwMRNBcbFUyI56rXPvANQf3 ycBPusea5I/Dw4jU4W6GmA+KnD72JCw= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142906euoutp01de0ae574b177e2aae12d742a49769856~yOCZukme72783027830euoutp01d for ; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142906euoutp01de0ae574b177e2aae12d742a49769856~yOCZukme72783027830euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488946; bh=yzLVEVoC51q0kiEHcn5lFzpeprpnxNh9RSZm3CgLznw=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=YapIIPGeo6UtoKnrOw0E2jh3ReyHWKrHHmEiQyUInlp4KSlYxp/L/OiXftCBNIToZ NdbeJmuIhweJNqmEp5GcJEurA5vwyFzz+vWs/MgtuF8bRGPGRlAWqS0ntDKKKMMxGj 2UqNrOu58jjXE2KQXhaCvloLIoReTt24Jj5nLy78= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142906eucas1p2d99cf5db5353012f5c7e394c72654656~yOCZbd3hY2346823468eucas1p2b; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 6B.2E.09552.1B636C56; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b~yOCY9kYJh0934709347eucas1p1k; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240209142905eusmtrp1db904eebec0428be2c7c1271c40b4f46~yOCY86pwm0528405284eusmtrp10; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) X-AuditID: cbfec7f5-853ff70000002550-97-65c636b12cf7 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 10.B3.10702.1B636C56; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eusmtip1bbccce327c924057684231d1edcf32cc~yOCYv0MCC3127531275eusmtip1c; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:04 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:04 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , Daniel Gomez Subject: [RFC PATCH 4/9] shmem: exit shmem_get_folio_gfp() if block is uptodate Thread-Topic: [RFC PATCH 4/9] shmem: exit shmem_get_folio_gfp() if block is uptodate Thread-Index: AQHaW2RUvpPeBHpDT0yQa2xBM9HYnQ== Date: Fri, 9 Feb 2024 14:29:03 +0000 Message-ID: <20240209142901.126894-5-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGvQcZbSYs34Nm8Xrw58Y Lc72/WazOD1hEZPF0099LBazpzczWezZe5LF4vKuOWwW99b8Z7W4MeEpo8X5v8dZLX7/mMPm wOOxc9Zddo8Fm0o9Nq/Q8ti0qpPNY9OnSeweJ2b8ZvE4s+AIu8fnTXIem568ZQrgjOKySUnN ySxLLdK3S+DK6Nl9ga1gG1fF0kVr2RsY93J0MXJySAiYSPzoP8XUxcjFISSwglHi0K9djBDO F0aJJe0P2SCcz4wSOy/NYe5i5ABrmX9BBSK+nFFi4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Generator: CA X-RootMTR: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B7F221C001A X-Stat-Signature: rcrsdjgj4fmaggkgk8oa1z8dh5mwjpwm X-HE-Tag: 1707488948-144285 X-HE-Meta: U2FsdGVkX1+hOhZ7wtYU00Yr8wLwoiP3zc47LgiBNeyy4ewPfOkL329/XDvBq5IJQnA8NQ45br4AzQGQSXLDhhu7WUWHtCoTh60FivP4VR8ZpNxn9VmXSfPKCb1cb0uy6g4KJQpAGfvzKCC+egisggOI8qFGXPvbdiXf+vezmSI4X5F/w10FpsJCfw6SCqFP4Cb5kzPyfM0OVVdjjM5+gCNGKnTNcRf3qtwJ1li4JmTAFWmpKwwrb7M7OlncQkx20YJT69aSb93mqP1Dp09v/8HS6qlfXk4Yw89KqpqVyakQI7PQrm8hSEL3LHhgv6jWCHfxQUwxahA/kCRXpoaYf6B4gWZZPttrD/QLQ9Pn/eWea88kM3vSYI/dAvxWigx1dM2dA+eosmJutbieLa7lSR5DyLUkUA4FFLp29JUGUcY6PXBrfPXjYAw9dkDwiBte6YiMZWTN5psugpL3aIi+RKyqsJWws0COYBj8LHKmYJo/4hG93VsbQC9W5n5uM6hkfTN9QkFmLqgRw0xRcGkl9gHa0L8PXbBb4TyI+PGf/MjKAutCFJ9nMLgWFk1MPgHbnjERxh7EZSMg7QWuV3MjrnbiXnulIfBjmXtc0qvHkGPwmjL5Cu4gMNdtjMBCF1PTvLAcxzcswUTmX+r/PvT+IcZjakIqcSRRTNyb1ChRcCdnAtDY/gqybxOJ9ose/OQkT3QQUVTDcc0DUh9qTxGUTDvCwicdeuaGmNdnM0fD4bINA4zvwGM8y2xF8wpoopIsXFLvt9nbduaXkFzySAtgvSXweNbxbF2GEBrMaVLZhalAvIlmfDvay3NMy2JbQKwnRzUfk3kLVoAJFA2YdEMkD9RbjebQuNObD3bHmpTTvmXS7YIxGGcBH49Y2rNTTrS1ZqvOS5vsU9e8Sw4dV/3WlX2A0QOU21apGR8itRy5uSgZZlXd0StV36swgSpwKV0Lcv7GbCNxejnxRqSib7w f6MhzFuN ISeKjsvpIvVoQ1fCrAIE0K6Kdw3hp9mv9aPyXu2+G8iZ90WnoVYLMn6VQDn1mKZUuSrDorm4Y6LMXkVVR1aYrDKT1U/ZA/NrNRDgTKHrhChqJz5BDJQWU/KwlKmWKLezcgNeYaVvgjbwHYpRFCJEj9hUOOAr6ud/MORg2KveU7UQMifo8rELRkXxIx3qqHBx+WnB8Ap9ZbQT1J8vNNjf1d7rw3Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When we get a folio from the page cache with filemap_get_entry() and is uptodate we exit from shmem_get_folio_gfp(). Replicate the same behaviour if the block is uptodate in the index we are operating on. Signed-off-by: Daniel Gomez --- mm/shmem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 3bddf7a89c18..614cda767298 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -256,6 +256,16 @@ static inline bool shmem_is_any_uptodate(struct folio *folio) return folio_test_uptodate(folio); } +static inline bool shmem_is_block_uptodate(struct folio *folio, + unsigned int block) +{ + struct shmem_folio_state *sfs = folio->private; + + if (folio_test_large(folio) && sfs) + return sfs_is_block_uptodate(sfs, block); + return folio_test_uptodate(folio); +} + static void shmem_set_range_uptodate(struct folio *folio, size_t off, size_t len) { @@ -2143,7 +2153,7 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, } if (sgp == SGP_WRITE) folio_mark_accessed(folio); - if (folio_test_uptodate(folio)) + if (shmem_is_block_uptodate(folio, index - folio_index(folio))) goto out; /* fallocated folio */ if (sgp != SGP_READ) From patchwork Fri Feb 9 14:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68A03C48297 for ; Fri, 9 Feb 2024 14:29:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EB816B0085; Fri, 9 Feb 2024 09:29:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 808D06B0093; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE0966B0087; Fri, 9 Feb 2024 09:29:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A3D3D6B008A for ; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 718BE804E4 for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) X-FDA: 81772497702.01.2711838 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf27.hostedemail.com (Postfix) with ESMTP id 67A3140018 for ; Fri, 9 Feb 2024 14:29:08 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=h1JyNx4K; spf=pass (imf27.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488948; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FCbzId5tUUljaKo+tPW5dyPNAxWuqwZJmK4aFsnXX4M=; b=1zOeAKpv4QxPapxpRgcs1CsiFBcUFbW3tZMNJbGT7ggub9qHv6txrOoF+fRlTblL1ZV5zc HiA1TMC2uq7KX0+pFSkQWS+4mzGiplCjqggNo2v8GK6KPycNgE2FCk9TwQqkdCq8+Md/24 djznT4Hr6p/M/OPIqZTivDAF8HT1hxc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488948; a=rsa-sha256; cv=none; b=sTHUqe/6Jag+8qtMeXp7wPYZSxBIJ3BgO7A7QG+wf7RbnYCWYOa+FrmrHxfgngMfpi/3HO 3+PR3V6HiOQrAuA9HAzgzzf3spRxkGxHVbvM6QJo4bup8bFAWnJ8w/dV9B+OZzH4PYDOoy i0eyrIzJpDdAEtsaPk2tFlNXVvGzvnw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=h1JyNx4K; spf=pass (imf27.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142906euoutp02c25feb24e8db4cb4e77dc12000cf772c~yOCaABEMJ2144921449euoutp02T for ; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142906euoutp02c25feb24e8db4cb4e77dc12000cf772c~yOCaABEMJ2144921449euoutp02T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488946; bh=FCbzId5tUUljaKo+tPW5dyPNAxWuqwZJmK4aFsnXX4M=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=h1JyNx4KMrteOAQd2xuXTYL0v8bGy8abrDejKZj6MfmF7XkTeUYjJO/0mlcML6jxY LVoThPtZVowwXE1i4ym/GrWCFWwXiJyUXv4z+NRkk11J5mp12q17wL1A1sDkfrNlA3 SQ5JHpmxkcLYKefpwei3RORrbhDJGjstMZeYyjgw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142906eucas1p2e47a246a10373a76799a079725583da1~yOCZtNsY_2329623296eucas1p2e; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FC.F5.09814.2B636C56; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eucas1p14498619591475e416a8163dbc96c90e4~yOCZTs0l-0937309373eucas1p16; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240209142905eusmtrp2a5418fa28a2ffb3a4fc54948ca8a399d~yOCZTFUmN2110121101eusmtrp2b; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) X-AuditID: cbfec7f4-711ff70000002656-40-65c636b2e6b8 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 59.6F.09146.1B636C56; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240209142905eusmtip2236828047c1df8be3fea7df7e76daca2~yOCZK_AE42332823328eusmtip2R; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:05 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:05 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , "Daniel Gomez" Subject: [RFC PATCH 5/9] shmem: clear_highpage() if block is not uptodate Thread-Topic: [RFC PATCH 5/9] shmem: clear_highpage() if block is not uptodate Thread-Index: AQHaW2RUm+AjPQwetUKmMMbff0NR9g== Date: Fri, 9 Feb 2024 14:29:03 +0000 Message-ID: <20240209142901.126894-6-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGnz7JWYxZ/0aNovXhz8x Wpzt+81mcXrCIiaLp5/6WCxmT29mstiz9ySLxeVdc9gs7q35z2pxY8JTRovzf4+zWvz+MYfN gcdj56y77B4LNpV6bF6h5bFpVSebx6ZPk9g9Tsz4zeJxZ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zQJvnRPcJroVOj9b2cFf8320z J2ORsxp/mdMZbg8LP76fGUKJnwPLH11v+SWrxFKckWioxVxUnAgAorJ4Z94DAAA= X-CMS-MailID: 20240209142905eucas1p14498619591475e416a8163dbc96c90e4 X-Msg-Generator: CA X-RootMTR: 20240209142905eucas1p14498619591475e416a8163dbc96c90e4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142905eucas1p14498619591475e416a8163dbc96c90e4 References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspamd-Queue-Id: 67A3140018 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: a5wsbe3ay17whwbh1ced1fgwup1gepeq X-HE-Tag: 1707488948-463219 X-HE-Meta: U2FsdGVkX1/JZSDGHmrZOEZKyKEj4jPa1l2s0G8bXAGRbmVa8yMR+7Diwhp4tUg+HBQzhX93opOVSWQ2f6TbAv3Rj3N3OoLecjCpx+/RHeEwcBFKkk5PX4Ue3HMxCDOxjLCuGiPhLSNMl3qh+la6bWz1STafYYeVWmt9+QtL8iRE7PEbGCa8CD021utfOsoE72dKoRU44b/0ZnI7tTsmUnPtotsJ+kxbW9oj41Nb+5tToZvM0ITf+Xyp1FMe6LHlyvlhgrjo8duMNMowqSjokfs7owIyK1yoTJE1p/7+MH5LgusmPR5aus99YBpSNDJvpi1isPJ1e+fNYutsFsjD2Icni6dk8jCYELch18DdGkgdDcgNqPLngp+jRVHNzj6pkOiHKcSLuyl2MvOmozgnLwC9lO5V3accUevY31wA1DzSRe7m6GN2840aKHElg4SoGMnA+Yitns7/zuZcNJ6oUqXE6sXJkQJj9Inmp50+UEdwvHjGSeqYMfrRPUPyvSk6YT97U/upm1XkIYacWa+e/Q1rMljiLJdaH3uDTUNb3Tbpxu3RFy/c+GkreKZvgKbk7+jXsAZ4Bj3EMODvbpzJanE9pkaU6xAAHm8GvSHc0irUcuY++GfEEGQbkW7D4e8sf/mElk/We296k1sYZgYA4hZpYINUvOowdy4Kr3dM2E0ZrZQ1JMEatxjs0M2G52R0i3sipWETrkHe4+eeMSdiR21LIPhtCDXdMH2eEHUnKJbLyB3w/jp1pLi2dBzmTMq/V3tU6vSkyMNdxtsNh9bS03YSIYB0P5OPYmPPEL2xW3Daa4syX7TrkBCR3mp7md6LpnpM/GFEOkxJX5RUCUot+4hnuZu3N1lhHdu6LMJt3JG6AGRnwtAMEuF2efjvb2Sv/2s9wsLmak6brVozdXM3Kn2PSf8X/eBcdGTL9fRibLZK/gYdqbJUJyoag5+OeRKyuV94qk2BtU7diXWHtgp UkVgxFn+ qvZ9d9QBp5ZiI0iMaFrfzW3J8Q1+e8vMesVykNHWmnZWn3imijmJ0MbS1NDejDpD7z+pBlRVtNSN8f6ZqRlyUhssN+1c8BMTzJi2fptYlRdjwZaIDGX3ZAwWpmFcsWJqn0521GpkcDPLjv+CepUeZkJ8iVfUgs23L9nkbKUV5IlvfaMCDdKmmXdwKk3Bt1Auwsfeh4vQi3wIsg80BLoim7H5JGw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: clear_highpage() is called for all the subpages (blocks) in a large folio when the folio is not uptodate. Do clear the subpages only when they are not uptodate. Signed-off-by: Daniel Gomez --- mm/shmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 614cda767298..b6f9a60b179b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2253,7 +2253,8 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, long i, n = folio_nr_pages(folio); for (i = 0; i < n; i++) - clear_highpage(folio_page(folio, i)); + if (!shmem_is_block_uptodate(folio, i)) + clear_highpage(folio_page(folio, i)); flush_dcache_folio(folio); shmem_set_range_uptodate(folio, 0, folio_size(folio)); } From patchwork Fri Feb 9 14:29:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551416 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 618B8C4828F for ; Fri, 9 Feb 2024 14:29:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C990A6B0087; Fri, 9 Feb 2024 09:29:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BD2016B0093; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D92A6B0092; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B845F6B0085 for ; Fri, 9 Feb 2024 09:29:11 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 962658105D for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) X-FDA: 81772497702.03.68956B3 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf11.hostedemail.com (Postfix) with ESMTP id 96BE240010 for ; Fri, 9 Feb 2024 14:29:08 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=VXwvMZgq; spf=pass (imf11.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488948; a=rsa-sha256; cv=none; b=cXR3lgZydwmB7w24SovTAysjGv/q/ZldbyQqbBluO7yj51Fn910sNn/NxF9egkGEazJNAE rPYzxJ9jdNtiHB2zluzuSwT8l8Xo9tCt6flfi41cXjMSDwl3jnQFwaHvg4AzSFzbo3Mv3l INvURwUboxr+jo5RWrXhGv2suSUf4aM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=VXwvMZgq; spf=pass (imf11.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488948; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oOOPXQ1C4QLRnGizBlTW9/7mF80l1aSAxMsYloK3g+M=; b=5/MA9LOweICunh6WKnV/LsDKK5D2AqBF5gx8NS63Ali2tcCdIGEo5O/mpuc8ocLc2WuXqu eIFPL9TKP5sVNgeT3fSDYKbRBi74hBYMSQ5aRTJWs9+ZNo2iy4Iw8OGLayFWR8olCMum+F NjGkTLPR8IK2xN9zsP3rfty3zUAoQI0= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142907euoutp029584dc25e294c1a1f4a7cf48bc33d514~yOCamKXhS2142421424euoutp02M for ; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142907euoutp029584dc25e294c1a1f4a7cf48bc33d514~yOCamKXhS2142421424euoutp02M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488947; bh=oOOPXQ1C4QLRnGizBlTW9/7mF80l1aSAxMsYloK3g+M=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=VXwvMZgqJhlzJrEbIdatR1upBBp2x0B0+/RtlptwGIxcD8Harg5N3Nq6kHxKB/GM3 VIz96cDx5AmzDsB+lRObwNrhSQb7C9zQCrxGXbhD7YEE1CqhR61cKdNQBj19jlo5au mgLa/TVfh9EinFtfloyomR5OIR+3qwQRH59aVKL8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142907eucas1p2072a6f2e9410ced2ddb2e9a8c7628edf~yOCaQzec22618526185eucas1p2C; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FD.F5.09814.2B636C56; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240209142906eucas1p2c31598bf448077f04eef66319ae2f3a1~yOCZzbmxq0060200602eucas1p2_; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240209142906eusmtrp1552e5b8ad10b0382bfcbdd74d7755208~yOCZyxTrv0528405284eusmtrp19; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) X-AuditID: cbfec7f4-711ff70000002656-42-65c636b241f9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B2.B3.10702.2B636C56; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142906eusmtip11fa07a35bc26d35a2936315444ab40e3~yOCZorTLt0114301143eusmtip1L; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:05 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:05 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , Daniel Gomez Subject: [RFC PATCH 6/9] shmem: set folio uptodate when reclaim Thread-Topic: [RFC PATCH 6/9] shmem: set folio uptodate when reclaim Thread-Index: AQHaW2RUZLM8QyQXnk2QIeewqLmB5Q== Date: Fri, 9 Feb 2024 14:29:03 +0000 Message-ID: <20240209142901.126894-7-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGixYZ2kxZ/0aNovXhz8x Wpzt+81mcXrCIiaLp5/6WCxmT29mstiz9ySLxeVdc9gs7q35z2pxY8JTRovzf4+zWvz+MYfN gcdj56y77B4LNpV6bF6h5bFpVSebx6ZPk9g9Tsz4zeJxZsERdo/Pm+Q8Nj15yxTAGcVlk5Ka k1mWWqRvl8CV8WDpN5aCGWwVu7vvMzUw9rN2MXJySAiYSEy68Zu9i5GLQ0hgBaNE2/RfzBDO F0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31598bf448077f04eef66319ae2f3a1 X-Msg-Generator: CA X-RootMTR: 20240209142906eucas1p2c31598bf448077f04eef66319ae2f3a1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142906eucas1p2c31598bf448077f04eef66319ae2f3a1 References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 96BE240010 X-Stat-Signature: q3x55zoxtkgo6pyk5pecm4i4886d48uo X-Rspam-User: X-HE-Tag: 1707488948-545201 X-HE-Meta: U2FsdGVkX1+cyz2Pp0GWN1vZynZyeqOPFhxSbXRgEfUASEkmq8pUNweMDd8mrIOHLANpo0DPuMYcRHtAcQy3o4iwxagq5TjgIl+yy2td2dZ93RWEgG7BVm0H45mPgeVG/lee3fWKV/mw/KmwDCQVjHWxj9c0/loQUgS4y2yHM1JLQnjEn9JjfR3nULRISb81KbftxJ3d0n6bCb9pO+h1nnv5idMq00tdNSmvCVaAPaAAODilJtSIgotqPc3OYi6uxdmzwOklbxlkbQJ4JLFObecWOB6OJD0ZPmrn+LZo2k98UYiFZZVITy7yHdcCmcyvkWt6w5LJKAp1DrpKH9pa/X8Mr4oCKoC+PwYfiGkBvkh6gxg9IT5N3o7DVeAALl5khqHF3l0CUXlFut/hSWY4bdzBrT7G/kA+LoxChQY8ZcjInddeZ5uY4ayTfOJE/iQ7c5J42WEp0lp5HIdfb2pRYORIT3bTkBiXcnhmITgayvyI0x97LMKgF9RYV+ePutnUmYgu1De/QcVJQgp3Pjw6ELZ6UTcAAIw59rReuzBw41+/7zU7weRHgaw+dDxIp5xXe20oZQhg0ddWv5GUAIiwgkHAffUHuN/+wN/gG+akbSiUZsoQaUBxMKO1y0n3evBYgK4vdDwKgHLDoYC4w3Z0pDM+S05mA7mTqHIHzGBqtOu/La3arv5QmMXyxX2yr3/Mjctv4hOsb7pvR8FnL7xqwvjI6nDPwVLfcEFJDxLn0mOUD966L4cJBRZIM2gaoTl+29JwJP0Lb+EafjCVNcZ0JfzwJ7bkBf13cLqzcvLL0aX5XOB7/WddNh20hvYeKACoNt1/uwY4thcUlbYSxuhQexlbNF3tnMcQLSn1NxCWBS5URjN+rLMaL9h4ysufRxLSAimEn+Wm30sxYcqI2GhgKjrVqHEUTqOiYz77nrWm6q7EeGYTzxxizL5NAElvuaPDG65+P0KOeCeThNe9REM CHv8d0cL Mj4zMkk7vReM5fWv3hWbjFTgEMMI/xKtle1xVtmrkxP/fnAF0cGzx+d/sBWkyG3fAxHWE5XdQSEGP9nJRRbvyYD/jF4f+ZLwM3PE5B6AoK4MKD/u5EJtbXnaKf2E1JKpofksCbvWjnA5DUWqBep8rMCmDzfNi/mzfy/N0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When reclaiming some space by splitting a large folio through shmem_unused_huge_shrink(), a large folio is split regardless of its uptodate status. Mark all the blocks as uptodate in the reclaim path so split_folio() can release the folio private struct (shmem_folio_state). Signed-off-by: Daniel Gomez --- mm/shmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/shmem.c b/mm/shmem.c index b6f9a60b179b..9fa86cb82da9 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -836,6 +836,7 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, goto move_back; } + shmem_set_range_uptodate(folio, 0, folio_size(folio)); ret = split_folio(folio); folio_unlock(folio); folio_put(folio); From patchwork Fri Feb 9 14:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551418 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 611E8C48297 for ; Fri, 9 Feb 2024 14:29:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BA1A6B0095; Fri, 9 Feb 2024 09:29:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 266636B009B; Fri, 9 Feb 2024 09:29:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC74C6B0088; Fri, 9 Feb 2024 09:29:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 66C5E6B0088 for ; Fri, 9 Feb 2024 09:29:12 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3FB5F141067 for ; Fri, 9 Feb 2024 14:29:12 +0000 (UTC) X-FDA: 81772497744.26.A99A221 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf14.hostedemail.com (Postfix) with ESMTP id 4B59D100009 for ; Fri, 9 Feb 2024 14:29:09 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=RBme5bg9; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488949; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2ukBs3XODipZcH9UMRwa+Bu+eJvhDnac4gizoogX/Is=; b=meISIpNjkVpLB/2tgKnc6uJkEgInHcwFDX12dBo3ZDiLhcCe+zONNoMxCyWjmkS6f1fGKw OECGEU66cxWrsLj2g8MmPGb5hdDGL3IK2uWZ2B8aSIuCW0H1SArKuoDu+X1FuuGnRdI9uI 9epXnx+7lEUwhg3P/5dMpNfo565gPtQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=RBme5bg9; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488949; a=rsa-sha256; cv=none; b=TOpp+Lhkv9R+pFmEPLs6Vkm8RRCXJxl0up28KUZS7R4w7eqWCuaoyUGif70dYF4TtkZxSC KHxJS9mEmDWzBYHMUg6MmmcMwvCGs6nuouX9v3HMS1T5K1yPqe/lI4sBhLlHfU3wnBooGf qMP9Xgcx10P4RpPNF5Cnv5wh42TYn1Y= Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142907euoutp0108a05b6566327b5c13de939de64974e4~yOCa8cBI72778527785euoutp01g for ; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142907euoutp0108a05b6566327b5c13de939de64974e4~yOCa8cBI72778527785euoutp01g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488947; bh=2ukBs3XODipZcH9UMRwa+Bu+eJvhDnac4gizoogX/Is=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=RBme5bg9CdOVU1oMxV4Ybb5Xo1Nj93LPn/TZtYuGuDM8JoXqabMx1IU3QdKo7ub71 br84AeHS1lrt3ijAYBC6HuMLYGxyp0VVNLhcqZ+bvQl9HOZFq7OxWRJ+FKG5t7UoD+ ozfa6KR1lEkjdqiPt4HA+LzBQOIeV3uqHiwc+BsA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240209142907eucas1p22dc004862a93d76c2817fc28c5432e48~yOCapm-8m0060200602eucas1p2G; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 9D.2E.09552.3B636C56; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eucas1p2024d2809a150c6e58082de0937596290~yOCaQYIdi0486804868eucas1p2E; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240209142906eusmtrp1ee69ff838c2b80b9dc3c11119a3a418b~yOCaPfpUX0528405284eusmtrp1C; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) X-AuditID: cbfec7f5-0bd9da8000002550-a1-65c636b3a878 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 04.B3.10702.2B636C56; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240209142906eusmtip2e2024a73a312042137f498874cbdbfe6~yOCaHDNtj0196001960eusmtip2P; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:06 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:06 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , "Daniel Gomez" Subject: [RFC PATCH 7/9] shmem: check if a block is uptodate before splice into pipe Thread-Topic: [RFC PATCH 7/9] shmem: check if a block is uptodate before splice into pipe Thread-Index: AQHaW2RVHDRO8t3PIUKSo0ZMZU2cLg== Date: Fri, 9 Feb 2024 14:29:04 +0000 Message-ID: <20240209142901.126894-8-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHKsWRmVeSWpSXmKPExsWy7djPc7qbzY6lGhzsEbeYs34Nm8Xrw58Y Lc72/WazOD1hEZPF0099LBazpzczWezZe5LF4vKuOWwW99b8Z7W4MeEpo8X5v8dZLX7/mMPm wOOxc9Zddo8Fm0o9Nq/Q8ti0qpPNY9OnSeweJ2b8ZvE4s+AIu8fnTXIem568ZQrgjOKySUnN ySxLLdK3S+DK2Nt1ibXgMW/F1u2fGRsY73N1MXJySAiYSDT3bWbtYuTiEBJYwSixdU8vlPOF UeLjpW1MEM5nRolHX84wwbSsnzCDBSKxnFHi6ckvjHBVy/a+Z4dwTjNK3AK6G6QFbPKuqeog NpuApsS+k5vAikQEnjNKtO7+COYwC9xmlpjTPosRpEpYIEyi8eVldhBbRCBaYsLHZUwQtp7E 06m/2UBsFgEViTU7ToDV8wpYSdz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Vg/YQZLFyMXh5DAUkaJaweuMEMkZCQ2frnKCmELS/y51sUGUfSR UeL/q5tQzmlGiZ4JO5kgnBWMEsc+dLOBtLAJaErsO7mJHSQhIvCUUWL670NgS5gFbjNLzGmf xQhSJSwQJtH48jI7iC0iEC1x/dsnZghbT+Lp1N9gk1gEVCTW7DgBVs8rYCVx8+tOsHohIHva 9tNgNZwC1hLzHq0HsxkFZCUerfwFVsMsIC5x68l8JognBCSW7DkP9ZyoxMvH/6Ce05E4e/0J I4RtILF16T4WCFtRouPYTTaIOXoSN6ZOgbK1JZYtfM0McY+gxMmZT1gmMErPQrJuFpKWWUha ZiFpWcDIsopRJLW0ODc9t9hIrzgxt7g0L10vOT93EyMwVW079nPLDsaVrz7qHWJk4mA8xCjB wawkwhuy5EiqEG9KYmVValF+fFFpTmrxIUZTYBhNZJYSTc4HJsu8knhDMwNTQxMzSwNTSzNj JXFez4KORCGB9MSS1OzU1ILUIpg+Jg5OqQamHrZNE+tE/n5ST+rf8t4pdfe+hpfaF18a/mAJ 6jJc6ar0y0CNY9qfh0ff+sstOslotzB9xZUnC8v93RibZiT2Piy/a9Ib6s7W52euIN84+aGC rH+dW3pxo/Zyc/NnAifeWU/o2XHtTUv8u1U3w4qUZKSeaH2+3PrCW1ws1k5h4YFynSlCG1nu zL0YLv9FRPeBx4eNS1qXp+7MexN0Tn65XkkdZ99bz+zQtGuPg+xfp/MpbHrY7LFx1rc79rNV lWL9Wbr0L9blVHez8rG/frrul67L7au7T3JE/Vvn/aC8qNrY44fPshtbanV7ei8s5YjdIu1b ZDsxXHvJjXU3CounL41h5OsTfW7yu7htIpMSS3FGoqEWc1FxIgA4VgMl3gMAAA== X-CMS-MailID: 20240209142907eucas1p2024d2809a150c6e58082de0937596290 X-Msg-Generator: CA X-RootMTR: 20240209142907eucas1p2024d2809a150c6e58082de0937596290 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142907eucas1p2024d2809a150c6e58082de0937596290 References: <20240209142901.126894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VoqqBq+AsTGIZKHYcXdoOlOcYk1A/2njljat2Yk SzWABNba hgrGSDEtD6u6V+bzF7IJjpjpzVZLAhbLlWXPhjfWdg7dPpKYH3y406n0Kwu3MH4RZhdKRVcNPNSBkflentRUx6nuYpTjdubQDpJMQV2h4fsHJYS2NbV3Lg1mAycqapWtWE+FEG1qRd2iz6ephGv85nuAhHHYM+UG9eVJr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The splice_read() path assumes folios are always uptodate. Make sure all blocks in the given range are uptodate or else, splice zeropage into the pipe. Maximize the number of blocks that can be spliced into pipe at once by increasing the 'part' to the latest uptodate block found. Signed-off-by: Daniel Gomez --- mm/shmem.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 9fa86cb82da9..2d2eeb40f19b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3196,8 +3196,30 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, if (unlikely(*ppos >= isize)) break; part = min_t(loff_t, isize - *ppos, len); + if (folio && folio_test_large(folio) && + folio_test_private(folio)) { + unsigned long from = offset_in_folio(folio, *ppos); + unsigned int bfirst = from >> inode->i_blkbits; + unsigned int blast, blast_upd; + + len = min(folio_size(folio) - from, len); + blast = (from + len - 1) >> inode->i_blkbits; + + blast_upd = sfs_get_last_block_uptodate(folio, bfirst, + blast); + if (blast_upd <= blast) { + unsigned int bsize = 1 << inode->i_blkbits; + unsigned int blks = blast_upd - bfirst + 1; + unsigned int bbytes = blks << inode->i_blkbits; + unsigned int boff = (*ppos % bsize); + + part = min_t(loff_t, bbytes - boff, len); + } + } - if (folio) { + if (folio && shmem_is_block_uptodate( + folio, offset_in_folio(folio, *ppos) >> + inode->i_blkbits)) { /* * If users can be writing to this page using arbitrary * virtual addresses, take care about potential aliasing From patchwork Fri Feb 9 14:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551419 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B023FC48297 for ; Fri, 9 Feb 2024 14:29:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FE706B0088; Fri, 9 Feb 2024 09:29:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 570D06B0099; Fri, 9 Feb 2024 09:29:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 283A66B0093; Fri, 9 Feb 2024 09:29:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E850D6B0099 for ; Fri, 9 Feb 2024 09:29:12 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C60A81405C3 for ; Fri, 9 Feb 2024 14:29:12 +0000 (UTC) X-FDA: 81772497744.22.FA19C9E Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf04.hostedemail.com (Postfix) with ESMTP id C6EA44000B for ; Fri, 9 Feb 2024 14:29:09 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=tjFYJKAe; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf04.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488950; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=a88W1Bbg0jxB2ngLMkFDtFwflxkCFGav4/gOzgelMLM=; b=QNHF/09zWsOKuEIqb6UhJIXvSWHe+hBYcIIqjvBx805/GGkio60W7lw0aaUkkNjxvK8M2X Gbuww3rFXOPVLPD5Gl8mVrcBV2jr6Cj8wl8TgX8/17gqXUFV3HgrXcBFqe1/q87PvmuEDP Irh7/+C5Owc+nshfF5c/1mlWg7QEvS0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=tjFYJKAe; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf04.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488950; a=rsa-sha256; cv=none; b=PBLEWlAmwWSPAHIqGmnNkV5Zg0CSpNoKE+QMlvZwpiNhDxE03aQe5j//Fgy4DuV//xLAS4 Q5yCDAhTnfrjlwn3OrHw/V6j0dYFa1ElTA743Ti+hfX/9KY/rrfbnCFOYlkoMcNiiLeLF9 LKGU7n2JeYva1i3pnMWQ1nN1M8ZGR/M= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142908euoutp02c0dd40786008434e64adb0841c12100b~yOCbjCirx2144221442euoutp02k for ; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142908euoutp02c0dd40786008434e64adb0841c12100b~yOCbjCirx2144221442euoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488948; bh=a88W1Bbg0jxB2ngLMkFDtFwflxkCFGav4/gOzgelMLM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=tjFYJKAebkiJIwpM50vhlXOLbPn0zREBKWRH/LD5cD5jan0ZiYFAg0HXrgf2WLmT+ 4J0RCX0UfX9sCyYkie2JirnYLxF74XihbO/qQ6de9Qxb5XZ4yxE+zw+c0hn6j4HAxs ASETTTjD5AfGyHF8E0CxWzVIEW020EKZorD5gM1E= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20240209142908eucas1p16a6b31632e8d9865f952e959c973c8e5~yOCbPMlkz0281802818eucas1p1s; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.0E.09539.3B636C56; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2~yOCatdJaJ2253522535eucas1p2p; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240209142907eusmtrp11d733555d1468f5959c30cb5a5a11e05~yOCasoSCp0528405284eusmtrp1H; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) X-AuditID: cbfec7f2-52bff70000002543-1c-65c636b3da7b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F5.B3.10702.3B636C56; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eusmtip1170d8fecd9e85f89a441b27f26df0489~yOCaisoha0140701407eusmtip1F; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:06 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:06 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , Daniel Gomez Subject: [RFC PATCH 8/9] shmem: clear uptodate blocks after PUNCH_HOLE Thread-Topic: [RFC PATCH 8/9] shmem: clear uptodate blocks after PUNCH_HOLE Thread-Index: AQHaW2RVqhumUoqlFUi8PRO0fiHHFQ== Date: Fri, 9 Feb 2024 14:29:04 +0000 Message-ID: <20240209142901.126894-9-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7qbzY6lGnhYzFm/hs3i9eFPjBZn +36zWZyesIjJ4umnPhaL2dObmSz27D3JYnF51xw2i3tr/rNa3JjwlNHi/N/jrBa/f8xhc+Dx 2DnrLrvHgk2lHptXaHlsWtXJ5rHp0yR2jxMzfrN4nFlwhN3j8yY5j01P3jIFc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rrKpyeISS57mXR iX0xRy7dUrsq0Cq02mSuejtbv6tLf++laUosxRmJhlrMRcWJABo8BnvZAwAA X-CMS-MailID: 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2 X-Msg-Generator: CA X-RootMTR: 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2 References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspam-User: X-Stat-Signature: 7nb6qw3pts49ujrbexiyhe1oh6eyt6cw X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C6EA44000B X-HE-Tag: 1707488949-991146 X-HE-Meta: U2FsdGVkX19cVA2QrvIM83HxhId3IA4F4k28autTwv5F73U+qWBUS3AQmUh13mKXVTMG0m5Mj6h7I7BE3sdwDoXhz2nGTLuzAwPjlmgsdtG2T0DzaJg7f9hJDnzdmicpCLCNmOqHQCqNAAyPKiF43JzqL1trxsKEPQz7edfPHxKbUuMdQCgAzuPHOpC1iVwfvxMaGOcqnzQFsjP+wo0/qH7dWGQ46s5TF2Zx85np4uMBsgCV2kufgazf2KK6259f00S+hFf/wT77NkcAMOV65ml1sZd8OdOVHANOf4PsQ74F3OXldl8MsKDjtPCeSub1egW9LpVcVACymZNAP3zT+so0sko3+ZgQDE3FPeaCHp3tVLoPR9t2MQ5/fh7QtbxkvIB5CF4b3x+kszNMhfA4JtueyVG4dRGRvpwvCg4Vy8hLxT/He1rFj3yt1fvWQoL1tmv/hASNPwRrnoC8uqrekaRtYeGu8suvHKzthfP/T4xCb0vDN7CT8MV+yjiXXZQX4GAIXk5eQtTlE4K/cOyxLdSBTiUJzWGB5wM2cSn8Ke1sOeNcAGBkVVNrd4sENcdmQpryNSnq/1rVFRXvlaHhOgUT/gZyvq6nSoEzhS6p2I/EC7Jdo449EKWG/uPvDtHQ/oeScR7kQ27DC/0jcmKYHQ/ErOeOtGOo4GpCrIr9sxUMGUxwMSfRkUJDGDmUfy/BdWnOdEPO81cz0wLL3Gtvl1gHfyyoF2OnuYHVhrFvMToBA+AweIi4uJYvQtv2OaY0HEz9CuH6aGUX6zBhRwSYPvEYnI5sOhpwj29PttyeuVKVlWg44OXomZ30c2s/295TXP8ui51SJq8YNJBHFfBmKcfq9TEAr6hECuxrOl8gBhT7/KCY5m+4woh/6NUYmscmTGBN9+4wFMV6hCFe1E2BINKourEQLTnH4/G4mzbg1AuTZlIVJ8QGo8zVf2aLu51dFUnOXUi6kGkp8clwavC XodVacww RDVmoljURV6V76al2+DmjMs8kQl4PWV06Pm9cV+EIY5iS8Nfymdbon6LVh5lfJAtVsi9dPGaLwCFFi+XdYfGg8HlwwKky3yGEqaiPHWtRaRz2ShnP/EotJ7VJy+DoAKCmFRQW//kDsV2kbj/BWDSyTusfwgNnJ2NlYq71/zlT87Qkj7TBe/9na2581/kXcJogMtIoAOULO44yHjv8AJW6JMmeig== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the fallocate path with PUNCH_HOLE mode flag enabled, clear the uptodate flag for those blocks covered by the punch. Skip all partial blocks as they may still contain data. Signed-off-by: Daniel Gomez --- mm/shmem.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 2d2eeb40f19b..2157a87b2e4b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -209,6 +209,28 @@ static void sfs_set_range_uptodate(struct folio *folio, spin_unlock_irqrestore(&sfs->state_lock, flags); } +static void sfs_clear_range_uptodate(struct folio *folio, + struct shmem_folio_state *sfs, size_t off, + size_t len) +{ + struct inode *inode = folio->mapping->host; + unsigned int first_blk, last_blk; + unsigned long flags; + + first_blk = DIV_ROUND_UP_ULL(off, 1 << inode->i_blkbits); + last_blk = DIV_ROUND_DOWN_ULL(off + len, 1 << inode->i_blkbits) - 1; + if (last_blk == UINT_MAX) + return; + + if (first_blk > last_blk) + return; + + spin_lock_irqsave(&sfs->state_lock, flags); + bitmap_clear(sfs->state, first_blk, last_blk - first_blk + 1); + folio_clear_uptodate(folio); + spin_unlock_irqrestore(&sfs->state_lock, flags); +} + static struct shmem_folio_state *sfs_alloc(struct inode *inode, struct folio *folio) { @@ -276,6 +298,19 @@ static void shmem_set_range_uptodate(struct folio *folio, size_t off, else folio_mark_uptodate(folio); } + +static void shmem_clear_range_uptodate(struct folio *folio, size_t off, + size_t len) +{ + struct shmem_folio_state *sfs = folio->private; + + if (sfs) + sfs_clear_range_uptodate(folio, sfs, off, len); + else + folio_clear_uptodate(folio); + +} + #ifdef CONFIG_TMPFS static unsigned long shmem_default_max_blocks(void) { @@ -1103,12 +1138,33 @@ static struct folio *shmem_get_partial_folio(struct inode *inode, pgoff_t index) return folio; } +static void shmem_clear(struct folio *folio, loff_t start, loff_t end, int mode) +{ + loff_t pos = folio_pos(folio); + unsigned int offset, length; + + if (!(mode & FALLOC_FL_PUNCH_HOLE) || !(folio_test_large(folio))) + return; + + if (pos < start) + offset = start - pos; + else + offset = 0; + length = folio_size(folio); + if (pos + length <= (u64)end) + length = length - offset; + else + length = end + 1 - pos - offset; + + shmem_clear_range_uptodate(folio, offset, length); +} + /* * Remove range of pages and swap entries from page cache, and free them. * If !unfalloc, truncate or punch hole; if unfalloc, undo failed fallocate. */ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, - bool unfalloc) + bool unfalloc, int mode) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); @@ -1166,6 +1222,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (folio) { same_folio = lend < folio_pos(folio) + folio_size(folio); folio_mark_dirty(folio); + shmem_clear(folio, lstart, lend, mode); if (!truncate_inode_partial_folio(folio, lstart, lend)) { start = folio_next_index(folio); if (same_folio) @@ -1255,9 +1312,17 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, shmem_recalc_inode(inode, 0, -nr_swaps_freed); } +static void shmem_truncate_range_mode(struct inode *inode, loff_t lstart, + loff_t lend, int mode) +{ + shmem_undo_range(inode, lstart, lend, false, mode); + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); + inode_inc_iversion(inode); +} + void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) { - shmem_undo_range(inode, lstart, lend, false); + shmem_undo_range(inode, lstart, lend, false, 0); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); inode_inc_iversion(inode); } @@ -3315,7 +3380,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, if ((u64)unmap_end > (u64)unmap_start) unmap_mapping_range(mapping, unmap_start, 1 + unmap_end - unmap_start, 0); - shmem_truncate_range(inode, offset, offset + len - 1); + shmem_truncate_range_mode(inode, offset, offset + len - 1, mode); /* No need to unmap again: hole-punching leaves COWed pages */ spin_lock(&inode->i_lock); @@ -3381,9 +3446,10 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, info->fallocend = undo_fallocend; /* Remove the !uptodate folios we added */ if (index > start) { - shmem_undo_range(inode, - (loff_t)start << PAGE_SHIFT, - ((loff_t)index << PAGE_SHIFT) - 1, true); + shmem_undo_range( + inode, (loff_t)start << PAGE_SHIFT, + ((loff_t)index << PAGE_SHIFT) - 1, true, + 0); } goto undone; } From patchwork Fri Feb 9 14:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 13551420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88554C48297 for ; Fri, 9 Feb 2024 14:29:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84FA16B0093; Fri, 9 Feb 2024 09:29:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71DD86B009A; Fri, 9 Feb 2024 09:29:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5911B6B0098; Fri, 9 Feb 2024 09:29:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1B99E6B009A for ; Fri, 9 Feb 2024 09:29:13 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E71F3804E4 for ; Fri, 9 Feb 2024 14:29:12 +0000 (UTC) X-FDA: 81772497744.20.41FC0A7 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf26.hostedemail.com (Postfix) with ESMTP id EC0AD140016 for ; Fri, 9 Feb 2024 14:29:09 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=mJJtc+wH; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf26.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707488950; a=rsa-sha256; cv=none; b=xdKhstvuRsgMJiF39FjeoPymCj26QO+kWAyLU86grZJ2Jf4zIZfc0MxNLFOOjLGDkxhJyR H90aM56okzyzAaUcvA/kdmeWPsQAGGtj7Vq1+FU1zJ4PnbgU8+Zx00klXqZbDZV36PbzvQ ZsP46OnYgqz+xR/ZtjVGoZul0G3W/M0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=mJJtc+wH; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf26.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707488950; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=in2JJaC6z0hyyXkhiWr41goVesPZul0LbQ6MoMc6gD8=; b=q1mcjfqVimkFDzok2vwaqzoCtFgsEGHQdXPHWFTplu7nVt59KKT7aA6aWqjMnzrAMzrBXu D4uIwJ5U2YD9SULs4Gp292k1V7FjM0ogoednrqnoYeXhLGL4IPpi0oUyIXxBmuE+F/vTU0 4LMl24bAbVye5UGcqrmksJg/b6TM948= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142908euoutp024e84987c5b3932b8e48ab892bc2cc741~yOCbvaunr2144921449euoutp02a for ; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142908euoutp024e84987c5b3932b8e48ab892bc2cc741~yOCbvaunr2144921449euoutp02a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488948; bh=in2JJaC6z0hyyXkhiWr41goVesPZul0LbQ6MoMc6gD8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=mJJtc+wHdVtbKLh9QIe7WtgIgcGvC/B7E1+ZDWt2UxA33cabY3UIi4T3tWqSUlyvs yEGnYQKz1wxb/PjnFfzkToMEELRWBnnxFDineTR5mPq9vNfWPgZ4lZfJh6/EYSyx/P ybgJyEjcl+8w1l9CZXdElNkQD12UfNGefzPFdUQI= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20240209142908eucas1p1973ff851315c007e944feacc1f5a865e~yOCbhG5KR0281802818eucas1p1u; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E7.0E.09539.4B636C56; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eucas1p12155b2fb002df5e0cd617fa74de757b7~yOCbH0wck0925409254eucas1p1e; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240209142907eusmtrp227ac3a1f0f02114b44aba3f8379080b8~yOCbG3YFC2110121101eusmtrp2l; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) X-AuditID: cbfec7f2-52bff70000002543-20-65c636b4eed0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 8C.6F.09146.3B636C56; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eusmtip12fe86939f9724620bf04f483aa2a19ca~yOCa96s592720027200eusmtip11; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:07 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:07 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , "Daniel Gomez" Subject: [RFC PATCH 9/9] shmem: enable per-block uptodate Thread-Topic: [RFC PATCH 9/9] shmem: enable per-block uptodate Thread-Index: AQHaW2RVXX84xcoe2UmZR8TV2QDYag== Date: Fri, 9 Feb 2024 14:29:04 +0000 Message-ID: <20240209142901.126894-10-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrAKsWRmVeSWpSXmKPExsWy7djP87pbzI6lGhxoE7SYs34Nm8Xrw58Y Lc72/WazOD1hEZPF0099LBazpzczWezZe5LF4vKuOWwW99b8Z7W4MeEpo8X5v8dZLX7/mMPm wOOxc9Zddo8Fm0o9Nq/Q8ti0qpPNY9OnSeweJ2b8ZvE4s+AIu8fnTXIem568ZQrgjOKySUnN ySxLLdK3S+DKOHP0NUvBRdaK/gs7WBoY77J0MXJySAiYSKycN5+5i5GLQ0hgBaPEhIMvGSGc L4wSU54/Z4VwPjNKNE64zQjTcmTrdRaIxHJGiVXf37HDVfU2t7NBOKcZJd7+7mGCm7x580Jm kH42AU2JfSc3gbWICDxnlGjd/RHMYRa4zSwxp30W2BZhAUuJkzMusYLYIgJ2Eu1LzzND2HoS J/s62UFsFgEViTU7ToDV8wpYS2yf0gJWwwlkz3u0ng3EZhSQlXi08hdYPbOAuMStJ/OZIL4Q lFg0ew8zhC0m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CmhL7Tm5iB0mICDxllJj++xDYEmaB28wSc9pn MYJUCQtYSpyccQlsiYiAnUT70vPMELaexMm+TnYQm0VARWLNjhNg9bwC1hLbp7SA1QgJWElM 236aDcTmBIrPe7QezGYUkJV4tPIXWC+zgLjErSfzoR4SkFiyB2K+hICoxMvH/6Ce05E4e/0J I4RtILF16T5oyChKdBy7yQYxR0/ixtQpULa2xLKFr5kh7hGUODnzCcsERulZSNbNQtIyC0nL LCQtCxhZVjGKpJYW56bnFhvqFSfmFpfmpesl5+duYgSmqm3Hfm7ewTjv1Ue9Q4xMHIyHGCU4 mJVEeEOWHEkV4k1JrKxKLcqPLyrNSS0+xGgKDKOJzFKiyfnAZJlXEm9oZmBqaGJmaWBqaWas JM7rWdCRKCSQnliSmp2aWpBaBNPHxMEp1cA0N4J99YyKawouF9Xrm7I00zad+Ov9u/C0kpTU Rb3mbuWrzvv9XLYaT30uoJZadHyV6qwL5TOPz6zR2CEsP7Xuz638jdZP3R5kb40LeVWxqC1X aaLgrSBdk9OvGxosqtcp2RRKL/rbbW3++/qLj5feuJ9JXvyw7bneLod87ksiBn1vr5gXCa+6 /0D4r7rl1bSrflJ/b+o2yE/4UB1awRXWIR8q9En6pOqFZ4vY1004euK0xw+uqFv3N0X+r5D7 wJpTd943Y/VvF64Pdz4Hytj/KLzpcbNseTSz+06pfQVTWOTSFb+t9OmO2J+zbbPJaXHDFu3Y oHx9D57/Kxd/SZDccOR4tN8a2c23F1rwf41VYinOSDTUYi4qTgQAc+RC9t4DAAA= X-CMS-MailID: 20240209142907eucas1p12155b2fb002df5e0cd617fa74de757b7 X-Msg-Generator: CA X-RootMTR: 20240209142907eucas1p12155b2fb002df5e0cd617fa74de757b7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142907eucas1p12155b2fb002df5e0cd617fa74de757b7 References: <20240209142901.126894-1-da.gomez@samsung.com> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EC0AD140016 X-Stat-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UBFNX4mfdar6U38FWxtYam+B0MYJmqrU5wfDxvhGdtyFklXog8B5Rdz13xFZIBfCtTVuuhISzt8weWfJvqEBNNzO8lnJHNZ/Vr9brkQ4Kxl+lW6xVn7KJy5lmSOh4hYq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the write_end() function, mark only the blocks that are being written as uptodate. Signed-off-by: Daniel Gomez --- mm/shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index 2157a87b2e4b..8ff2d190a9e4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2964,7 +2964,7 @@ shmem_write_end(struct file *file, struct address_space *mapping, if (pos + copied > inode->i_size) i_size_write(inode, pos + copied); - shmem_set_range_uptodate(folio, 0, folio_size(folio)); + shmem_set_range_uptodate(folio, offset_in_folio(folio, pos), len); folio_mark_dirty(folio); folio_unlock(folio); folio_put(folio);