From patchwork Tue Sep 13 19:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 12975310 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 89E3EC6FA8A for ; Tue, 13 Sep 2022 19:58:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 062436B0075; Tue, 13 Sep 2022 15:58:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 011A96B0078; Tue, 13 Sep 2022 15:58:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DCDC38D0001; Tue, 13 Sep 2022 15:58:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C68D76B0075 for ; Tue, 13 Sep 2022 15:58:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A08681A0B8B for ; Tue, 13 Sep 2022 19:58:02 +0000 (UTC) X-FDA: 79908123204.02.326B5CF Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf23.hostedemail.com (Postfix) with ESMTP id 6343A1400B5 for ; Tue, 13 Sep 2022 19:58:02 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id g12so9221976qts.1 for ; 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=bzKzWy8H14Zk8DITKAGF/blnSh7JuRkj5HDTvZdwxB8ovuPr6eZ2pT8jmQqe/yH0g6 xIMXoaqeHyQmfZBGYqtGddIXHhmvX1Bf5Qo+lZdEX9G2udcKRlKH3rT4CyDhov5oGDPj K5wvHVvK+8Nv86898t/CWyxQcccb6Fmnj+w+EdBjHJoc3g4r1opZym1OKwAw0HbUGcGg bVQqrrEGIBftCtjgA7MMQYgibpiS54kQVZe/wTRJLMKg8xanloNdQZkVeBI4SzDqRx8n iokpvn6KiP3neAcYQ1koEwfV3aTF/ad7Yg+OzvsKhf4waiFPSUoeFJkbh0s6x4dwrvVy JOnA== X-Gm-Message-State: ACgBeo2xj6xv6veS9k+cK7pbds2QxqKwbPZiyKW/M34fnhUJqoGBVls2 bx4fX1+s7yeC4p+yZ/wjlPQ= X-Google-Smtp-Source: AA6agR5RQ3Vz73r+e9pp4sPmIM/iMa/zHS6QVY1LvvDFqMY99XQUTUB/nmtdr1ce7F9gfpRjTDrD5Q== 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663099082; a=rsa-sha256; cv=none; b=EOPkkuvICGLy8Z6WO9mx/GxVZCM/sh0nSIgtxzUafrOn/cA1a/oeu/ZTy4Ps2vKakSbsCY oAAVrxKXYnQUGdYHG0f8L1LjcoddXV4CSx4p3dJZp1+o+ad5Ygof7aJ3RNo7FnwoDPKstU WNgPRCIpiRRTAmgUN/8rhbuanCMOJlk= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lQy156yj; spf=pass (imf23.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663099082; 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:in-reply-to:references:references:dkim-signature; bh=Ae0x/cYtHCzUmIbnlOleUipnU3BBydliG8CbSfbHHfI=; b=d+iuKDTbhn0I0Ht14g0arcDE1U2fimKi09B7VXXSkjHkPt+V/3s7dtE1xi45GqoqUd8gkJ acAWZ6fptg2PKYUwTKQIbUO+Nv2u3bogb6canmS7ktnV9NAi9tbdzIlJxuMd7PnMwpMzLE ZvtQGATEHKDnhetfiTZUebe5FAkxRXQ= X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lQy156yj; spf=pass (imf23.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Stat-Signature: t87rctg6h8sqwr6qbjwocabewowudqcc X-Rspamd-Queue-Id: 6343A1400B5 X-HE-Tag: 1663099082-425423 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: 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; }