Received: by 10.223.176.46 with SMTP id f43csp756553wra; Fri, 19 Jan 2018 01:14:05 -0800 (PST) X-Google-Smtp-Source: ACJfBospg8aVTCNiaifJh7fQFutYwx+M3+jHujJ78cCeXisabqV70IWQwJaf3zK0vsRc2zZwP4sX X-Received: by 2002:a17:902:bd47:: with SMTP id b7-v6mr1244278plx.300.1516353245390; Fri, 19 Jan 2018 01:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516353245; cv=none; d=google.com; s=arc-20160816; b=lDV1tQ3qPX8SaHry86ZKkqhnRx7UxwFIRmO4lNwcWOc2KWbbhNXMrCxP6Tz49ppxeq UKCpDqc2aZ1AfLcAcqysW075v90nXhVBwySQ41Es85PoQ4s6+DzOeKpjEAFc/Sf8tVZ3 Bw2R6CJtDJg+dwsSIpFtV4LXfWiwtTeWIHobNIimu1+evd9z0gG0tdYCz1HT4AWoJr9T aA6UUv7JIqRYl1bERSdMsh7LYfnFvQXsBSrkixduP/7dWRK8vGJc1mD/vzKyC4NxWjoQ hbshYlfpjAJShPWMRifcP6xgBbdTalj3lpXZHpM95WqrXA5YZjPLS33RkOYm+B9eIxpt RNuQ== 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=7zZOksggR62jjMjxT1kMH/ee50skA7396TZT2Q3UPDw=; b=PldrhQVlIWqawJ5ig/kUpHUVBPm/4W9vea9z67YpVZc6/xb6ZihddQ/9a+HQtScjsd UTWnvtXzyPX758rxB459ew8ew3VoziZp6uqXz8x+8Es7ZxW07U3RT/d0zXYc/QTP4PEQ fZAVqLxht7ZmNLVSgKoRTdKU7cVDdK/NpfcqdlbgCOFUYpDsXS7hZnkv3eXq2fOIIcSZ 62oMzkVl7A0ExqVwYNblUhN+RL7sNneiwuPGnwDlkQtu9crdTTtE5/gS8ztFkamgpWpz YKUvsgBQSWfYV/wKyeAUvpJ8GE7z/HZCR3aO1PePJALUob/piK2Gq3SQMhaCdDFl8IaV vOnA== 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 v35-v6si677095plg.724.2018.01.19.01.13.50; Fri, 19 Jan 2018 01:14:05 -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 S1755038AbeASJNZ (ORCPT + 99 others); Fri, 19 Jan 2018 04:13:25 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38944 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754070AbeASJNV (ORCPT ); Fri, 19 Jan 2018 04:13:21 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0J9AiNW083033 for ; Fri, 19 Jan 2018 04:13:21 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fkd0t22nn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 Jan 2018 04:13:20 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Jan 2018 02:13:20 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Jan 2018 02:13:17 -0700 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0J9DG8812714278; Fri, 19 Jan 2018 02:13:16 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70337C603E; Fri, 19 Jan 2018 02:13:16 -0700 (MST) Received: from [9.85.72.196] (unknown [9.85.72.196]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 1F244C6042; Fri, 19 Jan 2018 02:13:12 -0700 (MST) Subject: Re: [PATCH v2 1/5] powerpc/mm: Enhance 'slice' for supporting PPC32 To: Christophe LEROY , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Scott Wood Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <49148d07955d3e5f963cedf9adcfcc37c3e03ef4.1516179904.git.christophe.leroy@c-s.fr> <87vafyz265.fsf@linux.vnet.ibm.com> <84dc1df4-db2f-be11-c1f3-5dddd1e44983@c-s.fr> <28c3ba39-ef31-5ff3-7672-3e9d1942be94@c-s.fr> From: "Aneesh Kumar K.V" Date: Fri, 19 Jan 2018 14:43:11 +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: <28c3ba39-ef31-5ff3-7672-3e9d1942be94@c-s.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18011909-0004-0000-0000-0000138A8E9D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008405; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000247; SDB=6.00977207; UDB=6.00495442; IPR=6.00757129; BA=6.00005782; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00019125; XFM=3.00000015; UTC=2018-01-19 09:13:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18011909-0005-0000-0000-000085BAE455 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-19_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1801190119 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/19/2018 02:37 PM, Christophe LEROY wrote: > > > Le 19/01/2018 à 10:02, Aneesh Kumar K.V a écrit : >> >> >> On 01/19/2018 02:14 PM, Christophe LEROY wrote: >>> >>> >>> Le 19/01/2018 à 09:24, Aneesh Kumar K.V a écrit : >>>> Christophe Leroy writes: >>>> >>>>> In preparation for the following patch which will fix an issue on >>>>> the 8xx by re-using the 'slices', this patch enhances the >>>>> 'slices' implementation to support 32 bits CPUs. >>>>> >>>>> On PPC32, the address space is limited to 4Gbytes, hence only the low >>>>> slices will be used. As of today, the code uses >>>>> SLICE_LOW_TOP (0x100000000ul) and compares it with addr to determine >>>>> if addr refers to low or high space. >>>>> On PPC32, such a (addr < SLICE_LOW_TOP) test is always false because >>>>> 0x100000000ul degrades to 0. Therefore, the patch modifies >>>>> SLICE_LOW_TOP to (0xfffffffful) and modifies the tests to >>>>> (addr <= SLICE_LOW_TOP) which will then always be true on PPC32 >>>>> as addr has type 'unsigned long' while not modifying the PPC64 >>>>> behaviour. >>>>> >>>>> This patch moves "slices" functions prototypes from page64.h to page.h >>>>> >>>>> The high slices use bitmaps. As bitmap functions are not prepared to >>>>> handling bitmaps of size 0, the bitmap_xxx() calls are wrapped into >>>>> slice_bitmap_xxx() macros which will take care of the 0 nbits case. >>>>> >>>>> Signed-off-by: Christophe Leroy >>>>> --- >>>>>   v2: First patch of v1 serie split in two parts ; added >>>>> slice_bitmap_xxx() macros. >>>>> >>>>>   arch/powerpc/include/asm/page.h      | 14 +++++++++ >>>>>   arch/powerpc/include/asm/page_32.h   | 19 ++++++++++++ >>>>>   arch/powerpc/include/asm/page_64.h   | 21 ++----------- >>>>>   arch/powerpc/mm/hash_utils_64.c      |  2 +- >>>>>   arch/powerpc/mm/mmu_context_nohash.c |  7 +++++ >>>>>   arch/powerpc/mm/slice.c              | 60 >>>>> ++++++++++++++++++++++++------------ >>>>>   6 files changed, 83 insertions(+), 40 deletions(-) >>>>> >>>>> diff --git a/arch/powerpc/include/asm/page.h >>>>> b/arch/powerpc/include/asm/page.h >>>>> index 8da5d4c1cab2..d0384f9db9eb 100644 >>>>> --- a/arch/powerpc/include/asm/page.h >>>>> +++ b/arch/powerpc/include/asm/page.h >>>>> @@ -342,6 +342,20 @@ typedef struct page *pgtable_t; >>>>>   #endif >>>>>   #endif >>>>> +#ifdef CONFIG_PPC_MM_SLICES >>>>> +struct mm_struct; >>>>> + >>>>> +unsigned long slice_get_unmapped_area(unsigned long addr, unsigned >>>>> long len, >>>>> +                      unsigned long flags, unsigned int psize, >>>>> +                      int topdown); >>>>> + >>>>> +unsigned int get_slice_psize(struct mm_struct *mm, unsigned long >>>>> addr); >>>>> + >>>>> +void slice_set_user_psize(struct mm_struct *mm, unsigned int psize); >>>>> +void slice_set_range_psize(struct mm_struct *mm, unsigned long start, >>>>> +               unsigned long len, unsigned int psize); >>>>> +#endif >>>>> + >>>> >>>> Should we do a slice.h ? the way we have other files? and then do >>> >>> Yes we could add a slice.h instead of using page.h for that, good idea. >>> >>>> >>>> arch/powerpc/include/asm/book3s/64/slice.h that will carry >>>> #define slice_bitmap_zero(dst, nbits) \ >>>>     do { if (nbits) bitmap_zero(dst, nbits); } while (0) >>>> #define slice_bitmap_set(dst, pos, nbits) \ >>>> do { if (nbits) bitmap_set(dst, pos, nbits); } while (0) >>>> #define slice_bitmap_copy(dst, src, nbits) \ >>>> do { if (nbits) bitmap_copy(dst, src, nbits); } while (0) >>>> #define slice_bitmap_and(dst, src1, src2, nbits) \ >>>>     ({ (nbits) ? bitmap_and(dst, src1, src2, nbits) : 0; }) >>>> #define slice_bitmap_or(dst, src1, src2, nbits) \ >>>>     do { if (nbits) bitmap_or(dst, src1, src2, nbits); } while (0) >>>> #define slice_bitmap_andnot(dst, src1, src2, nbits) \ >>>>     ({ (nbits) ? bitmap_andnot(dst, src1, src2, nbits) : 0; }) >>>> #define slice_bitmap_equal(src1, src2, nbits) \ >>>>     ({ (nbits) ? bitmap_equal(src1, src2, nbits) : 1; }) >>>> #define slice_bitmap_empty(src, nbits) \ >>>>     ({ (nbits) ? bitmap_empty(src, nbits) : 1; }) >>>> >>>> This without that if(nbits) check and a proper static inline so that we >>>> can do type checking. >>> >>> Is it really worth duplicating that just for eliminating the 'if >>> (nbits)' in one case ? >>> >>> Only in book3s/64 we will be able to eliminate that, for nohash/32 we >>> need to keep the test due to the difference between low and high slices. >> >> the other advantage is we move the SLICE_LOW_SHIFT to the right >> location. IMHO mm subystem is really complex with these really >> overloaded headers. If we can keep it  seperate we should with minimal >> code duplication? > > For the constants I fully agree with your proposal and I will do it. I > was only questionning the benefit of moving the slice_bitmap_xxxx() > stuff, taking into account that the 'if (nbits)' test is already > eliminated by the compiler. > That is compiler dependent as you are finding with the other patch where if (0) didn't get compiled out -aneesh