From patchwork Wed Jun 21 16:45:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287735 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 6B88EEB64D8 for ; Wed, 21 Jun 2023 17:04:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1C858D0003; Wed, 21 Jun 2023 13:04:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ACC9B8D0002; Wed, 21 Jun 2023 13:04:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BAEE8D0003; Wed, 21 Jun 2023 13:04:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8FD148D0002 for ; Wed, 21 Jun 2023 13:04:56 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 391381A099C for ; Wed, 21 Jun 2023 17:04:56 +0000 (UTC) X-FDA: 80927379792.09.CC696EC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 7DAE51A0044 for ; Wed, 21 Jun 2023 17:04:42 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PLRq9KKL; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687367083; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=V8mDv0EPPLn9jbcc1q5//Yn83nwPOxgWUqrHoyXGI0c=; b=BAjWkJJ8Dc72J9rJVw1ZgKSvMXmj3WqKpfLnU16cMRjTS8/yrhVjkCyAiEWus6vuHjfJCk rGFt4kL/NrGpRxViOEBJOMPdTn9hjvSw+8R7kDX4jdz5oCRZjCs6AImRcCsFpKZ71mV7cU OXgGT/2iRuArfUqsndWEe+Lyu+8MPqA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687367083; a=rsa-sha256; cv=none; b=YzjqLGXcUqh6VwSKHyFp/xbmldVWMbFkRyAX+g2OVyLT9kNJ+P7+X1jCz4Blii6dcfAoK/ cThl95EEVDL8dnfhptY8yqwF37nbHZ1vkvoOvXeiVZ85uxeSlp84nCJ+k6H6QBskJhR3jo WJZyEMiq/++kn38iR0YFFcbe1Y8TA0A= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PLRq9KKL; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=V8mDv0EPPLn9jbcc1q5//Yn83nwPOxgWUqrHoyXGI0c=; b=PLRq9KKLTjSuYOK7GHTRrCHMdg 05lLjp1ehbCv+052CPARXxvQnb1O43zxj7iURZQn/E1jaN0bwIQW5tu0K45Zbr+3zxWU+wPrVZlCK +QqsOSr6EUqo15LlAazBFikNdb1fRpMqJvFYQgSLPIYQxMIV53HL0n1UNVHnv6JnPh6JKkExbpJ6p J6MYSwHHyE8H5k3lgy2R+EbEeMzUGq7Yt8LNMEzUcWUZ+ExfwFRmFIPsNXNCW5Mk31QYFy5kzCoHz 0e5RPgd7Cd8SGsqqWpYTptkDT+lG0sounVV2V2o0EUvc/3O7Y3fLam5B//dQFJa/rpuagffUbR3Pv xw/swJBg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjDg-9p; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 01/13] afs: Convert pagevec to folio_batch in afs_extend_writeback() Date: Wed, 21 Jun 2023 17:45:45 +0100 Message-Id: <20230621164557.3510324-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7DAE51A0044 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: naxebjjzyexajt7piwgm9qwatagpkbq3 X-HE-Tag: 1687367082-787347 X-HE-Meta: U2FsdGVkX18bdlMrk6i35EKBT9IQOrWKxYagFYIHaWC46gjo8OM/hop4shRcuElRwDfSHQKkYhmJRTYntRtdEC/4O1q+E1cDIt6bM3mVOOKmuj8O28py8M/+QBCcTScM1azyqePMWLJ00joVtk1mH8/UD53h8DAaVnyYstjX8V8eOCt+cyd2eLNDc8Co712P4gLrNGVHVXIiKCp4jv6VAf1nvael3uyrVJqpCJDU05VFd/OasMtSrEXx5zYozSH/eohe/EftWRtF1i912pR4uImwlcfIUAHFdSGfVUIpyyZmMHLDWpBg9DD3I3tfS0lBUr2IQ9fHY9XWqaWhPgpKPGtCGm6X6XhoRX/F1S4GSTBRAeKIEsEf6HuNrfl03efTGPO7TGXOCWMIMzbBXl5unkjOlLpoMECdf6YkoxoYVbPV6gl/lKfaSbHdYLrhH+L7CCNTzCx78Ew4fi8erVkwfboiiId4EvgiEIYL1O5q8gsnT2vijLdR1sjtu9GZFaPyumnW5fdBr8I5sxbPgv+C8OVcW45Kll3pwqZOd4xg5ClQczldFthBlUBMawv29SAujwyF0Yc5kIbA4HiO977zgcjuGegTSekzLN/W7XsHxD13quenwHpQLPcg/sX8oFEgpXt/NHCZRXOLU9lWj/fCX9B3Swc7NM6Dn/S4XpRTsnX1bt1U+LRVAGSlfPeOBZXW5AV4e9Y13/14iTTu1Qlak9eAqUVr76THTS5Les7kzOwUGBI/WOgWh8WnO9vGHicBpO8WihkbRcGuizL294SiuMyP8YYuEMijNTfNp46SPZj4kn+jbCOJG3H+ro8Ubc9jQ+ySLJ0pSLwHeWiL5lJSh/3dmdAHE4n34QiB50u2nxiCAMldNDlT4n6GT+2QJeJCcF+P0KcAENogxjkVUTwynTcf2kJuvA8mQAxN2JqY87JWWBhWAy11CVg82RTCyF0coaNHarynPT426bDHBub e/mhXzXN 0A2XtbM0zcHyF+oySnzqt+GDRS+NmFQgpEIDIp0rnhpB3ksoNQzdtGEpwuYIfq27fNZ/krYJoA61IfBbMHL7l3B6ljd2AGWh+VDk5+wahi/EJSRmFPJqXa/rt2RBNNNqwcGkNDbCV7F/VXejGgixndTvP4Uve88xa8zdvyXRNsyMAMeugDCwvtylEIIe5U6gELlj3d4JFbIyulExI3gEw0yPT3Lb/yJavgJOz 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: Removes a folio->page->folio conversion for each folio that's involved. More importantly, removes one of the last few uses of a pagevec. Signed-off-by: Matthew Wilcox (Oracle) --- fs/afs/write.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/afs/write.c b/fs/afs/write.c index 18ccb613dff8..6e68c70d0b22 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -465,7 +465,7 @@ static void afs_extend_writeback(struct address_space *mapping, bool caching, unsigned int *_len) { - struct pagevec pvec; + struct folio_batch fbatch; struct folio *folio; unsigned long priv; unsigned int psize, filler = 0; @@ -476,7 +476,7 @@ static void afs_extend_writeback(struct address_space *mapping, unsigned int i; XA_STATE(xas, &mapping->i_pages, index); - pagevec_init(&pvec); + folio_batch_init(&fbatch); do { /* Firstly, we gather up a batch of contiguous dirty pages @@ -535,7 +535,7 @@ static void afs_extend_writeback(struct address_space *mapping, stop = false; index += folio_nr_pages(folio); - if (!pagevec_add(&pvec, &folio->page)) + if (!folio_batch_add(&fbatch, folio)) break; if (stop) break; @@ -545,14 +545,14 @@ static void afs_extend_writeback(struct address_space *mapping, xas_pause(&xas); rcu_read_unlock(); - /* Now, if we obtained any pages, we can shift them to being + /* Now, if we obtained any folios, we can shift them to being * writable and mark them for caching. */ - if (!pagevec_count(&pvec)) + if (!folio_batch_count(&fbatch)) break; - for (i = 0; i < pagevec_count(&pvec); i++) { - folio = page_folio(pvec.pages[i]); + for (i = 0; i < folio_batch_count(&fbatch); i++) { + folio = fbatch.folios[i]; trace_afs_folio_dirty(vnode, tracepoint_string("store+"), folio); if (!folio_clear_dirty_for_io(folio)) @@ -565,7 +565,7 @@ static void afs_extend_writeback(struct address_space *mapping, folio_unlock(folio); } - pagevec_release(&pvec); + folio_batch_release(&fbatch); cond_resched(); } while (!stop); From patchwork Wed Jun 21 16:45:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287671 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 7ED41EB64D8 for ; Wed, 21 Jun 2023 16:46:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E4688D000E; Wed, 21 Jun 2023 12:46:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 46BC78D000D; Wed, 21 Jun 2023 12:46:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2492D8D000E; Wed, 21 Jun 2023 12:46:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 153D78D000D for ; Wed, 21 Jun 2023 12:46:11 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DDA9CB02CA for ; Wed, 21 Jun 2023 16:46:10 +0000 (UTC) X-FDA: 80927332500.23.7BAE5D5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 0883440029 for ; Wed, 21 Jun 2023 16:46:08 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OU4HmcXW; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365969; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KFMiCla2naG7Z7vKPwGKVD4TrVn4emFE0PLxxevs+7o=; b=hQ6P6C/mTRntT7pXksT1B6Rl+uYQwZkfSDqwgqIhGUwXA32qzooQUOEl8Ie2L6+iY7rQ+8 EA1ZYwJd5j6eV9tw/JKfq8brs6oIk4zMLhJF+kXN8YEsTzjFRk7yyfGkuobuKR4QQOUYjL rZuBVVRmoIURazN1zbqZmIo3E9VRqP0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=OU4HmcXW; dmarc=none; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365969; a=rsa-sha256; cv=none; b=qi1RBfKyGDZnvYYgsBBB+WNRSTAnytkUrjGstybQUlpCcSgdoOjIJxPOZ5A3F5sC0f+F+T HQQtozVtiFl/5rXKOrLxDe1HooRHnXCUvfOZKDyOgIssyN5FB3b6ZCf4QAng3ueLh5Ilv6 nGO/UCc/1q4Pcv2YK6ol2dz2MbZKNCY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KFMiCla2naG7Z7vKPwGKVD4TrVn4emFE0PLxxevs+7o=; b=OU4HmcXWzyUGQD65hDOdwkgu0o u74l9DMZxcBXT5V4Z5qLLe5pROXO6krjW5ruc1DT0SkscC1GAv6CUiRHqoT/xZNB+FTYdY7HTZcSC 1nPv6XnNmEo7hrUJxM01iosMG8Y0Ym2VcY6jvvzCBkvQC7lZJfWEJjt8YGSGMlqEn7izRDRm51hz1 GMTsyqcMH1J1dyYFMGFeU3Saag7AZyuOX2CkLBm+3ksa29C3VbudjYZzIgY5yxIiJcoHDGi0dytI4 BSi9r/ik6bNx2dBlS0BKcqh1/yQ1YIwWVl75bC6VUoMpy4h0Khgb2dDFrfbmsM3CyCJYXba2lPTTt z9KQ53Ag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjDi-Cc; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 02/13] mm: Add __folio_batch_release() Date: Wed, 21 Jun 2023 17:45:46 +0100 Message-Id: <20230621164557.3510324-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0883440029 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: jk5mzst39inacjxkstbhcxo1hkjomfab X-HE-Tag: 1687365968-253639 X-HE-Meta: U2FsdGVkX1/w2VlcEUCvO5SH8Tbn3SS2GWxnWnUjlLvB5KSEF82G29qnskVc/NM3TBnzQv90wCVMJbfIk/BTGB5xjQX13umL2EY+kvyNvCf3zavsU8it2gz+uGxw5Ppdo7g3VM89LW+EcT3TmrjporLzGGS0OaqEGpGAWR/5qeVZABvr/n8P7SF8PXc7doRwH9egsaefqbyc18gxRjzhNl62t5Zq/BreTUOvZxpRkeIpTEsaiFbcYH4B57XRZC/TDItAno/cFYIYwW5E6M71BwTMMBXin6ui3wdQjnizQfqZYi8L8JEznRloEem07Ha0zwL+Qh3mTafCmC+rFvoO6Dy2wjwkIGc/VMhk6PqvFHqncpEH6WZL4c1tY8VV8mLhd7tspFwIz+l/n7X2fFPy/fAx/24uE8DiPx24AAfmM8HivUjwSnzbpvQnSYb9/tKihCkWODcAKTh+NNNVvghqKAls4/aygCNbvLQmqt4aqt3wkWrJ829qXtinXZ8yk72x2Rjz27W6klrZaiJqV2oXl2hBzBpQwJBQbPnrQk+H8VblzbV4uUhHV8k/52dqBG6rbIKOu+zjn36TLKWhQm5IzrF8C/ZW93EIDIBnAee5ImrPY87K0ftV+y2O2R2v0mIdjbgeaKywxcKrnlDMA89rmuXvDXujzYOEjBoOtvZVveW5aiNjoiRTrF3tR0wuFQSynXh2ExwjLf5jy0nkYaOUlIOSDA88M1IbQekES90EikEdlW/qPw91f6NROH0CyT/Wqw+iP4o1ffWdKpBIhFvJxOsdAz1Y4rds0qWoc7m4UtbdjIML0VRC5f2q8CeiTHrPC+25mYQoOPjPX6T9asB47pMh59wX8rQCdSjIRw1KdXL7eIYFhS4ZCkqWNs/bfBN+ACdu7XHQcMWAAVQsGyG19byROXttxs891BqFeUARJqqBJZZIFLPK6HNlb3NwhbIw1pBMrL57ZJAfLq2uC9H n4WDDIWN w0IU+KHnYMHsgYgxXs4JhdGqId7U4ZfjM4rAiQxtWEzBoqZ4Zt3H5DP3Ev6loEmW4W18ItqBND03QuA7w0L2SJu36JfWTjVMraP356XzXhhJPwxxlWuhorQ16lnbgBBljt+LNCk3s132FwsvcduwChfdT4pYD95oBMlg869uSxtQZHS9FDExXbfLve664b7t8lqSB+o/X9JBh92FyzS/9INELtzfnaK/xuQFP 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: This performs the same role as __pagevec_release(), ie skipping the check for batch length of 0. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index f582f7213ea5..42aad53e382e 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -127,9 +127,15 @@ static inline unsigned folio_batch_add(struct folio_batch *fbatch, return fbatch_space(fbatch); } +static inline void __folio_batch_release(struct folio_batch *fbatch) +{ + __pagevec_release((struct pagevec *)fbatch); +} + static inline void folio_batch_release(struct folio_batch *fbatch) { - pagevec_release((struct pagevec *)fbatch); + if (folio_batch_count(fbatch)) + __folio_batch_release(fbatch); } void folio_batch_remove_exceptionals(struct folio_batch *fbatch); From patchwork Wed Jun 21 16:45:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287672 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 5AE16EB64DD for ; Wed, 21 Jun 2023 16:46:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C5348D000F; Wed, 21 Jun 2023 12:46:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 979258D000D; Wed, 21 Jun 2023 12:46:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE888D000F; Wed, 21 Jun 2023 12:46:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 67A828D000D for ; Wed, 21 Jun 2023 12:46:14 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0B7A51607C3 for ; Wed, 21 Jun 2023 16:46:14 +0000 (UTC) X-FDA: 80927332668.15.AA3D997 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 334441C0020 for ; Wed, 21 Jun 2023 16:46:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=J7syLfgL; dmarc=none; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365972; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jTDGdnu+fG/6kslyclH2srz/sHr6MJEFetnoOEAqThE=; b=cqT+fgG5OoCVYK6iR424EeBqD5H9XuiBbHAScf9d/p5MAGSqL+0+7DP80r/E86g6h711C7 9Qy/NE8D3p3fYV8/6gBgVm79vJZ46/Nj0Y6stFqjo776byCQD4OtTjr1lUpTzT0KpL7+Ue bTWk2fnQx59gWu05nNKZjq1+EW3k06c= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=J7syLfgL; dmarc=none; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365972; a=rsa-sha256; cv=none; b=c7DUP4jGdJhlC4xen6SGFc/cEtws+RxceUJGsUE/7b9TFtJj8A5LtGHz5gJAe9kNg7FxnO MpRxAnoLP/mJdCBbziuAgIzQAmqt7SR9CKshiaMz4yghdXZ/yMeCUJSflSZLZ7YOpyN5pm Pi0mWDJk4LP0LZYXi4BpMBBANWoaQZY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=jTDGdnu+fG/6kslyclH2srz/sHr6MJEFetnoOEAqThE=; b=J7syLfgLtqZEvF+FaGdNCpIxYK FGrBsHrwiUgwuOgUEvOX2i7PWXG/ZXhqiAhW6CpfyR4l4rDqNGULpmdUDJAIMFqrXnlWMyJuuuQew CRIwuxDz6BodPG9A2vL0dc3r9jSUjJ096kbZOKhyXbwTEF5WnPbOv35W1YxmyI5xeO3eW9SZeu6Ui elEI4SaI8VG431yTXK/Agfd1OvARTxSno98kcl4XPxpk7V8Q46NmOwcGLYx7LMoOCYaku65I0hGaM vfxZSH7R76ZxcVPpw10enxxDEKsn/iEIr1hxmLFS6RNnFgRQiKGzIC7i3HzHCE4ZskLC1FZi9nT0k 4UQzvpAA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjDk-FK; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 03/13] scatterlist: Add sg_set_folio() Date: Wed, 21 Jun 2023 17:45:47 +0100 Message-Id: <20230621164557.3510324-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 334441C0020 X-Stat-Signature: jfq96gtdkf5hdufee9n4jectcz11fark X-Rspam-User: X-HE-Tag: 1687365971-647013 X-HE-Meta: U2FsdGVkX19W7CDOmaVHOgH3OUnJo0B1fAjMOT9D5sD1+N5y41uO137QioUmfJ3lvaZVTvCukjQnU+Fhn5YcRw9hbEduXSzLECi078Hb+GOq9jAl6TzBoe54rjxl1qhwmKx1wRweX4M9rWVxjdrYQMxcTVFGD5gV2As+yirNYJLF6/dvikoh8fPX1ECcGAFRZ8vzYmws3Ffkwhxwlns4+oTPXo/wlN+qpwYNEpiToXUxCUjy5rrlHS+JLu03EzupZA1gCsv+fSZEiKdsiGV0H+9viFR9P8WZ75aPS1OBpe8knXtxaM4Uy11JJLEVPXBKku34+FpNWdIoBWz+iiw54btualC27bQq5uaWHbf1vQ4vmpMcHoV3918DIM72T/RnrfYsIlEq7UhxrVMyLKF5vE55YNcuo1m112hQwgwjFNgFttBIaeQfqxV7AWsAJhW1J0CyPc+/0D4GZPaaVn9zDpN4njoIC/Li8GfN3lotOxuVVE5frL+t49pC/Au5g0NdmHdnE+2ZWpc+MHRhN2sHqorSt79oa6+TfFhZmkyeQW41k0/2VuSEm7+P4xnPfl+UW35/2Ik9QE1yYQQfxVDneblRDtEpxli9pkpupwhTQ8eYPRkca/DMhW0K9CZsfUxaSp/jgtDcH0oPYD+jwefvy/lC8esJGzaVbtXO2MHx52WPWrfJ0rolCrs3zCm+eci11b5cZPHXs5cU9zVBQ+bNJQ55XlCaBOXTKGYwQthPDUOJwu4FllbG4XL6eZFLF8lbj65R8nqOxlMySccsXMZpeddnFlhbO4HWZA9vweulhCSwGhpXFSr6Xu5ZwxHwzPfKeH/GWp6X2VGqB/fY62NP6Hvd21LX6i+a0+drmly9I4zY9SCJer2870k5rEEuSHnStg93V7hPyf5+nHmyDEfGZR0Nc6mimJcDQdIy/VpTKeyeuO0RnHxD8ONphki0CjsHU4pBh3VJHGhlcaNM7tH 7SJCe6KF yrznih33oK8j1QQefgo7d7gBE+C5EEnYMDJPp3pY5cGW+o1oszAn0ske1E26quWRobKjlKz3so4R5aSLVV6ghCQAHfQAF3pS272G/7myZToGgalQtbzNffzkwe6m8n8gmXEp/sOP0nek2f0p6mzj5qCN0ODRznu0oRXD6/RpWYKq4szgnJ5dD0cLiqHAMyCDMfQoOpCtzeYvGZZa+7JKsE8uRXlg075Te7TeS 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: This wrapper for sg_set_page() lets drivers add folios to a scatterlist more easily. We could, perhaps, do better by using a different page in the folio if offset is larger than UINT_MAX, but let's hope we get a better data structure than this before we need to care about such large folios. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/scatterlist.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index ec46d8e8e49d..77df3d7b18a6 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -141,6 +141,30 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page, sg->length = len; } +/** + * sg_set_folio - Set sg entry to point at given folio + * @sg: SG entry + * @folio: The folio + * @len: Length of data + * @offset: Offset into folio + * + * Description: + * Use this function to set an sg entry pointing at a folio, never assign + * the folio directly. We encode sg table information in the lower bits + * of the folio pointer. See sg_page() for looking up the page belonging + * to an sg entry. + * + **/ +static inline void sg_set_folio(struct scatterlist *sg, struct folio *folio, + size_t len, size_t offset) +{ + WARN_ON_ONCE(len > UINT_MAX); + WARN_ON_ONCE(offset > UINT_MAX); + sg_assign_page(sg, &folio->page); + sg->offset = offset; + sg->length = len; +} + static inline struct page *sg_page(struct scatterlist *sg) { #ifdef CONFIG_DEBUG_SG From patchwork Wed Jun 21 16:45:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287673 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 3C5D9C0015E for ; Wed, 21 Jun 2023 16:46:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C3AC8D0010; Wed, 21 Jun 2023 12:46:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 975448D000D; Wed, 21 Jun 2023 12:46:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C7F48D0010; Wed, 21 Jun 2023 12:46:17 -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 6BDF28D000D for ; Wed, 21 Jun 2023 12:46:17 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1708EA09A9 for ; Wed, 21 Jun 2023 16:46:17 +0000 (UTC) X-FDA: 80927332794.03.42FC155 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 0EC4B180028 for ; Wed, 21 Jun 2023 16:46:14 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=JXUQqB4d; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365975; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eONAo72om3NJJPfeQU98nnaiEyx1girYaBRrJpkgqkU=; b=BkyE2hyNBO7aWjocYhkJ0hORCAwVmKnzQqvpczMA0zJWLlzgpDu87i2pVju+makuGG0NMA nsFgxmUF3Ao5DjRgJhsSdi45eIGHdF9HgXmERZUXqXg2fSba9XGwuD15EGXpEJNvbBVGf/ iFSrfDCZbOct7SVq/zoUUAx2MvH59GU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=JXUQqB4d; dmarc=none; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365975; a=rsa-sha256; cv=none; b=VHbjf/j68KFmg8nO7mfgb+Vb6fYknmMKQbrgOXI5bKAQ/0Ilji5k/DWW1lgUtJluOLhMSG VLHbcL2LlDqltUQDyqPS0/6xcd0nredp1dc2DXwLG712trNqbf4g5zK2631nqc2XmVHxpV XH1DjvP3P3jQPqt3na2A1PNTSKqdxCg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=eONAo72om3NJJPfeQU98nnaiEyx1girYaBRrJpkgqkU=; b=JXUQqB4dBUOu93/qitkyE97f3Z vicwKtf2V+aPt3Dbg9/7v8WVwzM1uW09KbzEgrV7HoZavbGv57iMq0P8yKRiVHqblH2VN4jJwQ51P 3UBOa8B2hu7+kv08AyN/nJEB47YJdT5WmFl8qEnhdI5jyaHNGAsAFAZ1nL/q35cRWiLbB1YToy/e8 42a1+W41mg0rHN6jVqxvTZByBSAn9Z9fMtkxjLN56svcogUEoy8anGD/EDPT8G5k/Bd4memePz7s9 CrQmO7YpoNGtdgXoNsSSDZ7tXeMZyLnRddcjDjPExN2w8ZnbHBneVjox+kOnqzeVCqXZWHclrs02X NKuWOUMg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjDm-IE; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 04/13] i915: Convert shmem_sg_free_table() to use a folio_batch Date: Wed, 21 Jun 2023 17:45:48 +0100 Message-Id: <20230621164557.3510324-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 0EC4B180028 X-Stat-Signature: 38abmis3bg1ghgs916ery5fsamye67dy X-Rspam-User: X-HE-Tag: 1687365974-792507 X-HE-Meta: U2FsdGVkX1/fo6pvSgCCHeIcxSqJX4VvDJy4RV0efTqcMxu0UVeQ64WQ7tLdK7MWdwIMJyfpsQh7tGm1t3HnZjhgfvKRLNEenmmbKAZtk0SPker7Lu0V3gcU3/qIF5bS7FNKELQHIDXISJw1Zvyz9F19q74FV5Ix1qRyAUxPmomHtD1wFWkdS9TfnGo9n/6mMJ26kkQULAoNmu7Q1UNRfAsGpkLRsVDSlPTka5eOjoBbBFMBgpkQQrNxvGDyvQ704y1AJk1WaUPmUMgdnJnq4duh9Ju+PgvSBTcmprCGw32UhKncLzGra+by2/6J0OFRbHi92cOAM8WM9DAlqOjm1FnwSOTKjgbIWrLa8u/eQEzcGCl1BKS1nhGgwlOukVh4DK5X2+Oo5HgYLjZlOLz4TNCYo8KlG9+IWLeGOp5yjyQ/IZhQcepbf2dnkNk5ZXEZnANnhQx6DSGqprhxFDAqZ0srzB55UWcs5DyipkVMFPJX7mVSMXo33WoQkbDonFtnHuSXwuIa9ar8fi6kncsJcM6y3SDScBgyJlF8VgI6FeIZ+7q2HoTH2f/PBXB1U3AiksjBcKaWXnYHzALrGLqSZobnCAbyCh99/G9NGA2Yg9gACwpFHJyG9UXRBxfGzoDQdP673IDNxzNqIastyNlYo63PQdV2rPtp6ubg/5yWV70eVNXoH9SDKmJcwIZAJnXJKLc3W3CURkg1P5OL5QQjdzsXw59uREkl0qib8EG6qWqzTTmcHLp+Fi9A97biUsydoRT2QfE+Ze4VuG+3Uxh4an1C6CqGOrnh5vtFjpMkQ7mtrKE1os5ryEVyRB+4ZpzWqiKpEvb96hNhY0f+yZIqGmziuPEh4xVShUsYRF6m2hZP6tssrKsWH4ri11SYvd+0EfMymrNa9/YF3Wdr/ZwALwzXLiZ59rnK3y6ln2eCCSQUiZGcSYtl866APs88LFc373TYLqYcDGPh9dpI5RU AUTe5FGC 3QZwJ3RaeE5uQv6T75uu/Nyj5G7UAKjMkL/By/WiPQdqO0M8pDUSykItNp9MYqMY7Ct9piOkQfeTPMxrsE87QB57TAMGL0o1tbVovloy21npZuugFwWslZw+sZqr8bVGWQvYzQhDumDUifb/1p7XCk+zmHniqH6H04gZARNSHzj8vVypAJinrQ2/lTsaAVTbP0bFE6JqGhE0ww2jH8e4dFsHlpqqNEXcivuDF 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: Remove a few hidden compound_head() calls by converting the returned page to a folio once and using the folio APIs. We also only increment the refcount on the folio once instead of once for each page. Ideally, we would have a for_each_sgt_folio macro, but until then this will do. Signed-off-by: Matthew Wilcox (Oracle) --- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 55 +++++++++++++---------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c index 33d5d5178103..8f1633c3fb93 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c @@ -19,13 +19,13 @@ #include "i915_trace.h" /* - * Move pages to appropriate lru and release the pagevec, decrementing the - * ref count of those pages. + * Move folios to appropriate lru and release the batch, decrementing the + * ref count of those folios. */ -static void check_release_pagevec(struct pagevec *pvec) +static void check_release_folio_batch(struct folio_batch *fbatch) { - check_move_unevictable_pages(pvec); - __pagevec_release(pvec); + check_move_unevictable_folios(fbatch); + __folio_batch_release(fbatch); cond_resched(); } @@ -33,24 +33,29 @@ void shmem_sg_free_table(struct sg_table *st, struct address_space *mapping, bool dirty, bool backup) { struct sgt_iter sgt_iter; - struct pagevec pvec; + struct folio_batch fbatch; + struct folio *last = NULL; struct page *page; mapping_clear_unevictable(mapping); - pagevec_init(&pvec); + folio_batch_init(&fbatch); for_each_sgt_page(page, sgt_iter, st) { - if (dirty) - set_page_dirty(page); + struct folio *folio = page_folio(page); + if (folio == last) + continue; + last = folio; + if (dirty) + folio_mark_dirty(folio); if (backup) - mark_page_accessed(page); + folio_mark_accessed(folio); - if (!pagevec_add(&pvec, page)) - check_release_pagevec(&pvec); + if (!folio_batch_add(&fbatch, folio)) + check_release_folio_batch(&fbatch); } - if (pagevec_count(&pvec)) - check_release_pagevec(&pvec); + if (fbatch.nr) + check_release_folio_batch(&fbatch); sg_free_table(st); } @@ -63,8 +68,7 @@ int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st, unsigned int page_count; /* restricted by sg_alloc_table */ unsigned long i; struct scatterlist *sg; - struct page *page; - unsigned long last_pfn = 0; /* suppress gcc warning */ + unsigned long next_pfn = 0; /* suppress gcc warning */ gfp_t noreclaim; int ret; @@ -95,6 +99,7 @@ int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st, sg = st->sgl; st->nents = 0; for (i = 0; i < page_count; i++) { + struct folio *folio; const unsigned int shrink[] = { I915_SHRINK_BOUND | I915_SHRINK_UNBOUND, 0, @@ -103,12 +108,12 @@ int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st, do { cond_resched(); - page = shmem_read_mapping_page_gfp(mapping, i, gfp); - if (!IS_ERR(page)) + folio = shmem_read_folio_gfp(mapping, i, gfp); + if (!IS_ERR(folio)) break; if (!*s) { - ret = PTR_ERR(page); + ret = PTR_ERR(folio); goto err_sg; } @@ -147,19 +152,21 @@ int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st, if (!i || sg->length >= max_segment || - page_to_pfn(page) != last_pfn + 1) { + folio_pfn(folio) != next_pfn) { if (i) sg = sg_next(sg); st->nents++; - sg_set_page(sg, page, PAGE_SIZE, 0); + sg_set_folio(sg, folio, folio_size(folio), 0); } else { - sg->length += PAGE_SIZE; + /* XXX: could overflow? */ + sg->length += folio_size(folio); } - last_pfn = page_to_pfn(page); + next_pfn = folio_pfn(folio) + folio_nr_pages(folio); + i += folio_nr_pages(folio) - 1; /* Check that the i965g/gm workaround works. */ - GEM_BUG_ON(gfp & __GFP_DMA32 && last_pfn >= 0x00100000UL); + GEM_BUG_ON(gfp & __GFP_DMA32 && next_pfn >= 0x00100000UL); } if (sg) /* loop terminated early; short sg table */ sg_mark_end(sg); From patchwork Wed Jun 21 16:45:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287648 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 A3314EB64DC for ; Wed, 21 Jun 2023 16:46:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F78E8D0009; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A8748D0002; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2233D8D0009; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EC1F28D0005 for ; Wed, 21 Jun 2023 12:46:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 97FA4C0927 for ; Wed, 21 Jun 2023 16:46:05 +0000 (UTC) X-FDA: 80927332290.29.4475009 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id BC0C04001F for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WBpyN9BX; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365963; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yzS6LjqchbTZ4R7rHRoGuy4VZGAEBFE5nqlz2+V2o7A=; b=UgSYQMkSJweI7q9/5RE+vH2xdb14hnWlEmlB2+yLy6Os7cjbVpnuN4qraKE9Dyc/egb2vz OTAKIi5ns6j7Kw7SngO+Rfi1orFR9uXtz8GIstC2pZ8D6s3bHz00SRPcsA/di+z3mghpBb K25vOsIBt7VHM55Jzpw/IZUWzOl646s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365963; a=rsa-sha256; cv=none; b=RtX9Tr50xkZriWczyZlL6vMKSiAvLr5LoZ9SR5ofugRH9QWmk+G+6tRqOCpVflIk/KTyZR RMDzGu7lNRiYUEJE0XZubBUmhz3wBEQHs4jtRE7N+ApD5H6YMpUpzLv9H1407YU1+b/qsn bf7siv59nJpvOiZt3KqyZWCb9Jd3zwE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WBpyN9BX; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=yzS6LjqchbTZ4R7rHRoGuy4VZGAEBFE5nqlz2+V2o7A=; b=WBpyN9BXXz0sujrWmftgID2xoV kdlIrjAuPrDvE02NGbEGcLyBZ4Gh5juLzLRwS1aTs/iFXq/1LzJmB5OnGfnoB/gk9TrEijhUjAXEa zfpHDMGrt3LnGpZtYE4JE6eWPWyYdp2X2QggxQXZSI//nfSqIYLKPmLQneg7ai1fOJgcdgv30e8MD nMvTO7EwuTOqP49d04wRvN5Qg/gyTbkAb6jsLtg9q8C+RRUI0bD+XBrJIyUyiEfPwvF9jfze9zMT6 j21Ep+8UpwfWW4NGk2mJombjhn0YtTQ396FgivudfclsdbCqddsGj33hwbEIDLfpb4JolRAADXAQL nT3lFN0g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjDo-LH; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 05/13] drm: Convert drm_gem_put_pages() to use a folio_batch Date: Wed, 21 Jun 2023 17:45:49 +0100 Message-Id: <20230621164557.3510324-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: BC0C04001F X-Rspam-User: X-Stat-Signature: 1dc6fw76t31pgwu1zjcthwkjm33f9xpf X-Rspamd-Server: rspam03 X-HE-Tag: 1687365963-916360 X-HE-Meta: U2FsdGVkX18LsqJf3XjiLjLFBYwZrp2UvkIoXgbqMsjPHBYcBwuDg0eAoSuDVdSf1J/ASV893HYQFQ7TpjPYRhgQ53QUhECoIphWiVjdCJYU/Mc5pMrbtiuUIbLt+3BUHN9X5oQ5D1LWl2bMB200CrsDvLxTTZDLhT48FDsLQRqt4HAPjTaUiqmAjTKTSFV5DCfHgT8DMvjTUDZyRFYAGTykGgWteiusoZvlmmhvA4Vg53WaAPo4jMu4uZq5URr45B3a5boaAE5AhifBgqQhEmOTLXXyBmefLnNJ9g7VlmU7wV3a6WQbgtNsLWeEahByFMnndHbPnl8LXHsGBGc1ENBtoSjn6G59XS9iRsfj/j8LzUErfQkHnICiapFHHYiG5WBR/6ayzmaJPbWrKq1dkFFy2JH4bVqeNIU7WrYj7/lniVPpW1HznWjhqYBXI3S33Q2nXqcqHc6q+UT6Ox1nI8/ooAhOWXbXax0veMDOikCnmM06yG5ldYpkk88rsLixgNtW730zW++jYFk3O2V2Ph3MbtOnQNs4QJx86Ed+Rq1I4kyWRViWDT3ZPbkQN68FsHWiULcvnPwZHAPX+5ObNQ6aByt1ZT0kvXEtV4R88+WSwXukm3tIA2exid5h9N+Mb4cy+bpArpoC/BFXoXdWBCevuv9BYoxfBn1eEanowXeBZcdstLnEclzEPBRxP3rkPHevdlSsuQnoJGOCaw1NNQIduoEPf48X4Qw0mgBlYqzAXMzEHI7ptSI7HX4fNrZPaMNumWV2BwiQTuPizXB3OkoHKceGfPsvu0S8PEb0Og7+yoZJD3b4WB3Oj2bHyHvxpsjXISn/SDJeNhQpfeBrppzHBWzZk95DLpACeq4fhpVlNCW61EQmH9IGoAHOVSHaiaZ7AhTwoaP84SIc2FxVgNNpYg+GlO66ZxBWasDzipiO0v3hhj25YVXfCZUqd6CaXZin7VrLxQLhxA4MKnM BeVWo/+m xggt4YWjtWx0/gB9oARC7E8SPKZnNuLrz9quxkFJHPkw3awgUEdeUi9UPpBCZs9V3HcHIQQASiwYJbIdl5Rczd6CPtFicTMJCTPUCTnMSnxgUaBomx8MGg2xPYl7O/sgjU7ymsCmgDKl/O8yQhzxfLx+o/7D0uvhq2TnIMshvt/eLTQJGGB6Uxj/x/iuyWqCL1BRm4MxqXs6yc75m4gwVPWiuYYUk6hasFrGC 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: Remove a few hidden compound_head() calls by converting the returned page to a folio once and using the folio APIs. Signed-off-by: Matthew Wilcox (Oracle) --- drivers/gpu/drm/drm_gem.c | 68 ++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 1a5a2cd0d4ec..78dcae201cc6 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -496,13 +496,13 @@ int drm_gem_create_mmap_offset(struct drm_gem_object *obj) EXPORT_SYMBOL(drm_gem_create_mmap_offset); /* - * Move pages to appropriate lru and release the pagevec, decrementing the - * ref count of those pages. + * Move folios to appropriate lru and release the folios, decrementing the + * ref count of those folios. */ -static void drm_gem_check_release_pagevec(struct pagevec *pvec) +static void drm_gem_check_release_batch(struct folio_batch *fbatch) { - check_move_unevictable_pages(pvec); - __pagevec_release(pvec); + check_move_unevictable_folios(fbatch); + __folio_batch_release(fbatch); cond_resched(); } @@ -534,10 +534,10 @@ static void drm_gem_check_release_pagevec(struct pagevec *pvec) struct page **drm_gem_get_pages(struct drm_gem_object *obj) { struct address_space *mapping; - struct page *p, **pages; - struct pagevec pvec; - int i, npages; - + struct page **pages; + struct folio *folio; + struct folio_batch fbatch; + int i, j, npages; if (WARN_ON(!obj->filp)) return ERR_PTR(-EINVAL); @@ -559,11 +559,14 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj) mapping_set_unevictable(mapping); - for (i = 0; i < npages; i++) { - p = shmem_read_mapping_page(mapping, i); - if (IS_ERR(p)) + i = 0; + while (i < npages) { + folio = shmem_read_folio_gfp(mapping, i, + mapping_gfp_mask(mapping)); + if (IS_ERR(folio)) goto fail; - pages[i] = p; + for (j = 0; j < folio_nr_pages(folio); j++, i++) + pages[i] = folio_file_page(folio, i); /* Make sure shmem keeps __GFP_DMA32 allocated pages in the * correct region during swapin. Note that this requires @@ -571,23 +574,26 @@ struct page **drm_gem_get_pages(struct drm_gem_object *obj) * so shmem can relocate pages during swapin if required. */ BUG_ON(mapping_gfp_constraint(mapping, __GFP_DMA32) && - (page_to_pfn(p) >= 0x00100000UL)); + (folio_pfn(folio) >= 0x00100000UL)); } return pages; fail: mapping_clear_unevictable(mapping); - pagevec_init(&pvec); - while (i--) { - if (!pagevec_add(&pvec, pages[i])) - drm_gem_check_release_pagevec(&pvec); + folio_batch_init(&fbatch); + j = 0; + while (j < i) { + struct folio *f = page_folio(pages[j]); + if (!folio_batch_add(&fbatch, f)) + drm_gem_check_release_batch(&fbatch); + j += folio_nr_pages(f); } - if (pagevec_count(&pvec)) - drm_gem_check_release_pagevec(&pvec); + if (fbatch.nr) + drm_gem_check_release_batch(&fbatch); kvfree(pages); - return ERR_CAST(p); + return ERR_CAST(folio); } EXPORT_SYMBOL(drm_gem_get_pages); @@ -603,7 +609,7 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, { int i, npages; struct address_space *mapping; - struct pagevec pvec; + struct folio_batch fbatch; mapping = file_inode(obj->filp)->i_mapping; mapping_clear_unevictable(mapping); @@ -616,23 +622,27 @@ void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages, npages = obj->size >> PAGE_SHIFT; - pagevec_init(&pvec); + folio_batch_init(&fbatch); for (i = 0; i < npages; i++) { + struct folio *folio; + if (!pages[i]) continue; + folio = page_folio(pages[i]); if (dirty) - set_page_dirty(pages[i]); + folio_mark_dirty(folio); if (accessed) - mark_page_accessed(pages[i]); + folio_mark_accessed(folio); /* Undo the reference we took when populating the table */ - if (!pagevec_add(&pvec, pages[i])) - drm_gem_check_release_pagevec(&pvec); + if (!folio_batch_add(&fbatch, folio)) + drm_gem_check_release_batch(&fbatch); + i += folio_nr_pages(folio) - 1; } - if (pagevec_count(&pvec)) - drm_gem_check_release_pagevec(&pvec); + if (folio_batch_count(&fbatch)) + drm_gem_check_release_batch(&fbatch); kvfree(pages); } From patchwork Wed Jun 21 16:45:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287649 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 E1870EB64D8 for ; Wed, 21 Jun 2023 16:46:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A5768D0002; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68F758D0007; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 351668D0005; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1351D8D0002 for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CC8B140987 for ; Wed, 21 Jun 2023 16:46:05 +0000 (UTC) X-FDA: 80927332290.28.C496D20 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id F416416001E for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mY+uBPiy; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7niWMu6g/Ga9ZksmA0zYh6a0pI2cBG5yqVDcIc9jMKw=; b=rO6ctD9uezkCwuiMdq594qew4Kxgk0YdcXaOKrfXDi9YQyf55ry0R7NJgYBEE+KjDpUPPp 4iWTxOl2EYoS3igo0AMzEogtYOr2VvB0YXy7xUayRA/okGWA52n5txM0SxnK4MhXOJP0jO RsDr0AQClVXtg3+CumY2LnzISTyWqkY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mY+uBPiy; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=PsWrBvR73ncbImzpOmp41MvEf2gfywa1nJ5N1pzxBCZzdwwQc4e/pWauUM3+HNzOOFURn6 KWRbo1GaZENB9APb2aZDlCEoBQPsQoA0Mb1zJ9izhQnXSz8dZ012l2WOVvx+r2D7Tj7cFL enZwr16oUq8E1ZOvh6+KNEpbNgT+OZ0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=7niWMu6g/Ga9ZksmA0zYh6a0pI2cBG5yqVDcIc9jMKw=; b=mY+uBPiycIfHNeNVplxKugqw8y ja2K6C7MvJK6a5FI2+yURLUgfwFYXZEiQLFhJKZKFoH26P6b8EqoKQNl4q/RV/1sfv1WL7OKRLXrA INno6Z7BtR+COXHsKd7SXQ6k1Df/kRG5SHduBcfxktVSs0GP9cCVaLt+gjY79DWa5MOXGMXWbYAT6 etNCZZSKWiK1mHVDNJ+WCmubynjm50iSWFRDEX+P84WWha4AngPA+I2KS8lh3AQ0Lhy0SKsmaFCKv oy8NE0qqvtkZw7y0DBgRqj6k2mTOcmX89ClyhVMXPPrdLQC/DiqTeH0jAYyZs7bulU0tpckAefW40 zJ4u14gw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjDy-P0; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 06/13] mm: Remove check_move_unevictable_pages() Date: Wed, 21 Jun 2023 17:45:50 +0100 Message-Id: <20230621164557.3510324-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F416416001E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: guzi453nk6odpychj6sa3qt47r5qkt5u X-HE-Tag: 1687365963-379476 X-HE-Meta: U2FsdGVkX18geuquIap0m2XWBjxcIpN3nuNxOHCvXajrpK5EjvGSdXZ6iPHPB1t0YxThUsp5EKJifZhvX34rW06dfQ2RdHoAcP+8nhPKjQLN6cA+SZ/SSc/W2dmkNDfXQkLK35gmCO2oiIJ+uIxmgV9atU0Gkbw7+gu5sRVCpT56DfPETtvvK0UTITxpDnXaVXY1i090n0tB7nle4MOtOBs5Z0PkOaM1eUr6r3eqXJ2sMOMQNTVacXkBhgyNhio+q+YDPuhwOUpteZVgKIO0q/BExgjD6Vh3cI6Tmcd1u0pcTBDrPwN3zh0hNAahj5jsvsz+1nTMCQokmFh/FVp/5Fr0VNBbAeokUkFnGoQqLNplxnCsgfwyCL3AYMm88lKKDmeAss5LVWmkbGn6Mex0aVitRTi+awk6MXwlfM7ui0vLqbDGMMTShuD1YM6j8Vb8reUkzN8qD/jJpUfVWQ9p/VtA6RZyGlFS+XOtVeKgPciU/8QERagVw/dGY4vOwf/1RwWlk18fxEyeatQbvzss68agO/zC72dMigENGrPh6USxSBSNrM6z248EDrtdwIWjIM4wF7N2/MxC3bw67sav9g2W4tzB6UFobC7Rr5YAo7etiTv4gY+bxBhq+guWJ8U/c29CqeUk0NCINfEUpRR3t+NQcqXX7X4aiCDR4c1/mrgmCsWkG35UTIUTSdmVyAnkUyU/xKjMbxoHT0ML0wn1+kBAo8VSciaeZP4LkfGQFQX+TVdHurCIpQEF299DTE4f2GGL273keC8h4p9GoLlFbZHOLpuUbbT/n+UZxNYsHvH1fOHY++Tayz/qWmuZSHFj/U9Nnlpcr07ItbUGfCZRVCHG7jNnzSZ7zVsj+kEprpTZbexFAP655p/uaMZPWX9eQBqd+4Kvy1PylB+gsabTB/VJs5Gu5UWK+EnNB2ektMbGqFd0mJBBKLTAgT8aR0M38Nz6VK3PHKjI1cInloL ph+r0xOJ JwBrrdmnF0U2s/g4hUWH3xEZB6kxQw8U5XwlSQS7o+7KUx+pgz7gtHF8EL9hE5cE7reb+TOQ7jdxha4CfD4Bq5dvvXmk3Uaxo6bZ2iuTfy+wD5v09Jjbu7OhT2FB+uQGw9qALC3r4uDmtvpfJVfCmD0VYKAkUGCfApVPnLlk6Rq5aG5hd/E6h9WZxe7/b1YpkFfBngiJ3BFCkSnXPjx1aeQjlPgBeB1ItutiL 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: All callers have now been converted to call check_move_unevictable_folios(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/swap.h | 1 - mm/vmscan.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index ce7e82cf787f..456546443f1f 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -439,7 +439,6 @@ static inline bool node_reclaim_enabled(void) } void check_move_unevictable_folios(struct folio_batch *fbatch); -void check_move_unevictable_pages(struct pagevec *pvec); extern void __meminit kswapd_run(int nid); extern void __meminit kswapd_stop(int nid); diff --git a/mm/vmscan.c b/mm/vmscan.c index 45d17c7cc555..f8dd1db15897 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -8074,23 +8074,6 @@ int node_reclaim(struct pglist_data *pgdat, gfp_t gfp_mask, unsigned int order) } #endif -void check_move_unevictable_pages(struct pagevec *pvec) -{ - struct folio_batch fbatch; - unsigned i; - - folio_batch_init(&fbatch); - for (i = 0; i < pvec->nr; i++) { - struct page *page = pvec->pages[i]; - - if (PageTransTail(page)) - continue; - folio_batch_add(&fbatch, page_folio(page)); - } - check_move_unevictable_folios(&fbatch); -} -EXPORT_SYMBOL_GPL(check_move_unevictable_pages); - /** * check_move_unevictable_folios - Move evictable folios to appropriate zone * lru list From patchwork Wed Jun 21 16:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287666 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 65E2CEB64D7 for ; Wed, 21 Jun 2023 16:46:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E8688D000A; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C58AE8D0007; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6698F8D0005; Wed, 21 Jun 2023 12:46:06 -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 2208C8D0008 for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D6F424099D for ; Wed, 21 Jun 2023 16:46:05 +0000 (UTC) X-FDA: 80927332290.25.5152940 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 2232410001B for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jUfm5Cn2; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5w9pZnjuH0cui0+bbF2YOmmpAFWEgjcRmo7ue1AvTtQ=; b=JSUAwrVBpyIIv5qxE3qWIUC3jCUfczCVXgsygugHWXyKH1GtyjOIO2+ncYiOs+0YCo/fUX 497t5erO5/rfSuyg9fGsFPLXcxir1Vknc8gWih0k6eXDUQ0ZhZ5S0l6VDJvUOsWjfUe7Gs 4zT8Is05gjTJJV1Y5AxukM+NsL26wn4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=whs6WGLHl74HHgGd4e3HcnlyU5uLPJ3DLV1SRU5WPNdUxVt4GYmI2Q0yerjTbMibcnyUKa XHjn2WKr072FIIOAhI4brl/zcjW4EYhmUaSCyXG6OGa77pKAI2p16EUalOG6uMYUFdojmZ X+jMyjx76nnAddqG9Evwaze5k3TEan4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jUfm5Cn2; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=5w9pZnjuH0cui0+bbF2YOmmpAFWEgjcRmo7ue1AvTtQ=; b=jUfm5Cn2cwJWNOM2prgSqprGkR LmBwKRhuxKAUtr8BE0MWy123wKScLJoAtBpp0gWtFk3qBzdvXx83AHH41KrVC1zrHidgkWPuXbrUN WfjD0ZrDlse8jhsHm3mVGDt2m2kicLbSXaIYsdsLwQGBh+zoXbupr5MgiE7h5bsNCA2miJz2l/Fzn JGs/PkNFCac9dJLJDLKFksQrmKWOn8+imY/f0PkCnuqNBHAGKE/4jhmFP0h25e/UcAXoK54snBzmr ASDFZdUINRldKxUu0XLKMVMG+6bqx2IQgdu4zsWwH2B//OzYxwHJGhCgXv+2qTr4vXqFF+Ng3qqub 1asVHOzQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y1-00EjE6-T3; Wed, 21 Jun 2023 16:46:01 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 07/13] pagevec: Rename fbatch_count() Date: Wed, 21 Jun 2023 17:45:51 +0100 Message-Id: <20230621164557.3510324-8-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2232410001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jxphd7wsufq7y76bsrk3pmswom8e7agd X-HE-Tag: 1687365963-377169 X-HE-Meta: U2FsdGVkX1+TeTEcicndVwDEwqyGew93IXSz5o5sgoWiKn8oeTH9EovpOqDz59z0NgLNCLRbz2bFFmdKlkPuNNNcgC2tGM3MX1osYyxlrCIoa/5Te0Fok6YloBvKjvQWWr2cEP9rOjReUVmdcmZQ6YA8fHwspk+/qeYb4nnMwx1ZAhYBrn05WUvM0cZOZbjGU5tyxGZCtoYkSuGqGC1RBdy7GE8cLveILRrbq1E2Sk9DW7kpqc8h1Uq6iGZd+hiQxvN6tExq/3RaVRxfH2Xw6ZIdPaKbyi5kIPf/29PYYhVVCAqRfBYa0nkDhLwghiKesLzhG2PF9KwBSJCs0/YeAaPNq4iG0RA4joVQ399jyLEy0sOZcGJd98eq3HT6Qk2mHeiSlFICLbprl5dAZS58I9tFBjN9C9QuclP/5Ldo+PV3zClcL6QjcG+TidT1c6qLxzrqIMUvc0vkUcoKHeMuJikB1Vb3188bL3fPvmO/xgfJ/KIC4IAPWKce+DElL7au9ZaOirZL3aljasdq/XyPnWl0J5e5vLWKXUkmPkPxBq8/KZacSaFkf3E0Il/NfXI09UojVLAZv1PVQibZ7wumeHMLGnp0Ncdy2GAk72ofoZvWUquu78VLWNizcvmigqLpsYIH6fnG/pz3LmIHYAqxJ8vj8rlrH3Ilto2zT68GyLjix+td8IB9Xewv7deY+acM2Wijd5RAXSyZ9BH6FU9Ie+10rITBUNsKI46xLb3gmnBJ+lEVATts2rffgzjvar/xBzji/6jLgQPrI9NQjnfbDEpNXREviyvuyWLIxVQUXmc9QsuWvCKDlEHR6G0i2CKKdBuiUT570hOnWq5fMvjPO3dFTqEFV9tIlEHYZBBSUbpEC8xjlJQKsscWiw1/pwjTTev6T81YC3yWAhHB74aGvT5QpoCtWTl0hA97CFaAw50jxoSzrQqOmZHavJIRuGyAEAKQg1C5PnFApPaHBdo nGO1aHGC i36CF7BkPD7EwkxcSHiI1Ile26NFDN5XKfkfOqmpIvz58iVoC+I4InXQeYzZD3XQaVR2lAYm2heNTz2/KWAnTR+5T+BJ7OZdtRndMKwReAqn+i9QcnJAAYNwlBt0merRdivSQTN8GpE3wQdp1DKcFBvahr1G7d2BEbq0igtNtlL5Dac4mSZv4/FdQzHqxWFSBlfSR8ckvupEv+P6y/Ff2h+uyDRMzpAbF969t 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: This should always have been called folio_batch_count(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 42aad53e382e..3a9d29dd28a3 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -105,7 +105,7 @@ static inline unsigned int folio_batch_count(struct folio_batch *fbatch) return fbatch->nr; } -static inline unsigned int fbatch_space(struct folio_batch *fbatch) +static inline unsigned int folio_batch_space(struct folio_batch *fbatch) { return PAGEVEC_SIZE - fbatch->nr; } @@ -124,7 +124,7 @@ static inline unsigned folio_batch_add(struct folio_batch *fbatch, struct folio *folio) { fbatch->folios[fbatch->nr++] = folio; - return fbatch_space(fbatch); + return folio_batch_space(fbatch); } static inline void __folio_batch_release(struct folio_batch *fbatch) From patchwork Wed Jun 21 16:45:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287650 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 98015EB64D7 for ; Wed, 21 Jun 2023 16:46:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C40098D0005; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72C118D0008; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 492828D000B; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1748E8D0006 for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id BA961C0942 for ; Wed, 21 Jun 2023 16:46:05 +0000 (UTC) X-FDA: 80927332290.30.D29062A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 95203C0015 for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PW4Dwh4G; dmarc=none; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S9L58IPbLSJMGWxFtvlnrG4TzIQ7IOqSwhUMe45kT8U=; b=Cyf01w27kFGmuVxKtmq8swP1SKyqs6aii5H27Gvx3+Cx1I4CHAq8t+VZZ4zDDOFv3tJcAF ZJbNW5xsLPUcASvbAdMcE38BUJz5iyAG5d1CY+nYdrPrEb5+NIyqAMA9CWcnnc93WV17t5 rk9nkwbONs3Cr7WMoRuOkoFCbny5K3U= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PW4Dwh4G; dmarc=none; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=MOmU9UIQ8Ve7gezvqbL76RnSmZ1Nirf2217llLPzzI1Bb9Rhp8yi4R5UyueVEkTDTOgDvl /1Uf/D2tCH/fYUTxG3+MOCkOcjNJBDAXKzIy5+EW+Z0su/IC5nFjUTR9zOPnrVfK9gzxKD i9OSuZGZBBmYlYBQKyFLgvN1WjJjHfc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=S9L58IPbLSJMGWxFtvlnrG4TzIQ7IOqSwhUMe45kT8U=; b=PW4Dwh4Gf1suM6iF8qmdwxhedV dGBA+OGAVi6nz1TzXhqQwejLNG6p8I/gHBdyJdF+v9Gwlfc+qXUjfsQRhEupLyGODb3oBlcxjqeZg MjDYrwlGzkp9KSAXfQWGPMLoY7z8XE2Ha7+Drv6kVcDGv88l6mKIj3vMNnmJc0wPJLF/1/j23opEa eo5D3L64k7UfoSUT0lpwRO6h7SIv4cOQ8G08UCt/pjyMlmUKsodXKsDFTzzN9xwAVenix5X7iC12y ymJp18fQp4MbBy2x2WRcwk0mKw0eF20AfD6Cvpc56WVKj7Wa6gjeZD91h/NOb3XGNU2NojtTr6joC HO//Edeg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEL-0r; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 08/13] i915: Convert i915_gpu_error to use a folio_batch Date: Wed, 21 Jun 2023 17:45:52 +0100 Message-Id: <20230621164557.3510324-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 95203C0015 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: c6j3dghcotn9kku1h18inezufon5mnpa X-HE-Tag: 1687365963-64682 X-HE-Meta: U2FsdGVkX1+N8Ic+yLR7oBJFAXfhEezjNSWxfIVanqn5INAJZsSRf1L8QDn5ZL9V6Dmx/eZHyImf4MF/KQ6Rd1dTaaqrqGAzWryltfo5k1ZKHO9ZoL3ho0FTuS4I005D5VWoWyQfK/qfr7xNpIHG0h4J58HzOB0g1nqdy+i0vAAVqKnB2Cl5sAx/XRV9VdPz2GHMsffKZGbZCTI2OwjylIbg0S8ITU41cd9jE89Hl38OBrZLJu78nHvGMQ9NNM4o2f+alnbZIE6FkxD3QF0Pxch/ltvtsF8bN8to+qCMuQRL23dvNam6zBCoAxB3qW1wigA1xS0bVhplt9+YPq0fyuHe0xpvrksGkwqLc2lRZ6DtSkEGniHOE11cawjW1i2l0bpjm9ZV3fh98i1H5v8VGqFzrNY78eXbRHk/DdxRVj3oEyYpQxc2WZe+blyO4cb/7gY3y6DwpjWyuwx5iB9f0jNR11Xjrg43bk+HV6w38psxvCn7FECCENJgj9nb0FRvNcJ3fgPN+CS7KR075+jK1ZtHfn5zrmYaEwrN3KuxdtwrM5klsrjiGMbrAgMaPuxN+AwrtQ3CdibllQ1DkPvvV44w4jKLoHdie388AwYuZJhJz3Bzh3cFVhnojP8l5QpjWyTmtoXPL+ZztjuZK8h99osheLKed2nudUr3BxwoSEzRLNJAQZMm08wHqIdHq+kW/MFzvkLl9ZLFNWDxJzhDpvjMSHckKSAJqqP2Y+3fkT+YJkqM9YK9oBXLkVneMd0tirJMAUdJiduxCnkWXRiS/sNPsOjcxlKu7EAF1FA6KYOcmZi7ICo823nAyqiiTzBAuKyrF2vPf6WB1uYgPK4S04fWMryhUCovodfCiaoVvWOE7HysGhvzlfTkAqlp9r7ygvJp7fTefLI0XiKlXXf40mmt4BbxO1ILqBJWb5lNR15Lc4JdX1WbKOIE4BjIQrGZ9jI39VnyB+jhRMVn1CE XNSTtZ3e SlDbbV+oyjq+HbwpsG6Uc50T1oisR/6p49GAtSgGVIG1hx4hcLeJa3i0kfPU1stveCoEwg2HaATQZW+Og0DCpTVOQ5OOgTDLLiF/PhtZjQFNIN0syJKJpoxoTOzVUgZ11qiUzX5Tlq9p4stZ6Mqn5hlL7oVB+cAKWroc3xotadrRmjthGxIfEGaAOZyAYQfF276oenmXxlmVxTj+QUpngf2CErqQRyqduWKqI 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: Remove one of the last remaining users of pagevec. Signed-off-by: Matthew Wilcox (Oracle) --- drivers/gpu/drm/i915/i915_gpu_error.c | 50 +++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index ec368e700235..0c38bfb60c9a 100644 --- a/drivers/gpu/drm/i915/i915_gpu_error.c +++ b/drivers/gpu/drm/i915/i915_gpu_error.c @@ -187,64 +187,64 @@ i915_error_printer(struct drm_i915_error_state_buf *e) } /* single threaded page allocator with a reserved stash for emergencies */ -static void pool_fini(struct pagevec *pv) +static void pool_fini(struct folio_batch *fbatch) { - pagevec_release(pv); + folio_batch_release(fbatch); } -static int pool_refill(struct pagevec *pv, gfp_t gfp) +static int pool_refill(struct folio_batch *fbatch, gfp_t gfp) { - while (pagevec_space(pv)) { - struct page *p; + while (folio_batch_space(fbatch)) { + struct folio *folio; - p = alloc_page(gfp); - if (!p) + folio = folio_alloc(gfp, 0); + if (!folio) return -ENOMEM; - pagevec_add(pv, p); + folio_batch_add(fbatch, folio); } return 0; } -static int pool_init(struct pagevec *pv, gfp_t gfp) +static int pool_init(struct folio_batch *fbatch, gfp_t gfp) { int err; - pagevec_init(pv); + folio_batch_init(fbatch); - err = pool_refill(pv, gfp); + err = pool_refill(fbatch, gfp); if (err) - pool_fini(pv); + pool_fini(fbatch); return err; } -static void *pool_alloc(struct pagevec *pv, gfp_t gfp) +static void *pool_alloc(struct folio_batch *fbatch, gfp_t gfp) { - struct page *p; + struct folio *folio; - p = alloc_page(gfp); - if (!p && pagevec_count(pv)) - p = pv->pages[--pv->nr]; + folio = folio_alloc(gfp, 0); + if (!folio && folio_batch_count(fbatch)) + folio = fbatch->folios[--fbatch->nr]; - return p ? page_address(p) : NULL; + return folio ? folio_address(folio) : NULL; } -static void pool_free(struct pagevec *pv, void *addr) +static void pool_free(struct folio_batch *fbatch, void *addr) { - struct page *p = virt_to_page(addr); + struct folio *folio = virt_to_folio(addr); - if (pagevec_space(pv)) - pagevec_add(pv, p); + if (folio_batch_space(fbatch)) + folio_batch_add(fbatch, folio); else - __free_page(p); + folio_put(folio); } #ifdef CONFIG_DRM_I915_COMPRESS_ERROR struct i915_vma_compress { - struct pagevec pool; + struct folio_batch pool; struct z_stream_s zstream; void *tmp; }; @@ -381,7 +381,7 @@ static void err_compression_marker(struct drm_i915_error_state_buf *m) #else struct i915_vma_compress { - struct pagevec pool; + struct folio_batch pool; }; static bool compress_init(struct i915_vma_compress *c) From patchwork Wed Jun 21 16:45:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287667 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 51D1FEB64D8 for ; Wed, 21 Jun 2023 16:46:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 543CE8D0007; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E12408D0006; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A62FF8D000A; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4FFFB8D000C for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 24992409A9 for ; Wed, 21 Jun 2023 16:46:06 +0000 (UTC) X-FDA: 80927332332.22.D3E8460 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 0EAE740005 for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="b7ub/H7B"; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=AQBN8EOVNpFsbWS+GiPKIXRePvvUD9BdImp+Rjg78p8=; b=Ikz/RdsU2xTfWYwkbjt84rH91nUxLeMNaqrng2Pm/Tyz9DNPulcyO6fONngEVPxqRz3EK3 q36okkOXo1AMyDoTuZowDPzSn8Yw8oFj0aid8KSz4cAVunO9rdo6rjOfstFthPamDl3Pky tmEluNTyhC2IksjU/fJZeETnJzX49DM= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="b7ub/H7B"; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=wuj8ThslDC5QxEviCeuzAnyjh7klD6DlkJk4vT2DWTQt6w3QbodN5ZFMcLL46HpLzhl8Tx EFFjyO0ZLnPMMjx4p1iWOuJFUbfdQ4uh/UFiRmkQy21AESyQmxcQ2Qq/pZmBeZcQu/KVfh rMPLxbHn1v5MltBT+WKS0scM4Kg/ols= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=AQBN8EOVNpFsbWS+GiPKIXRePvvUD9BdImp+Rjg78p8=; b=b7ub/H7BmTbgUPuQXUwrP95FRP 0IEUGdTz1HyQpbYbP/rbXcBqz+W7V+5ZyOjKUhJSJl1n0gWxNajfSW0gpLlDNGLr+5x3X7lQR0rGc sJWHL9uXmDvqiZXMwcdWkmeIwBlxZ0p2TGny4RZf+u9Oy/cwjqb38MgaLGQbLvGbHq+8CEI/DGZKo gUMOu3TMpZs3AvjXPtNNn7A40mwTZlRy5EJveUHHXZJ+ekg0kRdv2vQGboivcW/SubBxp2z4OSPtU 9wVf5kjxK4hgOVoj68acJOECaVXYQcN43ZnqYfbigs2K4HQL3lMwUjSgTAavCrqxUYqENlRUp9rhI tkXqYsRw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjER-5C; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 09/13] net: Convert sunrpc from pagevec to folio_batch Date: Wed, 21 Jun 2023 17:45:53 +0100 Message-Id: <20230621164557.3510324-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0EAE740005 X-Rspam-User: X-Stat-Signature: xmn61rpjwmn4mmxd15q7aeqp7rausc4c X-Rspamd-Server: rspam01 X-HE-Tag: 1687365963-163921 X-HE-Meta: U2FsdGVkX18TvpNkDY8XcGtjXqAl25bX75i8EAvCmMpPQMVK1EfTCSquo5Bvc/4nLS5emynqFhXgXfMPmgcFkOJerEsDaS6g+KhOFQgZNWJueK+89Q46zujHubHMpAChYHtfS8hY1qxVM8ygZX2r/tnEq9Tn/FVsoUyq923Sm95dW2NHJu4wRdhjNnqvhsm1foaVdP0t7Glitk/onBnEHAfnPgn/5KPuYNZKuji4wqwye+KGTU6R9mMYolK8GSsY9Z/HhWuQm3uEqTQip8+G4K/RO0DbPV7l88tuPsu07MKcxi3h0cQDmi9U97r7oeXeHUX21vYCFP6pxhG6fmtLBE0iY9q7PiU3sYkAuxzQ4ha6hlE9SJaL3RxvoYhEkc1McGYiub67bVQqmVQNsKpycT/fZyN5CZHoB6IYHlaVd47westNqLju/65n3mo4bVsvhv5/ORL9NWDSYSX7VzvqQ7Eau/5Q6P6cSL389l2KdiEocq6B+AerJrAIAd8Wu44Hav92gCbmrHsHdt2yKyBlAKMr6pouTRz7sUHINGjyK7Pyf52yeUc5x9C6dzqyRp9LG3f5LArW2J6BmR0oGKVfFEMpX2DgUre4aVabry1uUn9pPS0m+rjhJwCN1DyPCR3CPjYS0PsytOj7J8qkhYjrP/G83xZn8t28mUTMQhuTv4B4EUXJPVOCQVcjvEcJkD350VwCHCtBS4NSi0IjKSD4a5AEh5f5Tk81/PeAQ9U+hNnTnWrle49b2HYjXGbE6mToShXTBJylCPvQufH9KCwfaeqq0+ezmbXrkaUiDNSUdhVETtWEV4ufzuWUzHrLZ1kIHefzBEe7aTRf7tLzZ4+Jw+vEhVjj8b9d+NZNOW883WlgLpvqxnkcL+W9XkiE8qgDNOWzdGn5c0MBEPl0bwnonUbVAQ+FKpXSr+gj5MUM5aWY+0RL0/IJL+QVkEEV9P3kLrB+r6y5xBjuQ9G7iYU y5Nsm5jz w3HMCarXbpwTqs1QKNaF0bpxCTQhpzFEUd5sbWrIlMb2wqsgMIdC/Gxbd5MNMsI8LS0TskNbt7zouHf3ktpbQM6R8sYRO35HxBC2Guhh73iMZv1gutIggrk9p1cJT176gnVVPnx3bE+m2Kd4xNoeAnxGTE1rYOUJO5A3SiCopFBAmgivSIq+x5KX9dgrpdy6PEauV3A1w/Jc+HZBvGAZyZIpG2STypz4aRA30 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: Remove the last usage of pagevecs. There is a slight change here; we now free the folio_batch as soon as it fills up instead of freeing the folio_batch when we try to add a page to a full batch. This should have no effect in practice. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Chuck Lever --- include/linux/sunrpc/svc.h | 2 +- net/sunrpc/svc.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index c2807e301790..f8751118c122 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -222,7 +222,7 @@ struct svc_rqst { struct page * *rq_next_page; /* next reply page to use */ struct page * *rq_page_end; /* one past the last page */ - struct pagevec rq_pvec; + struct folio_batch rq_fbatch; struct kvec rq_vec[RPCSVC_MAXPAGES]; /* generally useful.. */ struct bio_vec rq_bvec[RPCSVC_MAXPAGES]; diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index e7c101290425..587811a002c9 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -640,7 +640,7 @@ svc_rqst_alloc(struct svc_serv *serv, struct svc_pool *pool, int node) if (!rqstp) return rqstp; - pagevec_init(&rqstp->rq_pvec); + folio_batch_init(&rqstp->rq_fbatch); __set_bit(RQ_BUSY, &rqstp->rq_flags); rqstp->rq_server = serv; @@ -851,9 +851,9 @@ bool svc_rqst_replace_page(struct svc_rqst *rqstp, struct page *page) } if (*rqstp->rq_next_page) { - if (!pagevec_space(&rqstp->rq_pvec)) - __pagevec_release(&rqstp->rq_pvec); - pagevec_add(&rqstp->rq_pvec, *rqstp->rq_next_page); + if (!folio_batch_add(&rqstp->rq_fbatch, + page_folio(*rqstp->rq_next_page))) + __folio_batch_release(&rqstp->rq_fbatch); } get_page(page); @@ -887,7 +887,7 @@ void svc_rqst_release_pages(struct svc_rqst *rqstp) void svc_rqst_free(struct svc_rqst *rqstp) { - pagevec_release(&rqstp->rq_pvec); + folio_batch_release(&rqstp->rq_fbatch); svc_release_buffer(rqstp); if (rqstp->rq_scratch_page) put_page(rqstp->rq_scratch_page); From patchwork Wed Jun 21 16:45:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287668 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 B2AA2EB64DD for ; Wed, 21 Jun 2023 16:46:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 800F58D0006; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13A268D000D; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 926628D0006; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 452768D000A for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0F328B02CA for ; Wed, 21 Jun 2023 16:46:06 +0000 (UTC) X-FDA: 80927332332.24.01CA071 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 212C61C0006 for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SA7wCjqc; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/u3R6ommui0jzmNm5KqQbCKjAYY2UMYMLfe/n8/4JuI=; b=atDuVY91wX/2cMHPZZ3HAB5ulPf/dIYGGOF/hZEiLgxKW1GguDlqTcSc5wAOHGCA2VbFP6 /q4MHUwid2rdVxVxbBOHJ9cPQQmGWETusdLmxMDm34i4aihlnvBdhqGlBmebx3q3Q6lziS JHXRoJicxf+GGf/L1QGdBGQDakwXUD4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SA7wCjqc; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=e8PB+MJREmPoIeCK6zrm2x+9ecDJ2JkOrtUyQDnGJqumSMPBBErBtVN0N8YdCRfLa5UDX+ tN0TNs8bXLwldoJrFa9tAAMhzt0QbNXIXcZUVvH7FjFJ2MxPuK+hPT2NsD2DkUrym1w/7M G5/0PLuRo+sv/VVkOIG/kIJ8Szg0j3g= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=/u3R6ommui0jzmNm5KqQbCKjAYY2UMYMLfe/n8/4JuI=; b=SA7wCjqcWMwZI6QRZjnXU4BdsS H2NVvLwwEgWYTdDfqbIir6UM//Pdysn6BSpEU5tQrwXLiUi9lYRn6b1kZ9qx1fAUBvXd7kLDwwkhY 5AAQLBbNy1luSMqNDTeWh+iK0WGYWrfqKDGYqZciSOpheoDHNVBuHpWm43NXX9E4ZJXfruCyIH/UW HB+wG8b8HwLzzjf53mwVPcA53m7cznZE0yRcrwmRkU0fOjoCKs9ya07eXP9QmjjMztGSPQSsClls5 jOcuaSGUbCg3/YuJMblU2LvWjfE9SoN7h5k2L6Zq6mpZcMsd5xCOJiy9+fCqNLsH/jrQq/u4kXAFF K/koQlnw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEX-9H; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 10/13] mm: Remove struct pagevec Date: Wed, 21 Jun 2023 17:45:54 +0100 Message-Id: <20230621164557.3510324-11-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 212C61C0006 X-Rspam-User: X-Stat-Signature: rq97zf9dfzf7r8c4jbgo7tnep5don83f X-Rspamd-Server: rspam01 X-HE-Tag: 1687365963-469386 X-HE-Meta: U2FsdGVkX1/5+cQtt8W17/AwehMKLtvOuyqbpGTOfB1Ycg0qGlLCJHT5s0ewKGKfkCaU3/KBCqgWwzyZuT904vOfDjCBCH0juWrQDBvJveIyvn1/upDfC8DT1weaIorPtw5oXc0dT6Ie0mPr7JdMIL8Ij4rejeOBRIivMz/SUpPPJRDO7BffbjEC3vn52bsQHp7kfEcTvKhICBR+pUJGOE7ldzo0K/TpKzxt7VuwtUDH/D9bplz9JqqQf+IAOAem9XFUauHLukfT0Y245i/s/hvlRNk9VynkB4e1zejnQoMFqRkK7+ZooeTcR8kmcipRRGCBnR3AEVXzK4O/CxqEB097gguWmv9XjRTRhkD6JsViR/ldEGhY3GhBeCAiuHUUXO4cvkLeKmp9Jq/1OH6u12CfxsBj2LlolIASZO1Wq+mSUQDC/SJtbE4b5yvFkBzpbGY9+2Xaqib3iGc8WaS+NxpuL9gW9CzvKtfAaq/syOGHUWGfSzPtiE8SAIalAjEzH+ekFPvCBh3h2N/90VERuK3sn1uF2Amt1yOhP2Ys6RHqqpOpLYOZCduxVD0k1OsigUjIf1wZqrDwvQ8LaFNHI4ofqNYkOeEDgam0G33pShKhcGLDIjjf5rcqbBUWS2PkNB69GRBvgEwOtJlqWF/OUXxQLW4YijZlp/upTeNmOxXAz6znrAPdvQRI7AlTxeWLVYxkN0hwlo700fEDlkmp0zaIMcREiEgPrsTqJwlvkXOw+PcKYq78m2MaNp1IxzC5blyeCXtN3VGC2YnT/6ELGIUpQplGfXxygvgqfBJRffmdNsSjiqN5bRfCqvNHG8AH0Fw2FuBW5AC4WBLNo75Z22ZtWc6vYrdjJUVpfWpqAAQm2lpQltHs7Akvy6oAAJcCD8XavD6L/nWLzPJBwEgkR9LeQqhzfot4XMajaWkK3o5T5cWJkY2JG+s+HTf8ueC6FszKqhZ+sybaUOq1WI0 irPkHDDH u22WtPrb14hfAatLrelZxEsezVNdmeeKDP7UGY9WbPGKuWcYmCIJSky01y/+yYq0VybfXI1KNxJaLb+2U1uZRGAotQN4hgH/TDQPxwr/MbrQ1gDXhhvSvFyOlBaJBALKPGWIUOr4+F30hqjZQY9JiGB3oc96wrM9qsUZNAkd/JdlaDHg5ml3OUJidfg== 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: All users are now converted to use the folio_batch so we can get rid of this data structure. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagevec.h | 63 +++-------------------------------------- mm/swap.c | 18 ++++++------ 2 files changed, 13 insertions(+), 68 deletions(-) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 3a9d29dd28a3..87cc678adc85 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -3,65 +3,18 @@ * include/linux/pagevec.h * * In many places it is efficient to batch an operation up against multiple - * pages. A pagevec is a multipage container which is used for that. + * folios. A folio_batch is a container which is used for that. */ #ifndef _LINUX_PAGEVEC_H #define _LINUX_PAGEVEC_H -#include +#include -/* 15 pointers + header align the pagevec structure to a power of two */ +/* 15 pointers + header align the folio_batch structure to a power of two */ #define PAGEVEC_SIZE 15 -struct page; struct folio; -struct address_space; - -/* Layout must match folio_batch */ -struct pagevec { - unsigned char nr; - bool percpu_pvec_drained; - struct page *pages[PAGEVEC_SIZE]; -}; - -void __pagevec_release(struct pagevec *pvec); - -static inline void pagevec_init(struct pagevec *pvec) -{ - pvec->nr = 0; - pvec->percpu_pvec_drained = false; -} - -static inline void pagevec_reinit(struct pagevec *pvec) -{ - pvec->nr = 0; -} - -static inline unsigned pagevec_count(struct pagevec *pvec) -{ - return pvec->nr; -} - -static inline unsigned pagevec_space(struct pagevec *pvec) -{ - return PAGEVEC_SIZE - pvec->nr; -} - -/* - * Add a page to a pagevec. Returns the number of slots still available. - */ -static inline unsigned pagevec_add(struct pagevec *pvec, struct page *page) -{ - pvec->pages[pvec->nr++] = page; - return pagevec_space(pvec); -} - -static inline void pagevec_release(struct pagevec *pvec) -{ - if (pagevec_count(pvec)) - __pagevec_release(pvec); -} /** * struct folio_batch - A collection of folios. @@ -78,11 +31,6 @@ struct folio_batch { struct folio *folios[PAGEVEC_SIZE]; }; -/* Layout must match pagevec */ -static_assert(sizeof(struct pagevec) == sizeof(struct folio_batch)); -static_assert(offsetof(struct pagevec, pages) == - offsetof(struct folio_batch, folios)); - /** * folio_batch_init() - Initialise a batch of folios * @fbatch: The folio batch. @@ -127,10 +75,7 @@ static inline unsigned folio_batch_add(struct folio_batch *fbatch, return folio_batch_space(fbatch); } -static inline void __folio_batch_release(struct folio_batch *fbatch) -{ - __pagevec_release((struct pagevec *)fbatch); -} +void __folio_batch_release(struct folio_batch *pvec); static inline void folio_batch_release(struct folio_batch *fbatch) { diff --git a/mm/swap.c b/mm/swap.c index 423199ee8478..10348c1cf9c5 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -1044,25 +1044,25 @@ void release_pages(release_pages_arg arg, int nr) EXPORT_SYMBOL(release_pages); /* - * The pages which we're about to release may be in the deferred lru-addition + * The folios which we're about to release may be in the deferred lru-addition * queues. That would prevent them from really being freed right now. That's - * OK from a correctness point of view but is inefficient - those pages may be + * OK from a correctness point of view but is inefficient - those folios may be * cache-warm and we want to give them back to the page allocator ASAP. * - * So __pagevec_release() will drain those queues here. + * So __folio_batch_release() will drain those queues here. * folio_batch_move_lru() calls folios_put() directly to avoid * mutual recursion. */ -void __pagevec_release(struct pagevec *pvec) +void __folio_batch_release(struct folio_batch *fbatch) { - if (!pvec->percpu_pvec_drained) { + if (!fbatch->percpu_pvec_drained) { lru_add_drain(); - pvec->percpu_pvec_drained = true; + fbatch->percpu_pvec_drained = true; } - release_pages(pvec->pages, pagevec_count(pvec)); - pagevec_reinit(pvec); + release_pages(fbatch->folios, folio_batch_count(fbatch)); + folio_batch_reinit(fbatch); } -EXPORT_SYMBOL(__pagevec_release); +EXPORT_SYMBOL(__folio_batch_release); /** * folio_batch_remove_exceptionals() - Prune non-folios from a batch. From patchwork Wed Jun 21 16:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287669 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 C5504C001DB for ; Wed, 21 Jun 2023 16:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A49978D0008; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26D828D000B; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF2A98D000A; Wed, 21 Jun 2023 12:46:06 -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 A90528D000C for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 57D7A40987 for ; Wed, 21 Jun 2023 16:46:06 +0000 (UTC) X-FDA: 80927332332.23.99AB132 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 33EF48002A for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=t7EgP9l+; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=H7xjtBA+jzTamJkZvSrBReaOKW0qDsx5kc7RVJ9s550=; b=JHcGmnK/qaepHputZJTg07QqWViQ6QuymZMfXPRhCrA7f2/8QKzwnPFkfXoAASASLBIZln PjpQFD0cyTq60IKV1IE+CKi5Iu9aIwbQf3UIpfFORldjU87+XFMkNx9fw2ClXjxzNyz/Z3 +zY6g+ti6GU6MDZqaaMxlPgPoOs5ZJA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=21YFTUGrDfxwSJVTJYDYq3DjQfwFuTklCznCPYlEwiUli5tzl36f+XtOXnfPocZ8lW+x9A rozXmUOc4NeskPKi8Xp5zEgAx79oEwvVKiQXMW+YAFy8L2dfD0UwTkYCj24IW1kie+nE// pq9PpnPW8H69lbALWB6bl88UNXkOzeE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=t7EgP9l+; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=H7xjtBA+jzTamJkZvSrBReaOKW0qDsx5kc7RVJ9s550=; b=t7EgP9l+MssKQftiMAo7VAdBCc Nv98h8aNtVO16LGaXGeEq2m9ltD2DVLbWxZHMVIHdnansE52q8B0dmRkBjGAlUiCMoIMy/OreImcr 5cqHvjHzMp6Nq3yxahSKcv8h0zZPtEmJc2nmPl3Y7HZoHQEaS6cdgbsAZkrux0e53j9vMSEKgXdOK EKZ68SjKoRwct8bGiDcah4w9QZ3tVXt3ANsdqnDF3UeEkp2GKmn12AODcUbhsUcILgUOYmiiBAZWV 9DXjTmPrk3hO4ePJxd9hC8YahWikG3UdRtJUwE1RGLdoobQf/AQ8MdhsOblwR8sJo3t78oQYQslj4 WpEPi5ag==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEd-D4; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 11/13] mm: Rename invalidate_mapping_pagevec to mapping_try_invalidate Date: Wed, 21 Jun 2023 17:45:55 +0100 Message-Id: <20230621164557.3510324-12-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 33EF48002A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: o3cpncjmgrxtff83en78dh981w5br4ht X-HE-Tag: 1687365963-901829 X-HE-Meta: U2FsdGVkX18UCLj7VYi77QYFcvB+tqNvFHOWKi0h9+92w8LO7+5TEf9qBuIZv7LQaDrQ4tS3cFH2GI6bmVQ7iFiq3L5xwkTv+t+ioD1qMoyfKFX38fQRyhndDzopgeQsr4paa2I47xjD9/g6Cg/MbrTs32B753Lh+aauvJ/F4XytsxTuGI3QwuWQ4VqAh0+vmUdVJVZAmQz2NHkHygmU16Dt2HHbFLl1CpdgzpuvRcGLjcbp+4lUApG/cQ5LszONW56KZSIwFcMe7IEFYnrM9DT4Hlvoeavp1d/l1ckj9i5kSWU1hC4lkRQPSnhuBJimlvOfayAkdc5A/4/dkH11iBgcTi7L1ySyH8ZqihV+daF8xKhmcKqrvZV8Bv0axIypYE1mOBcyyMq5G/cHf/O0tB2AjQZioMxxLIEGyf+iP80z1npill4O1KpgY5Va4biB60GX3UNUcBmFHpTzmvQzZav0zKkxT5L8nPjnpTCiRBMrsuN6fqvdgTl0Tk4lm5asLtvbRdO4Dht6fQJ7AgDHas2I0EkiX1Dre4gpieK5HiNS/jSKJtu3K26JtUycHay5eOXr2P6mSS8dL9FXNGyvLVqXojIW2ol4UP/a9M/7H2aHEw28curR/7iB39c/bgbid/rUfmdm54+YTVxf+Ur5fEGqUKraVEIWwsVbYKSI7l6TGRKuBxAYbmQG0KxUlZfjY79Cgy+5xTVtT7E7GyEHsmFnd0TM62vVsE8nUZ3bDXaBtWx1iEwWPD0NRhFdLi7/A1eW+nz5Rja9D+tz0+fhoiYVwiw9i/8fRVr8F4okbtSL4HUoiCRvAsY7NvQukmgCTZl3FOdR71nHlsnC1+O+DtMUkrEoQgm7QYbCUmMp7xF4au/OD9NfP5Lc61pknut0/AtCh8tJ2cVOqvO/OjxGhlSHnrzvGrn6CRJKkGCtc2/4qIfoLw0pg/31WJogxoWzc/774XL2k7yzT67+3Cu VFWhN47s qplIKOBYAvwwHhdvd9b17uZ/LKjr+vvc8aLcPmr8pw0V29SRfBbnAWWt8bfruaOBb6851rSh72f1lk1jbfVjm0+eI+rXsapH5UmqQtYQgfKNc9U9LKPRb1M6AN1G2NGHBvxNB59np+Cw1D1Vmi5B+hw2kDHwqDVK7dLuoKDUSLixDM+MGeza2mubzhu4S7DuPqcu/0xiRB1pg4xFJG7ZcxrqfD83pWl/7v1y+zAXo9INtwpo= 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: We don't use pagevecs for the LRU cache any more, and we don't know that the failed invalidations were due to the folio being in an LRU cache. So rename it to be more accurate. Signed-off-by: Matthew Wilcox (Oracle) --- mm/fadvise.c | 16 +++++++--------- mm/internal.h | 4 ++-- mm/truncate.c | 25 ++++++++++++------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/mm/fadvise.c b/mm/fadvise.c index fb7c5f43fd2a..f684ffd7f9c9 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -143,7 +143,7 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) } if (end_index >= start_index) { - unsigned long nr_pagevec = 0; + unsigned long nr_failed = 0; /* * It's common to FADV_DONTNEED right after @@ -156,17 +156,15 @@ int generic_fadvise(struct file *file, loff_t offset, loff_t len, int advice) */ lru_add_drain(); - invalidate_mapping_pagevec(mapping, - start_index, end_index, - &nr_pagevec); + mapping_try_invalidate(mapping, start_index, end_index, + &nr_failed); /* - * If fewer pages were invalidated than expected then - * it is possible that some of the pages were on - * a per-cpu pagevec for a remote CPU. Drain all - * pagevecs and try again. + * The failures may be due to the folio being + * in the LRU cache of a remote CPU. Drain all + * caches and try again. */ - if (nr_pagevec) { + if (nr_failed) { lru_add_drain_all(); invalidate_mapping_pages(mapping, start_index, end_index); diff --git a/mm/internal.h b/mm/internal.h index 119a8241f9d9..2ff7587b4045 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -133,8 +133,8 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio); bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end); long invalidate_inode_page(struct page *page); -unsigned long invalidate_mapping_pagevec(struct address_space *mapping, - pgoff_t start, pgoff_t end, unsigned long *nr_pagevec); +unsigned long mapping_try_invalidate(struct address_space *mapping, + pgoff_t start, pgoff_t end, unsigned long *nr_failed); /** * folio_evictable - Test whether a folio is evictable. diff --git a/mm/truncate.c b/mm/truncate.c index 86de31ed4d32..4a917570887f 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -486,18 +486,17 @@ void truncate_inode_pages_final(struct address_space *mapping) EXPORT_SYMBOL(truncate_inode_pages_final); /** - * invalidate_mapping_pagevec - Invalidate all the unlocked pages of one inode - * @mapping: the address_space which holds the pages to invalidate + * mapping_try_invalidate - Invalidate all the evictable folios of one inode + * @mapping: the address_space which holds the folios to invalidate * @start: the offset 'from' which to invalidate * @end: the offset 'to' which to invalidate (inclusive) - * @nr_pagevec: invalidate failed page number for caller + * @nr_failed: How many folio invalidations failed * - * This helper is similar to invalidate_mapping_pages(), except that it accounts - * for pages that are likely on a pagevec and counts them in @nr_pagevec, which - * will be used by the caller. + * This function is similar to invalidate_mapping_pages(), except that it + * returns the number of folios which could not be evicted in @nr_failed. */ -unsigned long invalidate_mapping_pagevec(struct address_space *mapping, - pgoff_t start, pgoff_t end, unsigned long *nr_pagevec) +unsigned long mapping_try_invalidate(struct address_space *mapping, + pgoff_t start, pgoff_t end, unsigned long *nr_failed) { pgoff_t indices[PAGEVEC_SIZE]; struct folio_batch fbatch; @@ -527,9 +526,9 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping, */ if (!ret) { deactivate_file_folio(folio); - /* It is likely on the pagevec of a remote CPU */ - if (nr_pagevec) - (*nr_pagevec)++; + /* Likely in the lru cache of a remote CPU */ + if (nr_failed) + (*nr_failed)++; } count += ret; } @@ -552,12 +551,12 @@ unsigned long invalidate_mapping_pagevec(struct address_space *mapping, * If you want to remove all the pages of one inode, regardless of * their use and writeback state, use truncate_inode_pages(). * - * Return: the number of the cache entries that were invalidated + * Return: The number of indices that had their contents invalidated */ unsigned long invalidate_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t end) { - return invalidate_mapping_pagevec(mapping, start, end, NULL); + return mapping_try_invalidate(mapping, start, end, NULL); } EXPORT_SYMBOL(invalidate_mapping_pages); From patchwork Wed Jun 21 16:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287670 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 BB8F1EB64DD for ; Wed, 21 Jun 2023 16:46:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D331E8D000B; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63FD48D000E; Wed, 21 Jun 2023 12:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E4478D0008; Wed, 21 Jun 2023 12:46:07 -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 EA1968D0008 for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BB2C01208CC for ; Wed, 21 Jun 2023 16:46:06 +0000 (UTC) X-FDA: 80927332332.17.02874CA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 6420F180011 for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fVZ+hZCi; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365965; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6bhEYpaGLo7Jfiv7Oy69a9Rbop+oIUfrkuAWfFjKyOQ=; b=tMhcehqaYNRhKNN+Py6GR3KjkBe3PE+d1DyUk2o5dRtWAL9IfmdKLv+p4qdv4/UH5hrlwf WBRdZvHxOD3TzWEzXonE0f34+MPbR6HrzROcSQt3VSR79lhCcRBN7lxt++t1QR/7P1JvvB QFzarrIyt6wxfOTXcWxwzR4JIdSw/2s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365965; a=rsa-sha256; cv=none; b=TllHEdYfsM/RqdwJjB1OTN0PcD0u9kC0o90djOa3pF7t1vp+HdRETYxCLG4GwJuy3odyyQ viM5gH6ZL8uKTQ7bpAq1WtFfyT2VasQt07+0zgeHbOgeOY+nAjTpEQK3S6gT/V8BoPCbPf yDZ7sl0ybwVdLI18ttwdCyxk7eGGEqo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fVZ+hZCi; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=6bhEYpaGLo7Jfiv7Oy69a9Rbop+oIUfrkuAWfFjKyOQ=; b=fVZ+hZCi7U6/W3v6NYZl+xn2jM 1lVvZ/cm5oqnPHkQ4EN7CqyGeAw3OMc02BCqfH3FTZmTMHtCBD4UugTykydjG+4AmzTCgaS9E8NLc wKJc9To6lc+TRJYTmbE9iZpa5GxvUxBx93xjO14Of2MZUZKkLfhAFBexr19TA9W5Gd5B2U373kAvV GmaNimalG9cGk8dLFYvIyCnvuLSvif6kbPYg/4lQKcbQpvf5FV10wKGWpAg6nhnlY9wVPc67Bm56J qj3Q3UL1kqOhdvt6U+UEl8OlB/v8JQGW4W3cGebFFTHD4WcBZZyOxiaJ0GfE+kgOuTUknBoJ8vlyb be8Lx8Hg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEj-HR; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 12/13] mm: Remove references to pagevec Date: Wed, 21 Jun 2023 17:45:56 +0100 Message-Id: <20230621164557.3510324-13-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6420F180011 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: py4wnhr55kfdr8ift6gw9c16o78njzs8 X-HE-Tag: 1687365963-577649 X-HE-Meta: U2FsdGVkX1/F0ERC+oLxvFHKS0EOhf8+ffowecUb+/O6qGwUIzB5ilFoihjkV7qz95Lu1e1WLyNw7ZT0Cr1q/NAllMSxCWTyLlWG0K8n4O9fsBsjF6uLREE+n9Gaf3bGoZe8a1NgmkwApGcEZmmC4jdOc1Q8u/04P+CpaW2zkcOxkTSlF14AJF4Xz8pZFqbmuGp2RzntI0W7KKjbfPLaLb8WcGPtp616bzGX9ps8/zRplZwpUZOQG3Y1kEKWH9TB7Q8APv2ArVY9Y5HRs8ouOuX3V80Y8t/VkMH6vWR0MKgtNnC5AOPkWgTYOCa/0kMMEBFVUPpuh9ou+/zIZC73gKQhLMl844L5LRDazpQ2Ggh4K2u3pa0QYdMzgY0DvDrr2BsVPm8njkFsyXZs/N5aDGW72kRsuGbyYfHT753nJ8I6ji+gh/DWD4u9yYIWAd4NFFY8ThCTK10clJJmpRF26N5PxjBOTDcLRBkMDSDbIEBbXQpdpwVQ+dY5eaQRDRYG7jKBrbFCNbMiFSKPd6CwNbklhPesAhy9WzNvBBxWypMo6bop13sZduXONeRaEjw8iVAAdj/Jzc+eeLmok4GfR5N+vbfSdzZbF9pK+g+zey7HjMOm9Ar51uNv7tMQGC2ojaq2gQl3Rn33ilgYcO5bmz18uKaAXci6CrACduw7QR1RfrxCJWB8M2KQNPAqIo+vS3XmjnHNaBcVX3pytPefhjcqiaWWVeYY/uAAehJATQmeymo/oFtYqwK4BTDqE4BK2AxNmqrJqMOUqfkLRtRkcLOcHJAeutyhD2Wi7jdayWuyiYTJ6l3atqu2D/miQ/VhAgo+HZGAlParlWvswqPp6h9FjmiMUHDCAOFmIIhh+UuU4r2eknBYCbY2U/BM+ZyoyweX9p8hZrYuRZMK2NQ+CHkdua8iYbMzuwo03xGXQjfMfUpPkaHCaRZtgtg7urxrENGFVJQIlTq9GchEwBo kVMm7i5X tRkoULhwKf0FOAbD0d0426vXLBrWOvPslX4RgEQQD+rh6YgZ4EE0Gwcm1rIZLpeL3pC3ZzZYWORyCS1oXwvIFn2MDSuFE53Je3d3b2D6OsLhCN5n/eHr9PprHAS9t+BGR86kfRd0OfbskpoNZWDER9ZChmRizgOKlCY0zJDl9i34Uvf3hbC8Q2VjOLQ== 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: Most of these should just refer to the LRU cache rather than the data structure used to implement the LRU cache. Signed-off-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 2 +- mm/khugepaged.c | 6 +++--- mm/ksm.c | 6 +++--- mm/memory.c | 6 +++--- mm/migrate_device.c | 2 +- mm/swap.c | 2 +- mm/truncate.c | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e94fe292f30a..eb3678360b97 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1344,7 +1344,7 @@ vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf) /* * See do_wp_page(): we can only reuse the folio exclusively if * there are no additional references. Note that we always drain - * the LRU pagevecs immediately after adding a THP. + * the LRU cache immediately after adding a THP. */ if (folio_ref_count(folio) > 1 + folio_test_swapcache(folio) * folio_nr_pages(folio)) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 5ef1e08b2a06..3beb4ad2ee5e 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1051,7 +1051,7 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm, if (pte) pte_unmap(pte); - /* Drain LRU add pagevec to remove extra pin on the swapped in pages */ + /* Drain LRU cache to remove extra pin on the swapped in pages */ if (swapped_in) lru_add_drain(); @@ -1972,7 +1972,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, result = SCAN_FAIL; goto xa_unlocked; } - /* drain pagevecs to help isolate_lru_page() */ + /* drain lru cache to help isolate_lru_page() */ lru_add_drain(); page = folio_file_page(folio, index); } else if (trylock_page(page)) { @@ -1988,7 +1988,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, page_cache_sync_readahead(mapping, &file->f_ra, file, index, end - index); - /* drain pagevecs to help isolate_lru_page() */ + /* drain lru cache to help isolate_lru_page() */ lru_add_drain(); page = find_lock_page(mapping, index); if (unlikely(page == NULL)) { diff --git a/mm/ksm.c b/mm/ksm.c index d995779dc1fe..ba266359da55 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -932,7 +932,7 @@ static int remove_stable_node(struct ksm_stable_node *stable_node) * The stable node did not yet appear stale to get_ksm_page(), * since that allows for an unmapped ksm page to be recognized * right up until it is freed; but the node is safe to remove. - * This page might be in a pagevec waiting to be freed, + * This page might be in an LRU cache waiting to be freed, * or it might be PageSwapCache (perhaps under writeback), * or it might have been removed from swapcache a moment ago. */ @@ -2303,8 +2303,8 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page) trace_ksm_start_scan(ksm_scan.seqnr, ksm_rmap_items); /* - * A number of pages can hang around indefinitely on per-cpu - * pagevecs, raised page count preventing write_protect_page + * A number of pages can hang around indefinitely in per-cpu + * LRU cache, raised page count preventing write_protect_page * from merging them. Though it doesn't really matter much, * it is puzzling to see some stuck in pages_volatile until * other activity jostles them out, and they also prevented diff --git a/mm/memory.c b/mm/memory.c index 9f2723749f55..d034c52071f4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3404,8 +3404,8 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf) goto copy; if (!folio_test_lru(folio)) /* - * Note: We cannot easily detect+handle references from - * remote LRU pagevecs or references to LRU folios. + * We cannot easily detect+handle references from + * remote LRU caches or references to LRU folios. */ lru_add_drain(); if (folio_ref_count(folio) > 1 + folio_test_swapcache(folio)) @@ -3883,7 +3883,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) * If we want to map a page that's in the swapcache writable, we * have to detect via the refcount if we're really the exclusive * owner. Try removing the extra reference from the local LRU - * pagevecs if required. + * caches if required. */ if ((vmf->flags & FAULT_FLAG_WRITE) && folio == swapcache && !folio_test_ksm(folio) && !folio_test_lru(folio)) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 02d272b909b5..8365158460ed 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -376,7 +376,7 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns, /* ZONE_DEVICE pages are not on LRU */ if (!is_zone_device_page(page)) { if (!PageLRU(page) && allow_drain) { - /* Drain CPU's pagevec */ + /* Drain CPU's lru cache */ lru_add_drain_all(); allow_drain = false; } diff --git a/mm/swap.c b/mm/swap.c index 10348c1cf9c5..cd8f0150ba3a 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -76,7 +76,7 @@ static DEFINE_PER_CPU(struct cpu_fbatches, cpu_fbatches) = { /* * This path almost never happens for VM activity - pages are normally freed - * via pagevecs. But it gets used by networking - and for compound pages. + * in batches. But it gets used by networking - and for compound pages. */ static void __page_cache_release(struct folio *folio) { diff --git a/mm/truncate.c b/mm/truncate.c index 4a917570887f..95d1291d269b 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -565,7 +565,7 @@ EXPORT_SYMBOL(invalidate_mapping_pages); * refcount. We do this because invalidate_inode_pages2() needs stronger * invalidation guarantees, and cannot afford to leave pages behind because * shrink_page_list() has a temp ref on them, or because they're transiently - * sitting in the folio_add_lru() pagevecs. + * sitting in the folio_add_lru() caches. */ static int invalidate_complete_folio2(struct address_space *mapping, struct folio *folio) From patchwork Wed Jun 21 16:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13287651 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 72D3BEB64D8 for ; Wed, 21 Jun 2023 16:46:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F06588D000C; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B1B48D000B; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E0DF8D0006; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1B3018D0007 for ; Wed, 21 Jun 2023 12:46:06 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CF7DF160774 for ; Wed, 21 Jun 2023 16:46:05 +0000 (UTC) X-FDA: 80927332290.26.65ADCA8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 3278E180009 for ; Wed, 21 Jun 2023 16:46:03 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ROBkxSux; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687365964; a=rsa-sha256; cv=none; b=WcyOQ6h0rTAatCe89kedUo1y3zOVzWliW8z2HzUg+gOVUUkFaE2p444DeK1KPsH3wFLWDC WB/fvW0h1jFlowx6bOLozr5Xel8J+EquOGHzEcTk48YGNiZ5l8GOe4IxAZRX+MunSRPyuX TfvXXf+9qHUk9FOsIc8/MNTOkNZQ/8w= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ROBkxSux; spf=none (imf24.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687365964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8TiSCbnL9mJc/af1uk/cttNt5G00aLFokvOncuurQEU=; b=QYSnForVd7Hj2enKUmSO/EBfMblfFZooJJuSxKorBPoCFqrdIANMDjf61/NtrpWqL8YNz+ dcthrEGpy0PfApg9U0z62eOlaWqCEtaKZqYujWrldDwLsR2NLlrAcLmVWrHHdmNX60/+kP S6z3jwimwPnLkAhjGxIwo59TGvNzR1k= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8TiSCbnL9mJc/af1uk/cttNt5G00aLFokvOncuurQEU=; b=ROBkxSuxyK2GHbWwt0qLgFJiv8 zmj9C6CSHPQM7LyW41/OjbHPRndJOpiS6l5UG+bFw4bxt2G+Ca7A4O02XW/hXrAyAyyAbJMtRBI8r utehe7BbwNc6CVtpJO37VKw3d8j5SlrD8p0NYvoc8pLtWcqyqllAEQ9zMkh80iRJ0C6+pqSF/oH6C 84eZ0XPv0VUhnwCY5IUj6PaAMQvlFyUmc2KJEaEsXJxuERpYSwSOxsIiY96AQnV53rDs25P4xDSor f26+lGIPExHjRgT8ClXur7P2d8b4h7khDh7JQZha7/A8GMB16vux2F4j1+4MR3dBM2Nyij9QAVuoG PqM1b+Jw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qC0y2-00EjEp-LV; Wed, 21 Jun 2023 16:46:02 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, Andrew Morton Cc: "Matthew Wilcox (Oracle)" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 13/13] mm: Remove unnecessary pagevec includes Date: Wed, 21 Jun 2023 17:45:57 +0100 Message-Id: <20230621164557.3510324-14-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230621164557.3510324-1-willy@infradead.org> References: <20230621164557.3510324-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3278E180009 X-Stat-Signature: rgfjcqb3yrj79tp15qfq1meoadrmf64w X-Rspam-User: X-HE-Tag: 1687365963-828394 X-HE-Meta: U2FsdGVkX1/8jesIpR89LeoNwHdLVTNIcvFe+eESGH6rEAhgO7cdRbt+OgDveXS7E5rmjcqA8/VgNmO5kfPo8IR1FM2Isv10Dqsp3sJ+KJhkh2NrW+769+lEkOZ7W3MdM0YQeBYsk/ADX/zaJXgrimMPPuyF70QxeD6gHmKygDrnDLHlU/LXPvXxhTcBcahoQ8w2QFAj1zyLgXZmNKx1OH4xRp1hPDbBg94o9ZB6sap4cyHvhHiJDyeeBrZUAjJcy+WmbWTc2MZFwGHEj6feu8Y2VBbgnOxLwPEgHfbg7GuCYueZurRQWjA9T2K5I4RHL+DeYf902LiivUFBQQHnt/9R3Po/XS/aQ2ZoS+PjDtHOVhlNG+jBNbQ3TTFXB0CKJSw3Qp8s++i7bx8i+oGlSkWx0twv12n3EixTt+VZCpBhfl6ERMYnW48ABdqyKu8XA1RBUsIsP4g8mMWBoULoopZYRjmB8ZR0qNkFBORBQ6apRc0PSepqxbR4rD8galXiXvdyJz9BdzDHTdJYsgRDeScUC0F5xI+q0AXn5F/2P6pL34pif9MKg6tJYJaQ5XzIPzgfWDjD1oGsC9ie1qrwWv2psYqX07RnSBaQIxuoBem8YfHuSLcj81dr0W8szrtodAnxly5Rp4PKReglsm3nnv/ntazoDzWJN8tFhsKiiQu+2ThpwNBkyMkzJXlgWhO/yuBk9umfaT8MmGmh2P8UZcYQsJMxpw5sMzuk8f8CBXidq3lKmEQdtR9teHsbPm44hmdl9s4W6ET+19v6ofBNhogO6/9TJ7+qnMYjCpq6SYoWAq81x680KkuIKncJUAeYowykDy7260EUiJXt6jsNvjdUWnowAZoSbgEZPgvpK/xosIekhmRLOB++onjQFAQWSLpqoARNG53/Vgg+0AxTGIHWlc0I0pXFPzMKWdyggU8qFxpRDy09v4l2/66uxxaggecz7S891b2ks6plOJs zWzGDV0P cfmTPsnd6Y3kIEmcGMUSxqKcXMALkvu1IKoTZnrNTSi3n6mSG2SpVgKBHV67GhzQyRM6Ip8v91zDI6aEy5rcNU4hroyWyMxANGQALJszT96svVIDshM3MywE2pvH+pawbHWxtQjZZLLnSFJM3rKtXj47su67lzk70uni8MdNRCC6vOqrVg3BKYSJKvQ== 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: These files no longer need pagevec.h, mostly due to function declarations being moved out of it. Signed-off-by: Matthew Wilcox (Oracle) --- mm/fadvise.c | 1 - mm/memory_hotplug.c | 1 - mm/migrate.c | 1 - mm/readahead.c | 1 - mm/swap_state.c | 1 - 5 files changed, 5 deletions(-) diff --git a/mm/fadvise.c b/mm/fadvise.c index f684ffd7f9c9..6c39d42f16dc 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 35db4108bb15..3f231cf1b410 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/mm/migrate.c b/mm/migrate.c index ce35afdbc1e3..ee26f4a962ef 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/mm/readahead.c b/mm/readahead.c index 47afbca1d122..a9c999aa19af 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -120,7 +120,6 @@ #include #include #include -#include #include #include #include diff --git a/mm/swap_state.c b/mm/swap_state.c index 4a5c7b748051..f8ea7015bad4 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include