From patchwork Sat Feb 10 10:56:41 2018 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: 871663 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zdpvh4LGWz9s82 for ; Sat, 10 Feb 2018 22:03:44 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zdpvh2rVSzF0bZ for ; Sat, 10 Feb 2018 22:03:44 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=aneesh.kumar@linux.vnet.ibm.com; receiver=) 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 3zdpm10fsbzF0gJ for ; Sat, 10 Feb 2018 21:57:04 +1100 (AEDT) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1AArsjG111807 for ; Sat, 10 Feb 2018 05:57:02 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g1uxu4sfw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sat, 10 Feb 2018 05:57:01 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 10 Feb 2018 05:57:00 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 10 Feb 2018 05:56:58 -0500 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1AAuwWm46596296; Sat, 10 Feb 2018 10:56:58 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1359124037; Sat, 10 Feb 2018 05:53:43 -0500 (EST) Received: from skywalker.ibmmodules.com (unknown [9.199.32.204]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 10919124035; Sat, 10 Feb 2018 05:53:41 -0500 (EST) From: "Aneesh Kumar K.V" To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au Subject: [RFC PATCH 3/5] powerpc/mm/slice: Reduce the stack usage in slice_get_unmapped_area Date: Sat, 10 Feb 2018 16:26:41 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180210105643.11857-1-aneesh.kumar@linux.vnet.ibm.com> References: <20180210105643.11857-1-aneesh.kumar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18021010-2213-0000-0000-0000026AB7D4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008509; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000251; SDB=6.00987639; UDB=6.00501330; IPR=6.00766995; BA=6.00005823; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019477; XFM=3.00000015; UTC=2018-02-10 10:57:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021010-2214-0000-0000-000059107C2D Message-Id: <20180210105643.11857-4-aneesh.kumar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-10_05:, , 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-1802100141 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" This patch kill potential_mask and compat_mask variable and instead use tmp_mask so that we can reduce the stack usage. This is required so that we can increase the high_slices bitmap to a larger value. The patch does result in extra computation in final stage, where it ends up recomputing the compat mask again. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/slice.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c index 259bbda9a222..832c681c341a 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -413,8 +413,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, { struct slice_mask mask; struct slice_mask good_mask; - struct slice_mask potential_mask; - struct slice_mask compat_mask; + struct slice_mask tmp_mask; int fixed = (flags & MAP_FIXED); int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); unsigned long page_size = 1UL << pshift; @@ -449,11 +448,8 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, bitmap_zero(mask.high_slices, SLICE_NUM_HIGH); /* silence stupid warning */; - potential_mask.low_slices = 0; - bitmap_zero(potential_mask.high_slices, SLICE_NUM_HIGH); - - compat_mask.low_slices = 0; - bitmap_zero(compat_mask.high_slices, SLICE_NUM_HIGH); + tmp_mask.low_slices = 0; + bitmap_zero(tmp_mask.high_slices, SLICE_NUM_HIGH); /* Sanity checks */ BUG_ON(mm->task_size == 0); @@ -502,9 +498,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, #ifdef CONFIG_PPC_64K_PAGES /* If we support combo pages, we can allow 64k pages in 4k slices */ if (psize == MMU_PAGE_64K) { - slice_mask_for_size(mm, MMU_PAGE_4K, &compat_mask, high_limit); + slice_mask_for_size(mm, MMU_PAGE_4K, &tmp_mask, high_limit); if (fixed) - slice_or_mask(&good_mask, &compat_mask); + slice_or_mask(&good_mask, &tmp_mask); + + slice_print_mask("Mask for compat page size", tmp_mask); } #endif /* First check hint if it's valid or if we have MAP_FIXED */ @@ -541,11 +539,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, * We don't fit in the good mask, check what other slices are * empty and thus can be converted */ - slice_mask_for_free(mm, &potential_mask, high_limit); - slice_or_mask(&potential_mask, &good_mask); - slice_print_mask(" potential", potential_mask); + slice_mask_for_free(mm, &tmp_mask, high_limit); + slice_or_mask(&tmp_mask, &good_mask); + slice_print_mask("Free area/potential ", tmp_mask); - if ((addr != 0 || fixed) && slice_check_fit(mm, mask, potential_mask)) { + if ((addr != 0 || fixed) && slice_check_fit(mm, mask, tmp_mask)) { slice_dbg(" fits potential !\n"); goto convert; } @@ -571,7 +569,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, /* Now let's see if we can find something in the existing slices * for that size plus free slices */ - addr = slice_find_area(mm, len, potential_mask, + addr = slice_find_area(mm, len, tmp_mask, psize, topdown, high_limit); #ifdef CONFIG_PPC_64K_PAGES @@ -585,9 +583,10 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, * mask variable is free here. Use that for compat * size mask. */ + slice_mask_for_size(mm, MMU_PAGE_4K, &mask, high_limit); /* retry the search with 4k-page slices included */ - slice_or_mask(&potential_mask, &compat_mask); - addr = slice_find_area(mm, len, potential_mask, + slice_or_mask(&tmp_mask, &mask); + addr = slice_find_area(mm, len, tmp_mask, psize, topdown, high_limit); } #endif @@ -600,8 +599,9 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len, slice_print_mask(" mask", mask); convert: + slice_mask_for_size(mm, MMU_PAGE_4K, &tmp_mask, high_limit); slice_andnot_mask(&mask, &good_mask); - slice_andnot_mask(&mask, &compat_mask); + slice_andnot_mask(&mask, &tmp_mask); if (mask.low_slices || !bitmap_empty(mask.high_slices, SLICE_NUM_HIGH)) { slice_convert(mm, mask, psize); if (psize > MMU_PAGE_BASE)