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 94297C77B6E for ; Fri, 14 Apr 2023 14:39:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22AE7280003; Fri, 14 Apr 2023 10:39:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DB3C280002; Fri, 14 Apr 2023 10:39:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07C2E280003; Fri, 14 Apr 2023 10:39:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id EB77D280002 for ; Fri, 14 Apr 2023 10:39:57 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C046F1A02F5 for ; Fri, 14 Apr 2023 14:39:57 +0000 (UTC) X-FDA: 80680256034.16.89C0135 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 5C6034001E for ; Fri, 14 Apr 2023 14:39:55 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PwZPjzNG; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@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=1681483195; 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:in-reply-to:references:references:dkim-signature; bh=sG4yK/TOLxym+JLV5xeX+hZs0uy2QtpBhj9MkCeWpIE=; b=IpYShth69gdvAxlmaF1r3gy8GmVjWeA5Wy8YYEcv1xk3mnxXAMZH/JYKpaZ+aE3UfWK64g qfxX9a8NgQHj1PEBu4G8YIWamGRB/W3AfMgffr/PvFynbYDKw+LjlEvNBbcvdBY+pDJKfl KMTWI4x60oGqOZqP7iW382wvssLIcyw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PwZPjzNG; spf=pass (imf11.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681483195; a=rsa-sha256; cv=none; b=4VAUOpAqvsApQd/GM+JrWc5a0kasXlop5GL0bLy4ndsvrE+Xev6ztFI8NnrZFgY27MWjnq mN9LGS8DhWKNNmYlOJxtxmoQ09dOtfq6nH5U2aZA3DG0QAX4cepsFTxeULSYmpua7yDjWa RVgzLFOzEWLAkeFLxN7tI/8bCAv6+LE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681483194; 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: in-reply-to:in-reply-to:references:references; bh=sG4yK/TOLxym+JLV5xeX+hZs0uy2QtpBhj9MkCeWpIE=; b=PwZPjzNGXDwOyo+NXuN98S2RxFmBfx0WYiOodroVjQOTRnTY9dMAHsXVNMZ5sLJIKMBK/P dQ9RlkcSdQLlin0SSBZ+dldFgoochWmD8VzImXu69OLUpzonGJ29HdT2MT2jHaW/XTgo7+ 5Bm7BQnCbId+fngp2LUngTURn/hIMOE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-Kldmw6q9NZKWex76SPqijQ-1; Fri, 14 Apr 2023 10:39:53 -0400 X-MC-Unique: Kldmw6q9NZKWex76SPqijQ-1 Received: by mail-wm1-f69.google.com with SMTP id p12-20020a05600c468c00b003f0ae59f2e1so1480360wmo.9 for ; Fri, 14 Apr 2023 07:39:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681483192; x=1684075192; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sG4yK/TOLxym+JLV5xeX+hZs0uy2QtpBhj9MkCeWpIE=; b=VF8+rnqb+6hNxR09z3QVqCW1pL7FsoZv0uvsfPBOaLgcBKUiytd1Ott0GLqzBm/d1w DEhKe93tDmUviFR4bcCnZUqPWNH2BodyFLLj/MoaAg7tkeDcJVVo566idMsfbr19miOD LgvczOmMjLTHVnnsxIzcpyGLTfoxLYQcLg+BfS5FQfQVw6WHMyhCfDWpN2KvHfJljh4y kVtYJoqzzjdY3T2E1RpP5dDJ30OQGVxnHCS8HEWjRn/IG/hevwwPqwlU39TNrMQY3cA3 4CmPeflhFWvWN9fwPnSO70Vq4Z2QyDhYYj8OGZDT6Rr7v+jB5mJyvp4dR+4+wFhRpbeS d/5A== X-Gm-Message-State: AAQBX9e3Y9UvS3HNjoE2D4u44aa4XCTc83MaQWwjwSgPW7fBpXb91Nai BT4OJMYTPHVDOeOdS8KJvXsIdOADR31B8ZPWdcinTCeOipyBxJG/QbkB6xuOKxPH3QStwlPoYRa 8Ytj40rHQZt8= X-Received: by 2002:a1c:e916:0:b0:3ee:b3bf:5f7c with SMTP id q22-20020a1ce916000000b003eeb3bf5f7cmr4436935wmc.23.1681483192284; Fri, 14 Apr 2023 07:39:52 -0700 (PDT) X-Google-Smtp-Source: AKy350ajpuhomcgDMexRQTagIyyjV3SARUkfLNZ+e4RtxbW08d/nVJC7kwMoDCf3qu8qVSGUOA1iUA== X-Received: by 2002:a1c:e916:0:b0:3ee:b3bf:5f7c with SMTP id q22-20020a1ce916000000b003eeb3bf5f7cmr4436921wmc.23.1681483191916; Fri, 14 Apr 2023 07:39:51 -0700 (PDT) Received: from ?IPV6:2003:cb:c702:5700:cb5b:f73a:c650:1d9? (p200300cbc7025700cb5bf73ac65001d9.dip0.t-ipconnect.de. [2003:cb:c702:5700:cb5b:f73a:c650:1d9]) by smtp.gmail.com with ESMTPSA id i8-20020a5d5228000000b002efb4dc5a5fsm3734751wra.7.2023.04.14.07.39.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Apr 2023 07:39:51 -0700 (PDT) Message-ID: <377e6f67-e1c1-38d7-9743-9783c90489b8@redhat.com> Date: Fri, 14 Apr 2023 16:39:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] mm: page_alloc: Skip regions with hugetlbfs pages when allocating 1G pages To: Mel Gorman , Andrew Morton Cc: Vlastimil Babka , Michal Hocko , Oscar Salvador , Yuanxi Liu , Matthew Wilcox , Linux-MM , LKML References: <20230414141429.pwgieuwluxwez3rj@techsingularity.net> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230414141429.pwgieuwluxwez3rj@techsingularity.net> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5C6034001E X-Stat-Signature: ajtwi5orm6po9omfk1j8999w67nnhz1f X-HE-Tag: 1681483195-234695 X-HE-Meta: U2FsdGVkX1/m76zlIExZuo5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WD7vcOSp3YER6ByDWQ5nK8ikpfjwiQolnruqHNmgh9NU9Kzd7OHWNAOEvhzYhouWGo1iEOy6M2mEylZcSROAIPn7OXROxUII5GCWSDFCYb1cFQQeeRNuVrP7S1P1SHPIbJPgDnTpeO6w29Sw0mdVuxbhkt2eqJMtMQN0fOjDyInbefoYKCzoEWoVXJR3+XCrN1BpN1QIOKQjV4g3llEB04MmVJSiEJ2NRuoOhEL4TN3QnsaJUte7fKLkccfUdAA/Yoi1gcZbOTuI0fgM9CVg4coM9EMYVA3IxV8rlgQvriKf0e5bT02OFKpg7T/KuoVgk1GJeZSvUC9pur12JzIyq8GNJHFWM0fiSd60OKFl2XwgncZBDxek1KmBBmuWC+qVtPjyO7VG4pZ6qqlfJ/rskU8wZdZDnN22qmP5RgcjJwqAVUsMGXAibkPVHYddXvkoKPLaxCGzu4nKe8nh7Dllizc0dZ4iBxERlyEboxJXwgyO7fYUx03PSFUxCBZ15yan9oi07z1rgFs= 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: On 14.04.23 16:14, Mel Gorman wrote: > A bug was reported by Yuanxi Liu where allocating 1G pages at runtime is > taking an excessive amount of time for large amounts of memory. Further > testing allocating huge pages that the cost is linear i.e. if allocating > 1G pages in batches of 10 then the time to allocate nr_hugepages from > 10->20->30->etc increases linearly even though 10 pages are allocated at > each step. Profiles indicated that much of the time is spent checking the > validity within already existing huge pages and then attempting a migration > that fails after isolating the range, draining pages and a whole lot of > other useless work. > > Commit eb14d4eefdc4 ("mm,page_alloc: drop unnecessary checks from > pfn_range_valid_contig") removed two checks, one which ignored huge pages > for contiguous allocations as huge pages can sometimes migrate. While > there may be value on migrating a 2M page to satisfy a 1G allocation, it's > potentially expensive if the 1G allocation fails and it's pointless to > try moving a 1G page for a new 1G allocation or scan the tail pages for > valid PFNs. > > Reintroduce the PageHuge check and assume any contiguous region with > hugetlbfs pages is unsuitable for a new 1G allocation. > > The hpagealloc test allocates huge pages in batches and reports the > average latency per page over time. This test happens just after boot when > fragmentation is not an issue. Units are in milliseconds. > > hpagealloc > 6.3.0-rc6 6.3.0-rc6 6.3.0-rc6 > vanilla hugeallocrevert-v1r1 hugeallocsimple-v1r2 > Min Latency 26.42 ( 0.00%) 5.07 ( 80.82%) 18.94 ( 28.30%) > 1st-qrtle Latency 356.61 ( 0.00%) 5.34 ( 98.50%) 19.85 ( 94.43%) > 2nd-qrtle Latency 697.26 ( 0.00%) 5.47 ( 99.22%) 20.44 ( 97.07%) > 3rd-qrtle Latency 972.94 ( 0.00%) 5.50 ( 99.43%) 20.81 ( 97.86%) > Max-1 Latency 26.42 ( 0.00%) 5.07 ( 80.82%) 18.94 ( 28.30%) > Max-5 Latency 82.14 ( 0.00%) 5.11 ( 93.78%) 19.31 ( 76.49%) > Max-10 Latency 150.54 ( 0.00%) 5.20 ( 96.55%) 19.43 ( 87.09%) > Max-90 Latency 1164.45 ( 0.00%) 5.53 ( 99.52%) 20.97 ( 98.20%) > Max-95 Latency 1223.06 ( 0.00%) 5.55 ( 99.55%) 21.06 ( 98.28%) > Max-99 Latency 1278.67 ( 0.00%) 5.57 ( 99.56%) 22.56 ( 98.24%) > Max Latency 1310.90 ( 0.00%) 8.06 ( 99.39%) 26.62 ( 97.97%) > Amean Latency 678.36 ( 0.00%) 5.44 * 99.20%* 20.44 * 96.99%* > > 6.3.0-rc6 6.3.0-rc6 6.3.0-rc6 > vanilla revert-v1 hugeallocfix-v2 > Duration User 0.28 0.27 0.30 > Duration System 808.66 17.77 35.99 > Duration Elapsed 830.87 18.08 36.33 > > The vanilla kernel is poor, taking up to 1.3 second to allocate a huge page > and almost 10 minutes in total to run the test. Reverting the problematic > commit reduces it to 8ms at worst and the patch takes 26ms. This patch > fixes the main issue with skipping huge pages but leaves the page_count() > out because a page with an elevated count potentially can migrate. > > BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=217022 > Fixes: eb14d4eefdc4 ("mm,page_alloc: drop unnecessary checks from pfn_range_valid_contig") > Reported-by: Yuanxi Liu > Signed-off-by: Mel Gorman > --- > mm/page_alloc.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 7136c36c5d01..b47f520c3051 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -9450,6 +9450,9 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn, > > if (PageReserved(page)) > return false; > + > + if (PageHuge(page)) > + return false; > } > return true; > } > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb