From patchwork Sat Aug 17 09:51:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13767123 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 1989BC52D7F for ; Sat, 17 Aug 2024 09:55:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C70868D00D2; Sat, 17 Aug 2024 05:55:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C21B38D00CF; Sat, 17 Aug 2024 05:55:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4C738D00D2; Sat, 17 Aug 2024 05:55:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 80ED28D00CF for ; Sat, 17 Aug 2024 05:55:40 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 344D21405E3 for ; Sat, 17 Aug 2024 09:55:40 +0000 (UTC) X-FDA: 82461280440.11.2A635E3 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf16.hostedemail.com (Postfix) with ESMTP id 9C03F180018 for ; Sat, 17 Aug 2024 09:55:36 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723888483; a=rsa-sha256; cv=none; b=CmsgYPSUKTZceOXJkvMbggI6vvl5k/zIaHH2aO4ky0sUuPEZG6DrQGF75OTC1fS4eqaTpj kwz7HAjN9bh4/BzM23AwoxXoyJdy3zHZvfCjjZj0twDla6e5MKx9v1r1ACyGNocF44hoLx qBFCODYi+f3OKpb5j1lazkW8fnLRsfk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723888483; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I44YpIuFLRLlRlWnLHWyrzjJAp1EUdVZKO72vVlACD8=; b=6Jj/XrSDo5KO4nwPSqA6Up34TR7Z3JxvKuogUIj924IhlQ/E5pkcJ7XGIM+MwdABE7qVGr yemq+Ewcb4RLFpbxrVe7v+uRT6RpRL4mtxb0jpZAs03BpnCGTSNhedCqxgmw+renx5lbQJ /snHssKziTfZbgHBx1tt7Dt3iHB89ZY= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WmDjr02Wgz1T7NP; Sat, 17 Aug 2024 17:54:56 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id A23E8180087; Sat, 17 Aug 2024 17:55:29 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 17 Aug 2024 17:55:29 +0800 From: Kefeng Wang To: Andrew Morton CC: Matthew Wilcox , Alexander Viro , David Hildenbrand , Sidhartha Kumar , , Kefeng Wang Subject: [PATCH 1/5] mm: remove find_subpage() Date: Sat, 17 Aug 2024 17:51:18 +0800 Message-ID: <20240817095122.2460977-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240817095122.2460977-1-wangkefeng.wang@huawei.com> References: <20240817095122.2460977-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Queue-Id: 9C03F180018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: tufzzeb15gihohsbqnak7wa3ax6kxsn9 X-HE-Tag: 1723888536-752084 X-HE-Meta: U2FsdGVkX1953dCCUOYmIUhWxeMPsXhua+v2X67mTLelfTBYuOpwZR4fMgaiDkghlIDCuOds/Krcxp6uNf/J2SeKWO2CRogoqAl8k4caGxUUwoYw96EaQ4GZ0hIuz+5x1EcqsRhjHg6VIn1/EtHdYRSsYRxpRU0BGrSzVGdwJsQhVwvuElmu6c48AyrOdarAqNAKW/cJ4V/N7j7vVCVq/tlaMkew+bvUxrjEdzsbXEmmAk2W9UpWNUdbU6Kio6DGNhDqlgNW3av89Q0ebpn0TTwiJz9jEvP+nKwGzizEQkKWt3c4gauMweeljeQ7ib6McZashCOatPudB3vGl/Rk5z0THe0qvta9aFx4wmgp4bPpsnWBoBDVJhStaIUtM1rm303TFVYBQBmfaUIAPDt0oJbbV3knG1tNradY6RGGWfkld0Pp7PrnsFjec4dnRWXuxKJngTWW72nNNuJ8F5W015J/iTlJ8GjLOVn8eMQ7S8Y16yPRLapi81zMFeawsAa9hMu4VUIEwNOsw3UOhkENpLShVuOMLcdR9JjZZi7O8TNOoYSzFQzK/qYsWz2HqMcv6L6DTrjbH08/hs2s6oIG8hnELAcbz91wDOfM9P/Vyj48H3jnFwUPOeW9FMJ/V4Hcl7Pq76fnibdvRQC6TuVcHJk1ZOKk1bbrvwqaU62YGE29iferFHhUV6pB+UeuBRD7dTYbKI1dOE9LlGuU02NinJPhHSlcrIyvf8EZw3CFkFsFxHLgqcvQ4cEI2d0kvLL4YnvqK1OWS0IBMlBh+tz3P9rp7OuHMxF/z7mroZESO3Eo9M5BHfryY7oH3kaYpwUo6sfi6btmrIxz6kDRb8kMX21r2SPHugm4t3/grKBNuBUoNChctttZRCN6HIV5xUn+MIgaHcRcsehtYLbKW/ZQgt8jV7BPetxCbafOP5cmEA1+ThVujpLYgrsU/PGNd/mQyHiLMQCBrIpND/IxcNu rW/5fntK 1u9GeZs1SiLNMp9bPXhaszRxcjbUyWm4avuQddBL+G2kTg+4cNvuasmSiZyvO1iPDKbd6M36/oQr4Y6/mgJ+slKQsh8aSSZYM82v5CW7trs0tYNSB/09q2eD9ZXLgqzyg8M64fB1eP3RPhgr8G6ksnI0DjxZNVZeLztCe+IbUdD4zw9vsxbhiAX5MwEf9PL9pqEuz 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: After commit a08c7193e4f1 ("mm/filemap: remove hugetlb special casing in filemap.c"), the find_subpage() should remove hugetlb case as the folio_file_page(), furthermore, we could convert to use folio_file_page() to remove find_subpage(). Signed-off-by: Kefeng Wang --- include/linux/pagemap.h | 13 ------------- lib/iov_iter.c | 24 +++++++++++++----------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d9c7edb6422b..68f59cd7637d 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -860,19 +860,6 @@ static inline bool folio_contains(struct folio *folio, pgoff_t index) return index - folio_index(folio) < folio_nr_pages(folio); } -/* - * Given the page we found in the page cache, return the page corresponding - * to this index in the file - */ -static inline struct page *find_subpage(struct page *head, pgoff_t index) -{ - /* HugeTLBfs wants the head page regardless */ - if (PageHuge(head)) - return head; - - return head + (index & (thp_nr_pages(head) - 1)); -} - unsigned filemap_get_folios(struct address_space *mapping, pgoff_t *start, pgoff_t end, struct folio_batch *fbatch); unsigned filemap_get_folios_contig(struct address_space *mapping, diff --git a/lib/iov_iter.c b/lib/iov_iter.c index 4a6a9f419bd7..b0bb1e5ff331 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -891,21 +891,21 @@ static ssize_t iter_xarray_populate_pages(struct page **pages, struct xarray *xa pgoff_t index, unsigned int nr_pages) { XA_STATE(xas, xa, index); - struct page *page; + struct folio *folio; unsigned int ret = 0; rcu_read_lock(); - for (page = xas_load(&xas); page; page = xas_next(&xas)) { - if (xas_retry(&xas, page)) + for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) { + if (xas_retry(&xas, folio)) continue; /* Has the page moved or been split? */ - if (unlikely(page != xas_reload(&xas))) { + if (unlikely(folio != xas_reload(&xas))) { xas_reset(&xas); continue; } - pages[ret] = find_subpage(page, xas.xa_index); + pages[ret] = folio_file_page(folio, xas.xa_index); get_page(pages[ret]); if (++ret == nr_pages) break; @@ -1408,7 +1408,8 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i, iov_iter_extraction_t extraction_flags, size_t *offset0) { - struct page *page, **p; + struct page **p; + struct folio *folio; unsigned int nr = 0, offset; loff_t pos = i->xarray_start + i->iov_offset; pgoff_t index = pos >> PAGE_SHIFT; @@ -1420,20 +1421,21 @@ static ssize_t iov_iter_extract_xarray_pages(struct iov_iter *i, maxpages = want_pages_array(pages, maxsize, offset, maxpages); if (!maxpages) return -ENOMEM; + p = *pages; rcu_read_lock(); - for (page = xas_load(&xas); page; page = xas_next(&xas)) { - if (xas_retry(&xas, page)) + for (folio = xas_load(&xas); folio; folio = xas_next(&xas)) { + if (xas_retry(&xas, folio)) continue; - /* Has the page moved or been split? */ - if (unlikely(page != xas_reload(&xas))) { + /* Has the folio moved or been split? */ + if (unlikely(folio != xas_reload(&xas))) { xas_reset(&xas); continue; } - p[nr++] = find_subpage(page, xas.xa_index); + p[nr++] = folio_file_page(folio, xas.xa_index); if (nr == maxpages) break; }