Received: by 10.223.176.46 with SMTP id f43csp513545wra; Wed, 24 Jan 2018 01:36:22 -0800 (PST) X-Google-Smtp-Source: AH8x225Si1FaAOF9AoO84llQIuIbRO6I61wdBMRWui1zD8xgHsu4euc0wSaByUS4veFDF+9591ee X-Received: by 2002:a17:902:e65:: with SMTP id 92-v6mr4719702plw.148.1516786581973; Wed, 24 Jan 2018 01:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516786581; cv=none; d=google.com; s=arc-20160816; b=BIsWdb7Vd/CwAecLynR+gMXsTfREPMUB5SV7408Gtqb0YAKKPoLO/Ew68k4CDmbMcN Nwg+Hp6lfQKRZBqhHx4CsUd2LWhcyWElf/UlcVELjYictA2XFD4elDjma0AwRzOGAYdJ VzPfGdoilf59sYuslt3UQIKGIzXs6uRL0Xvbz/80vqcXig5tiaBvByldOwBB+umSeOQt 98TAzZjYq0XnZFPvLrAUMAaLB+AZSEHPugCYcH0+X9zFB0Sy6UBq4UHH+Ekg4jAHOS12 kUQJkmX/zSVSaeqDIE36ZT3TYPmtLY9LdhZvoucb4knzsEqz0RddpRVeYTPYTeTQ+xZT czdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=5mKiX7lWKBZUTTFNaGzPvb542l4bkgytbuz3ufG4rT8=; b=DbFo/EmyxsBZmC3TW9avNrfn4JcrHtfHjUigsIy8anj6uLNcdTu092ppvswKZr9NtM lXyyg4Dcn0jyCXTbexTWobxjK/XozfmPRZ8O2knTPFFnsQUvJMcc5pFN0gLoGTs3DLvM NTnCzg38tBv6S5WUxpHgiw2zsWmGJe/COLJwpEQOrc2Jaw2gMZc2kef9jsKCeuCsLpS5 pETYkeOTPoKwDmIKq8HVXJy8+APYJnStCBd0ZSwkrMwm14fui1NlsfVj1Z4ED+VVMO7U bU6RCR1xLw3R7jKp/4jT0OvFTv+NKk30ogWlhxgs24EmgbTve27PSYUqbk8g3jZneZY2 fKdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3si7481599pgv.486.2018.01.24.01.36.07; Wed, 24 Jan 2018 01:36:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932784AbeAXJfi (ORCPT + 99 others); Wed, 24 Jan 2018 04:35:38 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44998 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752524AbeAXJfg (ORCPT ); Wed, 24 Jan 2018 04:35:36 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0O9YO2i038021 for ; Wed, 24 Jan 2018 04:35:35 -0500 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fpptb23ww-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 24 Jan 2018 04:35:35 -0500 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 24 Jan 2018 02:35:34 -0700 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 24 Jan 2018 02:35:30 -0700 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0O9ZUbu13435310; Wed, 24 Jan 2018 02:35:30 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4159DBE03B; Wed, 24 Jan 2018 02:35:30 -0700 (MST) Received: from [9.124.35.86] (unknown [9.124.35.86]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 295C4BE038; Wed, 24 Jan 2018 02:35:27 -0700 (MST) Subject: Re: [PATCH v3 5/5] powerpc/mm: Fix growth direction for hugepages mmaps with slice To: Christophe LEROY , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Scott Wood Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <6920f6efe2dcdabf59350b2d31ee6bd4bdef57f4.1516783089.git.christophe.leroy@c-s.fr> <362a93307a09b521878c47a8999a39a228184293.1516783089.git.christophe.leroy@c-s.fr> From: "Aneesh Kumar K.V" Date: Wed, 24 Jan 2018 15:05:26 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18012409-0012-0000-0000-000015A555A9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008418; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000247; SDB=6.00979597; UDB=6.00496528; IPR=6.00758902; BA=6.00005793; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019179; XFM=3.00000015; UTC=2018-01-24 09:35:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18012409-0013-0000-0000-000051322FC5 Message-Id: <9aea8b6f-0d1a-b700-efe4-8efcebc5d16d@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-24_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801240129 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/24/2018 02:57 PM, Christophe LEROY wrote: > > > Le 24/01/2018 à 10:15, Aneesh Kumar K.V a écrit : >> >> >> On 01/24/2018 02:32 PM, Christophe Leroy wrote: >>> An application running with libhugetlbfs fails to allocate >>> additional pages to HEAP due to the hugemap being done >>> inconditionally as topdown mapping: >>> >>> mmap(0x10080000, 1572864, PROT_READ|PROT_WRITE, >>> MAP_PRIVATE|MAP_ANONYMOUS|0x40000, -1, 0) = 0x73e80000 >>> [...] >>> mmap(0x74000000, 1048576, PROT_READ|PROT_WRITE, >>> MAP_PRIVATE|MAP_ANONYMOUS|0x40000, -1, 0x180000) = 0x73d80000 >>> munmap(0x73d80000, 1048576)             = 0 >>> [...] >>> mmap(0x74000000, 1572864, PROT_READ|PROT_WRITE, >>> MAP_PRIVATE|MAP_ANONYMOUS|0x40000, -1, 0x180000) = 0x73d00000 >>> munmap(0x73d00000, 1572864)             = 0 >>> [...] >>> mmap(0x74000000, 1572864, PROT_READ|PROT_WRITE, >>> MAP_PRIVATE|MAP_ANONYMOUS|0x40000, -1, 0x180000) = 0x73d00000 >>> munmap(0x73d00000, 1572864)             = 0 >>> [...] >>> >>> As one can see from the above strace log, mmap() allocates further >>> pages below the initial one because no space is available on top of it. >>> >>> This patch fixes it by requesting bottomup mapping as the non >>> generic hugetlb_get_unmapped_area() does >>> >>> Fixes: d0f13e3c20b6f ("[POWERPC] Introduce address space "slices" ") >>> Signed-off-by: Christophe Leroy >>> --- >>>   v3: Was a standalone patch before, but conflicts with this serie. >>> >>>   arch/powerpc/mm/hugetlbpage.c | 2 +- >>>   1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/arch/powerpc/mm/hugetlbpage.c >>> b/arch/powerpc/mm/hugetlbpage.c >>> index 79e1378ee303..368ea6b248ad 100644 >>> --- a/arch/powerpc/mm/hugetlbpage.c >>> +++ b/arch/powerpc/mm/hugetlbpage.c >>> @@ -558,7 +558,7 @@ unsigned long hugetlb_get_unmapped_area(struct >>> file *file, unsigned long addr, >>>           return radix__hugetlb_get_unmapped_area(file, addr, len, >>>                                  pgoff, flags); >>>   #endif >>> -    return slice_get_unmapped_area(addr, len, flags, mmu_psize, 1); >>> +    return slice_get_unmapped_area(addr, len, flags, mmu_psize, 0); >>>   } >>>   #endif >> >> Why make this change also for PPC64? Can you do this #ifdef 8xx?.You >> can ideally move hugetlb_get_unmapped_area to slice.h and then make >> this much simpler for 8xxx? >> > > Did you try with HUGETLB_MORECORE_HEAPBASE=0x11000000 on PPC64 as I > suggested in my last email on this subject (22/01/2018 9:22) ? yes. The test ran fine for me kvaneesh@ltctulc6a-p1:[~]$ HUGETLB_MORECORE=yes HUGETLB_MORECORE_HEAPBASE=0x30000000 ./a.out 10000000-10010000 r-xp 00000000 fc:00 9044312 /home/kvaneesh/a.out 10010000-10020000 r--p 00000000 fc:00 9044312 /home/kvaneesh/a.out 10020000-10030000 rw-p 00010000 fc:00 9044312 /home/kvaneesh/a.out 30000000-33000000 rw-p 00000000 00:0d 1062697 /anon_hugepage (deleted) 33000000-35000000 rw-p 03000000 00:0d 1062698 /anon_hugepage (deleted) 35000000-37000000 rw-p 05000000 00:0d 1062699 /anon_hugepage (deleted) 7ffff7d60000-7ffff7f10000 r-xp 00000000 fc:00 9250090 /lib/powerpc64le-linux-gnu/libc-2.23.so 7ffff7f10000-7ffff7f20000 r--p 001a0000 fc:00 9250090 /lib/powerpc64le-linux-gnu/libc-2.23.so 7ffff7f20000-7ffff7f30000 rw-p 001b0000 fc:00 9250090 /lib/powerpc64le-linux-gnu/libc-2.23.so 7ffff7f40000-7ffff7f60000 r-xp 00000000 fc:00 10754812 /usr/lib/libhugetlbfs.so.0 7ffff7f60000-7ffff7f70000 r--p 00010000 fc:00 10754812 /usr/lib/libhugetlbfs.so.0 7ffff7f70000-7ffff7f80000 rw-p 00020000 fc:00 10754812 /usr/lib/libhugetlbfs.so.0 7ffff7f80000-7ffff7fa0000 r-xp 00000000 00:00 0 [vdso] 7ffff7fa0000-7ffff7fe0000 r-xp 00000000 fc:00 9250107 /lib/powerpc64le-linux-gnu/ld-2.23.so 7ffff7fe0000-7ffff7ff0000 r--p 00030000 fc:00 9250107 /lib/powerpc64le-linux-gnu/ld-2.23.so 7ffff7ff0000-7ffff8000000 rw-p 00040000 fc:00 9250107 /lib/powerpc64le-linux-gnu/ld-2.23.so 7ffffffd0000-800000000000 rw-p 00000000 00:00 0 [stack] > > Before doing anything specific to the PPC32/8xx, I'd like to be sure the > issue is definitly only on PPC32. > I am not sure I understand the problem correctly. If there is a free space in the required range, both topdown/bottomup search should be able to find it. Unless topdown found another free area suitable for hugetlb allocation above. My take is we should not change the topdown to bottomup without really understanding the failure scenarios. -aneesh