Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7046621rwn; Tue, 13 Sep 2022 12:59:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6v9fcgv2gz28OHxyY2HsgK3ZLNWlWmxnyl2qRns8fzRRLFQdZwk4zJc6e9yoTzPnH3rM5f X-Received: by 2002:a17:90b:1a90:b0:202:ff17:4a80 with SMTP id ng16-20020a17090b1a9000b00202ff174a80mr890376pjb.213.1663099181809; Tue, 13 Sep 2022 12:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663099181; cv=none; d=google.com; s=arc-20160816; b=FA3bhbBVtawHIalB6iujt2bSxW2aUnlhahpNdo5/ml1zTGQP+wOZ35x92J2fhxSELZ CPQtcHD/syZn4k7JMhCpQyRnYte6N1ts7PbcpIoHIPR/R0sd69bO2RJa9OuGt3lAItcl 9Yz4Ds5AtKMSyD9HDvYEM3q4NBDGBGBdG9Kc4x09RAFG0sR4IryhRsWJN28SH7iK03EM +aC6x6GHAEA9Tm3HLrYjhXWuIG41ob8fZbkXSQ4y81BG8JUSpb9ruNVmiU2oO10evVfx f27q4Vef16jzh4s9BQ5ipX3P683OkzBil+XHXNE1VuJU4NxDxhfUIuhvJlQprbpmkCCy fWMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ae0x/cYtHCzUmIbnlOleUipnU3BBydliG8CbSfbHHfI=; b=xKNKwf8MCUNz7Bi62954aqztK9guXDnSEu7FKu04sEGVieVelAb0D+6SSYcUz8mFIQ fh6XsqPupPMbhhgtbPRxf33kDZDnoasLuHhgLGNSTWBvWmtHS0JjGSGNg2I//q0LU+Z0 d1Vfqhs8eCiB9ub5JZPfUKAaiIl8fQ4kR9GZNRptq6hCBSR4OVZgo7dSG9puZ5CyCJGn vxD+QoJYsFjsg+hhUFr9GcR9muawE4IMA3WTF+Ji5yHac1zBFhU8xXt8/UOcJ7YzwKmk 5unDCoFtylcAkqBuGtDmYNbNaWCd3Rd563JPkyHmHnRBv/z3WBemubd6elxZlDIPI2jX BWWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lQy156yj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a170903019000b00176ab430a57si12899848plg.546.2022.09.13.12.59.30; Tue, 13 Sep 2022 12:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lQy156yj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229759AbiIMT6O (ORCPT + 99 others); Tue, 13 Sep 2022 15:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiIMT6D (ORCPT ); Tue, 13 Sep 2022 15:58:03 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE7472697; Tue, 13 Sep 2022 12:58:02 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id cb8so9637682qtb.0; Tue, 13 Sep 2022 12:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ae0x/cYtHCzUmIbnlOleUipnU3BBydliG8CbSfbHHfI=; b=lQy156yj9m33v2+lsCppN/1SSiL1+HSKUeGu4OKDvKzsWQP9uaxSZeRF6KYff4/ZX1 T8ar9K8mrC7poQnpcOlicqZBPrnyrX4lQmy/efXceAo8c/r+O7+kebNQPiRqxM6b8RHk nqDdqIjYqMl2UkmBaLyC3jNoxqdBf+LTtzsYTc4L2U/V/TdvsthKIhCb1FgggCffFcVL 4UCRPgfEkwehGvOaibbczRrkl3etaXkViPMT1ZepP3U6LDqZx2jP70X41REaFOYLplOf cOzr55DR2HMCT6kc/P98YRx0lPP2AD9Ny8hyMOuXORVZJrRjvmaKZrJZ1BXySGhbtpI9 HDig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Ae0x/cYtHCzUmIbnlOleUipnU3BBydliG8CbSfbHHfI=; b=DhK79UjZYFX6oR2ZfYRzZaRib+JuOiQw8zC14/4oqBwzjoVvBskxTnNUCUo+YU570S B5CZYKkrdBf5SwmIMYGyhv/n0nQVNWtcdtummZTCM0UGL0qkAs/xpdg/H4boH+pE0V9V yNnJE8yAHHm5NHtpw73ESZKl9QW0K8FTlUT77nRa8MmIZjyn7k80pomSnX/iXKsxf/jt eMcbYT9SF2INEc+LzvA4qoehtyBZ95C/UEdreXGb1AJ+P7CpAgZ8SaYBy7XlXjzhAbD1 b4/+ggHwwyaafLccNik9c5gSOMZXg42FzxbmAC0/kJXemAWbVjbqBVRP2pIP+UUYFtSk QSng== X-Gm-Message-State: ACgBeo2JCDymnw+Bopy8tAou9papj5jEbvfJOtWdQd8u6UDfWCnRq0uE HXtocqxXjAP+AHFJ9lJ0vIw= X-Received: by 2002:ac8:5790:0:b0:35b:fd92:6fb8 with SMTP id v16-20020ac85790000000b0035bfd926fb8mr4051143qta.53.1663099081690; Tue, 13 Sep 2022 12:58:01 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s11-20020a05620a29cb00b006b8e049cf08sm276305qkp.2.2022.09.13.12.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 12:58:01 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Mike Kravetz , Muchun Song , Mike Rapoport , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Doug Berger , Florian Fainelli , David Hildenbrand , Zi Yan , Oscar Salvador , Hari Bathini , Kees Cook , - , KOSAKI Motohiro , Mel Gorman , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux.dev Subject: [PATCH 02/21] mm/hugetlb: correct max_huge_pages accounting on demote Date: Tue, 13 Sep 2022 12:54:49 -0700 Message-Id: <20220913195508.3511038-3-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913195508.3511038-1-opendmb@gmail.com> References: <20220913195508.3511038-1-opendmb@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When demoting a hugepage to a smaller order, the number of pages added to the target hstate will be the size of the large page divided by the size of the smaller page. Fixes: 8531fc6f52f5 ("hugetlb: add hugetlb demote page support") Signed-off-by: Doug Berger --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e070b8593b37..79949893ac12 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3472,7 +3472,8 @@ static int demote_free_huge_page(struct hstate *h, struct page *page) * based on pool changes for the demoted page. */ h->max_huge_pages--; - target_hstate->max_huge_pages += pages_per_huge_page(h); + target_hstate->max_huge_pages += pages_per_huge_page(h) / + pages_per_huge_page(target_hstate); return rc; } -- 2.25.1