Message ID | 20230218002819.1486479-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 44CB3C05027 for <linux-mm@archiver.kernel.org>; Sat, 18 Feb 2023 00:29:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0D5A28001C; Fri, 17 Feb 2023 19:29:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C728A280002; Fri, 17 Feb 2023 19:29:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC1D328001C; Fri, 17 Feb 2023 19:29:18 -0500 (EST) 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 982C5280002 for <linux-mm@kvack.org>; Fri, 17 Feb 2023 19:29:18 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 740B5160923 for <linux-mm@kvack.org>; Sat, 18 Feb 2023 00:29:18 +0000 (UTC) X-FDA: 80478528396.12.B824102 Received: from mail-vk1-f202.google.com (mail-vk1-f202.google.com [209.85.221.202]) by imf23.hostedemail.com (Postfix) with ESMTP id 97BB0140006 for <linux-mm@kvack.org>; Sat, 18 Feb 2023 00:29:16 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=n5krxTWv; spf=pass (imf23.hostedemail.com: domain of 32xvwYwoKCPgoymtzlmytslttlqj.htrqnsz2-rrp0fhp.twl@flex--jthoughton.bounces.google.com designates 209.85.221.202 as permitted sender) smtp.mailfrom=32xvwYwoKCPgoymtzlmytslttlqj.htrqnsz2-rrp0fhp.twl@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=1676680156; 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=Hf03eS1BobxnoyUk+0ZYrZ8zRMgrel2ztMkHa50OYSI=; b=YUcFb06Qk+Fh6uLAp2JgmrJtRi7AEXzgOnREp6w1QNw8QeAyLhWfNm7iksUdluopDxIqHM ZPlk8APeGTHCwsVihcq1bRTM0eP6EnCyh/FLHOS1Hrmod39gbkGwKheUsv/PnjMiVvPDCF KxsXaRqowvmM7WAKqD7wzmge9url7ag= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=n5krxTWv; spf=pass (imf23.hostedemail.com: domain of 32xvwYwoKCPgoymtzlmytslttlqj.htrqnsz2-rrp0fhp.twl@flex--jthoughton.bounces.google.com designates 209.85.221.202 as permitted sender) smtp.mailfrom=32xvwYwoKCPgoymtzlmytslttlqj.htrqnsz2-rrp0fhp.twl@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676680156; a=rsa-sha256; cv=none; b=Oos4cR1goXOGoabtPRXKRqWS8iKiM3xGab7u8eGbE1uNd4i9ZpYEpgIxk1qgaAlypOdsyz Ds3Bkosb2jSxF3hJv8IiR99Y1pk1VN8pQ4ud9EDVP/XPdMZzO0HpwjLrhZNKTIX0N8w/ag EBHU8v7ks2kiecMd+7SsfXKKErRIa6M= Received: by mail-vk1-f202.google.com with SMTP id y26-20020ac5c81a000000b003e1a7591524so1067592vkl.1 for <linux-mm@kvack.org>; Fri, 17 Feb 2023 16:29:16 -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=Hf03eS1BobxnoyUk+0ZYrZ8zRMgrel2ztMkHa50OYSI=; b=n5krxTWva4Sf4Vsvk57VrejZS7qh83I29bbOukhXhjxnbyiLVwsIU1jYSB+TyjblCL MilLcyhHjSUyY+1YLmOg+OnBETPCIOw/L4b8Fi1wC+MKnO4VLbaVIbLLSIpqvEF5fKek S7PVzlegxhgRs1TdpdgnswFYQr0DAofh6bzKR/4aYfTbY2USEybj9EjCijALtRxrpFmY oRt8kPX/U/3EtMyNyG9s3xqsF3Jx65+txOMviZr70m7fuLxiVCeDc004dBLqVT+P2gLb aZ2Lhu7IFeKdLx2Du68oGZvPZtxzFiuZ9OH+JAdOUn2J1T26W3LFbmXb5sUZtm1q1FgI +6FA== 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=Hf03eS1BobxnoyUk+0ZYrZ8zRMgrel2ztMkHa50OYSI=; b=PeIeX0Yta+7mokTDHIDpL8uIhaHKYNqjsTE+32GK+wI7PC0rw9hceMKU/YRrPLznNA oY/xTjfN1iKB4G4Jd+mLgkde5ISya0ExLqg9ucDUEetrrAqoEMQNKqPBrLD3+Fan/EV8 kKtOuiIiCgx1Gv2jTDsIaLvwKFCw72u5forVjkEtLrLUJwf1imEu6v2Z1cqmufJdMuAg Y+lKLbJSo4DiRsGtwboOjS7DrGyAei9PZeC95kLlI21lGc39EVyG/WWSaD1NAj2apxyW jdTggt61aQXO4N+rCB8Cq/4gVagxezPY1ItIrFsk/agkt6HAM0Ow7BgwHjAa8NpzBgWz PJXA== X-Gm-Message-State: AO0yUKWT3uKtLqFDeDlW+Xhafxz1/0OfpbmxwjHTynI5huX8xgxqtqQ6 427ho0XTPDrGJqb4K34QnLeSKTz2p/azyxJn X-Google-Smtp-Source: AK7set/xeVdMk4/mlhl6jkXC1OYI04ENP7/RQfinMSut9jH5SSiIHmeo9doCVF6zrjX21weL0A1G0FvBpBxmEp3t X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a05:6102:356b:b0:415:48ce:8597 with SMTP id bh11-20020a056102356b00b0041548ce8597mr942711vsb.8.1676680155862; Fri, 17 Feb 2023 16:29:15 -0800 (PST) Date: Sat, 18 Feb 2023 00:28:05 +0000 In-Reply-To: <20230218002819.1486479-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230218002819.1486479-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230218002819.1486479-33-jthoughton@google.com> Subject: [PATCH v2 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>, Andrew Morton <akpm@linux-foundation.org> 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>, Frank van der Linden <fvdl@google.com>, Jiaqi Yan <jiaqiyan@google.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton <jthoughton@google.com> Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: p4ercg5r9m4ujoakfijonergq685ggsi X-Rspam-User: X-Rspam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2PCE3LN7/Srew3X2GwMH0ZVQ+AiWRzkUqZtRUgwIbKHjbmJ5h4AZwJzYuTkvCleh/vg6D1uil2rI73oZPOChd8dQ7aC7uLd50JwRwapoBMfP2eY/1s9ACvB4qHO1b2ZIgugFgBKeElnwH5p004jwiGlq/d+ZDaG04JvIKP611FjOgimLBaoLp2Iw4KI/E5NT+QJMdRQb6/+/TpbXfxMiUvK4j3/spcG1gt8tSui2L8a5tbnHyX+YfBkudainEqhSrgSnjpNFLJVF+sR8eanQBPmWoVUdWAvY2Qs8B88gdKgW/gpWVY57+E3A4Yj+LWt2Hzx91EFY+C26+K64V2q2JqUAgleDSqx4L08c40NGEvZahuRmVKrYtnEZXaij8BoGZh4/zJXxB6KABpkAzQwL9yaoB6eDiyBibqj5NioZ3PVMt0/FBPvkbZZSL3EjQWxC0wPsoiyNEqIcnqFA5xuDicTUMra3az7GqBjlgnVSBwt9auKfBX87E8l4IiRriC0nmAiAIZmV8AE8w7n8TLr4JFnxAx5ZGxg7fa0aJZDZfi7jW1Au9U6g9NiZkw7Lteyi8rNG4kxoJ0p5lzk9/FCwfVafyT9T6VK8XT6v9Y6OUAlbwE7noMw0GmrqWfM6kA8tokyx+f1/9vgbF4KSVkpz9EY8t+79OGXvEyY68JoGzEwMlI= 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 |
hugetlb: introduce HugeTLB high-granularity mapping
|
expand
|
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e20df8f6216e..667e82b7a0ff 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7941,6 +7941,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>