From patchwork Wed Apr 3 17:14:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616512 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 5568ECD1288 for ; Wed, 3 Apr 2024 17:15:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3B2A6B0089; Wed, 3 Apr 2024 13:15:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC74F6B008A; Wed, 3 Apr 2024 13:15:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF25C6B0092; Wed, 3 Apr 2024 13:15:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9351D6B0089 for ; Wed, 3 Apr 2024 13:15:12 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0776D160261 for ; Wed, 3 Apr 2024 17:15:05 +0000 (UTC) X-FDA: 81968870970.21.E8503BA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 76FDA1C0005 for ; Wed, 3 Apr 2024 17:15:03 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=O6+39Y3c; dmarc=none; spf=none (imf20.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=1712164503; 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=PV5UzSxT44kEb6CXRTq0MrEyiFGg30Ta3X7PuDVeqgc=; b=cqsFhaZxFyJLeL+qaQtF93m2lnWmahSuIiDikJQFkRipNZ6f/BddIphE1qrWsw1uZik6aW Rl6BzGX5+6xOnSGlu4QvQmqqsaanHmWuM2gY/pZIrSPrAy7LdklLrghl+ASxosrz/6KeCB dAkQshodTX2lDrYlLBeCf0Jfp12azz8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=O6+39Y3c; dmarc=none; spf=none (imf20.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=1712164503; a=rsa-sha256; cv=none; b=2Oqs3i/1L6S4b/ZMOqvIJITqq2UAo3krTyF6YRM+6vnyAbtMvXrm1WrCefkC4+pdP034kO EhZZdqQLGcPn0W1uUWb1AtIzBbPx49tCeHAaMMls5aM2VfjG/eOZJ6eMir3Sj8s8cfvHmY aDE0hzZ6ncRUajqvBhUQWMMUxjJxH5g= 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=PV5UzSxT44kEb6CXRTq0MrEyiFGg30Ta3X7PuDVeqgc=; b=O6+39Y3cqfq3/j0yYE+/iPXAL0 hbwNKgv7dJBqPHYibJqj/20b3p6ucW8gY4agsx4sUkPXoaKMfQUANxQLb3T5GCU5p34NhrbzjoeBq 88619o6cVdcdZzPcLHEQIQKpFzlWZzsb3N7X75LAvXw0IEoDzxipLREDBUTGw8PAYheqJOcj2Crut Q6rxT/qcD3pXBfdtaZ9PqyULVT67OS/NwMmBFElvq5Gk0eseYGyD3QOWflvhIT1D3afPn/nVVNhVA Ppgy7ekTjYs5bX3147tEggxSQjgNNvY96EW7042kehl1iFkUzdmjJOxe87S5zOW+8eOnpIVehrAGJ pLRZNwUg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4CQ-000000063wX-0l0Y; Wed, 03 Apr 2024 17:14:58 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Christian Brauner Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/4] proc: Convert gather_stats to use a folio Date: Wed, 3 Apr 2024 18:14:52 +0100 Message-ID: <20240403171456.1445117-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403171456.1445117-1-willy@infradead.org> References: <20240403171456.1445117-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 76FDA1C0005 X-Stat-Signature: qu5czexeeybat7jjhefosm487taeuehe X-HE-Tag: 1712164503-948145 X-HE-Meta: U2FsdGVkX1+Aqru63RLsUNMQFT6nzms+gmeArNFsO64AEC4m+XiGW6DOmNlBH53rhFiyL+21eZyNxHJYXcoND0TJmaw3jrtDbOF0AdsajgAetrRF65ZfE5M2+VkAHpeRamc8LwsERIayYL0BvTIk1zRe+8DSBMxsnSH/5ZLDfT48dauUUR6wIsXTkk7q/kw7+NnTk/veLaBikkZs7Y0Ffqc15nkoo6tnUcDtvgwn3w+vVlt3zI1EXkHXLCh3Vpu0irPS7ieh91uU8PjOqMSPz0pJjbzyqxKQ0iBdz4E2fGw9fPElAY+y9tGGu6wXdE31DDJ3WAQA5ccz3/4nSDNdV6ingB/H6BbmoJFs+/J0xvV+hTA/B4wIWM7CJ5E1Cg52zNnVCQJCAA2LbHtKK+nCMsUL7FHAVTSgl6DEYWpfXl7ayRFUTVbaXM6fcBQSGsrV82U5EK76HPYrlccv9JhwLt2quRk9iAI+KGX1+LG+CWB51xheM3sqOg/PAnyTeNYD7D8XmEfqCMeRtMRt5Gx36EUXj14WXaUfHFzeNwc8944XKX3DVp6AWX2iGGC4NW4bmaYVRkUX6t6Q/+P3lHJL5vD/JITpnQAr9zwaIqs7b1jRiHwMSU68QrBR9ndUhgLvDD1LyUVceFzZo/4W1hn2YwipfaDEtKR1vhVmeC9x82QbcJWAd3vSKJmB3HROJke6bIo+UP+HhonR3Gm5gBGqdWNU7/dpj5wu4KeUldyCGtCHFJ3AJHrOls7YsMmGJq4GvnPs80SRBMh5qXhkA61PlisJxJV0d8Yg0PKuSUrwUF0n8UqBRo3RbXShOJcDqni7+PfDY2CIBGqy4s4aYj1hUOKQYPo01eDtP3LM8TksAsQc8UPIl7lRsAEXKHFExA93I6fWPvVC4gmg5P5l+7TQ8xCa8Jk8JKz8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replaces six calls to compound_head() with one. Shrinks the function from 5054 bytes to 1756 bytes in an allmodconfig build. Signed-off-by: Matthew Wilcox (Oracle) --- fs/proc/task_mmu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e8d1008a838d..5260a2788f74 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -2549,28 +2549,29 @@ struct numa_maps_private { static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty, unsigned long nr_pages) { + struct folio *folio = page_folio(page); int count = page_mapcount(page); md->pages += nr_pages; - if (pte_dirty || PageDirty(page)) + if (pte_dirty || folio_test_dirty(folio)) md->dirty += nr_pages; - if (PageSwapCache(page)) + if (folio_test_swapcache(folio)) md->swapcache += nr_pages; - if (PageActive(page) || PageUnevictable(page)) + if (folio_test_active(folio) || folio_test_unevictable(folio)) md->active += nr_pages; - if (PageWriteback(page)) + if (folio_test_writeback(folio)) md->writeback += nr_pages; - if (PageAnon(page)) + if (folio_test_anon(folio)) md->anon += nr_pages; if (count > md->mapcount_max) md->mapcount_max = count; - md->node[page_to_nid(page)] += nr_pages; + md->node[folio_nid(folio)] += nr_pages; } static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma, From patchwork Wed Apr 3 17:14:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616513 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 2DF69CD128A for ; Wed, 3 Apr 2024 17:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07A776B008C; Wed, 3 Apr 2024 13:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFD446B0093; Wed, 3 Apr 2024 13:15:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB5BC6B008C; Wed, 3 Apr 2024 13:15:12 -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 94F8D6B008A for ; Wed, 3 Apr 2024 13:15:12 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1970380CE5 for ; Wed, 3 Apr 2024 17:15:12 +0000 (UTC) X-FDA: 81968871264.12.CD045B6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id 3637410002C for ; Wed, 3 Apr 2024 17:15:09 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uv9Z4GOP; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712164510; 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=wbcNRsb1B9OYyyrrlq1n5AUXVLnlKeePbbuQlBkeIGo=; b=ZjLzcQ+Sp0xa1RO8YI3TOkDmIzlo8v6iA2byw6s7NWfVxwJCKoJY4MJre4aGpsAA4AX220 YaBtUOWMc6DnaBvEm7MRPZ+1jaXCx/8VYQdzJPdHae155xGd1kz9ai/Og7o0yNknjVkFtO kUnFFofo9XcmFmzlAO7DbS3WpVKxOJk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uv9Z4GOP; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712164510; a=rsa-sha256; cv=none; b=wGChLME8EmJgOuw6ThMqGQrKtKazBpLPoQqWbw850pMLp9EhwaA5fi2Qrn6xW2L5EL0YFB adN7oOjR3yLQeSHeoJLTEenr+FBQvGtcciqTgv6JOWMFmCR7sjbD6hGvDdYz189l+W+SKj 5FF+QR6EEpBCHXuQDBj1yPatjWcEYtc= 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=wbcNRsb1B9OYyyrrlq1n5AUXVLnlKeePbbuQlBkeIGo=; b=uv9Z4GOPcU9GrYuVe8vFQvs4wb FykzKMLugI66A2IzTVi0QUC1kE9TBiYbaKEtcUK9zNvPJ1EkotCNOGAcZT8SHdsGMEUTjFagya8mL 11sii8ap6W1w9r+zeGgY9/t7ZpLQOIz6iA86bjk8KQoCfF7Y6+CQeHW55t9S6wSgcQ/YyT4wYgJTf PQZPiW4kNV//tGP6mRut5v0i2+tRoZvo6O2rnOFKivIFdAFW/w2WzRvm+7NbqKrf9YfRPBFLTGaw8 z5WiAAx1WFoOcWJhsC71C47cOizzZAZQ668LTjiXdOuBg2lXoC6kewTMi28sHFFRLGr7e2BoyQUv0 9Zh38Byw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4CQ-000000063wZ-12bp; Wed, 03 Apr 2024 17:14:58 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Christian Brauner Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/4] proc: Convert smaps_page_accumulate to use a folio Date: Wed, 3 Apr 2024 18:14:53 +0100 Message-ID: <20240403171456.1445117-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403171456.1445117-1-willy@infradead.org> References: <20240403171456.1445117-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: wxibdx5fhmz7ogrx1fq5c3he7ckpa17w X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3637410002C X-HE-Tag: 1712164509-609771 X-HE-Meta: U2FsdGVkX187QIC7DRVTz3cU8C15qrL9A3g0FBpWR0XUU/d7iP9kxKl36tG5gztj6FDUmCK8C0JUy3OtslrR5PpenP1UKLUtHkrks19EmLkWINn8ISbsaZwzTkbzUn0yMxayR6NQTjfUxAiRcOarwpcu3g1mOV9OH8W6Co4coqxbCm5JiuzGiPjOzk5PKTVkIgTs+tI8cUVm03991s8yUo6ge5GMIH0J67ok927tU9PkMc9cPCIxzp2LMpfwZ7CTerI1EIwmwnUG6JRpGiPbSPK/n2+IlW4I9NSGHuHH6fx/Da/qAeDFx2ZfSLhefAe+vBuSB43iDjKrVMHIRehh2WAGSFiUF/WJmm/be+rMSqL5jkKyV0rm3i22v93U7ehuTa3L6DfCsTurTk4YKf9xSvUm/QQ+c/0ZP0b9uYmpIrCM2/ilnZHWPVfWvIEPjs+oYrIzVj7lpuiXe6dRKsn6MLjokCPMjeHuWiViMXoqg0Vp3uHUzdGeeN5M7xB8jcwKi58uk41Bf6IeLKzthiTakUHOlra/jPxJzRWTKDBL/OWaPPZVCkJTCMejwBn9S8VPW3NkdneUEA9VXeS4e5tUd9nFzvpWfSreySbsa9CmsT8TU7aOH6rDXe1gVvg3ZtQbYymhlD4lJikaqcY+D2AirthF71c76k+rsC4ko7J0Du+tC+HXv0VyLBRelUwp0RHVbYNV3H3ZxrT+2zEcRb0bK986rQKh1QLE3nCV7paWzNuM4aYHfrYrZaIHaxi0N40hNFqQ1bRUqRtIBa+/3ad0jFYFlGgZToYORW4Xc38JW1Vl8ioCNZmEKtbhVjQBjPw4t1JrWxDKBrmoQhW5vHN3xiX4vvW7jA9g8dbJvprlpxxL4doAQwMeDk0cvdfUuaeoR5DzJBZUyc7OGsI5gBzizk99XLZoNglqzhoFiiYqXX/5TZ9QVI4rb1PX4Vo9MFR5Fd2yN1+dD1CNYIgiL1i Ng5Z6/3p HQvxSUJdgkJc65hXJIf5vgxh/ntl/xMbPqQCI3BR0/Z+TTPKvqJDm75K+vAEBtgYeuyJNa2RJQvUwe9sHNmrPTj/htOKZUJv0wv+cbSZ3ud+K/iaHkF0QyJX7I4Ca8+sUgTxu98/nhjtqPHUfNPSriPTczDVG/mAsPFVy4n0BLQIRCn/isDaJaAg6YWt2q/8jRJf+kD0wjSQzVSIFUyoGsOk2PrFp2UU4q7en X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replaces three calls to compound_head() with one. Shrinks the function from 2614 bytes to 1112 bytes in an allmodconfig build. Signed-off-by: Matthew Wilcox (Oracle) --- fs/proc/task_mmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5260a2788f74..2a3133dd47b1 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -414,11 +414,12 @@ static void smaps_page_accumulate(struct mem_size_stats *mss, struct page *page, unsigned long size, unsigned long pss, bool dirty, bool locked, bool private) { + struct folio *folio = page_folio(page); mss->pss += pss; - if (PageAnon(page)) + if (folio_test_anon(folio)) mss->pss_anon += pss; - else if (PageSwapBacked(page)) + else if (folio_test_swapbacked(folio)) mss->pss_shmem += pss; else mss->pss_file += pss; @@ -426,7 +427,7 @@ static void smaps_page_accumulate(struct mem_size_stats *mss, if (locked) mss->pss_locked += pss; - if (dirty || PageDirty(page)) { + if (dirty || folio_test_dirty(folio)) { mss->pss_dirty += pss; if (private) mss->private_dirty += size; From patchwork Wed Apr 3 17:14:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616511 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 39564CD1288 for ; Wed, 3 Apr 2024 17:15:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C79126B0088; Wed, 3 Apr 2024 13:15:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C2A3B6B0089; Wed, 3 Apr 2024 13:15:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B18686B008A; Wed, 3 Apr 2024 13:15:09 -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 94FD86B0088 for ; Wed, 3 Apr 2024 13:15:09 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 12BB8140D27 for ; Wed, 3 Apr 2024 17:15:09 +0000 (UTC) X-FDA: 81968871138.24.B19600A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id 1A74AC0021 for ; Wed, 3 Apr 2024 17:15:06 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tLVspOYU; spf=none (imf28.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=1712164507; 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=4iptMz7iSD6DXWLkWwgnqB96gIdT8SCjbHmreUMaKzw=; b=ZK388Zvb1tHjBiLjmVbrqIL8AyLkHP/rpyzPbAnOv+hJ43vxwljXbevatBRLktwYBomXtw 2Ucfr0HtTmshTJ3GtTxMI6qabu47GyPk7OIRn+m4H8VQjxwAlYZWa+2+pkGMC/i8qhiIB2 bRYdMFp76gnHoMSpxlzBXqjHBLsU2wc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712164507; a=rsa-sha256; cv=none; b=8Wl9zD6HCP29R0KAXsorMWZ3lTHF8mKmEBji3WL32Av19KWQYXLMUxfBR0oCwFSAusjoDg 2VzwKwz/f/i0ZytIZwUChy0HiMHFqcbCbfa46xhxzsJodQPbJpUlXaXEroX6/byq7xhXtG Uicn2apgpx70guD/FwjT2ZDix6N5048= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tLVspOYU; spf=none (imf28.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=4iptMz7iSD6DXWLkWwgnqB96gIdT8SCjbHmreUMaKzw=; b=tLVspOYUdHehXPrlIVsS17Syyx qVwDtTnKGCgJR4mEvk69rFbm1UtyJOYvOvsImj4sZVqVRMAfF82EkNnqcsP/GDFZ+xSfCkMFxDlpa rgYab8ZAq3rp8r94El+Zfa1AUrclnIYJ69fnvnyvrqfR5DEcfJsWQ3+O8AdvTWkt0y3gKWc4N2/eY zP8tVnypyNn6Q3D5+0dJ2XEJ6cEtiOUUeYUOhnPHsuyIGGksFX3KKeTRSbC5lLEUk8URVbJBtCthJ rNJpOkE8CCsA5lgBHr+lcyNXvEyPyh86qN13KNgPC5K/eBH1+Q8VtRp1f+Wdd+ki8k8NTpc+kRXsC 6oKiA7EA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4CQ-000000063wb-1M8s; Wed, 03 Apr 2024 17:14:58 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Christian Brauner Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/4] proc: Pass a folio to smaps_page_accumulate() Date: Wed, 3 Apr 2024 18:14:54 +0100 Message-ID: <20240403171456.1445117-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403171456.1445117-1-willy@infradead.org> References: <20240403171456.1445117-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: twkx76cs1nc6e9xtx457y1pqoenuqy1m X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1A74AC0021 X-Rspam-User: X-HE-Tag: 1712164506-760979 X-HE-Meta: U2FsdGVkX1+gonffefyxLEJ3IlPy4v+q8NZ6tP5DRb2aAIMR0/qu6VekE6ZlIcQ6eurwyv3uRH7hSsBS7OhzKUcWzhOhLYYt0+NFxjtIR4/u5tEEqIUBXMlwHKWP6DzS37DN4gNi0M/jcBLvzebVSPlGJEw+KzDP2bIJPznqHoHeYSUeLfAgg3bdTtTR0/oPjus/lBCF8BDRtRmW1Z1dsmfhaUmewSuoiWqx14W1kPC+BOkgbTPXphm3FGsW9MyMK8KXshht6DDOAsHasSh5/7n+Y9ll5EVag0mcPkH1n1jOrcGV3dXS2KQCZcsqD9nKZz/MVpvh3vdwdM6OdAGMF9Fp8L5xV0vKrMV0+3s2PFUjqG2uEXc49kWA+SRA3mKB6apLT+8KVeoQW+AK0ss3T0W4Apkk63XmOgO8kM+cNYKMm6o/Wnoho2+zaiqyBHcNMFjxZcXmcM7U+Y1/oePPNGqsAFSsgYewFG0OnP1ifBwcgvNXNNc8YpuGkkrvzGNqVMclI0XN25hYYv9TvP5kU2sl2aX9F5ADEWITt3XiESWLGPKnAmeI1mYxyD6aSSW+yWgTcJEunk4X/MNz5JaYltM4JRHuPmyhzOT6zrYaPV8NJUJFOaKSpMWKrTUJoERlmXwUIV0yV3TZnGk6l0iVAgW/h923PpGaOCWDeSXVyExWCLTvds9FHHboIPdxLn8CuYYtc5Dkzt/Ko7FroTexx3XoAGbZjkqu6nNoAzR0voQgVG9QQzP3UAUXrCbKr57Sj8mmiJVIcV7lV06pWp2uUJsd1aKj68pk7UeMVDrFIaU7HFH+Xu54bIM86NawTY03ZFqFNQvnCB8TUjU9fNhlfsRvD+Eud98kYFGNlcIJGa44wRk6zchp7oJFhyQlR1E2tVVUrZ2cZ/d+k3vKie/oSQG9DUHZ24tm X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Both callers already have a folio; pass it in instead of doing the conversion each time. Signed-off-by: Matthew Wilcox (Oracle) --- fs/proc/task_mmu.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2a3133dd47b1..6d4f60bc8824 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -411,10 +411,9 @@ struct mem_size_stats { }; static void smaps_page_accumulate(struct mem_size_stats *mss, - struct page *page, unsigned long size, unsigned long pss, + struct folio *folio, unsigned long size, unsigned long pss, bool dirty, bool locked, bool private) { - struct folio *folio = page_folio(page); mss->pss += pss; if (folio_test_anon(folio)) @@ -484,8 +483,8 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, * as mapcount == 1. */ if ((folio_ref_count(folio) == 1) || migration) { - smaps_page_accumulate(mss, page, size, size << PSS_SHIFT, dirty, - locked, true); + smaps_page_accumulate(mss, folio, size, size << PSS_SHIFT, + dirty, locked, true); return; } for (i = 0; i < nr; i++, page++) { @@ -493,8 +492,8 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, unsigned long pss = PAGE_SIZE << PSS_SHIFT; if (mapcount >= 2) pss /= mapcount; - smaps_page_accumulate(mss, page, PAGE_SIZE, pss, dirty, locked, - mapcount < 2); + smaps_page_accumulate(mss, folio, PAGE_SIZE, pss, + dirty, locked, mapcount < 2); } } From patchwork Wed Apr 3 17:14:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616510 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 B7AC9CD1288 for ; Wed, 3 Apr 2024 17:15:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C6CB6B0085; Wed, 3 Apr 2024 13:15:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 376C66B0088; Wed, 3 Apr 2024 13:15:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23E3E6B0089; Wed, 3 Apr 2024 13:15:05 -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 0725F6B0085 for ; Wed, 3 Apr 2024 13:15:05 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 54245A1271 for ; Wed, 3 Apr 2024 17:15:04 +0000 (UTC) X-FDA: 81968870928.03.B90405E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf14.hostedemail.com (Postfix) with ESMTP id 1EC17100005 for ; Wed, 3 Apr 2024 17:15:00 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EyN7KUC8; dmarc=none; spf=none (imf14.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=1712164502; 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=zWvUIcsgXfFVuJ3plWmn3jZ25kr2d4+5CtI/6v4IbBA=; b=M7QDSifHx03+kEQTN9fNSaYnyg+PKz4MbXzLW0pN0zwAgmFD3ZcbOXPnDTgKmDnJBvH9i8 sutMsuTeRMEX68pWmighbqJKSpCSUMbV8xpgJtp9vjUVOGdc9+R8Ju1yQ+zC3E0h8+mhlA CL3njw04+XlYcbez0iBVQ/eQcOk3/gc= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EyN7KUC8; dmarc=none; spf=none (imf14.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=1712164502; a=rsa-sha256; cv=none; b=5173NCF+WBK7j4zncDterNj4ucv9CiVPspZgXXwamtnSk2Qxj0neKuQWTiseYyCP2sYRci QwGsrqoDLGwE3knHUCIW8D+WBgXL9xFie5rtgl0g7Niv+cGuBr1Cr1krkHiCHDEdelDQgN emFs0yNF6VJ+PsSXXSK2bVW3eL7JyGQ= 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=zWvUIcsgXfFVuJ3plWmn3jZ25kr2d4+5CtI/6v4IbBA=; b=EyN7KUC8CWA2zAqaLb9X7NG1GP GiSUNPS5vCVIIMlu35ZijnrORpg4bFnx1SG0fwp47fcz0JivmxA4ljepc7FfUUJFStQIsk6geXoHq xuJGMUjuSk0Lsl4pnJ6N9a7wlNslepkcuIjr/DPavSZEIiqrVztxU8O/vh41CBlA27k4kcOvkiS8d 5uOUtp8fbCvv6mQcpkbzeJJ2w5WkFqPrXrheTO96txE5EdVCIUxEql5NtRwOOOtNW2Top9YH6kyEJ rWamjBmbFg90mAGxY/MoGrDN13bPd0cHR6ou2rSq0ZiSNiqDAGhEh2O4KpoyWOs27H8B5Ab1kEdAg n26ENKww==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4CQ-000000063wd-1hvu; Wed, 03 Apr 2024 17:14:58 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton , Christian Brauner Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/4] proc: Convert smaps_pmd_entry to use a folio Date: Wed, 3 Apr 2024 18:14:55 +0100 Message-ID: <20240403171456.1445117-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403171456.1445117-1-willy@infradead.org> References: <20240403171456.1445117-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1EC17100005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: iguondhffwzpu3qye4zojb5u9tc117kh X-HE-Tag: 1712164500-91004 X-HE-Meta: U2FsdGVkX1+j5onb5HEk8OV99XqGxY78woW17sd5yyW6cqPyy/J3Y51NZZamfJCDyT7lm9abTao1BqlonRFwMdDsiBNWB5BNC0oCo2ZH0GFbYGnsw1yfEQc8zvsEzbMRdYEBeGBWtMAgC+Wyww6sNiX+r74SIb5MSCuVwmln0Z8BMHbymT97QF3mymrVkszlTGdrZzWo+m8houP63zW835SSu/xg0VlBY1KlA1T89hMsePThe9AQee3vqzgDHqY5PzYaox966mKIAkcHa1EGfbHl/0YOEEzII/bPMgr+ElzwulQux/qN/6k8vpB61yo+VS+AL3UE10YF11NGHHRqhLF4uUP2LjtzibjAeArz4k28wEsALx9IKFFL793whAUiWjmdSMDNSXBqgnmDoM3lqGWqnSpOe3cEIHsE/Ec/tDTMyu5P38UyEY2TYud11qvszTPAQZZGb3k2bM2QiCmcSs+uFDA5ieIRGtQeKDcksO4h5aqNdcALKnj4wZUBohjQP0IMh52N4db1CGFXoEjHh/e1sXZBnS6u0iesw5PGUQEYzkskP8xhWeqPXz+ep5nN6z1DqnqTBVL5LpIYnYW4bRX0cwS9eGmS3Jg+5HBpv2ugL4MHlBw3hjrmEIXJxPY7SWNYTSQtl3bUWvccSzgCzMOA9GjOuMTA9rkxamDU6M94OPi1BP6SUVxfJdDcXevSr4eEPHiTz+eW9YeLZ1WgSG4Xt/nkxkaHdo+6+R553Jvmk5w9+JabdFgQ9/WPCOHm+Ot+16cKnrbsFKLs8gh+X3CApOP/Dq1Hu4BmWRQ406OHlD5eroegtWynzggDr5ximqBN6uuP8RU2ZwLa2XpueZ25ai8mJoLgYFvkhBrL7a2QeIoQ7e4Vo1gcA2kfGunao614UJH+Kbi09mCdq/h4U7YnYbXoevwR X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Replace two calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) --- fs/proc/task_mmu.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6d4f60bc8824..8ff79bd427ec 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -578,6 +578,7 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, struct vm_area_struct *vma = walk->vma; bool locked = !!(vma->vm_flags & VM_LOCKED); struct page *page = NULL; + struct folio *folio; bool migration = false; if (pmd_present(*pmd)) { @@ -592,11 +593,12 @@ static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr, } if (IS_ERR_OR_NULL(page)) return; - if (PageAnon(page)) + folio = page_folio(page); + if (folio_test_anon(folio)) mss->anonymous_thp += HPAGE_PMD_SIZE; - else if (PageSwapBacked(page)) + else if (folio_test_swapbacked(folio)) mss->shmem_thp += HPAGE_PMD_SIZE; - else if (is_zone_device_page(page)) + else if (folio_is_zone_device(folio)) /* pass */; else mss->file_thp += HPAGE_PMD_SIZE;