[5.10/5.15,v2,1/1,RESEND] mm/truncate: Replace page_mapped() call in invalidate_inode_page()
Message ID | 20240213140933.632481-2-r.smirnov@omp.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-63645-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp562090dyb; Tue, 13 Feb 2024 06:11:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU9QWTSFOcGiC0YrkO57em6IY6m/IjwQFTnizlaixr2Kcty7J4iegYSVQ1V7G0YoHcLtycxvBSG+nIyDDrGvXc4l4gNrg== X-Google-Smtp-Source: AGHT+IEAavH5a5Vc56VawB0rYc+wQ1OuFdIAyjIGKpaDY+Y6NyvWBslhyO/zmGLNsGzdpAxLqf1y X-Received: by 2002:a05:6870:d8cf:b0:21a:1702:d6f6 with SMTP id of15-20020a056870d8cf00b0021a1702d6f6mr8637399oac.4.1707833488395; Tue, 13 Feb 2024 06:11:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707833488; cv=pass; d=google.com; s=arc-20160816; b=ZGhSqWI4W4H+725W1tMAp1H34DVZs00cmco4W2BAsjABuRbJlBo3z2mS2hlbl76WiH 6uyU3ElJtEnFOw+kr+wRfwBSAFw3oLzSZiFFMxscqjVf8K1Ao6ym2s8yAYvYCpVyc5UR cVBLKEo0qOQvuL2aW61Zz/699kmip55wwU4+F27pW8YqLXvBjK3Lm6cUodY3xCBXDYzD zSZ8Qm4yHKTP/wDQqrgaLbgwMHjOYr0u1CxVWh2OSCBIWwZLCzE5ZDuZG/n/PvuXNQtq WTXkj/aO0DNu+CWUFvOu3bmsc47nW/LcldEcWtQNExXmLVLNbcQ9lqa5KUxLHpmQP7ZG x2Kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=O4bxFIxTxliAhbxcpp9TKWKH4jIswUEZlfCRJGbzDmk=; fh=mlqknVucN8N6DSrFumbvr8nIJ43mORv360m902joyqw=; b=iLutdmMLOgTpsTK9S4vLEKoXiTo6YWhYQjiEB5093ySNRY+EO/qA86yPZ16YMFZ7ND U6uI2SpFnKSsWTkyuXyAGVCvll72Uj3fI3p4IIcGVVD7Q/pMQwpoX9r/smI3q+iVpmuU wT9Oy6CJ1wX/j+LNXnvviEqPW7fIGLsT3HqtoMUvT6lQ8BT43nI3aTQ8m/7Lz1RRY6Fv vAhIg7A5Zoz8PvaVajELT8tNz3cHXsLY8opTKtkWSNitdULFpwQ2pT2HmHJ5Dx9mgLIZ 5rBBhjmZ5Nbdl/nlZ752WJxxQz6Ac+wiZvU4N/yIobX6noOlv1B9ohzejbKkjqUTjrkP w0yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=omp.ru); spf=pass (google.com: domain of linux-kernel+bounces-63645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63645-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXPX6bG7yYY3Fy03dI2Aj0NGNY5EgY3yzus/yg/sdOXH+tMSGTR7h3zaNYHXPuyKtHEzM2Aj873Z4qTjjnB8i5bIEVWpA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id el14-20020a056122278e00b004c050b9d8e0si1077388vkb.197.2024.02.13.06.11.28 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 06:11:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=omp.ru); spf=pass (google.com: domain of linux-kernel+bounces-63645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63645-ouuuleilei=gmail.com@vger.kernel.org" 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 503ED1C2718C for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 14:10:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B53557887; Tue, 13 Feb 2024 14:10:21 +0000 (UTC) Received: from mx01.omp.ru (mx01.omp.ru [90.154.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39D0658122; Tue, 13 Feb 2024 14:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.154.21.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833419; cv=none; b=ak1GCqlpdgd8z3BpzPTA8vWAm0xgz0GH/O+iD4JiogdJzuHgrhh9qhn5uypcdeUCNrkZRIGz+s8LkE6QtNjQRdzoL0pe3c3kKq2/CG91nGatkuwmhZoD4IDsAmO7KzSE4j47tydebZnDBn+fTEyv9urTpf1jM+VMYWUgtKMn+S8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707833419; c=relaxed/simple; bh=LQFpv4X1hT+QUG0VEtK7cRc54lvNGdJoRVXIOPkgluo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p9mYoLPYpqGMbIJDlo+6U90aSp/txl86qD7EYbdGIfwbM+pk1lWPmxtw32gp8kITA+BBC0oOjrrdtIDhTB7dAyIjvlHb+pkU4SzPxek/e9pzlBcaHERw45JAfk+czQc0b4DOeMeLoXPhV37b0sSKC7oLTv+cn1k/6UR9ErtAts4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=omp.ru; spf=pass smtp.mailfrom=omp.ru; arc=none smtp.client-ip=90.154.21.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=omp.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=omp.ru Received: from r.smirnovsmtp.omp.ru (10.189.215.22) by msexch01.omp.ru (10.188.4.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1258.12; Tue, 13 Feb 2024 17:10:11 +0300 From: Roman Smirnov <r.smirnov@omp.ru> To: <stable@vger.kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> CC: Roman Smirnov <r.smirnov@omp.ru>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Alexey Khoroshilov <khoroshilov@ispras.ru>, Sergey Shtylyov <s.shtylyov@omp.ru>, Karina Yankevich <k.yankevich@omp.ru>, <lvc-project@linuxtesting.org>, <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, Miaohe Lin <linmiaohe@huawei.com> Subject: [PATCH 5.10/5.15 v2 1/1 RESEND] mm/truncate: Replace page_mapped() call in invalidate_inode_page() Date: Tue, 13 Feb 2024 14:09:33 +0000 Message-ID: <20240213140933.632481-2-r.smirnov@omp.ru> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240213140933.632481-1-r.smirnov@omp.ru> References: <20240213140933.632481-1-r.smirnov@omp.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: msexch01.omp.ru (10.188.4.12) To msexch01.omp.ru (10.188.4.12) X-KSE-ServerInfo: msexch01.omp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 6.1.0, Database issued on: 02/13/2024 13:46:14 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 0 X-KSE-AntiSpam-Info: Lua profiles 183406 [Feb 13 2024] X-KSE-AntiSpam-Info: Version: 6.1.0.3 X-KSE-AntiSpam-Info: Envelope from: r.smirnov@omp.ru X-KSE-AntiSpam-Info: LuaCore: 7 0.3.7 6d6bf5bd8eea7373134f756a2fd73e9456bb7d1a X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: 127.0.0.199:7.1.2;omp.ru:7.1.1;r.smirnovsmtp.omp.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1 X-KSE-AntiSpam-Info: FromAlignment: s X-KSE-AntiSpam-Info: Rate: 0 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 02/13/2024 13:52:00 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 2/13/2024 1:06:00 PM X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790793207404122405 X-GMAIL-MSGID: 1790793207404122405 |
Series |
mm/truncate: fix WARNING in ext4_set_page_dirty()
|
|
Commit Message
Roman Smirnov
Feb. 13, 2024, 2:09 p.m. UTC
From: "Matthew Wilcox (Oracle)" <willy@infradead.org> commit e41c81d0d30e1a6ebf408feaf561f80cac4457dc upstream. folio_mapped() is expensive because it has to check each page's mapcount field. A cheaper check is whether there are any extra references to the page, other than the one we own, one from the page private data and the ones held by the page cache. The call to remove_mapping() will fail in any case if it cannot freeze the refcount, but failing here avoids cycling the i_pages spinlock. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> [Roman: replaced folio_ref_count() call with page_ref_count(), folio_nr_pages() call with compound_nr(), and folio_has_private() call with page_has_private()] Signed-off-by: Roman Smirnov <r.smirnov@omp.ru> --- mm/truncate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/truncate.c b/mm/truncate.c index 8914ca4ce4b1..989bc7785d55 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -256,7 +256,9 @@ int invalidate_inode_page(struct page *page) return 0; if (PageDirty(page) || PageWriteback(page)) return 0; - if (page_mapped(page)) + /* The refcount will be elevated if the page is used by the system */ + if (page_ref_count(page) > + compound_nr(page) + page_has_private(page) + 1) return 0; return invalidate_complete_page(mapping, page); }