Received: by 10.223.176.46 with SMTP id f43csp2604467wra; Sun, 21 Jan 2018 23:53:35 -0800 (PST) X-Google-Smtp-Source: AH8x2257ia7wWrdRoAYj/T7IJIPiYduwGO9UYZ6r6stZXa9Tz6yzQYc86FPO9Ob1K+t4Z9hFI9yt X-Received: by 10.98.66.67 with SMTP id p64mr7611259pfa.227.1516607615468; Sun, 21 Jan 2018 23:53:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516607615; cv=none; d=google.com; s=arc-20160816; b=OELFwFflrHqR1LzWfCFXY6qDbQ0PIBSrA1PSySdI8t1KE63B0wZTz0ZAZOGX4PouHc i2NKiQogRFJMQME79LiYkc6NFTKRT0IHVi5vhBo26F/eoiRNlKDKVD91BjXF75A1PtHL tGeGU+tOVRdZcCiYqGEavH6TULHvWxTFzDTyuAyUzAz3VgYkppIqFpIjbJrKvmNszQVH myGRGu9EckHol971bTjOS4TpH83H0qKTlU8SdvEMiwH8SXZfppSccIm5UNQLy8qHbSAc io2BmXzGu9Qiogq3b1idq/H+iY8g6Xcj3/dnoSE2ctMkDE72d1ctutuvtODf6Ym/LIf8 U6fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=NEDg0UwpSoCto7kScM19bmTrDU3RWUcM1AWPpNHGVmc=; b=mXey5SOzFib42rtIj5KOhxybAisA9IfEZ7Ap08/dknJIX4jyXY4nknoRkKrENYqV6/ Ce20rVBCH8W7VDM+3wgFQUPVxAVIawbVarAE0oM281bW7hoW1EfspKBhhDaWOH0QoHJD Z670AFYHbkPUAJb87dxqPmAax2WqhW85I97afherwOcDAdXUMi7HVgkdPkd+gucK7FDU yHbFK6GEW2HdWA97IMLfvDoVcf9htkLsdoSJDbo1ZN0ebClR2IUqvc5fflpe/KnSoMXi 7c30xPSn57FDCwuGF8Sw++0WNp8+EYw/Lc06b+ABsMduBtERLI6Jjx1YXikG7ozo75wP LtmA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si1894926pfa.35.2018.01.21.23.53.20; Sun, 21 Jan 2018 23:53:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751028AbeAVHw5 (ORCPT + 99 others); Mon, 22 Jan 2018 02:52:57 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:31993 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbeAVHw4 (ORCPT ); Mon, 22 Jan 2018 02:52:56 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 3zQ3Z91WzGz9ttlF; Mon, 22 Jan 2018 08:52:49 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id nUWLsphNRDIa; Mon, 22 Jan 2018 08:52:49 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 3zQ3Z90fkwz9ttlC; Mon, 22 Jan 2018 08:52:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 555FA8B89B; Mon, 22 Jan 2018 08:52:54 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id aSyeQyppTgga; Mon, 22 Jan 2018 08:52:54 +0100 (CET) Received: from PO15451 (po15451.idsi0.si.c-s.fr [172.25.231.40]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E28A48B88B; Mon, 22 Jan 2018 08:52:53 +0100 (CET) Subject: Re: [PATCH v2 1/5] powerpc/mm: Enhance 'slice' for supporting PPC32 To: Segher Boessenkool Cc: "Aneesh Kumar K.V" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Scott Wood , 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> <36e8d873-4021-4266-bf5f-287f396ba9e1@c-s.fr> <20180120175655.GY21977@gate.crashing.org> From: Christophe LEROY Message-ID: <52c000dd-1625-a205-8ad1-04376beed2ab@c-s.fr> Date: Mon, 22 Jan 2018 08:52:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180120175655.GY21977@gate.crashing.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 20/01/2018 à 18:56, Segher Boessenkool a écrit : > Hi! > > On Sat, Jan 20, 2018 at 09:22:50AM +0100, christophe leroy wrote: >>>>>>>>> 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. > > It should work to define SLICE_LOW_TOP as 0x100000000ull and keep > everything else the same, no? great, yes it works indeed. > >>> I don't think so. When I had the missing prototype, the compilation goes >>> ok, including the final link. Which means at the end the code is not >>> included since radix_enabled() evaluates to 0. >>> >>> Many many parts of the kernel are based on this assumption. >> >> Segher, what is your opinion on the above ? Can we consider that a ' if >> (nbits)' will always be compiled out when nbits is a #define constant, >> or should we duplicate the macros as suggested in order to avoid >> unneccessary 'if' test on platforms where 'nbits' is always not null by >> definition ? > > Doing things like > > if (nbits) > some_undeclared_function(); > > will likely work in practice if the condition evaluates to false at > compile time, but a) it will warn; b) it is just yuck; and c) it will > not always work (for example, you get the wrong prototype in this case, > not lethal here with most ABIs, but ugh). > > Just make sure to declare all functions, or define it to some empty > thing, or #ifdeffery if you have to. There are many options, it is > not hard, and if it means you have to pull code further apart that is > not so bad: you get cleaner, clearer code. Ok, if I understand well, your comment applies to the following indeed, so you confirm the #ifdef is necessary. --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -553,9 +553,11 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, struct hstate *hstate = hstate_file(file); int mmu_psize = shift_to_mmu_psize(huge_page_shift(hstate)); +#ifdef CONFIG_PPC_RADIX_MMU if (radix_enabled()) return radix__hugetlb_get_unmapped_area(file, addr, len, pgoff, flags); +#endif return slice_get_unmapped_area(addr, len, flags, mmu_psize, 1); } #endif However, my question was related to another part of the current patchset, where the functions are always refined: On PPC32 we set: +#define SLICE_LOW_SHIFT 28 +#define SLICE_HIGH_SHIFT 0 On PPC64 we set: #define SLICE_LOW_SHIFT 28 #define SLICE_HIGH_SHIFT 40 We define: +#define slice_bitmap_zero(dst, nbits) \ + do { if (nbits) bitmap_zero(dst, nbits); } while (0) We have a function with: { slice_bitmap_zero(ret->low_slices, SLICE_NUM_LOW); slice_bitmap_zero(ret->high_slices, SLICE_NUM_HIGH); } So the question is to find the better approach. Is the above approach correct, including performance wise ? Or should we define two sets of the macro slice_bitmap_zero(), one for CONFIG_PPC32 with the 'if (nbits)' test and one for CONFIG_PPC64 without the unnecessary test ? Or should we avoid this macro entirely and instead do something like: { bitmap_zero(ret->low_slices, SLICE_NUM_LOW); #if SLICE_NUM_HIGH != 0 bitmap_zero(ret->high_slices, SLICE_NUM_HIGH); #endif } And if we say the 'macro' approach is OK, should it be better the use a static inline function instead ? Thanks, Christophe