Message ID | 20230105101844.1893104-33-jthoughton@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 B54CEC3DA7D for <linux-mm@archiver.kernel.org>; Thu, 5 Jan 2023 10:19:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 685908E0003; Thu, 5 Jan 2023 05:19:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 59A71940008; Thu, 5 Jan 2023 05:19:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C3568E0005; Thu, 5 Jan 2023 05:19:43 -0500 (EST) 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 271D28E0003 for <linux-mm@kvack.org>; Thu, 5 Jan 2023 05:19:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 02962140217 for <linux-mm@kvack.org>; Thu, 5 Jan 2023 10:19:42 +0000 (UTC) X-FDA: 80320349046.13.41A30E7 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf23.hostedemail.com (Postfix) with ESMTP id 773E6140007 for <linux-mm@kvack.org>; Thu, 5 Jan 2023 10:19:41 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=VKrl9diS; spf=pass (imf23.hostedemail.com: domain of 3PKS2YwoKCIMq0ov1no0vunvvnsl.jvtspu14-ttr2hjr.vyn@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3PKS2YwoKCIMq0ov1no0vunvvnsl.jvtspu14-ttr2hjr.vyn@flex--jthoughton.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=1672913981; 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:in-reply-to:references:references:dkim-signature; bh=fjKcTgCHQU9dL6HEL7BjnCeJzokWebjD5rXkoH4g/pM=; b=NDSzMCPl6duNvznpMQM8q1Gh0eDd2pgOGHkiasVZB3VuHhMrlWdJsfKWV0miTMahI161qu JU38O7k93T40xhdQY8z6FlXTTV1GHVeQHfcfr8g0W5JLg1Zl9fibAGrl4nPVgIkYlcHkEQ 6kjjGvlbbSktdULT+Y8KmzBfLfsS0MM= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=VKrl9diS; spf=pass (imf23.hostedemail.com: domain of 3PKS2YwoKCIMq0ov1no0vunvvnsl.jvtspu14-ttr2hjr.vyn@flex--jthoughton.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3PKS2YwoKCIMq0ov1no0vunvvnsl.jvtspu14-ttr2hjr.vyn@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672913981; a=rsa-sha256; cv=none; b=h77MQaGbHwjtGDEmXqklCZ0A1LQT72zPT9QwHvP7AvmkJDzFlhDzaU7rxdTAJYC8mqfpDT 0ei7Uk10PEXMPAX0VMtYLVytxXrDT3Z7duG1SQtm5cRrzyAieQxcCM1LIkI72ZrZpLtfXZ wLBtSl4y+Ick9AjgM0WDfk37yBv4i7g= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-434eb7c6fa5so374783627b3.14 for <linux-mm@kvack.org>; Thu, 05 Jan 2023 02:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fjKcTgCHQU9dL6HEL7BjnCeJzokWebjD5rXkoH4g/pM=; b=VKrl9diSEpwY713/gRrQ7D7jynnfdDKrTaaauRJ8Kmx76DzNiFvpsbu9cleofopMYY +vN1ez44452yYnBQYI9/ica76cicDmXhDVXewbjHC7ZvbpYxQspAVjUda//9KqW+Xs8u LR39HFBaerFN0EvlEGK+6/C5d0YJLK8kf7/07SPIgTMOJAJTpX9hXOYciZWdCmvO2ahR 6iZd5/Y9MDnIUiesI7LWvxsmnqWFe7L9Ef31ukl3F+hZHDBLwQWc9oEr3/AQYOzqITnW ykinTUIHoWMFPDqTP4+sgJ80WGoY/Y9vThhY32VjfbhOO1aAUa7akpnfIabYK+/jBMcc tlBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fjKcTgCHQU9dL6HEL7BjnCeJzokWebjD5rXkoH4g/pM=; b=oqWsaruawrubX7Kwrwzvor9wYxRybCdTiqubCbTpIr/4oLHH9hbYzVSp/FSnCKo1aL IeeDTnuL9gsjMc/lFv+yk1HZf9aZPECXueHHdbRQHz51hKQhewJQo5cY9MqUJPhq//G2 9BYqVUonVLPUU09HUr8mK7mkhXDTivGBf7uapTl66tTMsmvq0fAyXq+IoaTEh2lhpcXk sjOAOzi106iMktDgjjDAlh2nRkayAVRT7jnrq0e7VvI+w5Xjx+9ADE6JVOGDfVojHcmu PRuNnRDp4TMqL+cWOZKOVgAKl/SmQQPlFnyTlSTxyzBHZa6Q+tdDh2Jjzfu4Ab0mtm98 NmiQ== X-Gm-Message-State: AFqh2kqO3yR8VM/w0S/Odj2i7Zu4SqIOLXE5xTl2xDjCZC7tau+C4/tA AF/K133xKTdzlp6Heb6G9zrjNopcsmVjiU6f X-Google-Smtp-Source: AMrXdXtvsvCs5r5FUeplh9bq/0ejsb5delwBkknRcvX6W1H9wwf0TLqecw9cf1JUKuPILl1zHw3RCKREeb0/+0ng X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a25:b78c:0:b0:769:74cd:9c63 with SMTP id n12-20020a25b78c000000b0076974cd9c63mr4949127ybh.257.1672913980684; Thu, 05 Jan 2023 02:19:40 -0800 (PST) Date: Thu, 5 Jan 2023 10:18:30 +0000 In-Reply-To: <20230105101844.1893104-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230105101844.1893104-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230105101844.1893104-33-jthoughton@google.com> Subject: [PATCH 32/46] hugetlb: add for_each_hgm_shift From: James Houghton <jthoughton@google.com> To: Mike Kravetz <mike.kravetz@oracle.com>, Muchun Song <songmuchun@bytedance.com>, Peter Xu <peterx@redhat.com> Cc: David Hildenbrand <david@redhat.com>, David Rientjes <rientjes@google.com>, Axel Rasmussen <axelrasmussen@google.com>, Mina Almasry <almasrymina@google.com>, "Zach O'Keefe" <zokeefe@google.com>, Manish Mishra <manish.mishra@nutanix.com>, Naoya Horiguchi <naoya.horiguchi@nec.com>, "Dr . David Alan Gilbert" <dgilbert@redhat.com>, "Matthew Wilcox (Oracle)" <willy@infradead.org>, Vlastimil Babka <vbabka@suse.cz>, Baolin Wang <baolin.wang@linux.alibaba.com>, Miaohe Lin <linmiaohe@huawei.com>, Yang Shi <shy828301@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton <jthoughton@google.com> Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 773E6140007 X-Stat-Signature: pryeajch3epqfumoz7gd77nc37fpupbu X-Rspam-User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VAPWaD3Xs8sq+MA8pNvzMNXMOxnFUlG5Qg/+Yau7VD+uxvY1dGfsGdAoOaOwYQUWSwVhppQIwd0SDWXiTLA/MOceZ+seO5e5tOfe+B6HY3nmIyAy8MRBgiWXXDM/Y7tVmR6g2I1Gnjc5L/k5lkzXxxE8Oivy4G1AOepgm+t5hN9C9GyPmlUFzQ2Be2AyW2krEyNmwLseh9c3Ze4K7pl+WY9EBypo2hM2JyrINX9jVBxje550sW6KFqrPyCfLpB1VFB7MWFrtmdFnsw5Z/H+8VCWeUp/Tnb8SSihv/JIAum49dS5zoboKj4Hzctqzj4OOmMDLNFgSX5RyeK9HajeL8vPk22afhV+1CZlCsw7lcHTveAUEb1m4zTb3w0zDkr 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: <linux-mm.kvack.org> |
Series |
Based on latest mm-unstable (85b44c25cd1e).
|
expand
|
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 1e9e149587b3..1eef6968b1fa 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7780,6 +7780,24 @@ bool hugetlb_hgm_enabled(struct vm_area_struct *vma) { return vma && (vma->vm_flags & VM_HUGETLB_HGM); } +/* Should only be used by the for_each_hgm_shift macro. */ +static unsigned int __shift_for_hstate(struct hstate *h) +{ + /* If h is out of bounds, we have reached the end, so give PAGE_SIZE */ + if (h >= &hstates[hugetlb_max_hstate]) + return PAGE_SHIFT; + return huge_page_shift(h); +} + +/* + * Intentionally go out of bounds. An out-of-bounds hstate will be converted to + * PAGE_SIZE. + */ +#define for_each_hgm_shift(hstate, tmp_h, shift) \ + for ((tmp_h) = hstate; (shift) = __shift_for_hstate(tmp_h), \ + (tmp_h) <= &hstates[hugetlb_max_hstate]; \ + (tmp_h)++) + #endif /* CONFIG_HUGETLB_HIGH_GRANULARITY_MAPPING */ /*
This is a helper macro to loop through all the usable page sizes for a high-granularity-enabled HugeTLB VMA. Given the VMA's hstate, it will loop, in descending order, through the page sizes that HugeTLB supports for this architecture. It always includes PAGE_SIZE. This is done by looping through the hstates; however, there is no hstate for PAGE_SIZE. To handle this case, the loop intentionally goes out of bounds, and the out-of-bounds pointer is mapped to PAGE_SIZE. Signed-off-by: James Houghton <jthoughton@google.com> --- mm/hugetlb.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)