From patchwork Wed Oct 4 15:32:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank van der Linden X-Patchwork-Id: 13408906 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 1B8E0E7C4D0 for ; Wed, 4 Oct 2023 15:33:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA5BD8D007B; Wed, 4 Oct 2023 11:33:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A568D8D0027; Wed, 4 Oct 2023 11:33:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91D4E8D007B; Wed, 4 Oct 2023 11:33:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8272B8D0027 for ; Wed, 4 Oct 2023 11:33:06 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 51919C036E for ; Wed, 4 Oct 2023 15:33:06 +0000 (UTC) X-FDA: 81308172372.29.67C76A5 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf03.hostedemail.com (Postfix) with ESMTP id 539192000A for ; Wed, 4 Oct 2023 15:33:03 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1X7m7QNc; spf=pass (imf03.hostedemail.com: domain of 3roUdZQQKCF8CSAIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--fvdl.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3roUdZQQKCF8CSAIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--fvdl.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=1696433584; 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=Kg8KrxF1MaAZHMaouRE62ghspnPx54LKKfq75d6UIBw=; b=k8HlrbqhPbUVGAwaWTeOaEEnAasZgGhNHnsiQWzSpkSGjoQP8Uw1bidsGsxcGaQ0P7dhi+ FoN2oC5gqGvw8Ol37glAmzU+kurSBaOe/Ube2I3gQDnnIA6xaJow6c6QKaROznzgGhOVng 01nx8BYeizeOyAhjqXCmaRes6W1caZo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696433584; a=rsa-sha256; cv=none; b=viz/xDHFZLoEqXH+3N8dgE28OMDmLotyI6mFZnmlXV6Btky3R2YM9uIWvCOaDZ/Z/IS9ri 1EPfYUwekqa44jCQq0S9Y4zn7smijsPmjFXi18AQU+sX86fVBorFI1S2ZHGLzn6yDiC2Ct maFcdTBQyBlULdJ4/q4hMwr932RYGL0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=1X7m7QNc; spf=pass (imf03.hostedemail.com: domain of 3roUdZQQKCF8CSAIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--fvdl.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3roUdZQQKCF8CSAIDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--fvdl.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-27756e0e4d8so1970784a91.3 for ; Wed, 04 Oct 2023 08:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696433583; x=1697038383; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Kg8KrxF1MaAZHMaouRE62ghspnPx54LKKfq75d6UIBw=; b=1X7m7QNcUMGkaMkkzjkLMFPL5PihD17frKljz2NgXEG+wC60mC+TFCTnuPgyQAMJJF rBu5Vj4KnaYOFxpWu7PuwIJAS2JTVfNhgplcTpXfBqbnum1uK/5MV/6kqTFzSdWfevll G72YVx91m1lkGm0QIlnCjx5863uFWmG0prMMu8fyxlGZnwOH/f7RYGxZltBTW7K4rPBa /MheESTgkhQF3hMW9Owcnet8vtHfZ88+huvEsWZWEya7EmRIWzaiGEBKp8h+ZAZkTg1N AxnTwtajjdAz8MdS0sy/3NyfH0gvZ8veKI6nUwXILKjGcYeB82brdtowGycSjhih59gm P9Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696433583; x=1697038383; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Kg8KrxF1MaAZHMaouRE62ghspnPx54LKKfq75d6UIBw=; b=czZC4iOIHwTRBy2xaCPrFa93cxijK1e5nCtvkHK5FtwSAeeAbZ5bNxdGgGwE8/uOSo ZlxgEUS8/InVQmJCBnBHNrvnXUzszlx740eCBHA84iWZpQYbtrtV21Nf3TW9FGJEC5fU Fm3vmQrYYyZP0ZWQcSlMVOwRmt5g5kt3ymQRYI2zPCijBwiuL/LPN6X7vX80rBJF4WUZ rmwDlK9le2dXWTXCwVLp9Bf+pfWZwLO0f6KztaAeWvnHKBCr7D3kOeH+urDCq25xxYsD e9JUKAQFOk6/8Pfwrpfztjin2GzqkknrTeiblG1ziiTZFkv1jsC0CJlY9tW4kZaMQv4C 0Ptw== X-Gm-Message-State: AOJu0Yw2AqjF0W+DBfRImQpblwEu5PfTv0l3/EpmIT0O0AMPcZeuK89j f6czPw09SB29mktuZ8l+ONj6xJ3KQ7alpCucR+Wj25lZ9GpvQDMfZ3RR51JoPtjT6Ob7GQ2V3c4 YCftkW9tsYgMgUot4RUcsNvsxOlyp+uSihLqSF/vWiibO0O1B/C0= X-Google-Smtp-Source: AGHT+IF2/Oo1mqrRQ0NSnXCp6mE9O94gG0MEajDPkXGAxxwHeP2l5KqdfINq8Cht7pIZwlxZd767UhGN X-Received: from fvdl-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:46ab]) (user=fvdl job=sendgmr) by 2002:a17:90a:cf13:b0:277:1bd6:81f with SMTP id h19-20020a17090acf1300b002771bd6081fmr43080pju.5.1696433582689; Wed, 04 Oct 2023 08:33:02 -0700 (PDT) Date: Wed, 4 Oct 2023 15:32:48 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.582.g8ccd20d70d-goog Message-ID: <20231004153248.3842997-1-fvdl@google.com> Subject: [PATCH] mm, hugetlb: remove HUGETLB_CGROUP_MIN_ORDER From: Frank van der Linden To: linux-mm@kvack.org, mike.kravetz@oracle.com, muchun.song@linux.dev, akpm@linux-foundation.org Cc: Frank van der Linden X-Rspamd-Queue-Id: 539192000A X-Rspam-User: X-Stat-Signature: a1t6woj1t9pdg9k6igt87o8aybwem8of X-Rspamd-Server: rspam03 X-HE-Tag: 1696433583-678543 X-HE-Meta: U2FsdGVkX1/BQHFxbTCxn5r276qYR+BI80Plc05RKFaC1bTsDwoIxWkb39fQMvIR3+4CFrGOuK6vM7M/RtrDLS3GhfNCvYXpzQRXPc7CQiuyzd+9ylfNJ8KePk1wFrTm8klt6ujwb1kLUkh6ClOhxBlSBokOdoJl6fOKpyB46SNeMoSFYN1gAb5hpIwVkqgg7sr1247zxztb0xCVlfDYK64VMc24lpbsQIplOWk/gcHz7mx6njncUvCkteg6bEwLwFsQgZJCTVxSeEoF356/SB6vxzF99JStN2kk4NX8jCh5Mgwzsw4J4fdsbREDFeCpVyEUvD/feLmrV6Mc5nF6a3UHGNSUgdYLqbqjhTpaDAg91DaRJdYLtA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BPR12r4Xd4r4nPG6mwvN72ioMm8YiHPweknZY2NR5W7G6cFGaAxoHgckwpI56nS5QkTbw2EbTizY8z6ldX0bhFtcV92plCPm1d+ld3ScrH+WwYpDuZZsFa/PRHeLQz71AFe3UPMxBnL+7yTWQKjHn7PAIadm3KM7Rwg90Hldl8g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000391, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Originally, hugetlb_cgroup was the only hugetlb user of tail page structure fields. So, the code defined and checked against HUGETLB_CGROUP_MIN_ORDER to make sure pages weren't too small to use. However, by now, tail page #2 is used to store hugetlb hwpoison and subpool information as well. In other words, without that tail page hugetlb doesn't work. Acknowledge this fact by getting rid of HUGETLB_CGROUP_MIN_ORDER and checks against it. Instead, just check for the minimum viable page order at hstate creation time. Signed-off-by: Frank van der Linden Reviewed-by: Mike Kravetz --- include/linux/hugetlb_cgroup.h | 11 ----------- mm/hugetlb.c | 2 +- mm/hugetlb_cgroup.c | 20 ++------------------ 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index 3d82d91f49ac..e5d64b8b59c2 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -22,13 +22,6 @@ struct resv_map; struct file_region; #ifdef CONFIG_CGROUP_HUGETLB -/* - * Minimum page order trackable by hugetlb cgroup. - * At least 3 pages are necessary for all the tracking information. - * The second tail page contains all of the hugetlb-specific fields. - */ -#define HUGETLB_CGROUP_MIN_ORDER order_base_2(__NR_USED_SUBPAGE) - enum hugetlb_memory_event { HUGETLB_MAX, HUGETLB_NR_MEMORY_EVENTS, @@ -68,8 +61,6 @@ static inline struct hugetlb_cgroup * __hugetlb_cgroup_from_folio(struct folio *folio, bool rsvd) { VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); - if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER) - return NULL; if (rsvd) return folio->_hugetlb_cgroup_rsvd; else @@ -91,8 +82,6 @@ static inline void __set_hugetlb_cgroup(struct folio *folio, struct hugetlb_cgroup *h_cg, bool rsvd) { VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); - if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER) - return; if (rsvd) folio->_hugetlb_cgroup_rsvd = h_cg; else diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 52d26072dfda..7c3e479abb68 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4282,7 +4282,7 @@ void __init hugetlb_add_hstate(unsigned int order) return; } BUG_ON(hugetlb_max_hstate >= HUGE_MAX_HSTATE); - BUG_ON(order == 0); + BUG_ON(order < order_base_2(__NR_USED_SUBPAGE)); h = &hstates[hugetlb_max_hstate++]; mutex_init(&h->resize_lock); h->order = order; diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index dedd2edb076e..aa4486bd3904 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -262,12 +262,6 @@ static int __hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages, if (hugetlb_cgroup_disabled()) goto done; - /* - * We don't charge any cgroup if the compound page have less - * than 3 pages. - */ - if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) - goto done; again: rcu_read_lock(); h_cg = hugetlb_cgroup_from_task(current); @@ -397,9 +391,6 @@ static void __hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages, if (hugetlb_cgroup_disabled() || !h_cg) return; - if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) - return; - page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx, rsvd), nr_pages); @@ -869,15 +860,8 @@ void __init hugetlb_cgroup_file_init(void) { struct hstate *h; - for_each_hstate(h) { - /* - * Add cgroup control files only if the huge page consists - * of more than two normal pages. This is because we use - * page[2].private for storing cgroup details. - */ - if (huge_page_order(h) >= HUGETLB_CGROUP_MIN_ORDER) - __hugetlb_cgroup_file_init(hstate_index(h)); - } + for_each_hstate(h) + __hugetlb_cgroup_file_init(hstate_index(h)); } /*