Message ID | 20240409192301.907377-11-david@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 05185CD128A for <linux-mm@archiver.kernel.org>; Tue, 9 Apr 2024 19:25:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9ADF26B0087; Tue, 9 Apr 2024 15:25:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 95DA56B0096; Tue, 9 Apr 2024 15:25:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 825716B00A6; Tue, 9 Apr 2024 15:25:43 -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 646DB6B0087 for <linux-mm@kvack.org>; Tue, 9 Apr 2024 15:25:43 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2B6821602B0 for <linux-mm@kvack.org>; Tue, 9 Apr 2024 19:25:43 +0000 (UTC) X-FDA: 81990972966.28.5E6EC3D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id A5CDA1A0016 for <linux-mm@kvack.org>; Tue, 9 Apr 2024 19:25:41 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KJdP6vMQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712690741; 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=DDf71sS1dWCd5bf/gEaENI1Rp8VJQ5nXZAI6YpNXJLo=; b=X0KhbvGTfHaaFX6EDhvdQHyxYyOc9/RSfCeynGn6GidiOB2NuEQfv9EuaVls/jwciJtbSn 45xy0OdJevrMXFLVba9pR1VflfoLSdNr6gStXWWUt8IYwPuzaUdYRJuSDnnEiYUBVI/DQA 0R52D51QsXks78UlfVNdYqm+VGMbgAU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KJdP6vMQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712690741; a=rsa-sha256; cv=none; b=5XbV+X5qfFNHr6Hho09QN49ZC8SkhDCSuZBTCzQJCR7Y0OmCBicnQdAq9zPTl102O7Pgm0 L4idSnQHBjAqf34QUa8P11hmtwV79ZvAZo1mJkZHF78hEzmVNTBNvVXQpJY+r5VWfkN6Lg kKgHQki2+AyFdZ+y02iQt51jKuvppTk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712690741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DDf71sS1dWCd5bf/gEaENI1Rp8VJQ5nXZAI6YpNXJLo=; b=KJdP6vMQy7LR2tMT75htXB+desShi/Gz+q1U3jUSTjtN0egbmnoXPgj64ZIBx2AG3PMJpy WuQRofJdxk7IIuX+WyZqj3hk2xsKi1yRn57LjjDGh5gv9t9VC9VNKahXSloZPpOa7VoV3p 1a+MYFLg4fAHOpQ05K7UOhyXNxWKJj0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-vMa84eYMNlusTgwrdB_i6w-1; Tue, 09 Apr 2024 15:25:35 -0400 X-MC-Unique: vMa84eYMNlusTgwrdB_i6w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 592A9830ED2; Tue, 9 Apr 2024 19:25:33 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A7E840153AE; Tue, 9 Apr 2024 19:25:21 +0000 (UTC) From: David Hildenbrand <david@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, cgroups@vger.kernel.org, linux-sh@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, David Hildenbrand <david@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Peter Xu <peterx@redhat.com>, Ryan Roberts <ryan.roberts@arm.com>, Yin Fengwei <fengwei.yin@intel.com>, Yang Shi <shy828301@gmail.com>, Zi Yan <ziy@nvidia.com>, Jonathan Corbet <corbet@lwn.net>, Hugh Dickins <hughd@google.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Rich Felker <dalias@libc.org>, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>, Chris Zankel <chris@zankel.net>, Max Filippov <jcmvbkbc@gmail.com>, Muchun Song <muchun.song@linux.dev>, Miaohe Lin <linmiaohe@huawei.com>, Naoya Horiguchi <naoya.horiguchi@nec.com>, Richard Chang <richardycc@google.com> Subject: [PATCH v1 10/18] mm/page_alloc: use folio_mapped() in __alloc_contig_migrate_range() Date: Tue, 9 Apr 2024 21:22:53 +0200 Message-ID: <20240409192301.907377-11-david@redhat.com> In-Reply-To: <20240409192301.907377-1-david@redhat.com> References: <20240409192301.907377-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A5CDA1A0016 X-Stat-Signature: 34u5zn54xgxrfjfmttpgaquh7sny8wpr X-Rspam-User: X-HE-Tag: 1712690741-952025 X-HE-Meta: U2FsdGVkX18avXkeCLfKLrIV+JO+ctpzqPjj+Bz283LB0kFKgixw9HrSDCkDXEM2F66L2NIn6ZyRk1s8GLUmXvOZ0ddsz1PK08Uk/ZeebfoIJDKTNXA9/fFda67N13QHF5B+l/UDVmz0M5Tf7a7NJYbQ7kP+lJaZ2h+mfgsDPfDIEtrTZXi2JZWdOU89spLauGtnlT7f0ZCNyq2pb9N7lC59rnpa/MaAgzj6BBSOKEwqjZnxFPEyoqw+NiQvoU/hcOe27dRMv8Dzzre5re1ACuN4iZ/O4kuMXZImIbcG7fV/K0DmyRacx9cvcGn1U8YsSHgk/IY54gP+3seQS7WHMrGEA5yksB7ftetq/HKlARd0lrAyqGIE0XH+GuUOs9nTUOFMxf4cvCHKIKmKvzIFM3lDlMlBs6+ZIAz0o4kD8lym0jqA8Ct3royLFtQ/Bkt5cR3QIZQYKuQ/7NQpRETkYl2wFg52B+a/j0N2PAFYGaLRxJPCKVEOGldPrYhgiWSLZQy4Gsp//GTT+gglLZWotafdkNh1r/FW8W2VUxzQrX15WJNuasaQsp1fFedi5ulNK+myfpCATXJnNtoSvZlU1PjqTSIyihv3AFI49NuzXyQSNOJSkMTqIARgu1GDMXerlyJ4eig4bg/dC6QN1AzF3ip7AKIB56qXi3MdoWs4rdrhlDjhobvWZkiXY0hNa4BOefarVjHre029yq25vSjVvyKZcTElxCWLqDqAVQSyZwWiRyNPHMSMQGpRJn4qp2q9vYaVNIKLfJPqXTwGQsMZeJfqmyRJ3DsV0kaSDsIKXDlIvlNH4omKJKa1IGZcCnv24VY/9NZDynhcvIkEMl6bvFsFeicsRNtFmn7aTjEtCxUHbvKf3uDoUz3RFSS0oHkZ+43nz/++s6trOhh2MChDbnVssFyXFubxfSkKdzyw2F8SI+imuUWsJv/cZQT5XeKi 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
mm: mapcount for large folios + page_mapcount() cleanups
|
expand
|
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 393366d4a704..40fc0f60e021 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6389,8 +6389,12 @@ int __alloc_contig_migrate_range(struct compact_control *cc, if (trace_mm_alloc_contig_migrate_range_info_enabled()) { total_reclaimed += nr_reclaimed; - list_for_each_entry(page, &cc->migratepages, lru) - total_mapped += page_mapcount(page); + list_for_each_entry(page, &cc->migratepages, lru) { + struct folio *folio = page_folio(page); + + total_mapped += folio_mapped(folio) * + folio_nr_pages(folio); + } } ret = migrate_pages(&cc->migratepages, alloc_migration_target,
We want to limit the use of page_mapcount() to the places where it is absolutely necessary. For tracing purposes, we use page_mapcount() in __alloc_contig_migrate_range(). Adding that mapcount to total_mapped sounds strange: total_migrated and total_reclaimed would count each page only once, not multiple times. But then, isolate_migratepages_range() adds each folio only once to the list. So for large folios, we would query the mapcount of the first page of the folio, which doesn't make too much sense for large folios. Let's simply use folio_mapped() * folio_nr_pages(), which makes more sense as nr_migratepages is also incremented by the number of pages in the folio in case of successful migration. Signed-off-by: David Hildenbrand <david@redhat.com> --- mm/page_alloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)