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: 198926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp898699dyd; Fri, 9 Feb 2024 06:42:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURd+j8kDPkCgwsgs9T5sA/fpGed7/KkzWww008KJ/Op7BgPxtgt2vLTTD2J+/KQumGAM3AhRQa3jjtE/H9/3jtlujzaw== X-Google-Smtp-Source: AGHT+IEL+rKPgpwvcQ0yQIbHtGJsid5NaptbARXUTWMKs5p/qG0LfnRTTMW35miJqBtSOCS7maGB X-Received: by 2002:a05:6a20:9e48:b0:19e:9a7b:211f with SMTP id mt8-20020a056a209e4800b0019e9a7b211fmr2212353pzb.8.1707489733090; Fri, 09 Feb 2024 06:42:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489733; cv=pass; d=google.com; s=arc-20160816; b=bo9X5uDfh7bA2LpCm+7Fo8vDFFJF54caeMbFes6DSBy4yfvzq9rcl0LdU5UDBRejt3 t55MC7DYqFcimyGfS3AYxmMZra0zaTnCr0OZ61EzuhRU1gEuIWXvTE7Yst7kS/2Ozx4/ zg7QAGrks2Z90KoYBxgucnCn+l5UvPUWHwrgHJ4CkaXE/Uto4C/oGQ2T9ogkF5FFoVj4 7QNabmnzwDxwrU+yUNgmt0gYxBfQmhykBkHRLGgyMoq2iPn9oh5BjIpQwZ0D7SloSjIg iR/k5mxIlauQKqPuY0yhvAvAlgdLlN56Bozyn5+vyYr9d5O02ghLgBmkv0ajIfDDssVC VINw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=Xp/CDCIv8x19lL1UbiGyRLdd/wr0PppohAnD3gAfH/c=; fh=YRDp2Rua4z6t/nCvUIytrMVJmj35LXE4IKnlPtrs9yM=; b=Ds39Fge62IWjw1wAO+qtRoM2eU4wJqisJV1U0PZH/e7R96vS040TT2pUJMAP30ClKL CfUIa3dLkQDoq/BvJ0ZTNF/+jBefOkFAxJ5k1VVsc791VQwm32zmi7QgOs9UklUBFXZT VWPKd4eEeZku3vmPXuKuduGR87BWGTnAzD3PiL3bGs7ZsCzd3WtsUlLML72H4z0zefW9 aF9Mm55eP5YnoJRZTXVM5myn8ZYaKofxZOe6QtmiGQ9WWigeC6RHuDLhzMLaj9iz/3JJ 9/i+USKmlTLNRUARfeOX2BsNjwOVmi3TJvVXxIb510LWp0+jqx8BJTPiP5rP6oBChJmL 5h1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LzdQ56ug; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59450-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59450-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCWpv62uCa17wvKRNT54/3wGXczdkc4XEPpTl8Mhx4DXBKtMk/7FW4jyjchlY86DnZ3WiJgkYrYo4JkuzxD1TEivBYg1iw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s123-20020a637781000000b005cf268638edsi1910609pgc.177.2024.02.09.06.42.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:42:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59450-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LzdQ56ug; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59450-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59450-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 68FB2B23107 for ; Fri, 9 Feb 2024 14:30:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C19C56A017; Fri, 9 Feb 2024 14:29:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="LzdQ56ug" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56B1D69950 for ; Fri, 9 Feb 2024 14:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488948; cv=none; b=uVcuGSXxG9fTA1w6xyA2FCX++WSCd5I4MrF31XfoQZq7vjXy1m8IC1KvVGo7PKrj6c+gPIvOO+oGt3Doaupb9Pv7/N/tEPhqLFc1PS4Kia4UmL6HiIuG17diHxi+HiEEzi9w8jKouoTv6R/71SMF5hKsnVZNpvlFIUQ5y9YmJc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488948; c=relaxed/simple; bh=jJSsCzIPLDt1dUl38isaDgdPo1XoyXbEHM2UbvgYw/M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=K1rOhA6jo/oa/itVC/8gzYEPRPim5QyqjFCup54LKw+m2dQtNR+6k7UNMzvn2HgJ3dGTa8lQ7W40BOBWmGrNJRiBOvYy79E/uJS/XX5nMJEDLkYF/n2l+aW+GweqceGAhplMybsnir/ILViuLS0LIvWGSA05zwfQKs2U3Z2THFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=LzdQ56ug; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142904euoutp01044a07252a61cc6762edc66c3a0ab774~yOCX9DFcV2752227522euoutp01h for ; Fri, 9 Feb 2024 14:29:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142904euoutp01044a07252a61cc6762edc66c3a0ab774~yOCX9DFcV2752227522euoutp01h 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA02SaUwTURSFfTPT6VBtGAqRJ66AK9IKwehEjZGocRKMQYMmGBeqjHVpETpU kERFAVEkFQluhUBVEFAitioqm9pioRbDDyOCUZZaRFFBioBaBWkHE/59991z7zk3eQQqauT5 EAdi4hlljFTuhwuwCtOvJvHdZSYmSK0RUHnlZTj1xWgH1Eu1A6csWdcRqsuuxqjcyykIVV1j xqhXlXk41VY2yqNasroA1fS3nkc5fubha6bQjzXv+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aq/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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432754274179037 X-GMAIL-MSGID: 1790432754274179037 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: 198915 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp892091dyd; Fri, 9 Feb 2024 06:31:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOEu1CAwcqd98VgA9HgegM7tkLYBdvRU4jUldJk7PL9Go8t35j+6Ibo/hnC0bjZGsLgKPj X-Received: by 2002:aa7:d441:0:b0:561:2fd1:99e4 with SMTP id q1-20020aa7d441000000b005612fd199e4mr1531059edr.26.1707489111479; Fri, 09 Feb 2024 06:31:51 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWF+a4pOYNl+stB9dXs4Eizv79ePBki0Jb/PWX/nXGgjfaXhtUNnEg+HfP/19RBFZ7CvPAnFznS3sI8T/zauyACFSNm7A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c6-20020a50f606000000b0055d399cff3fsi904826edn.578.2024.02.09.06.31.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:31:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@samsung.com header.s=mail20170921 header.b=Pb7wORK5; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-59454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59454-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B7CD51F21FC9 for ; Fri, 9 Feb 2024 14:31:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 221F973168; Fri, 9 Feb 2024 14:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Pb7wORK5" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6900D374D2 for ; Fri, 9 Feb 2024 14:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488950; cv=none; b=qTqGiSR1NAScuzYPFAano+m/zOK7k2PZi8h079rskevh2HRJxHLLWwfCATGybg24jJCE24cWiaRlrTYwtEqljA6D/CG3ItHr8TnZPPm25NlK27GULAvBzO0Nr0wkffSrBxmATmXVjnvafNooHkmfSKiUqiIP5IaralZeoEzJqjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488950; c=relaxed/simple; bh=7bf71wmf0z3MtWLhHI9EN/ydOJJr2oHi6LZjYAv3la0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=TWwXyk/Vp/NLTsW3fzSleKDBlflmFG6Mi/6EqD99UiLv9sbZZtnCM4QpXaz/hGgiJtETGIaBRuN0AJDoNW88OHS9X5BBFUKumEU9vWGdmB/8Iq3SqHEakH8Gv0Jw8laNXq/+TfRW+3hMo9cF0zQ6tY1pcdtAuCZ2yopz+yHESS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Pb7wORK5; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142905euoutp01f9b310c9b8ffcc1de98b2c636da81042~yOCYwXbuA2868428684euoutp01P for ; Fri, 9 Feb 2024 14:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142905euoutp01f9b310c9b8ffcc1de98b2c636da81042~yOCYwXbuA2868428684euoutp01P 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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/cz7TBEb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Nt+mg3E5hSwlpj3aD2YzSggK/Fo5S+wXmYBcYlbT+YzQTwhILFkz3lmCFtU4uXjf1DP 6Uicvf6EEcI2kNi6dB8LhK0o0XHsJhvEHD2JG1OnQNnaEssWvoa6R1Di5MwnLBMYpWchWTcL ScssJC2zkLQsYGRZxSiSWlqcm55bbKhXnJhbXJqXrpecn7uJEZimth37uXkH47xXH/UOMTJx MB5ilOBgVhLhDVlyJFWINyWxsiq1KD++qDQntfgQoykwjCYyS4km5wMTZV5JvKGZgamhiZml gamlmbGSOK9nQUeikEB6YklqdmpqQWoRTB8TB6dUA9PO7ucnjn7xaNVfPk3bZgd/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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432102534649854 X-GMAIL-MSGID: 1790432102534649854 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: 198913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp891678dyd; Fri, 9 Feb 2024 06:31:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3AlzJ5WH34m04YmoA1QNPVgh0p0qJZyPgfrmVu0SEX3Pa4bxwzxLeE+3H9yG/u7m8GTWiVPL4YHuEBr5MCzB5ad56cA== X-Google-Smtp-Source: AGHT+IEt6F6BNcJ4HO3mj7t1lBed9ejTJsCcWynp85IMuIxwcz5RaInXC87+qfaK11Zqt9LxAcjS X-Received: by 2002:a05:6358:6f1a:b0:176:4135:fa3b with SMTP id r26-20020a0563586f1a00b001764135fa3bmr1478514rwn.31.1707489079623; Fri, 09 Feb 2024 06:31:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489079; cv=pass; d=google.com; s=arc-20160816; b=CP4SFJIE5FnBLLROGYq8bfRpE4nqbfQeZ3/i/f/nBFm0GXTcmOQd8B1ucChcv8jg7d biEb4UGG5j/QfU7rAC5leNEFjLzvx4Xd4dnWFzgWtF/zcJXplnsilcXxURHpO0igeNX6 EvBcVkR9TtIASB48EOCHk5VAHPela5DGTv2AZyHd0mrwslx3ckkVN1E0Gf3nQGvIo0hd 7zL16e1JIimMIX7VaOBE+doJ4qjN+KK4GmlrGCTNfkg8HRVNEqL+mbwG8s2PsVeIPUjY YYlxPJKIIDHErC6s8hL6N4ThWPUTmpD5nNupA3H+MU5lhf0rWDQTr2C6dECfuqPpz/95 qmbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=5EX9mww1Yf0rOpRLklIYKmjmJtYHS5jxFy+jU2z9Pew=; fh=LvyP7ys0AUVy6lZOQUIPKKHPfLmvYS3cHucwJcftXsY=; b=aOCftoVP1QMRKwvkykS/vZlopUp6+yEFgmwuFZx8srhliZryblNcRQMgTvkeUwIAOV vvq7LYPye7liqBOmACaFeGMHfZjbJpKYTEp9aCv2r8ZQF3VgjUPCs+FrGiQdrdg2Yqo9 BVUzkZHC/FNAEnlR6S7TzAi35Xl+CXWHoC18KTFMufkVkYfwob8eqQyAnW5o9Xm+iUWp DHoWzDMPQtm9TfirvEdrQTbDoFINuvQQhZtPMrQ4TbpZcqOkzSkocAtv47uiVNKjpNIA qxlrCJ/jkRRwmuVFA3HdDH1WwLYf122GtZr5O81ehMc0gLQcSw/oMfsZaWejMoD5t/gF KzKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iNLm28Q5; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59452-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59452-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCX6T2OhH1hEPlucPS0vCkJOhsnVnajU7LWM23tv1ZBGt4dHHc5yq5YfVq+o0xpv0Fiai9X5OM8PjCQ1xogYEOWbd1CjOA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a12-20020a0562140c2c00b0068c8519a28esi2067806qvd.398.2024.02.09.06.31.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:31:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59452-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=iNLm28Q5; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59452-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59452-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3EC171C229B7 for ; Fri, 9 Feb 2024 14:31:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 497376D1D4; Fri, 9 Feb 2024 14:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="iNLm28Q5" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D852569960 for ; Fri, 9 Feb 2024 14:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488949; cv=none; b=ePVMZbDUm84eto0QBG9xp1m/81XpWENyO28jibgQDXZP0Do7h3YYwCgC4lOkG1o6j0wjZZfGAG2l4tYcSIix5H4nHtSE7YcmdBecMQqb/Px5oi1CeBbF/WXlf4AduHTT7a9FdP3hP50QWDkp5zuv01+WwH4AyMHoXY68OdnDSgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488949; c=relaxed/simple; bh=upFi55BRB2EZorGwFdgX6LBZWv46QR8JKnPuxrtnafY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=IrzPDep6G4Gy/ijiVODQ36SjwmSpH/3SEAovR3mgCwrn8qii5C7D0+mBgVmrKVeY7bf6hipd8LQgy9NWiztjESAPx+YvEJBPPDX0aUMuEL2sGbSI9vDOAMUaYLi9/YmFgEnG9lyvgyvDcK5JGkWBWPhcEhu0P2rP6hitpNReRNk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=iNLm28Q5; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142906euoutp016f3adbfaf2da6399a5800c0bf40af16d~yOCZW2xLw2752227522euoutp01i for ; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142906euoutp016f3adbfaf2da6399a5800c0bf40af16d~yOCZW2xLw2752227522euoutp01i 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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+xCjNwaIkzquaIp8qJJCeWJKanZp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oVJ+YWl+al6yXn525iBCaqbcd+bt7BOO/VR71DjEwcjIcYJTiYlUR4 Q5YcSRXiTUmsrEotyo8vKs1JLT7EaAoMo4nMUqLJ+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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432069268553750 X-GMAIL-MSGID: 1790432069268553750 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: 198916 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp893499dyd; Fri, 9 Feb 2024 06:33:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRqur6ejEqpR6Gz+cEoV5asIsI4x1PGmc9iGAxAJIyJklUjHjh97okIEL8f+Qpy0yZvkVf X-Received: by 2002:aa7:8c4e:0:b0:6e0:9da7:8cfd with SMTP id e14-20020aa78c4e000000b006e09da78cfdmr439403pfd.5.1707489220531; Fri, 09 Feb 2024 06:33:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489220; cv=pass; d=google.com; s=arc-20160816; b=rfT3hQLJ1ytwRtIjVivYJ0jYznK9xzj7rKtLK4PjDIoWbOdPP4QxxE9Xw7+PltLcl8 9gO4o7Zqq7hutzjq8YQJYhUBpIk+IKOyr8WHOtTUNfm/mpbfNj1d22BLIadzVtJVslsh F5YNPTWF3oOsWPHq26p7ecgDZitGTnVPpkLEpYsWz86W3266eoXcZXINNutU1p0u+OxB t3vFONvl8xzhduJZ2gadK4zbJAWBZ9j7HJcft0hkfr3m7+4nFIjaFqe/pQBdz03+fcGG GarYzvli8tAqCXr2Yn1CP8Ztc9uMK2PLIn71TbTHKwIHiKm1la0hp+p8v9SIRP9Th4RZ BIaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=yzLVEVoC51q0kiEHcn5lFzpeprpnxNh9RSZm3CgLznw=; fh=bQVlJT9KITpqyd8NkmDnmGSqe9fEW3hkORtDX+BozwU=; b=yKOxZhchLAbDLklAJsc0cVCV2tdf4zbnYUMFPUOmvbYivgL4eYIGzA2ckExBLUw8A9 KRJwGurToL0AR5g6BZYPXumuZxaWQIH4Nww8m9/MXiNR3oaIsOgj+4Te3DYGkMT8W9Nh YlUfNYl6oQTGMD98aSsdROl+VPnDbu1rYcvw+4Wecdbs25Tj3ZoNCyWLdnKRCbzOY8WY lWvtla9JZLD1x86CFrMqboHwX+bZDxak7X+7VVxUosXmXWmb5jIjNK/vv/Rf6AhUjSOx PaXjCOlv6FQhZwD8aFsUHYATZFYj/15RotgEyWMcjeAoivVF745Dsn1+mfQw8nyyA0Wg Mg1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YapIIPGe; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59453-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59453-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCX3g6rqPai+FQEg4aJVXKvwMV8ojf40cBOXma5+/9aJWdmhdBHP02GZdkZ+/sYvjUEnMbeZ2cI/Xo/5tW3VXM0QYqvy9g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fh5-20020a056a00390500b006dfe269c8b3si398962pfb.151.2024.02.09.06.33.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:33:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59453-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=YapIIPGe; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59453-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59453-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0BEA8289D88 for ; Fri, 9 Feb 2024 14:31:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1170D6BFD6; Fri, 9 Feb 2024 14:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="YapIIPGe" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1884169962 for ; Fri, 9 Feb 2024 14:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488949; cv=none; b=iGXE52079O2y0YbYS0IaBhEW9Jab+uJUuNYYkrCV1dNvkKJ6NMqLzuOk6osORUnBWvUCWxfKR4uCoBPkmKtkQSCnaqBdqhXJQtKlDAzGhC+CCX4V7EmmA2cY0YnxuTOb//iulLZwEnpjNlaSsNO0S9fZ+zwfWImTWh42EMYjMK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488949; c=relaxed/simple; bh=0O3RfgYbkdJ1kGWT2lEPHUEzW3Hv7N5M06u8M3HTzN0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=sow1HMQAW+7SkcuCNwlA552UnBXIdZoOPot7wQDAdRm9fLKF/pHHHvj3nGl9WCXcgSg1umvI0npGQEVOA7GJsorYBy/JCQuj3bqxaLNHMdUjClraPZ//KEayUdTHyxz4fgBU/5WwLXaM1E0cPslddCMUPhXxedXcKr7agG3mwpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=YapIIPGe; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142906euoutp028948e1c930ef39c538739c1bd0b44e1e~yOCZvgqR32144221442euoutp02d for ; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142906euoutp028948e1c930ef39c538739c1bd0b44e1e~yOCZvgqR32144221442euoutp02d 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGvQcZbSYs34Nm8Xrw58Y Lc72/WazOD1hEZPF0099LBazpzczWezZe5LF4vKuOWwW99b8Z7W4MeEpo8X5v8dZLX7/mMPm wOOxc9Zddo8Fm0o9Nq/Q8ti0qpPNY9OnSeweJ2b8ZvE4s+AIu8fnTXIem568ZQrgjOKySUnN ySxLLdK3S+DK6Nl9ga1gG1fF0kVr2RsY93J0MXJySAiYSPzoP8XUxcjFISSwglHi0K9djBDO F0aJJe0P2SCcz4wSOy/NYe5i5ABrmX9BBSK+nFFi4dQ3zHBFm9bPguo4zShxec5PdrjBRxf+ ZQfZyCagKbHv5CawhIjAc0aJ1t0fwRxmgZvMEteunmcDqRIWCJT4OO8xE4gtIhAmsXrCMXYI W0/i/ru9LCA2i4CKxLwpK1lAjuIVsJJoa6wACXMKWEvMe7QebAyjgKzEo5W/wFqZBcQlbj2Z zwTxtqDEotl7mCFsMYl/ux6yQdg6EmevP2GEsA0kti7dxwJhK0p0HLvJBjFHT+LG1ClQtrbE soWvwebwAs08OfMJC8gvEgJdXBIreuawQjS7SDTMeQ81VFji1fEt7BC2jMTpyT0sExi1ZyG5 bxaSHbOQ7JiFZMcCRpZV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t/sUOsEpe49WQ+1DcCEkv2nGeGsEUlXj7+B/WZjsTZ608Y IWwDia1L97FA2IoSHcduskHM0ZO4MXUKlK0tsWzha7A5vAKCEidnPmGZwCg9C8m6WUhaZiFp mYWkZQEjyypGkdTS4tz03GIjveLE3OLSvHS95PzcTYzAFLXt2M8tOxhXvvqod4iRiYPxEKME B7OSCG/IkiOpQrwpiZVVqUX58UWlOanFhxhNgUE0kVlKNDkfmCTzSuINzQxMDU3MLA1MLc2M lcR5PQs6EoUE0hNLUrNTUwtSi2D6mDg4pRqYJvBIXfz2wOyYmnndl92bzx85trB8vd6cPV2H k98umZs256ByTdDzA2rF0qlvp3rtd6y5fKhp8d6csuUtIg7z1nKYbbxxauVyq1UGpzgvhZ07 frcw/9phERGNNuF1O7Yys606IDyjfHFzZr3rP7HrLOd3iS+av+OwR/GssGu6Oo5ymSf7T9nf C3vJxeqskzsnd997x9svn2VYlMwsuXxHJ5bPfcKZKe9/FF9x1E4tsF5pr/Sbe0JE6vzPt85v tZdgMavf8c7sfXL4+bYpAndVd3zjP7ct3PaKo8i1wlqRb1N954Xwbryoe/nNHsfTBmGGc2f/ f8m/Ze2Snca6gs5zr9dWJHmf+5wssHa59yTmzplKLMUZiYZazEXFiQDLC80l2gMAAA== X-CMS-MailID: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b X-Msg-Generator: CA X-RootMTR: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142905eucas1p150b096fab4b8a684b416d3beb0df901b References: <20240209142901.126894-1-da.gomez@samsung.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432216943928832 X-GMAIL-MSGID: 1790432216943928832 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: 198928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp899891dyd; Fri, 9 Feb 2024 06:44:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXnqvqz6WF2xHDX1OmCv1TTFqL9d5loh+cdyGKAYOS99BVCn40c3U3CXhlH/XGdL8ds7VlbuTHVEcg9Dtz4nusOjNAYAA== X-Google-Smtp-Source: AGHT+IFGnzAnNCgcvIfJWUC+pUJEqdMAeNxej8Z87tNgSsgT1snpeRxtexqhw66EHQJ6mQjCAvO7 X-Received: by 2002:a92:d4cf:0:b0:363:b33e:c8f2 with SMTP id o15-20020a92d4cf000000b00363b33ec8f2mr2148402ilm.11.1707489852876; Fri, 09 Feb 2024 06:44:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489852; cv=pass; d=google.com; s=arc-20160816; b=pj7HH7dzROjo3XLlpXFu514dEeGg9CAccfnxdpIcxMa1zb4yD9AMxSqlmyf0fFOs56 7iXsvam85gakWKTZ9xoD0bRv5pgW1m54BAjj7m1R9q2u0mMNWhFNQ5cKlexh4LD1h9tu SpC1L3BQpDkCWIbTi7juIa6w8Yxh9LTsaP64OtnKKon9aPYDn0kw+NhU9wU7fa072cNt Mbh3gBQ91f6FQJniMLFNM5Y0UqBDTIUebGot0vm5mC2shLg/8ANlhQYMi9gCETK+mtHg mF4tmiaGPbdUN2f7ZnPEkLFkIFm3i7adgkA/u5gz3D7yAwroKcIJBmwLYH//w/fACG7h IKmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=FCbzId5tUUljaKo+tPW5dyPNAxWuqwZJmK4aFsnXX4M=; fh=Ea4LWx0zk3O3tXZ1GtPxhyYPa8NaV43PTFb5SXdGTJE=; b=Oa3EUFXG8W9YC/bqlQqGxJoUUIfHcWRKhSeui+nzQC4HGTI8cIleG9ar9aKUSsGJO+ J0+cUIIoStw2bFQgdwr4U0cvqICrm9s1pXqAYjmGY5ckBE9CZSre3L34a8gRXc9tcxea Ch1mcdhkzLiYgXDyo5ndioDTckgLiKRj9LELcFBGMNby8xtUK9LPokAfuguhzEUGdTIS sd+3vUORyrbAnNRzGnXrsi7Llf66DGyni1CsqYVLX0Jy1toH/evpaesHt3bbbNKrjGOI Kfgbt4FHxT2xpeeXSw03JTU1EifXqvt95P8KLYNgh3NTwrOHw/GFun7fCg1WUpOS6JZ/ kRPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=h1JyNx4K; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59455-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCVEqOmMpvROoEnL+HX65WlmdeIOtzvton5traGAT8Dj9ejj9GD2sxylvzC01l5jI94ajEfmog14yDx2YCyPZKAJeGcGXA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k64-20020a632443000000b005d8fdaafe5bsi1767231pgk.550.2024.02.09.06.44.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=h1JyNx4K; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59455-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4F092B27045 for ; Fri, 9 Feb 2024 14:32:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5915174E28; Fri, 9 Feb 2024 14:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="h1JyNx4K" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DA3A69D26 for ; Fri, 9 Feb 2024 14:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488952; cv=none; b=EsO0T6AzCCAus2f8WnO9Us/4za87ItGPi15+hi8dqicNVYwy6sU/5wx34DhYV6uMEEohPnEORFYIJQ5+nKhChtkwQpRecn3HLhNoSDN3CH90721r7p9XF451OESHEWdWI9GXq2BWaf0RSCeKeoD6Khh/DPF3l2UpHAqZ3cOcbWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488952; c=relaxed/simple; bh=CPKJ6tUdoDF6Ha2IQ+4O/WOu+/5VM901pX9Tu0quqfk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=ZGHspLpMxrSlFReQa+ygpkn+AGufDeUf1TPHnWXCPJkgEZmQ1FAxuA7JnUAFprVR3sh9HC9Y/D3BPQ+3hmgOuZwVgN5snhoyQjJqdsHzR8iDPZ73DoaWJoNNq/8feH8a7JMmznroTGij8heb8YRjlsEU9OOWlVHVrzDvp5WXx3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=h1JyNx4K; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142906euoutp017389e53649f75be9c6da7e5fe213ad9e~yOCZ_oe3d2559825598euoutp01S for ; Fri, 9 Feb 2024 14:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142906euoutp017389e53649f75be9c6da7e5fe213ad9e~yOCZ_oe3d2559825598euoutp01S 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGnz7JWYxZ/0aNovXhz8x Wpzt+81mcXrCIiaLp5/6WCxmT29mstiz9ySLxeVdc9gs7q35z2pxY8JTRovzf4+zWvz+MYfN gcdj56y77B4LNpV6bF6h5bFpVSebx6ZPk9g9Tsz4zeJxZsERdo/Pm+Q8Nj15yxTAGcVlk5Ka k1mWWqRvl8CVsfnoYcaCrWwVn2evZ2tgXMDaxcjJISFgInGt5S9TFyMXh5DACkaJH59XM0M4 XxglXnyZwwLhfGaUuL1yLTNMy7fPr6FaljNKXPr8iQ0kAVY14TovROI0o8TNg9dZ4QafW9fI CFLFJqApse/kJnaQhIjAc0aJ1t0fwRxmgdvMEnPaZ4FVCQt4SizqegN2o4hAgMTTM3uYIWw9 iR3L/oHVsAioSMybspIFxOYVsJJY9fI3E4jNKWAtMe/RerCbGAVkJR6t/MUOYjMLiEvcejKf CeIJQYlFs/dAPSQm8W/XQzYIW0fi7PUnjBC2gcTWpftYIGxFiY5jN9kg5uhJ3Jg6BcrWlli2 8DUzxA2CEidnPgGHmIRAG5fEm2nboRa4SHw7vARqsbDEq+Nb2CFsGYn/O+czTWDUnoXkvllI dsxCsmMWkh0LGFlWMYqnlhbnpqcWG+WllusVJ+YWl+al6yXn525iBKa50/+Of9nBuPzVR71D jEwcjIcYJTiYlUR4Q5YcSRXiTUmsrEotyo8vKs1JLT7EKM3BoiTOq5oinyokkJ5YkpqdmlqQ WgSTZeLglGpg2t5TWf4iSZh9092XzwPKirbc858nMGv3Bq84hrhUHXueczUiH/8KhifxflTZ 8XHP1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CFLjqQK8aYkVlalFuXHF5XmpBYfYjQFhtFEZinR5HxgsswriTc0MzA1NDGzNDC1NDNW Euf1LOhIFBJITyxJzU5NLUgtgulj4uCUamDqlV++q2Ov5rY+4XmZ6z8EnFx4pn3Gs+PLT91Z wZ7cMFFqgQ63sErWhyMsi/bPWiHE5su7aZ93p6fto1IbgaoPh6rOSC4TuT7Bjr3v7hKToyqv fvzmnXvU5oZg9/alcesN96txxYeEq+//4W8X81v15vdLX39EdQoXXjZavcs64DGTYa7njvI/ frq9vB8OR98yWiBWKpc5m/froW83QzusZu3/JDUreqv51QSF7+Xi84Pljm2493lqyJKbbPPa lhf66uzaySRnd1Rrl8SFnRofzpZ/qHAJrYroF3igEDzJpNvzQJvnRPcJroVOj9b2cFf8320z 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432879630540907 X-GMAIL-MSGID: 1790432879630540907 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: 198929 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp900119dyd; Fri, 9 Feb 2024 06:44:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoxUDf38q4H737FXqin8xUHYRvY1hchkQvAH6sv/jLKCWk2c5Ye0uXMJXeMXMTYzyk4oBz X-Received: by 2002:a17:902:d548:b0:1d9:bd7d:3c79 with SMTP id z8-20020a170902d54800b001d9bd7d3c79mr1919559plf.26.1707489875173; Fri, 09 Feb 2024 06:44:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489875; cv=pass; d=google.com; s=arc-20160816; b=bQp4QPyNqNW/P5i3UVlX5Ru/+/p3gcAXIMhWjCA3qx9b5ls7b1JF63/cl2AaCSC+S4 fh1K8RQJRSzXkf/lFNkJ7bQphlF7WGdbFgvqDCGmkc3QBk6Mg9PnRqSQ+aE81w4+igNu i2fk8mX6ExqR2ZDTH8WNXhnOgHTn+0DLCT8s5v1yPnUHo8+iSTuIrf8e6oFOe8ocTqj5 XzKSdhwF8mo0j2DmuAAhwWcCUJrIUPoQv6P+xT6P86q/Cz1OkMu2r97rvKRxoENWTWEA fVu3QmaZQMuQubSwFHPnM9z7imt8vJXBL5kPl8RvHudZpf3bYjppPj3s/3kzONVXKYbB WVVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=oOOPXQ1C4QLRnGizBlTW9/7mF80l1aSAxMsYloK3g+M=; fh=JWN7B8Kx+Gc+P6JSpND1RZEsyk6oX/mlrwCOzpo9vi8=; b=m3bJT05K3nIMF5jK9YBWiCveu6VEGI12SNDtCgFktEohQnF+smhExIZLrgwuAiAuTa ZAy8pgIOGIzuk4vWHn2lINK7dpTBT9w2Il25jfqJR4SoYulYXJwUHg1tC/jr0A+DKlAO Ag0YRpLKv6Hc9A5CpeAwSXvVte1n/z2/1eosqHkZzBqjHqmRfQSXKJc/qgQwvyB/dyHy YGksqLq9jF/GS54CBgy5mxRXn3WH30HAxF/PIasbJHSmUFm8p/yrfmeF7nV6xN9hm400 ONelNjV0w4B/33BJKoZr+gddyvywIr3+ZVfe6s0uT15vJ5V1bOm3n5KiriqEjTRYaz7d Jacg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=VXwvMZgq; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCWIczT44rSikaPmfeWjDrUZWOIXKqtmc7wH8ivrdCAPlsgCxYgZgil1HxiKsEqvfla4I0zurEU90b6wy8FbCDxVXC7E0g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id mc6-20020a1709032b0600b001d8e4de7a1dsi1725725plb.581.2024.02.09.06.44.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:44:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=VXwvMZgq; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 78FA6B27329 for ; Fri, 9 Feb 2024 14:32:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ACB376046; Fri, 9 Feb 2024 14:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="VXwvMZgq" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C5C69D33 for ; Fri, 9 Feb 2024 14:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488953; cv=none; b=a2yDQ6TLQofbV4LnR/vjIkF9iDrBDXj1+cIVt0JmsSlCT3wrOhicxAej4SQ1+hisChv50U6Zf9DA1R49SvHHQwUMwhRunXUnptrFqiAe2L6CwLLNrV2RHFxJ3P7dK/Y7MhJ5NW2nTDvmzriDvRQ/5aLtSk/t8PTucWoiI6CMgzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488953; c=relaxed/simple; bh=DCzY/JGjb8mhsUf+XcmDhjOxoBtl8L/RsfsIsrJ7IU0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=rMXGUgLzFkxsr3flvvBKHGJI0XrTGhlhm7W0FIj5tFO5MuBtvWcP1CvjXqjUHVjyEsjXY2+OYJe/pmpMZWsGrvgC/AMZnPR8malk9pNkh9zbarXOx3hbHQEV1GGd0Yxf3hPJLGf0bXDFY4eJLq7DbuC0zpg9tTxdY7GL99L6l1E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=VXwvMZgq; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142907euoutp0177e3c18c562f6293cf5c045bce70a3e5~yOCamzUoV2559825598euoutp01U for ; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142907euoutp0177e3c18c562f6293cf5c045bce70a3e5~yOCamzUoV2559825598euoutp01U 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHKsWRmVeSWpSXmKPExsWy7djP87qbzI6lGixYZ2kxZ/0aNovXhz8x Wpzt+81mcXrCIiaLp5/6WCxmT29mstiz9ySLxeVdc9gs7q35z2pxY8JTRovzf4+zWvz+MYfN gcdj56y77B4LNpV6bF6h5bFpVSebx6ZPk9g9Tsz4zeJxZsERdo/Pm+Q8Nj15yxTAGcVlk5Ka k1mWWqRvl8CV8WDpN5aCGWwVu7vvMzUw9rN2MXJySAiYSEy68Zu9i5GLQ0hgBaNE2/RfzBDO F0aJ9o2vWCCcz4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ae2f3a1 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432903331230538 X-GMAIL-MSGID: 1790432903331230538 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: 198930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp900157dyd; Fri, 9 Feb 2024 06:44:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBOKLskSsrU/6crCEkXViCJoCTV64iyPaPOwAOUWWkV/S1BTLazDsw1QLORINQ+v/v48Vu X-Received: by 2002:a17:903:40cc:b0:1d9:196:4dae with SMTP id t12-20020a17090340cc00b001d901964daemr2263379pld.8.1707489878183; Fri, 09 Feb 2024 06:44:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489878; cv=pass; d=google.com; s=arc-20160816; b=YamXQ/G/HQTU9fIi+k325ALeapJg6b/an6ij/ZfBNvjTFkoT+dWXPMxv3D2yw+MfFH uNvE3ReTtUF5EZ5Djir5ebXVb5eTmQkif8p+jXUF5/eJVXteczL/ycKG6zm1iOOmPEks Uf0F5utYl4PN1gzEFNUUTezcIS5zoJGo09XOmgZFv5XsQkGR4ejtbx8uTltKsHs1kqdE M6MZUnAmsSW7pmp0VEuA5DyFQ8PbSecNWxQDrdGSjdEZsC38flwlJjMaF9w584BAdKxE boB9zAkI1Tbo/7Fp5IIs1DB35dRIOvamg4HysXRrEAfe6R+vWvDFTH+uBNLk2oaAs/rv +irw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=2ukBs3XODipZcH9UMRwa+Bu+eJvhDnac4gizoogX/Is=; fh=CPcpDWwGETcqC/iBrf8yeIgxT9c71+o8zXVoF1VeID4=; b=B2dhY3hn1gAL09B+FLnAIJwsFuSIHY1OkoYnVNtobdqucgwhOxf43agV7asa4Bx9Jz S3Wu5bpBxvd5SCsPxT4pGAWM+lytBFTlJr3LQMcsQZtEcXI9klHz4ikwg+J+Kb3nMU7L dhPD8d7utqLMV0OnRppW9hqNLYbexwNB/sSMzc+1QipUufRTA0mUGZINLNZwhug0aQSB EfY7OZ3gL2MFBU1l7wOV+2fE7DgjQuNexgyy80A61BUKxOLtjdS1raR4PLh06BkyhOFB jJuslyy63oTRA/LgVeM65/CED9PpGxmfnLHGEgjoX1K3c3LeAWXTEXx0/iQ02wR1q50R VAPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=RBme5bg9; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCX34phk5TWHC4g6T0ywoBKPTn9wcFP3jb772qmZOQ7FX6qOr1jb4I0OYWR5gIc70M0mSrWgH+kxCmE0SZinaZZmnMydDQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ma13-20020a170903094d00b001d8da1c6933si1823574plb.58.2024.02.09.06.44.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:44:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=RBme5bg9; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B6D89B271BE for ; Fri, 9 Feb 2024 14:32:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0B0B7604D; Fri, 9 Feb 2024 14:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="RBme5bg9" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905AE69D3C for ; Fri, 9 Feb 2024 14:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488952; cv=none; b=Q6eNJ2Cj4ek5Xji0bcU/SUlsIXhJ0h/3MkahE8YbYL5D9+jveuHnsTmYaglAeLkQ3H+05KIoIA/0hDbsgHG9y+GRX1KDWLy8YyAdlbuZmVmKaxGH0Mf6R6H5192kPIaVgCHLl6PECTk8lQWy3rsBIqUwarCkpegdPPI7c2D/1v8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488952; c=relaxed/simple; bh=oTRfFe+/EH7DLR5K66X2qKeSonuT+RMKMk6eYxbGvf4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=cLKVBUVXQsNYOHRm/Ju3wMsRXIhhThWb0RqiV7d5ScgmIThczkchC45CyBO9GSKnLS1IeMrettVwLhUWCjO0Gbf8b3Wxn+FNG9TJrzJK8pk90mA9VIm9l5gDXTU/HSC7wC9trLp3NMv4ViIeavMa3XfpsESQJZRzdKPI40NlTjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=RBme5bg9; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142907euoutp02a2b6a259c6689919044722ce24c21d11~yOCa8sUYT2144221442euoutp02j for ; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142907euoutp02a2b6a259c6689919044722ce24c21d11~yOCa8sUYT2144221442euoutp02j 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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/2UBsFgEViTU7ToDV8wpYSdz8uhOsnlPAWmLeo/VgNYwCshKPVv4CizMLiEvcejIf6glB iUWz9zBD2GIS/3Y9ZIOwdSTOXn/CCGEbSGxduo8FwlaU6Dh2kw1ijp7EjalToGxtiWULXzND 3CAocXLmE3DASAi0cUn8WXoRaBAHkOMi8eEPH8QcYYlXx7ewQ9gyEqcn97BMYNSeheS8WUhW zEKyYhaSFQsYWVYxiqeWFuempxYb56WW6xUn5haX5qXrJefnbmIEJrnT/45/3cG44tVHvUOM TByMhxglOJiVRHhDlhxJFeJNSaysSi3Kjy8qzUktPsQozcGiJM6rmiKfKiSQnliSmp2aWpBa BJNl4uCUamDKYLG9pbXYZZHxnJr3PgpWXVsVTfffPWH6oailKUAkdN6zxGBey78dFW49TjfO 6i5cEnZY+NmKWaHSkwN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y5EiqEG9KYmVValF+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-1-da.gomez@samsung.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432906366716160 X-GMAIL-MSGID: 1790432906366716160 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: 198931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp900260dyd; Fri, 9 Feb 2024 06:44:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXd0ytFH3bTSssk+5ITi5ltlfYV+sj3TR3ETCPe9jUw6XuVIZHXLaKW4VYu0iINZ8T29wfAB46XlfgLX0NadlkouRunag== X-Google-Smtp-Source: AGHT+IEaRSRd6tTk8dQiiWMf146aD0HEsTRTkwb2WFKBhfeWM814Yd0SBt6Alf7nrEY+5LUzXmKl X-Received: by 2002:a05:6e02:ee9:b0:363:d8dc:2a31 with SMTP id j9-20020a056e020ee900b00363d8dc2a31mr1986006ilk.14.1707489887813; Fri, 09 Feb 2024 06:44:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489887; cv=pass; d=google.com; s=arc-20160816; b=wipCNej4cf7V8a2ykTJ24ctLnrQqVngIlT7zik2fT6jpEgwLCy9WxZGuhwJeG0H4c1 T2zgi9jsVmgCSwZur1sJUFT3HGoJuIMgEyV/AH31q1xmw6q9rhNYjrZP4Unt/yAOITlx mab6lTVr6Zx6HX5wQsUpsEKj9J1ElRQikYgmNA06RqEpslx58zP+S4H9GgeazsEA8nc3 md/74vefeVow69MmxMZ4kATARCX38/AYdUA1W9JbnONEpAgJSpXXeopeo4RRU+jtA4/n 2OSuaZeRlOcIhryfnsQFz+n5eHcTh2xA8mJxaR9bjUiLjBDA3338kIAiQy0i8oR+YlY2 lJ+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=a88W1Bbg0jxB2ngLMkFDtFwflxkCFGav4/gOzgelMLM=; fh=YlqtYRcpf0j5NKNqzScupTwQ089wdLR6XPfkrPKdbvI=; b=G/FLieQ8bq7fGcWZE72ZK45oJwo+IPo0hF4DCOceM7vfmJhkl/L7aEuxmaqGcn3AU7 RTwWHI4b/jbcWjXMt0y6zrtGip34t5oUvlgoCHNTgXBUWP6fUuec9xzF/Ulzxm81LdUM x9xzwhDQmjTqmreOArfp68ljVs8gyLLsgV+T/JZdCwQv8PQxTDBhJIow+qLqnndrdsMF dSrdkkAKu/I+42oW8h3zwhQ+LITf5yXlTXCdsK3+XNAhdRAu5bVb1EnE8WiqdIWKtrvY b3amrxxc3XUdPge+xbvSDmtKEvvj00oqx1/9TqitMp5b2Mzn3ukPyn7LL4y5kgf/PGIh xQ3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tjFYJKAe; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCVKyXKmzBk3VPnpyTvXFmlyBWZIgSyUOjpl3HdI/cyjHLdNTwxpCWGzb8xCXH6QsYYHLYB+YTN4R4zj94dMAvJ/eNH0Yg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cb18-20020a056a02071200b005c5e24d4364si1923150pgb.428.2024.02.09.06.44.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:44:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tjFYJKAe; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1968BB27457 for ; Fri, 9 Feb 2024 14:32:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A46E762DC; Fri, 9 Feb 2024 14:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="tjFYJKAe" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C0BB69DFF for ; Fri, 9 Feb 2024 14:29:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488953; cv=none; b=Ssd2KTZoa3UHA/jg8ORIXL7z1Z5G3eMxY9MYWCkMygromumSliZqw/nihQB7q2Rl1RfERuaf+GAz1okE/cQ6vkY/JsogDGAh32bBoFYG3q4/d8VfsFITjZ/p3DeGZEFmzFOTesnu6sELFectAY/e9dRBtYIb2N92RmN2L41+Z6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488953; c=relaxed/simple; bh=8CpVZl2bJx8NP6Riuz2Y+yedCiDF5mfz2vl6gbJDV5I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=EBe7BGpfHX13qAhW2CiWd4vqco8dKA2m0c0kYoEVFyB+2n7rWBNWGq2VWpxvgSUfUMGpzExMbk2wZRjs7R+buovM6Mg9O1XaxzzQNgdAAHEwSk9JyJbvtqPqp9K7BBSuAxQY+XeBK+OP/IY8F+BW1G6H/0VN7CsY60w4jPkdqp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=tjFYJKAe; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142908euoutp017d8614aa37188ed7b24f3fafa37562f2~yOCbnh6ME2778527785euoutp01j for ; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142908euoutp017d8614aa37188ed7b24f3fafa37562f2~yOCbnh6ME2778527785euoutp01j 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7qbzY6lGnhYzFm/hs3i9eFPjBZn +36zWZyesIjJ4umnPhaL2dObmSz27D3JYnF51xw2i3tr/rNa3JjwlNHi/N/jrBa/f8xhc+Dx 2DnrLrvHgk2lHptXaHlsWtXJ5rHp0yR2jxMzfrN4nFlwhN3j8yY5j01P3jIFcEZx2aSk5mSW pRbp2yVwZZz/spat4Kh6RcOu1cwNjB/kuxg5OSQETCS+Ld3NAmILCaxglLjXkdrFyAVkf2GU uHp7LROE85lRYs/XJrYuRg6wjt+3MiAaljNKfPuTDlezousYI4RzmlFi2eaNjHBjd01VB7HZ BDQl9p3cxA5SJCLwnFGidfdHMIdZ4CazxLWr59lAqoQF3CQ+vt4AdpSIgLfEgcN/oWw9ibtb 3jKB2CwCKhJrdpxgBDmJV8BK4vkkP5Awp4C1xLxH68HGMArISjxa+YsdxGYWEJe49WQ+E8TP ghKLZu9hhrDFJP7tesgGYetInL3+hBHCNpDYunQfC4StKNFx7CYbxBw9iRtTp0DZ2hLLFr4G m8MLNPPkzCcsIL9ICDRxSTyf1c0O0ewisbN3ItQyYYlXx7dAxWUkTk/uYZnAqD0LyX2zkOyY hWTHLCQ7FjCyrGIUTy0tzk1PLTbMSy3XK07MLS7NS9dLzs/dxAhMbaf/Hf+0g3Huq496hxiZ OBgPMUpwMCuJ8IYsOZIqxJuSWFmVWpQfX1Sak1p8iFGag0VJnFc1RT5VSCA9sSQ1OzW1ILUI JsvEwSnVwFTMosD6fcXKB0qMJq97jYyXtCwWZ0iznmP0Qu/bH+3IPXGqqx2kdzQUzNB98UZE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mYlEd6QJUdShXhTEiurUovy44tKc1KLDzGaAoNoIrOUaHI+MEXmlcQbmhmYGpqYWRqYWpoZ K4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwaQVlVb6a+1XoycnNbsv8ipIy9Kwc/F2+Xuuv 2PbTb46RUtKNvelfIuf9P2mbYep98O66x1wVb+42sGg0380ueqExp/L/dR42+xNaz48p7inV rjU0MLt1Y/lXo54k01bdrNOTPVn5d7vULH2iueFYvY3kpllct1bnGc5Yy3/Pr/J+a0q0UmZN mVlup7lcl+bDGX6Mu51lGPmWzwyNjSirMAwJCbnx0bQkqnfFhojaG1m6713P9mlG+zd4/NXg /6N2041D88lc9zundxQ+D/WztCxycZp0foKrkvoNTocNx7fWHliclC0pk2rrKpyeISS57mXR 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432916810500375 X-GMAIL-MSGID: 1790432916810500375 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: 198927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp899883dyd; Fri, 9 Feb 2024 06:44:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBJr83my26V6kY9C5YcD8jJeJ985asygO1T9qaD0PHSu/Pr8KK7YiebV2+gKSAuft1wo0H X-Received: by 2002:a05:6a21:3489:b0:19e:a1b3:6e27 with SMTP id yo9-20020a056a21348900b0019ea1b36e27mr2318271pzb.18.1707489851887; Fri, 09 Feb 2024 06:44:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489851; cv=pass; d=google.com; s=arc-20160816; b=W28RIjRnlXDW9JABZV2lSc/BhtbdUM1wkGda6gTZBKHfl8pWDknFHmrON0YHLMSLx7 Hf7glKwXQqQZNH9vv8BAts24q5hcF6KCnGGBRWsOyRPyWwg2/cW6hHd7ax52WeqwS0W1 OOw/W1gwFggYkl93qtZc47ay0pdMv2G332fG6HbIL/W1wMxdsrnyedjYLXekWNNWPj0O c6+pLs9GRtE4JdzyqGyTFFTgIFcV5Xq9QxEdlzah+YCCXX7LRE5mslzITbjZtsRTvT9d y3JZSHuQq8t33OA4HGhi3rCtkDpPi3Ck4fTLHFirN0/3rauhMkLvwO2sZzXImm10cz4B Tm4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=in2JJaC6z0hyyXkhiWr41goVesPZul0LbQ6MoMc6gD8=; fh=yRtCD31ljSkhYR7IR3HvT1OUskOVzdxMy9xOeKHcrsU=; b=ki7LH0iwkxtmkVY2dW8O1wsMkdbEzgsRMzMQVzW8PTGWpnXsWYNrsH8zOLn28nNO+n o9VJ45QnVGDWWR4v+TVEWFOfyEMET4HD1afAiIBwDBFBM4MA1GY5VIXA+3QYW/nTqt+z VA7NHU32YyWCwUQ20eV5Fd9KIY4jYCkzO+NdAq+M1BeVs6ugl0jXpgtkyiCfaJWk8oQO wtLqlAkLDrfuO1aVxbhYmGnOWSUiB97tFGtwogcJ7PwHHUb1WXyjJ1kPue5I3KNnlycj lHg9kIWkaEU0E4WFiQdRHzprNxyxYTJ5bvTvbnBb5oD6wlf1yVmbX2sEE4KXxiTVqkKL xXvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mJJtc+wH; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCW50Ig52fAFThGkHOKl071JXs79XZtzXGqP6BWi36iZHNfPCjWrKqvvyXSRXITPa+KUaA/iaVzR1fl7lD1vzDZVcjGg3w== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id bn7-20020a056a02030700b005dbdc98c15csi1936875pgb.709.2024.02.09.06.44.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:44:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mJJtc+wH; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-59456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C5276B27021 for ; Fri, 9 Feb 2024 14:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F95674E25; Fri, 9 Feb 2024 14:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="mJJtc+wH" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFD8D69DE3 for ; Fri, 9 Feb 2024 14:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488952; cv=none; b=fSQuSAkCWECkhZCKZSl3MqpAfR6JBfnf+6Hsjk3a/zByB8uDbUzRIQ1AOo1GFfrDJR2E6ejfMoqGGsceaoofH10enzRCxq8R9eLMQoJLIYu8VhLZdXVX9gAAOxZ28TaYaoZpsOQxFyf04jV7Th5sA9KBNKmUabliBvrPg3PWVLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488952; c=relaxed/simple; bh=r6Ol6y0mnebhEygqGrvK/spAs7z687jAlcbMwM0SB6w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=NV2hbYPl3CUHNNGUYSfg+9vB0W94LK65fgJ6hJtbhhs7RexZzqrglt6WH0AYoGBWgnz08tOY1SRh6xOUf9nKHmYNJazEO0I88y4jqYs5GURyWGFg4ZR6mnPpE7Lq1u+HFZeWa74sBIgF1EJMxcpiQ9rZQLJL35sxuddKLEmM9aI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=mJJtc+wH; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240209142908euoutp028d15824f02ab651422421e91b0dfd276~yOCbzqiLG2377223772euoutp02n for ; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240209142908euoutp028d15824f02ab651422421e91b0dfd276~yOCbzqiLG2377223772euoutp02n 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 lFg0ew8zhC0m8W/XQzYIW0fi7PUnUJ8aSGxd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aB28wSc9pn 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432878870283788 X-GMAIL-MSGID: 1790432878870283788 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);