From patchwork Tue Apr 11 14:15:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 749510 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w2Tdf5GG2z9sNQ for ; Wed, 12 Apr 2017 00:17:10 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3w2Tdf4MhyzDqJl for ; Wed, 12 Apr 2017 00:17:10 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3w2TcS1TLPzDq5x for ; Wed, 12 Apr 2017 00:16:08 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3BEE0Km015786 for ; Tue, 11 Apr 2017 10:15:56 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 29rf064u9u-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 11 Apr 2017 10:15:55 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 11 Apr 2017 08:15:54 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 11 Apr 2017 08:15:52 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3BEFMs450528490; Tue, 11 Apr 2017 07:15:51 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A04AE6E035; Tue, 11 Apr 2017 08:15:51 -0600 (MDT) Received: from skywalker.in.ibm.com (unknown [9.85.80.49]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 42E366E03F; Tue, 11 Apr 2017 08:15:47 -0600 (MDT) From: "Aneesh Kumar K.V" To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au Subject: [PATCH] powerpc/mm: Update mm context addr limit correctly. Date: Tue, 11 Apr 2017 19:45:35 +0530 X-Mailer: git-send-email 2.7.4 X-TM-AS-GCONF: 00 x-cbid: 17041114-0024-0000-0000-00001638D080 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006917; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00846059; UDB=6.00417279; IPR=6.00624493; BA=6.00005284; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015004; XFM=3.00000013; UTC=2017-04-11 14:15:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041114-0025-0000-0000-00004A2AD2AE Message-Id: <1491920135-13612-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-11_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704110112 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rick Lindsley , linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" , Anshuman Khandual Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" We added the addr < TASK_SIZE check to avoid updating addr_limit unnecessarily and also to avoid calling slice_flush_segments on all the cpus. This had the side effect of having different behaviour when using an addr value above TASK_SIZE before updating addr_limit and after updating addr_limit as show by below output: requesting with hint 0x0 Addr returned 0x7fff893a0000 requesting with hint 0xffffffffffffffff Addr returned 0x7fff891b0000 <===== 1st return requesting with hint 0x1000000000000 Addr returned 0x1000000000000 requesting with hint 0xffffffffffffffff Addr returned 0x1ffff89410000 <==== second return After fix: requesting with hint 0x0 Addr returned 0x7fff8bc00000 requesting with hint 0xffffffffffffffff Addr returned 0x1ffff8bc80000 <==== 1st return requesting with hint 0x1000000000000 Addr returned 0x1000000000000 requesting with hint 0xffffffffffffffff Addr returned 0x1ffff8bc60000 <==== second return Fixes: 1b49451ebd3e9 (powerpc/mm: Enable mappings above 128TB) Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/mmap.c | 6 ++++-- arch/powerpc/mm/slice.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index b2111baa0da6..355b6fe8a1e6 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -97,7 +97,8 @@ radix__arch_get_unmapped_area(struct file *filp, unsigned long addr, struct vm_area_struct *vma; struct vm_unmapped_area_info info; - if (unlikely(addr > mm->context.addr_limit && addr < TASK_SIZE)) + if (unlikely(addr > mm->context.addr_limit && + mm->context.addr_limit != TASK_SIZE)) mm->context.addr_limit = TASK_SIZE; if (len > mm->context.addr_limit - mmap_min_addr) @@ -139,7 +140,8 @@ radix__arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr = addr0; struct vm_unmapped_area_info info; - if (unlikely(addr > mm->context.addr_limit && addr < TASK_SIZE)) + if (unlikely(addr > mm->context.addr_limit && + mm->context.addr_limit != TASK_SIZE)) mm->context.addr_limit = TASK_SIZE; /* requested length too big for entire address space */ diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c index 251b6bae7023..2d2d9760d057 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -419,7 +419,8 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, /* * Check if we need to expland slice area. */ - if (unlikely(addr > mm->context.addr_limit && addr < TASK_SIZE)) { + if (unlikely(addr > mm->context.addr_limit && + mm->context.addr_limit != TASK_SIZE)) { mm->context.addr_limit = TASK_SIZE; on_each_cpu(slice_flush_segments, mm, 1); }