From patchwork Tue Dec 3 10:20:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13892092 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 9C2FEE69E88 for ; Tue, 3 Dec 2024 10:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B72AC6B0083; Tue, 3 Dec 2024 05:20:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFBF16B0085; Tue, 3 Dec 2024 05:20:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 975976B0088; Tue, 3 Dec 2024 05:20:58 -0500 (EST) 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 756A56B0083 for ; Tue, 3 Dec 2024 05:20:58 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2641F160824 for ; Tue, 3 Dec 2024 10:20:58 +0000 (UTC) X-FDA: 82853253798.09.2B3C2A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 3E3DE160012 for ; Tue, 3 Dec 2024 10:20:47 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AAVa6kbz; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733221243; a=rsa-sha256; cv=none; b=qkeHq3q+o7leht7kfdn/uoS3RhcZp8ThWHfrMeioUwz4hrUBQniJGXTClnxJYNfASNUyy/ JcIVdrWc/3DIi8OLQX/DRDIezaDrAL9b/KWyOKY1MnkFC8HZ7pwlVe2pE6XXQ/7FVrA9P1 LGw1BawIsTAsnNqwcQAoiXX/B1QayTM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AAVa6kbz; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733221243; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=KuXsCiN6CgNOK8uGVa8JAJ/kvrPxb05TY8tmye2AuS8=; b=q1Db6sZR4G43iZi1YP7vobKZZ3R6/VlpA/NBIstUcsQ1ggxT8PgzBVXumdVck12rtELukL mdF4IMbexecmsBYOquqpxXQDU/cZEJoULwnlbNb7Qb/4rHNxgIqAGbHnNYr5qkkCVAApnz msqGa9Xkxur1Tyd6/hOdm3WNG4Q/RCk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733221255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KuXsCiN6CgNOK8uGVa8JAJ/kvrPxb05TY8tmye2AuS8=; b=AAVa6kbz7yp03iijHdYpOWfp02aolsUcOoXbev+NKpONp1jGfQHR6Ln7N7jXqXDebveFar Fhw5/S68ANM8k4s+oJhi/FnM03t5xFvV1WdsJ+KDgGv74d0mJIQ/5pYa6E+sz8kzJJVLrs TdIG9giJM7AzmXOE+sDfjIzWlfFvhq4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-1djSUpMwMGaL7S9JDnPfMA-1; Tue, 03 Dec 2024 05:20:54 -0500 X-MC-Unique: 1djSUpMwMGaL7S9JDnPfMA-1 X-Mimecast-MFC-AGG-ID: 1djSUpMwMGaL7S9JDnPfMA Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385dcadffebso1985484f8f.0 for ; Tue, 03 Dec 2024 02:20:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733221253; x=1733826053; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KuXsCiN6CgNOK8uGVa8JAJ/kvrPxb05TY8tmye2AuS8=; b=l7MWeYo9z+PFMoO2bQyVB5BvKwu60DE4jG5GW6gMdzvqEuPG39kQ/S9BK8kwV0oSQM bBqCZ9UdzD3Ub2Tn/Rm7OgPUK7j2HYAnaLizmFjZZDCQshB2Ts0mvgHmydpmUdKS1tVP 1EH2B1+SKYb6DXoAZS2DEkYFUq8LlvMonciQAzsXK7xWHO4UX8AAbSS8buh31hPENUsl ELqaegREvASrmyp/axrgjf8a1TFSoCt4KWbtdQxiK/btjUTXF+QTj7YRSiBkwK/JFQP0 Tp9P6AAFwJQeBJSDXoepnILqE+s34XTg5Q3oJK1Iwej9J1g04Ho2P3T0ZJ7/cYqAMJMU To4g== X-Gm-Message-State: AOJu0YzjyPPH9z4hsDIlMhkr708q7W9BreSWzGV+lynhZlt2nWYegPCZ yP6ZBMEjBVZTAo3cceG6Aa/XN6cejmhSCKfI9xr6f/KKBKwCAZz5LKGetca9dH7M9S28JWDIAVd Hw3vyTj76zDSI5sxHa1QHRpPpiWRPYM7ipaF18FiRaxtITceB X-Gm-Gg: ASbGncsn/di4ws8eEdyD8Ezz10BrR2of0sstyp07+qM0yndlz3aDC+k9uXs9hrAUn/t JIgxiv1RO+hFYGVKpM4oYMUYex/jqBicutqNr8ICNzv570ju9gf8TGtt6t2UPl6zPuhZFurMPZf ZQF4mOgCgWiOpRbcsEEv804pWdEWeWSSqpVRA1zCiU7GojRjqTl+UigFWeGLWLpwZJXy1VbPzp7 M8C8SRpaTJbbXw5hsBZncCAgd7I9Z/186HxvrYmiSPG7hYXzYZzoyDDAd1kT7T5uyKvgsiXZOvB Yi5899emOa9dHdcCNpC5hBiNonTyJ4ZXkXQ= X-Received: by 2002:a5d:6c66:0:b0:385:f1f2:13f1 with SMTP id ffacd0b85a97d-385fd3cd6f7mr1829088f8f.22.1733221252877; Tue, 03 Dec 2024 02:20:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUcQBJBdR4HizHodyjl1EPzzMhS7ngLuPEyY3t7jpaROf1CDbcTOfyfWdG/a/wFh72Na9XPA== X-Received: by 2002:a5d:6c66:0:b0:385:f1f2:13f1 with SMTP id ffacd0b85a97d-385fd3cd6f7mr1829074f8f.22.1733221252515; Tue, 03 Dec 2024 02:20:52 -0800 (PST) Received: from localhost (p200300cbc7461b00fd9ec26cc5521de7.dip0.t-ipconnect.de. [2003:cb:c746:1b00:fd9e:c26c:c552:1de7]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-385ccd3a56fsm14953673f8f.62.2024.12.03.02.20.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Dec 2024 02:20:52 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Oscar Salvador Subject: [PATCH RESEND v1] mm/memory_hotplug: move debug_pagealloc_map_pages() into online_pages_range() Date: Tue, 3 Dec 2024 11:20:50 +0100 Message-ID: <20241203102050.223318-1-david@redhat.com> X-Mailer: git-send-email 2.47.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: FIDJCwLplfp-NWd3V_fG9MXbsqEkRg7GXR3QhZncdDM_1733221253 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3E3DE160012 X-Stat-Signature: nobmq6zwpcdkkf7pgrhfw9h4h91tnc5i X-Rspam-User: X-HE-Tag: 1733221247-973661 X-HE-Meta: U2FsdGVkX18BZ/3i24kK3ZueMjJpFgmM8RmFm9edS5bEoTEJ8qE5udOvvOH0NIKyut1mZ8zY7jiIUAXFa09+ytB9NB6BQiNr7krpWXSWIPc7ICeOkOhaeen5wnyPZWeieSu+fCgy7tFPH++o2E3LcwsK/zueNWIBVfgSgD4EyFsqRAT3LmdtD7+ykLJAmkELB/LHY86M96g75V3W8dQZwFPIUhn9F47euOsc8/KqbUZ1ayFkLYHqik8bM+TXPUv5Qg/khT5gnO54/tsAWTIkTqRIE9t/COJZDSikJmsAIKvKAfQlnBje6fpZj3x69eB5TcOO9XYqa8hCSHmJUi9IS5opxVuhYcGmiHLFIHVzTa5TqY/FApC9GiPgTTSvkDR67QN+c4BQ0jY5owEO/7SrlV44O17Zchf2IJeVNZKM/c62lkaSWc35pNSM1prCxd7HXIYAD0cbc36CWMdfuiNn2PRQhSpi+dWC4h/zbDNe810Eyb43BRfnwcpdHiavZxTUs1VlEskGtT1ajrqVfjjoTUmDa9B2Enz1np3na0oOeiGTX7/QZLNJcVMu0g2ATLYaa94o96F+BHVulNj+vJ2+uYHv1tIEZef2Xgh8Wwmkv8iDpmB2QodpYhibp6dmOalB0e7jLT/v0gCOVBsURd+sEyrWPG1lMTenFx/hVD3F/Hkzh3f73lDBbZ1H3Ts6WFFr+dCM2YSmBvS1xejBC9fkxHKkKTfp8m8SXRkRuothttqicE5Cx9Iht48vUP5ZuFZOACpYyirKRIQN/P2384ZWVlxgP4+6sjzzBM2Kh/v/QkfJ+V74M/c8Ou5X3+TSZXNOw7qBvn7Z2btZ2VrJaoMbBKftzs29aut0CXWcL+uuFK6H+7hyV6ulzWC1A5WuA0sOG2plF2owVt3TJOCkyQYXep8urOdKDkiF3iGlnTigULeI3EwHBSUOMcA4PwCZW6SwFMXNRifSSIr05u7THUl zauQ7Brm ZOAbXVYC7e8wltCuZG0ilrA9gyat1rKAvM7VvMvwY3/7OR7TLGGx5FIVpyVJYiW0OUZ8MU1Mgdx3fzunOj2OuyG2oycz3kV5mnCEXAU+5w7hLEuBpu6jxY7Bc2k1Xd3/MNjeHIWzwkdeMQCHxPPoV2Bs9IHPIYkDCS1t5b584DY5JaiwmnrWTwU0aIWXZGy+6St2/zDu+UI1yp4+klG81rixAxFRtuvkyc/MnsWNHAQEBF3UTo+h5Yx49XASBxhjC9PKkLIik2mxxUEhLu34tZ4wrEdWjT/WbsgtXE9JyRK9Zx4dOaMMKkL3clQ9Nrlagu0Vk25c9+U+f1Zy4pnryauLwWR6ShvR2g4FbZ45r5XijcAh1cbnGsyIhtvJx9+dFhGevWc26eOIh9ebt7UNlCAdTJ/AGVTskO7OSA/aVmwCX4w19FGSFRrrF+i1fsXfP1systVEbKt9Qehuo+XsaaN+W/iQNZSEIjScLLMGPZVjE8ivxc2gS+PhHk/znqtIX+A2e3iz9ZfwRQXBdaOnbxzRucCXMLyX5Qdll 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 Acked-by: Oscar Salvador --- SMTP server issues, resending so it reaches linux-mm as well. --- 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++) {