From patchwork Mon Dec 2 11:01:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13895585 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 52120E7716D for ; Thu, 5 Dec 2024 15:32:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C640E6B0123; Thu, 5 Dec 2024 10:19:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29FF86B00EF; Thu, 5 Dec 2024 10:19:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46D536B00EF; Thu, 5 Dec 2024 10:19:15 -0500 (EST) 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 776E06B0082 for ; Mon, 2 Dec 2024 06:01:20 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0E469141A52 for ; Mon, 2 Dec 2024 11:01:20 +0000 (UTC) X-FDA: 82849727142.24.335901E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id D196140029 for ; Mon, 2 Dec 2024 11:01:12 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F0W+V0Sk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733137267; a=rsa-sha256; cv=none; b=wPwuz7hDaLHOWsf31jgtj7HDM7YvKsb7OOIzXfZbDUulD+salA7xF80f0OQ9nxyeLiUuul rMOI9XkUZ+XwmkSZlAHVNmAmMBJPJjxqegf+qhBVQIla40JHyP+cPB8UX/zxtVuBIudSIm H2E2SuyPf6ISKOR36zt67ZlPfD84obw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F0W+V0Sk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of david@redhat.com designates 170.10.129.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=1733137267; 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=5qe+kacRTUMIlGtiIXxBuiYgdy3mvLZJuJ7npnuXvo4=; b=m1ejmepeV+jtMHhxOmGcNbsx9NuObCwdVGHsXUoypCV9o84DaxORP5RlPR9IaF4V8Ut+DA AwWcviKiYPwAPF3DRsH9YrV/tRTfg12kBOgzYopMawv1/wMXWfIMacs40LJkF7VNReH/n+ 0Df6cVqczn6c9KbWVqWEDv7Vx0IhDeY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733137277; 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=5qe+kacRTUMIlGtiIXxBuiYgdy3mvLZJuJ7npnuXvo4=; b=F0W+V0SkD4d4VMxu+xlPq8b9v+XE9nO/gRGX8ndBXXaTD6VqYKErKqbkHHMAByEtisCbK1 jjdmQQ/esfExLhpQcLA5D7dBB6EqSmRteAIjzig0CRAVZZjE11WiWouqX9Y6lIm2Gc0GUv TUZidVKibTTMGUJSj8VLZYSqQR50Kwo= 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-675-KK3CtWbxPzCZTC6blB60FQ-1; Mon, 02 Dec 2024 06:01:14 -0500 X-MC-Unique: KK3CtWbxPzCZTC6blB60FQ-1 X-Mimecast-MFC-AGG-ID: KK3CtWbxPzCZTC6blB60FQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 EDEE0195421D; Mon, 2 Dec 2024 11:01:12 +0000 (UTC) Received: from t14s.cit.tum.de (unknown [10.39.194.150]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 370C130000DF; Mon, 2 Dec 2024 11:01:09 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Oscar Salvador Subject: [PATCH v1] mm/memory_hotplug: move debug_pagealloc_map_pages() into online_pages_range() Date: Mon, 2 Dec 2024 12:01:08 +0100 Message-ID: <20241202110108.451522-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D196140029 X-Stat-Signature: xp19q3tb8xbq8ij3ehj4t76p4rnrxb6y X-Rspam-User: X-HE-Tag: 1733137272-489411 X-HE-Meta: U2FsdGVkX1+D7Ll26DWcp74lNVne9wte9MSBe7QvjyBlWMhfGYzAjx51vb+Q8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O84Dbdhr7dpwVHSIa0HrahZeNB57vuzVrCV7LoE+ZScAT+znScdStSDO5rt+PKOPRa6EZgVUJbsMhqTK+H+zqvoerU6NsNlDYI+AWM9A3OuxhWiMVWjNoA9vRRv7YvkhtGRj6lrsZX0/vpYUk3aaWvFQF1m1dgywpciZ+cGbEUmjuF+FgObyRIhWgid8zdzetrOEib2r+RRLvAKpf5eu8NASAdkw2YdOkB5HmggqepVle0dCIeGBLgYjeDT2alHZwmsMUpH1ohfROQX95DLSaNbLfVOi+F7MHTBkUg1wG+voauDPAdzBAUw6sof9sUn8s4= 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: In the near future, we want to have a single way to handover PageOffline pages to the buddy, whereby they could have: (a) Never been exposed to the buddy before: kept PageOffline when onlining the memory block. (b) Been allocated from the buddy, for example using alloc_contig_range() to then be set PageOffline, Let's start by making generic_online_page() less special compared to ordinary page freeing (e.g., free_contig_range()), and perform the debug_pagealloc_map_pages() call unconditionally, even when the online callback might decide to keep the pages offline. All pages are already initialized with PageOffline, so nobody touches them either way. Cc: Andrew Morton Cc: Oscar Salvador Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 10 +++++++++- mm/page_alloc.c | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index c43b4e7fb298..20af14e695c7 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -650,6 +650,7 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) * this and the first chunk to online will be pageblock_nr_pages. */ for (pfn = start_pfn; pfn < end_pfn;) { + struct page *page = pfn_to_page(pfn); int order; /* @@ -664,7 +665,14 @@ static void online_pages_range(unsigned long start_pfn, unsigned long nr_pages) else order = MAX_PAGE_ORDER; - (*online_page_callback)(pfn_to_page(pfn), order); + /* + * Exposing the page to the buddy by freeing can cause + * issues with debug_pagealloc enabled: some archs don't + * like double-unmappings. So treat them like any pages that + * were allocated from the buddy. + */ + debug_pagealloc_map_pages(page, 1 << order); + (*online_page_callback)(page, order); pfn += (1UL << order); } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cc3296cf8c95..01927f03af0b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1293,12 +1293,6 @@ void __meminit __free_pages_core(struct page *page, unsigned int order, set_page_count(p, 0); } - /* - * Freeing the page with debug_pagealloc enabled will try to - * unmap it; some archs don't like double-unmappings, so - * map it first. - */ - debug_pagealloc_map_pages(page, nr_pages); adjust_managed_page_count(page, nr_pages); } else { for (loop = 0; loop < nr_pages; loop++, p++) {