Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4275218pxf; Tue, 23 Mar 2021 07:06:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7AEpbZV7UN1KMa22CrYPF6VPuucBuFPn0j305CSGlMSqvqap6R377P3m3PeRCiAu+RHV5 X-Received: by 2002:a17:906:7c44:: with SMTP id g4mr5013518ejp.269.1616508398935; Tue, 23 Mar 2021 07:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616508398; cv=none; d=google.com; s=arc-20160816; b=KZcRdlMWwAT/vrfW07pkA72As2xZpUd5RzW3bBANIAUPqsaSwelZrn51IvFnzJzqr8 4IgVRFf+Zb6z92lpSrkUECbxJzqPbrh9y538UAOaEAcyISJ7VIqbC2vbez5yY/AWQjXK x6RZmdgUkN5JoLTEU9lQPXA/h8YsX9qQe3zzvavw0hxaV9oTzm2y/Hi/Z+CU5y9Fue78 Za4DHyQ0OpgVp9+KoQc0jWbaJF0zKD02FaHq/Ae+5Ut0IbDxv4/uli9Y+4hhU8WU9UlO NOo1IJav/VDT3KyOmXPrm04U8kbk42We+YhtX3dkM5gEr0tliBJCW1FtDylUglOREb67 W1lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vxsGWWqSMrKfNxVOuIK22nNbCbQd+8H7DiNIZtQneS8=; b=GL4ZdwcKhJV6zglBq3zLd2G849jSUqqi2bbbCNE7956BgblFsms8npD5qeZ6EZ1qeT rYRU2GT94as4emv4kZFv9qdhz4Rkww91iRWAAFQ6JkMnCGF1JqRTjglC4qv37QNJzB0m UdUxTj/xquDpFEXEIaA/I/OjDBbyv83XVJeOyf1pe1VYpxVi8CeBBWCsEOJj9A6SPjVE R6xz5DbKCHql1S/vWxJU24WPcnSMtklejNo1jtucJN4pEK7Kxy3WUIgQfs5F3vGMiyDx GeeTfIfNl0/x5KFRGvHtdt0lU2wzNVyvxoYzoe7lbLi3f/rhAdKCQ+o1O4Wmvxy6/5ul iNTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UwUGSaza; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a12si13509064ejy.363.2021.03.23.07.06.15; Tue, 23 Mar 2021 07:06:38 -0700 (PDT) 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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UwUGSaza; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231848AbhCWOEo (ORCPT + 99 others); Tue, 23 Mar 2021 10:04:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58801 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231866AbhCWOEY (ORCPT ); Tue, 23 Mar 2021 10:04:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616508262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vxsGWWqSMrKfNxVOuIK22nNbCbQd+8H7DiNIZtQneS8=; b=UwUGSazaUXaBJlzDMIJsdBDkfjEaCV8VIOAuH4ccHE4GSPsDIszTsAyA2yaxZfwPr3TA3T 7QWDSJZz1YJYzpG5yZc86DzDkn3OFsMz6iIUx2DzF62HIIxwsMbcKDdSIDw2D2bCEe/HSt dMZaeHBsXRJWLACXdpSSBp5awGhOJc8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-eSjqDlG7Nwy-6LahJk0MOg-1; Tue, 23 Mar 2021 10:04:21 -0400 X-MC-Unique: eSjqDlG7Nwy-6LahJk0MOg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A66B388AF0E; Tue, 23 Mar 2021 14:03:55 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.40.194.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13F8C5D6D7; Tue, 23 Mar 2021 14:03:44 +0000 (UTC) Date: Tue, 23 Mar 2021 15:03:41 +0100 From: Andrew Jones To: Yanan Wang Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , Sean Christopherson , Vitaly Kuznetsov , Peter Xu , Ingo Molnar , Adrian Hunter , Jiri Olsa , Arnaldo Carvalho de Melo , Arnd Bergmann , Michael Kerrisk , Thomas Gleixner , wanghaibin.wang@huawei.com, yuzenghui@huawei.com Subject: Re: [RFC PATCH v5 02/10] tools headers: Add a macro to get HUGETLB page sizes for mmap Message-ID: <20210323140341.nkikwolwzpu6ectp@kamzik.brq.redhat.com> References: <20210323135231.24948-1-wangyanan55@huawei.com> <20210323135231.24948-3-wangyanan55@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210323135231.24948-3-wangyanan55@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org $SUBJECT says "tools headers", but this is actually changing a UAPI header and then copying the change to tools. Thanks, drew On Tue, Mar 23, 2021 at 09:52:23PM +0800, Yanan Wang wrote: > 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 > Reviewed-by: Ben Gardon > --- > 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..d72df73b182d 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) (1ULL << ((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..d72df73b182d 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) (1ULL << ((x >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK)) > + > #endif /* _UAPI_LINUX_MMAN_H */ > -- > 2.19.1 >