From patchwork Wed Mar 27 05:54:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13605591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F41BC54E67 for ; Wed, 27 Mar 2024 05:54:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED5516B0095; Wed, 27 Mar 2024 01:54:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E858F6B0096; Wed, 27 Mar 2024 01:54:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D747A6B0098; Wed, 27 Mar 2024 01:54:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C7FB16B0095 for ; Wed, 27 Mar 2024 01:54:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9F60C1C08C7 for ; Wed, 27 Mar 2024 05:54:51 +0000 (UTC) X-FDA: 81941755182.22.A9D62CE Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by imf26.hostedemail.com (Postfix) with ESMTP id 5116A140012 for ; Wed, 27 Mar 2024 05:54:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711518889; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=9LLKC4RDCfWd+ux9DOioyIYXRD2gu6cg+ayKnZ9sjsE=; b=xxNtNMq1L3421QKM7fGgoXXO31uI0kwXNlV+rFtmohMfHJSZazf/UjFn1oXRie10hCjNbq 1gVIMRCZxO6MbB3wtr+/+O2C3vvHUMpSyg+9mXlwVMGnHnEy9Xet77NAH+SCd7EKOTy+m1 UMndFK6dYmxogjkbvuaKEoQdeg39wTM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711518889; a=rsa-sha256; cv=none; b=2GnAAcOtnrPbNcbklaZMhCiicxs4OScGKreYGSWzdPF/L5o3qEiLfHNhml+dI2/+CMyfm1 KXHJpD3+YR0aNAxTupHkVOZJNfq59VZvEdOUztfmgHebYPFd7pTydYvXq9s/UJ7zmAHwE2 IC/6n9/p2QLuiTEFUyjsvFCX5qt1xRQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com; dmarc=none Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 42R5sBOs055570; Wed, 27 Mar 2024 13:54:11 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4V4G645Sjwz2Klktn; Wed, 27 Mar 2024 13:52:28 +0800 (CST) Received: from bj03382pcu01.spreadtrum.com (10.0.73.40) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 27 Mar 2024 13:54:09 +0800 From: "zhaoyang.huang" To: Andrew Morton , Matthew Wilcox , Christoph Hellwig , , , Zhaoyang Huang , Subject: [PATCH] mm: fix unproperly folio_put by changing API in read_pages Date: Wed, 27 Mar 2024 13:54:06 +0800 Message-ID: <20240327055406.1339636-1-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.40] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 42R5sBOs055570 X-Rspamd-Queue-Id: 5116A140012 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: je6cac7cgd65mcujrk4kp9wshk5ijmck X-HE-Tag: 1711518887-498586 X-HE-Meta: U2FsdGVkX18dDxTm0neXNhOSfueVQI8FK3AZr5QYbVbRa8VvrwpbceZDSd/E8HjzSFKd5qpFdrFdhfZ7mV/+M2JLTltqO8kus2IipyfKIXUzpMxybHiyBacDIp95kqu/MNgMiDgMs4571JRMcGHgV9ty99YieTQpINtEL6E3nnKJLjjOdKN1sire7VDjSoE6xXPJMK6Ia3xKot0jxOJtXtAWOEfVf5YBvTkaKlW7tqIqNAFq8cRqoGUc7o7R4LX+LJm6rdW0LNl+QGpcRxX5ADBs8VMBHdUCAYm3wunWx9dLdhZD6m/tALxKJX99p4SJiTJsLY/dd08CczX/JeLb/J39F4o2QD4Rtso67pslIwO1cBzMq/mLajf0Vh4MwPjrk3KCBUuctjT1hn8x4ugesu4ztTCA9i8qmPSofoQNPDgsNadF7Q7QRKWbUN4/NrtXdhtSaJoBVJlKprr6rX5hb2orrp4XbcBWDhNkraM6ITftK+sguojNUWQgzIgDu2AZnm8Y1DEH1ACUuxhrZTobyo6pLQGqN1jGYXEqTON7pL0DcvryhIDmo2R2LKz9Fkh4E0w61R8Idt4MMjU6+RfGNMSeVVxlXVp5NfUCn/CNdc7cKtyhYfEp0pOg7VCqaqFVs+SUINqpt0VM0D4A4K/1sYiu5MeJN/ELXukKtiIDXsdUghkEPTGky3tzn0xldxxviaX4jWItUgarLE7L4f7A2cvXppy528Q/MmYyLFC2Y/GIr7HnSuJ66PE1Czink4Fo/3ScYIvmT8O+SFOppcgQAW/E+eY6CcdY/0dSBUB6kzi9U2hICRS1OqvrKS3P/oIFfvvmOwBC8lcMDbu4hVfatV4peb4Kb1e1YPayknXH95eyYhrvpd/z0h3HyFyqt0eLTyyeepVRIJQK35V2pevxhozvX6t9YiSj3HWZLcw2+eqE7ki4naS5jBF7xCGzPPbyQEQSkZjnciLD1XiISzN hrod2PWu FIf2feynofRtLmGMb/9ogce5hYxOXP4Yig51lPW68aRQGHAV27xD8GWyXbuphUDrPyUAwMgvH5J0weKkjDynqZZvjEg/qFzvZrzM4m32/7VPe75ufLdgqIUhhJFvUwPvmvLHdbu0F7FI7N8My0TK51m0HjxtCrDLrHSh3oebRjdKd6Zpb8kuWoStpOk53ba7xvi4C X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zhaoyang Huang According to the comments of readahead_page[3], the refcnt which represents page cache dropped in [1] makes sense for two reasons, '1. The folio is going to do IO and is locked until IO done;2. The refcnt will be added back when found again from the page cache and then serve for PTE or vfs' while it doesn't make sense in [2] as the refcnt of page cache will be dropped in filemap_remove_folio. read_pages() { aops->readahead { [1] folio = readahead_folio(); } ... [2] while (folio = readahead_folio()) filemap_remove_folio(folio); } [3] * Context: The page is locked and has an elevated refcount. The caller * should decreases the refcount once the page has been submitted for I/O * and unlock the page once all I/O to that page has completed. * Return: A pointer to the next page, or %NULL if we are done. Signed-off-by: Zhaoyang Huang --- mm/readahead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/readahead.c b/mm/readahead.c index 130c0e7df99f..657736200a92 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -163,7 +163,7 @@ static void read_pages(struct readahead_control *rac) * may be used to size the next readahead, so make sure * they accurately reflect what happened. */ - while ((folio = readahead_folio(rac)) != NULL) { + while ((folio = __readahead_folio(rac)) != NULL) { unsigned long nr = folio_nr_pages(folio); folio_get(folio);