From mboxrd@z Thu Jan 1 00:00:00 1970 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 29577C32771 for ; Wed, 21 Sep 2022 22:37:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EDE480007; Wed, 21 Sep 2022 18:37:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89D466B0073; Wed, 21 Sep 2022 18:37:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 764CD80007; Wed, 21 Sep 2022 18:37:14 -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 672DC6B0072 for ; Wed, 21 Sep 2022 18:37:14 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 469BD40318 for ; Wed, 21 Sep 2022 22:37:14 +0000 (UTC) X-FDA: 79937554788.14.23D83D9 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf17.hostedemail.com (Postfix) with ESMTP id F097D40057 for ; Wed, 21 Sep 2022 22:37:13 +0000 (UTC) Received: by mail-qk1-f178.google.com with SMTP id 3so5039672qka.5 for ; Wed, 21 Sep 2022 15:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=jg/Gl7Z8koWCH3EVK8ZxePVcvCL50iYxWjhRlo72dUo=; b=qhBUOiiLFKbmBirKrjqRHaxf6UzRE/CkIjRJeQFwjs6UWeQDDJHP80BRI2/6t6w7yv G89CgjJ6D5YnRBos19KphDCEl45IUUwi2kWqwI+iNuIrYz0TcvbsTj90ZuAUj5AmIlm6 cNP5FPiT+KmytCQ3akPaoyK4OkoUo8FZIdw9suidyudRqm38qnfF4GJBDwDDpuiB2dvL 0eXQlIucL/Ci6S/n4OImFmLTYq61RrLaDuGCDFq56h50QvieE6iofZjnqCCfuEecNlRs nkUXjhbxb0Vi0kjwgVKxQlygYF0WFZCybourRbgEfKoguM1cBJDHXwBY2Yew2/xTpG8m F0Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=jg/Gl7Z8koWCH3EVK8ZxePVcvCL50iYxWjhRlo72dUo=; b=RKwdvuHLuGYHYIZNnDJCvkNVKwh1LH9Wf80EcuDa1oFTlDEimhB21hNDo+8pZFNXO5 z/rKgL5HI4qqmGN4w/dCLcuRE7bykkL6e/mqz03J9c2QdPErMPAyhENpDmTGEOtRmWO1 0tu2eUX84RVu1H6fnkWnj2nvKH0hg4EAkW7NSS0CCeChrQWd4H6+oRxF+QMZTf87sSjU 5DEZ2risZkvC3SQyMjG+QhQ6UubFvPiRKJCuiDYZcwgN/b3975W4dbkw1h0rADqGG0wW 3gtws/+D1yTZz9QJ4C9CTkS08gw1BombMFqxES+ewK76KiG1iG3Hle8B3+RTl2QeN1Q2 YUoQ== X-Gm-Message-State: ACrzQf0ozEQCRHTiRQhA31LVGcTR9XDdSZdJjuSRvKbLt+8DK6eSmDmX gd4FwuCzrPsYOFOwrLXJrII= X-Google-Smtp-Source: AMsMyM7sWUmFCQvM4gIOUFNORUgZqQSXmTTG3w2kCEpm9xYr/ksUyU2feKL+ClHC5s5wbNlVvpPmew== X-Received: by 2002:a05:620a:410e:b0:6bc:1ea0:19f9 with SMTP id j14-20020a05620a410e00b006bc1ea019f9mr210704qko.667.1663799832876; Wed, 21 Sep 2022 15:37:12 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id j13-20020a05620a288d00b006cea2984c9bsm2731540qkp.100.2022.09.21.15.37.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 15:37:10 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Mike Kravetz , Muchun Song , Florian Fainelli , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH 0/3] mm/hugetlb: hugepage migration enhancements Date: Wed, 21 Sep 2022 15:36:36 -0700 Message-Id: <20220921223639.1152392-1-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663799833; 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=jg/Gl7Z8koWCH3EVK8ZxePVcvCL50iYxWjhRlo72dUo=; b=RDcAjMDRoCvke/5oGteY+L02OqPpPTDJ9SXIzuBLwSKg9XwY67RFg42N/Jq72PXGhicvLN 4qG39KPg6dq3gX5ncipwXJjIRoN5vyBC+MAKqg7wtwjf0TTOcFXvMpiLIj5esj7s3rjDnR 0+N1oh+YDAvcBdvsJPPm39zJEgEv4e8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qhBUOiiL; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663799833; a=rsa-sha256; cv=none; b=EpEyxvBVciXNOnpnxU9izLwF9sBuPR8VI9SQhNoGLyYZM5u+nRgOxLdXckXDqZuOCefH0A JQD1TVcPxpUVZf4MAllvuTIBxZ71k+hs6PecGV2JQTTwfs8nieHs6nfiMHFCcIZ9EUvREO 87Qvtx3Z0T3CEdTZvpli4VTos+N9e64= X-Stat-Signature: cp5edaeo7dz1qbmze9xqdrws9abwm8sb X-Rspamd-Queue-Id: F097D40057 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=qhBUOiiL; spf=pass (imf17.hostedemail.com: domain of opendmb@gmail.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-HE-Tag: 1663799833-489296 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: This patch set was included as patches [04/21-06/21] in my previous patch set to introduce Designated Movable Blocks [1]. They were included there for context, but they have value on their own and are being resubmitted here for consideration on their own merits. The alloc_contig_range() function attempts to isolate the free pages within the range and migrate the data from non-free pages within the range to allow those pages to become isolated free pages. If all of the pages in the range are on isolated free page lists they can be allocated to the caller. When free hugepages are encountered in the range an attempt is made to allocate a new compound page to become a replacement hugepage and to dissolve the free hugepage so that its pages within isolated pageblocks can be added to the isolated free page lists. Hugepages that are not free and encountered within the range must be migrated out of the range and dissolved to allow the underlying pages to be added to the isolated free page lists. Moving the data from hugepages within the range and freeing the hugepages is not sufficient since the allocation of migration target hugepages is allowed to come from free hugepages that may contain isolated pageblocks and freed hugepages will not be on isolated free page lists so the alloc_contig_range() will fail. To address these shortcommings the HPG_dissolve hugepage flag is introduced to tag hugepages that must be dissolved when they are freed so that their underlying pages can be moved to the page allocator's free lists. This prevents hugepages that have had their data migrated to new hugepages from being made available to subsequent hugepage allocations and allows the isolated free page test of alloc_contig_range() to succeed. Dissolved hugepages must be replaced with new hugepages to keep the hugetlbfs balanced. To support blocking allocation a new workqueue in introduced that is analogous to the workqueue introduced to support the hugetlb vmemmap optimization. This new workqueue allows the allocation and dissolution of the hugepage to be offloaded to a separate context from the freeing of the hugepage. The sync_hugetlb_dissolve() function is introduced to allow outstanding dissolution of hugepages to complete before the isolated free page check is made by alloc_contig_range(). In addition, a check is added to hugepage allocation to prevent free hugepages within an isolated pageblock range from being used to satisfy migration target allocations preventing circular migrations. [1] https://lore.kernel.org/linux-mm/20220913195508.3511038-1-opendmb@gmail.com/ Doug Berger (3): mm/hugetlb: refactor alloc_and_dissolve_huge_page mm/hugetlb: allow migrated hugepage to dissolve when freed mm/hugetlb: add hugepage isolation support include/linux/hugetlb.h | 5 ++ mm/hugetlb.c | 161 +++++++++++++++++++++++++++++++--------- mm/migrate.c | 1 + mm/page_alloc.c | 1 + 4 files changed, 131 insertions(+), 37 deletions(-) base-commit: b90cb1053190353cc30f0fef0ef1f378ccc063c5 -- 2.25.1