From patchwork Sun Aug 11 21:21:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 13759887 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 88E35C3DA4A for ; Sun, 11 Aug 2024 21:21:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D7116B008A; Sun, 11 Aug 2024 17:21:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 885C56B008C; Sun, 11 Aug 2024 17:21:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 774476B0092; Sun, 11 Aug 2024 17:21:36 -0400 (EDT) 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 594C56B008A for ; Sun, 11 Aug 2024 17:21:36 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C4AEBA05BC for ; Sun, 11 Aug 2024 21:21:35 +0000 (UTC) X-FDA: 82441236150.09.C2355F3 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf11.hostedemail.com (Postfix) with ESMTP id 1CE8D40010 for ; Sun, 11 Aug 2024 21:21:33 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HuLlqvrp; spf=pass (imf11.hostedemail.com: domain of 3XCu5ZgYKCNMNJO6zD5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yuzhao.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3XCu5ZgYKCNMNJO6zD5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723411283; 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:in-reply-to: references:dkim-signature; bh=mBxodn3ncL47aIchV0k38iOmKnnFrlE+aQTP6s51zh8=; b=zS5vUrbm8P60E+nNkuUYPHlvN+jpEnXbZrtup5xvSOd8bOwKPkPiMiESuYvsVT3+PbHnPe APAD70Sjt+FB4GJuAmjuCUvCiwTXr7CT0/ICb5tB4RunZcbmG5HesQeJ58fj6clbV5LtOV Ksu3wXOMmRiDzRgcKVH9uJQZAFMAp9s= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=HuLlqvrp; spf=pass (imf11.hostedemail.com: domain of 3XCu5ZgYKCNMNJO6zD5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yuzhao.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3XCu5ZgYKCNMNJO6zD5DD5A3.1DBA7CJM-BB9Kz19.DG5@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723411283; a=rsa-sha256; cv=none; b=ElvNFmcWRiLwtfhVuW7Wxk0TR9thhhtNNX4SjkFtj9ftAVJsMh35zhuCUIVyCplVMbJ9tX 6wglRtTtd6pF/8r4Vdk4oMQn3WefIbK3RmNCoVZv8kmPZ/sBDGG3us2ZdVvbKYK8LSPTi2 wuwM22jokuqhlu+Iymiqu1Z9q+vSHe0= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0be2fa8f68so7194105276.3 for ; Sun, 11 Aug 2024 14:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1723411293; x=1724016093; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=mBxodn3ncL47aIchV0k38iOmKnnFrlE+aQTP6s51zh8=; b=HuLlqvrpv6SU1XfH7omCULEZjUSD/O1+caZDGYjDnhLac5hNQANuEDthmTcIzb2m4g DRXvHDYxjk4WAd8RGsVR7b9Oz4F3098wcAFqw+9pcNx2iBWhC0pzdpexmcDenFkwDa5T 7LkwJ4H1sd1Vvgtu9MMl3NyUgNnJYeJq+bXqmpXEZbM2qNp3AshDneZHQ21+ZKel6tLi 68OUxQ+YTJr3HbIAdOs5D789QL6xZu6mHIeMxFPRJje4fk7mArwrUz33Yktmjzb4lDQf 0JgyosSwcJvFm6leRVCRbfmTbF/HwOdwPdXxq1PnBxDmcMyzAlxV76tZJ/mAUIWuAANN S+pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723411293; x=1724016093; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mBxodn3ncL47aIchV0k38iOmKnnFrlE+aQTP6s51zh8=; b=ubpB6aZ7cHabMEkFo+ghyYe0+KkXUkUZAcybg5GP3Keimp2ghF8806W7JAzEMlneWU TEUAxMNSSbCm/Etv9N5PX2FH0tPlcwvbiTvCrCdywSO2ZTMn2O2G88bSXn6+6MJLchpN vHnJFANiO3ZTkr/oo9GC5HqMspaRH7l+THuv4gPyVx9IEtyZxIvQX0dmljh618uBoIlA Y/qVUm33lF65jZ8Oghxa3i69W82CG8NFXcJ44UFFhPAV/A2ATEN1WQFn8AF53pCc6/Rv tQObSzkn5Yte3H+FJL3KO3ZgLYC6oyogxAmE9R/g8H1VrAHUmfrAZiJonnhJ+G3xhTlR 94mA== X-Forwarded-Encrypted: i=1; AJvYcCW4aKssxLrWEkFuwzkFiRbwzHx20o4XJ4fCMTTiWl02ZauvkhvDmKSOn3Q6FWZoMKLI5tdLxPNE6x3llN9rh3hTCyo= X-Gm-Message-State: AOJu0YyHlCb1XMFg2E75cVtcpajA0wDQgDlkS2++lnweciHkOxnky7PF IuZAdwRohCy9Zknq3g/BVUGfq1BlVTBIJkjfNwploZqkrE4brLOjurYdkhgkVOQzT4tdrdS6aqB E8A== X-Google-Smtp-Source: AGHT+IFDMuZv5daYo57AB4TlP3rAjpDKVJCYpQFPl2Vwy95c8vjlp62B/QB4tXK7JtoEaxQaoZ9BYYpvXVY= X-Received: from yuzhao2.bld.corp.google.com ([2a00:79e0:2e28:6:c9c:12b4:a1e3:7f10]) (user=yuzhao job=sendgmr) by 2002:a25:aa8e:0:b0:e02:ba8f:2bd5 with SMTP id 3f1490d57ef6-e0eb9a01882mr133827276.7.1723411292989; Sun, 11 Aug 2024 14:21:32 -0700 (PDT) Date: Sun, 11 Aug 2024 15:21:26 -0600 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog Message-ID: <20240811212129.3074314-1-yuzhao@google.com> Subject: [PATCH mm-unstable v1 0/3] mm/hugetlb: alloc/free gigantic folios From: Yu Zhao To: Andrew Morton , Muchun Song Cc: "Matthew Wilcox (Oracle)" , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao X-Rspam-User: X-Stat-Signature: bh6gs4wrx7bdtitpta3ba1t5x7toqyfa X-Rspamd-Queue-Id: 1CE8D40010 X-Rspamd-Server: rspam11 X-HE-Tag: 1723411293-721789 X-HE-Meta: U2FsdGVkX19YHWwILmvfZ2NTMDvdkQaojvbleIiqMyObqJEIo8v1zCbvo1JvlMTdAUQYE7KTBLTVEJC6mScapKGKSZiFjXagwJszYqiXU0gCbnkp7DRAj66ZhziyWjGHqe17SkQrpDCRGaVK4pwYUbxurDTYsC7Do5gYz1ueLcw5f92FzoIvnxYWb1BMWLX9ZmYHdfZjK/yP5n8yJELsS3AjA+wqc6NGagCU6iHV8BX/qL+D6bYNTm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CJRKX0oG5dsz9rWvmYwdCZxWrxGdAm1EyU/DvnyAR60qblXlx7XjnMUs1w5TomK4amZqRD/kVlhn4w5k9E15hMF3gQRoG2I4nKw/2f/uQaf7UWlz8BfnJLT+NJNOZjMWy/padeYDCAUpLeCQVmrrYz/KU4kHZ4uf0YhRPsvc= 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: Use __GFP_COMP for gigantic folios can greatly reduce not only the complexity in the code but also the allocation and free time. Approximate LOC to mm/hugetlb.c: -200, +50 Allocate and free 500 1GB hugeTLB memory without HVO by: time echo 500 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages time echo 0 >/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages Before After Alloc ~13s ~10s Free ~15s <1s The above magnitude generally holds for multiple x86 and arm64 CPU models. Yu Zhao (3): mm/contig_alloc: support __GFP_COMP mm/cma: add cma_alloc_folio() mm/hugetlb: use __GFP_COMP for gigantic folios include/linux/cma.h | 1 + include/linux/hugetlb.h | 9 +- mm/cma.c | 47 +++++--- mm/compaction.c | 48 +------- mm/hugetlb.c | 244 ++++++++-------------------------------- mm/internal.h | 9 ++ mm/page_alloc.c | 111 +++++++++++++----- 7 files changed, 177 insertions(+), 292 deletions(-) base-commit: b447504e1fed49fabbc03d6c2530126824f87c92 prerequisite-patch-id: 9fe502f7c87a9f951d0aee61f426bd85bc43ef74