From patchwork Fri Jun 7 08:37:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13689480 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 ED7CBC27C53 for ; Fri, 7 Jun 2024 08:37:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E0E66B00A0; Fri, 7 Jun 2024 04:37:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 790226B00A4; Fri, 7 Jun 2024 04:37:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 631856B00A8; Fri, 7 Jun 2024 04:37:24 -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 413886B00A0 for ; Fri, 7 Jun 2024 04:37:24 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B938DC1002 for ; Fri, 7 Jun 2024 08:37:23 +0000 (UTC) X-FDA: 82203438366.09.0A6E5E0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id E821B100014 for ; Fri, 7 Jun 2024 08:37:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eS2FJ2Iq; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717749442; a=rsa-sha256; cv=none; b=cP0/GnMcGt0AE2OmlEgtAIsi1gjZOwoQ6Df/qDo0BZZHJCw06m2YLrv2NCMD0cYDg5VE2b Dxr3+GNQlkXPQ45h16WojyKGUe70lgh+8v4BVSk1FIrpSq6JpAAZIZvUvTSwG0tqvLuH5U YUAexZEPEVeIsc59t8jSkj6vlDRY+/s= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eS2FJ2Iq; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717749442; 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:references:dkim-signature; bh=M8ah2Ds86Vnl2swvOWW1huIAKIJrzy4AOAoWffTTPH0=; b=Cwe1WyodnaEgoQg2lVJ8YKr7+9jST/Rgliexm9p6tme+I/8zgRoxjOcGwLQY4g8AUfPjRw Qj5FuEbE4oDZCUdM69FKrBSotoBthx2pVCrR/vo5ZxRhyKRH6F5jjIQdDgGp6JDhk0f/EX /Zs1mVZINgbVkrm2JUC+fJkhM0zb8Yg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717749441; 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; bh=M8ah2Ds86Vnl2swvOWW1huIAKIJrzy4AOAoWffTTPH0=; b=eS2FJ2IqPlEm4YzQupjdA768wDome0eCCuNw4YnUEgVLD2oKC2l87XjW+JX7T6utKHDyPE 8RnCKCgrQuZGTg7uDhrKAMxhCunP/7pFooZo0MMfodyfPJptnWgHl+Reexjkzf0lDsH0Q8 V973JHleg11HYWFTOIyDB49xovcFe1U= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-wAHZVWDZNJy7X6xJAQaCKA-1; Fri, 07 Jun 2024 04:37:17 -0400 X-MC-Unique: wAHZVWDZNJy7X6xJAQaCKA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7D12D1935DE8; Fri, 7 Jun 2024 08:37:16 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.194.94]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A84A21956048; Fri, 7 Jun 2024 08:37:13 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Wei Yang Subject: [PATCH v1 0/2] mm/highmem: don't track highmem pages manually Date: Fri, 7 Jun 2024 10:37:09 +0200 Message-ID: <20240607083711.62833-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E821B100014 X-Stat-Signature: u71ke5qsqy5ejnpbx519kha7q4nmpou8 X-HE-Tag: 1717749441-426691 X-HE-Meta: U2FsdGVkX1+ctwE16LNK8l4LFLe4trGLH0w6TIS+7nf05gT5Fqvqfx2v1g22rgV9bOhw3bOAb/bFFiXIsBhdU7CL4p9V0b6dR3G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LCDNcMWkMkUTD6/SJbjZgNSTG1Z4CjnqUzoSQ01hsQCDjgN/5T/5Xy3CiAHpTbZLA3IrKzv2LFlqQmEf/kIiSse/ytipobN9yntdx9/xmTw5XKdxkpvmtSNfyvFKXDkLQJd7CEEBBCEFZ60/sK7rz6Ysk3qTpiGG72wyA02R7Kbovi6udGgM1kNTEyeg2XYCa/eo1T7MRiG5SlyTz8iDBnGLlSyq+XWBcXQPEEjX5gXaUYdxTak+JIv4wMUzMgkHqjDXAQvbMtHKsdnduMXW1vBP0E+k5+Om0pNU= 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: Let's remove highmem special-casing from adjust_managed_page_count(), to result in less confusion why memblock manually adjusts totalram_pages, and __free_pages_core() only adjusts the zone's managed pages -- what about the highmem pages that adjust_managed_page_count() updates? Now, we only maintain totalram_pages and a zone's managed pages independent of highmem support. We can derive the number of highmem pages simply by looking at the relevant zone's managed pages. I don't think there is any particular fast path that needs a maximum-efficient totalhigh_pages() implementation. Note that highmem memory is currently initialized using free_highmem_page()->free_reserved_page(), not __free_pages_core(). In the future we might want to also use __free_pages_core() to initialize highmem memory, to make that less special, and consider moving totalram_pages updates into __free_pages_core() [1], so we can just use adjust_managed_page_count() in there as well. Booting a simple kernel in QEMU reveals no highmem accounting change: Before: Memory: 3095448K/3145208K available (14802K kernel code, 2073K rwdata, 5000K rodata, 740K init, 556K bss, 49760K reserved, 0K cma-reserved, 2244488K highmem) After: Memory: 3095276K/3145208K available (14802K kernel code, 2073K rwdata, 5000K rodata, 740K init, 556K bss, 49932K reserved, 0K cma-reserved, 2244488K highmem) [1] https://lkml.kernel.org/r/20240601133402.2675-1-richard.weiyang@gmail.com Cc: Andrew Morton Cc: Wei Yang David Hildenbrand (2): mm/highmem: reimplement totalhigh_pages() by walking zones mm/highmem: make nr_free_highpages() return "unsigned long" include/linux/highmem-internal.h | 17 ++++++----------- include/linux/highmem.h | 2 +- mm/highmem.c | 20 +++++++++++++++----- mm/page_alloc.c | 4 ---- 4 files changed, 22 insertions(+), 21 deletions(-) base-commit: 19b8422c5bd56fb5e7085995801c6543a98bda1f