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,