Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3035504pxb; Sun, 28 Feb 2021 23:03:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUqL+q4mPj/Q/nUvsnHJhtpd+RmBsR8DnJli4sCcqFWFvjw7exy6koUvharP8DOlMPTJei X-Received: by 2002:a17:906:c0d7:: with SMTP id bn23mr14509194ejb.94.1614582221090; Sun, 28 Feb 2021 23:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614582221; cv=none; d=google.com; s=arc-20160816; b=rVLa+MdUs1eaCEeUKDMtxdMYPpSkm0UvIYidg3KUotVYQ9LFIipy+cakXk38pAmeTT RoffM10MacpigTjaFb59RlTDxwttcs/IHzbgHtOOf7PYKONwZnAOo4LDkFiV9cPPipZs GmdgUtjwdKJpSBQLiRXaT5aLiUpf1MfmvqfBIBwfj5zvV96jF+0De5ebfiHV1FUhksvy ah+dCbJghWnhU00qgn7r3tNdRlMF33EkyqL0w0cBDC1IKdGf9ZDFOTmVCmnGFtTDlBZh r5toO/09lUH0/1LgIIUyhVla995K++Q/mr/Bcbgu9FdI64URgN91VGFB10KoKytKvWQP 2rZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qGzs2kylNXWOvi+vcHUXOXnnXuTu1NAYmbFrX0eyyII=; b=rzSxtlqWTtvrElGE6fejFo+Olp3FpdFCG2XeVvsBf5l3y81CazZ1LLdJJmA6NlpH9d cmsexuybYdqRYJS5N3gD/Jl6nHnpC85+9LgzkA3+Pg9Gb5yCv16sNfNyibJQ0TzHUt3M vFNsjnOqrbfZJlgW4HKe2TKaVh59lEKLrvx8Q++D2r2bIk0kXmErInMc+PM28F2XlbZW H9J095Ama2fDQLW9IYC292jOV7lAKCCN81PdaMFE/qXp3yk7RdKyhtVfAe8ufkAYUuje Ui++oUnONjucmbXK15pG8OV8UCW48na44723PT67AZJYA8zY4I2jgF6HUeCbrlhaz28O eLUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si10570803edt.244.2021.02.28.23.03.18; Sun, 28 Feb 2021 23:03:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232257AbhCAHB3 (ORCPT + 99 others); Mon, 1 Mar 2021 02:01:29 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12657 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232221AbhCAHBQ (ORCPT ); Mon, 1 Mar 2021 02:01:16 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Dprfs03gwzlR8S; Mon, 1 Mar 2021 14:57:25 +0800 (CST) Received: from DESKTOP-TMVL5KK.china.huawei.com (10.174.187.128) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Mon, 1 Mar 2021 14:59:21 +0800 From: Yanan Wang To: , , CC: Paolo Bonzini , Ben Gardon , "Sean Christopherson" , Vitaly Kuznetsov , Andrew Jones , Peter Xu , Marc Zyngier , Ingo Molnar , Adrian Hunter , Jiri Olsa , "Arnaldo Carvalho de Melo" , Arnd Bergmann , Michael Kerrisk , Thomas Gleixner , , , , Yanan Wang Subject: [RFC PATCH v3 2/8] tools headers: Add a macro to get HUGETLB page sizes for mmap Date: Mon, 1 Mar 2021 14:59:10 +0800 Message-ID: <20210301065916.11484-3-wangyanan55@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210301065916.11484-1-wangyanan55@huawei.com> References: <20210301065916.11484-1-wangyanan55@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.128] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We know that if a system supports multiple hugetlb page sizes, the desired hugetlb page size can be specified in bits [26:31] of the flag arguments. The value in these 6 bits will be the shift of each hugetlb page size. So add a macro to get the page size shift and then calculate the corresponding hugetlb page size, using flag x. Cc: Ben Gardon Cc: Ingo Molnar Cc: Adrian Hunter Cc: Jiri Olsa Cc: Arnaldo Carvalho de Melo Cc: Arnd Bergmann Cc: Michael Kerrisk Cc: Thomas Gleixner Suggested-by: Ben Gardon Signed-off-by: Yanan Wang --- include/uapi/linux/mman.h | 2 ++ tools/include/uapi/linux/mman.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/uapi/linux/mman.h b/include/uapi/linux/mman.h index f55bc680b5b0..8bd41128a0ee 100644 --- a/include/uapi/linux/mman.h +++ b/include/uapi/linux/mman.h @@ -41,4 +41,6 @@ #define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB #define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB +#define MAP_HUGE_PAGE_SIZE(x) (1 << ((x >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK)) + #endif /* _UAPI_LINUX_MMAN_H */ diff --git a/tools/include/uapi/linux/mman.h b/tools/include/uapi/linux/mman.h index f55bc680b5b0..8bd41128a0ee 100644 --- a/tools/include/uapi/linux/mman.h +++ b/tools/include/uapi/linux/mman.h @@ -41,4 +41,6 @@ #define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB #define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB +#define MAP_HUGE_PAGE_SIZE(x) (1 << ((x >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK)) + #endif /* _UAPI_LINUX_MMAN_H */ -- 2.23.0