From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754520AbdEITPy (ORCPT ); Tue, 9 May 2017 15:15:54 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:38152 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754050AbdEITPw (ORCPT ); Tue, 9 May 2017 15:15:52 -0400 Subject: Re: [PATCH] selftests/vm: Fix test for virtual address range mapping for arm64 To: Michal Suchanek , Anshuman Khandual , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Shuah Khan References: <20170509190047.9271-1-msuchanek@suse.de> From: Shuah Khan Message-ID: <1e5d67b6-eaae-764d-94a7-ae1e083b03ac@osg.samsung.com> Date: Tue, 9 May 2017 13:15:43 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170509190047.9271-1-msuchanek@suse.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/2017 01:00 PM, Michal Suchanek wrote: > Arm64 has 256TB address space so fix the test to pass on Arm as well. > > Also remove unneeded numaif include. > > Signed-off-by: Michal Suchanek Thanks for finding and fixing the problem. I will get this into 4.12-rc1 if possible or it will go into 4.12-rc2 -- Shuah > --- > tools/testing/selftests/vm/virtual_address_range.c | 36 ++++++++++++++++------ > 1 file changed, 27 insertions(+), 9 deletions(-) > > diff --git a/tools/testing/selftests/vm/virtual_address_range.c b/tools/testing/selftests/vm/virtual_address_range.c > index 3b02aa6..ff6628f 100644 > --- a/tools/testing/selftests/vm/virtual_address_range.c > +++ b/tools/testing/selftests/vm/virtual_address_range.c > @@ -10,7 +10,6 @@ > #include > #include > #include > -#include > #include > #include > > @@ -32,15 +31,34 @@ > * different areas one below 128TB and one above 128TB > * till it reaches 512TB. One with size 128TB and the > * other being 384TB. > + * > + * On Arm64 the address space is 256TB and no high mappings > + * are supported so far. Presumably support can be added in > + * the future. > */ > + > #define NR_CHUNKS_128TB 8192UL /* Number of 16GB chunks for 128TB */ > -#define NR_CHUNKS_384TB 24576UL /* Number of 16GB chunks for 384TB */ > +#define NR_CHUNKS_256TB (NR_CHUNKS_128TB * 2UL) > +#define NR_CHUNKS_384TB (NR_CHUNKS_128TB * 3UL) > > #define ADDR_MARK_128TB (1UL << 47) /* First address beyond 128TB */ > +#define ADDR_MARK_256TB (1UL << 48) /* First address beyond 256TB */ > + > +#ifdef __aarch64__ > +#define HIGH_ADDR_MARK ADDR_MARK_256TB > +#define HIGH_ADDR_SHIFT 49 > +#define NR_CHUNKS_LOW NR_CHUNKS_256TB > +#define NR_CHUNKS_HIGH NR_CHUNKS_256TB > +#else > +#define HIGH_ADDR_MARK ADDR_MARK_128TB > +#define HIGH_ADDR_SHIFT 48 > +#define NR_CHUNKS_LOW NR_CHUNKS_128TB > +#define NR_CHUNKS_HIGH NR_CHUNKS_384TB > +#endif > > static char *hind_addr(void) > { > - int bits = 48 + rand() % 15; > + int bits = HIGH_ADDR_SHIFT + rand() % 15; > > return (char *) (1UL << bits); > } > @@ -50,14 +68,14 @@ static int validate_addr(char *ptr, int high_addr) > unsigned long addr = (unsigned long) ptr; > > if (high_addr) { > - if (addr < ADDR_MARK_128TB) { > + if (addr < HIGH_ADDR_MARK) { > printf("Bad address %lx\n", addr); > return 1; > } > return 0; > } > > - if (addr > ADDR_MARK_128TB) { > + if (addr > HIGH_ADDR_MARK) { > printf("Bad address %lx\n", addr); > return 1; > } > @@ -79,12 +97,12 @@ static int validate_lower_address_hint(void) > > int main(int argc, char *argv[]) > { > - char *ptr[NR_CHUNKS_128TB]; > - char *hptr[NR_CHUNKS_384TB]; > + char *ptr[NR_CHUNKS_LOW]; > + char *hptr[NR_CHUNKS_HIGH]; > char *hint; > unsigned long i, lchunks, hchunks; > > - for (i = 0; i < NR_CHUNKS_128TB; i++) { > + for (i = 0; i < NR_CHUNKS_LOW; i++) { > ptr[i] = mmap(NULL, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, > MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); > > @@ -99,7 +117,7 @@ int main(int argc, char *argv[]) > } > lchunks = i; > > - for (i = 0; i < NR_CHUNKS_384TB; i++) { > + for (i = 0; i < NR_CHUNKS_HIGH; i++) { > hint = hind_addr(); > hptr[i] = mmap(hint, MAP_CHUNK_SIZE, PROT_READ | PROT_WRITE, > MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); >