From patchwork Tue Dec 10 10:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13901212 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 3E111E7717F for ; Tue, 10 Dec 2024 10:30:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACB7B6B016D; Tue, 10 Dec 2024 05:30:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A7B8B6B016E; Tue, 10 Dec 2024 05:30:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9426A6B0170; Tue, 10 Dec 2024 05:30:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 763AA6B016D for ; Tue, 10 Dec 2024 05:30:02 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D90751C71DA for ; Tue, 10 Dec 2024 10:30:01 +0000 (UTC) X-FDA: 82878678204.07.88EB2D6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 9F5FE4000B for ; Tue, 10 Dec 2024 10:29:36 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cqkEZcpt; spf=pass (imf04.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@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=1733826585; 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=3GsygM6Nzd7DnPDhoBfVyscs8VOyb9HhJPZeXahbT28=; b=5z0bG8wnB7oJkeOtxQJwWVZ5zI81gqlmz5IP9JlpYbp7uMWMfb4qyK1twkram9QTAhMOht RrrMRjuu594yejXOOmwK8E6P9V1B8kMJPTDy1XPBhiqJXCNNJlYhGDfomJr4rHA1XX17NZ RhRJ+EEKsTsWaYqM5g4cegaGmf9y8qc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733826585; a=rsa-sha256; cv=none; b=5pup0JUcd02IKsf2AtOs3WdIrt3VxghEIq01Y51UN36IeJgqlF+Uc2u3sHwYFbQ2i8l43/ g6yqL0OCaoQTCpurdYSUpMOUl795h4BjjnqfTBuVZNs6vcec35qNxq/XRUO3wzjrNURkfd BX0ZkMC7q6ZZN1d2u5l40J/ylT+wOP8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cqkEZcpt; spf=pass (imf04.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733826599; 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=3GsygM6Nzd7DnPDhoBfVyscs8VOyb9HhJPZeXahbT28=; b=cqkEZcpt+hheNWbnb0RoPVHLwMEhNZ44mDYKD4a0jXIaHVPXATgd31dJA3ZJDFsAphr7WX 0FWqGa5zczZVfh4t/BP2LDJSs9c7y4iC0IWLvhAqMyN4W2sFRKSPN+sdCxTvLNsOEL5rXF Gh8t0b0TP8zhb7otpKLfXDAyVyDKkx8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-PgliRi3POlW4Ni2azVkHpg-1; Tue, 10 Dec 2024 05:29:56 -0500 X-MC-Unique: PgliRi3POlW4Ni2azVkHpg-1 X-Mimecast-MFC-AGG-ID: PgliRi3POlW4Ni2azVkHpg Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-434efe65e62so17097125e9.3 for ; Tue, 10 Dec 2024 02:29:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733826596; x=1734431396; 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=3GsygM6Nzd7DnPDhoBfVyscs8VOyb9HhJPZeXahbT28=; b=czZ+uZWrxfg9R/4JtMPAJ+rMVqISfX4RDN3B1Q8L6ay4+KB1V9WPANjJ7aeWw8atGE R+E/rrKOf48APQHci4S3Zk3vjRH5H7jqwe5DZD65BV2zydWc/vJuub8mCB/UUQ3GtHHl 14U/JJPCFQDEAT4OzxuydDo6PbuDr/VI7tR6iT66N/cPIS0EveExiNlvjSHZIFUXIBtt Wwo2MqmlEoOd3uohgkTfFLeB6R6KV+NFoar60I96dFyh66V3uciQdMrrbjxMdP6hLRjM LYysiab7J7a0e80zsFWXkrWqfPdWGdvaEBr4ogs5exam8cMkyzfyDUsO6r9ylSsTZ3Ep +WKA== X-Gm-Message-State: AOJu0Yw3GM6oDF9Nlkq+8vmuT9l3M70xn7BUe2Yi60N3yF20qglgavxU cyxdkkyHnGyOsLUFcVjYmdd8038BmzboteYGs8qLnYiKIvj1UHhkTbTBI/bxBgrd9J1rgSlfu+B rECzXNF6QZI/fKN+4LhfNjchwLOLxZZzfj815duc4fkO2ztBp X-Gm-Gg: ASbGncvjxgLTk+DU42MXDf2eSP2wkZ9Nx5sS2x6w74B4TAqFirdCOjzNbGpdIDajyMq q6z3+gZv5PJeP3j/W0yDEd3aFYfsQBRV+q9i31v++ix/N7LWYaB6YeFWJKS4xaH1otWlUkTC6Zz fdDxGstmqS4Pt3jWizRiFMR/xvbHAopYTMKSXrXdm1KDRHTHS6rXU2XrpGLOwvtCkcoU8dHqi3m hOyY7cah7gdkXpUrKgLhK7LtEmBZXM+j1cM9chWE/YBWFVcW5lD+U9bXWwY0DywQpVhlvgu/aR7 T1OzyY018sgwOCHlfFNyOaTlZQ2t13OWIxYLl9k= X-Received: by 2002:a05:6000:2ad:b0:382:4f9e:711f with SMTP id ffacd0b85a97d-386453d2a9cmr3015017f8f.6.1733826595719; Tue, 10 Dec 2024 02:29:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO3hLzX4uTUzOuyS45haTJxJ0zQ18nIw0l6fv8TvmCXKSia2JBwA5Dq7BQ92qLywW0aXOf2g== X-Received: by 2002:a05:6000:2ad:b0:382:4f9e:711f with SMTP id ffacd0b85a97d-386453d2a9cmr3014999f8f.6.1733826595383; Tue, 10 Dec 2024 02:29:55 -0800 (PST) Received: from localhost (p200300cbc723b8009a604b4649f987f3.dip0.t-ipconnect.de. [2003:cb:c723:b800:9a60:4b46:49f9:87f3]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3861ecf42desm15209824f8f.15.2024.12.10.02.29.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Dec 2024 02:29:54 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Zi Yan , Vlastimil Babka , Yu Zhao Subject: [PATCH v2 0/2] mm/page_alloc: rework conditional splitting >= pageblock_order pages when freeing Date: Tue, 10 Dec 2024 11:29:51 +0100 Message-ID: <20241210102953.218122-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: LadBdZiTI-1LBpC3Ttq2t2DRoIm96sJYTdOR5AAJ2nA_1733826596 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 9F5FE4000B X-Stat-Signature: icqxj9y59eytnhw5cdjjaj836twt7coh X-Rspam-User: X-HE-Tag: 1733826576-278521 X-HE-Meta: U2FsdGVkX19WB/+x5eKeLEBvvMpQ+zDgbnu2lJfEm1aGBtfvbM9hQzjh/95oskYlwQe1eh96Auro90YBhxNsL0ujtNZZ/Iuln0h8PJjR3RUlaDJ+KnsAEuk54xf/s8smZUfL90VaOZ9G2zQBulMYsg5egeOKNQZMuh6u6pfTSdsmiVBKI0Xw/QVOCEvBuOg99rNluS/F4/vTYb9kfhokPU74ciGm64BLlagYN9ahlrejTL9xvZTp0ql8ARQgMDYhEk0Tk+t0+gUDJWrYEP05F69LAQB2tAiifTdNalvcGY6TeCLZHbqhZUQBj6VqhTuefW7JLJ3k4tdgiQSA/yJvaAXdd+AdAYjXry2MA6gre67AUdJLWmcmvDRIpjFCWjfy0FrRSPaENP+atynYW45RoP2g7dogpJ7SoOBc6xxzECJiOHXXmYd9SIQwEyzJJBcU6e0rqSb2jZnll9HJ2RDwwmpBOLC3hLkQ23hWVj+dCSddFWGhfaW5FdrU/nt84dkeJwpe2fErrgiMsO7kVIU9Ap8mslpoCW8c2qhfYlYwr8cvqyehIKMLGFzIsVvhCGoIe/UxomrSY88EVpG7x1J+YIkWs8baLYbF2qBK2T2ytXHtzrSZWVEpnZQRa15VJdnz3WNags5J/3b3dyDnycugRraSPZ860IfnBpIk69mEv7L02wucY6ZKtlQZgaGwvUqwVgpwslJSEtPRdD0nEKkU8fYLQOyEt8iMfuU27JXhMBJo5iudH/MWNqKaprCgZ5t5bfgsJGYbHDOCBZjPO3xptO59Qq8xvWDIL5BENiyshgeAHVe2TJpt90vxBCp7Q30mdR1U9hsiHShSwEXleHbxKywKJ79oB2IGKzkz0RNf44E27bV7A8eqGJEeC1BU7um9NGm/pWEgBsB5HF/zBJlsFZ24fd3JbvxVuUCAVnWezR1RlrezCl56QvHg5dW9JBT5bPOL7M702atlZ1x8l8B XUK2aYD9 mpQL/VaQAJcEOGKYkM/NtS6nns6KgDWqSGhqfjJY6KVlSkCMho6hU9umRBPoNjJTjGBXhkjRZgcLdU9r2KLRA+4MVin4RYho5QiQM2sJMuV0xF+C6b1QXjL9TOp5cpG1AvMeUofT8m/LPZtuil4OvDSrFHn7qKnRmIJfCL0bjP+UQ+mUxpCkHcPI9gxVM9vNI2EKce8AeFJaq8ORj0uV1v54EU3lEhwm2j1rKac98btqZly9I9+q5Wwe0mJXSZtD/HidTVT4zCSzA/VGBOCp6ytaXQuFxk0f3jwKHLV9UuGmCxggKBgDjzB0oTCXKHrOi5J5F1zMpZJFZKAZ7IX3la3oxowe1rqqta7F14pJuE1TeWswW0uWnum6xSDVVP7HasLl8aQ6CQ8Hid2hgAcRsAMwpmQzh3WZsDwEutKR+UtQfsWpr6C/5LGau+mZm+LYuOWh4g6i71raJzXroURWvXPmTzhrRY+CfG/TejINqb2T+njgD9EijCvRvOM19f64v6ei6Yudmtb+o+fIWe9zrCIvLX4uz0OW7zSZ3CLa7ewTw2oX6JFwujfSZHwgDcqawBKI9ONAFFVIFnaPWt5DvZyLeDvEORbAEWl/KAmUojfQgX0Q= 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: Now based on [1]. Looking into recent alloc_contig_range(__GFP_COMP) support, I realized that we now unconditionally split up high-order pages on the page freeing path to free in pageblock granularity, just to immediately let the buddy merge them again in the common case. Let's optimize for the common case (all pageblock migratetypes match), and enable it only in configs where this is strictly required. Further, add some comments that explain why this special casing is required at all. Alongside, a fix for a stale comment in page isolation code. Tested with runtime allocation of gigantic pages and virtio-mem. v1 -> v2: * "mm/page_alloc: conditionally split > pageblock_order pages in free_one_page() and move_freepages_block_isolate()" -> Similarly avoid pfn_to_page() on something that might not be a valid pfn -> Add a comment regarding using "zone->nr_isolate_pageblock" in the future to the patch description Cc: Andrew Morton Cc: Zi Yan Cc: Vlastimil Babka Cc: Yu Zhao [1] https://lkml.kernel.org/r/20241210093437.174413-1-david@redhat.com David Hildenbrand (2): mm/page_alloc: conditionally split > pageblock_order pages in free_one_page() and move_freepages_block_isolate() mm/page_isolation: fixup isolate_single_pageblock() comment regarding splitting free pages mm/page_alloc.c | 73 ++++++++++++++++++++++++++++++++++++--------- mm/page_isolation.c | 9 +++--- 2 files changed, 63 insertions(+), 19 deletions(-)