Received: by 10.223.176.46 with SMTP id f43csp1060967wra; Sat, 20 Jan 2018 09:59:30 -0800 (PST) X-Google-Smtp-Source: AH8x224kXml/EqUsxik3MHH+x0rHTM9uCDchz0S0DTwdl6PA801M9okjSCwzhHkr09YXkGGz1o0q X-Received: by 10.98.245.69 with SMTP id n66mr3045639pfh.137.1516471170429; Sat, 20 Jan 2018 09:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516471170; cv=none; d=google.com; s=arc-20160816; b=ZCX8l0hKbMpEo/WZSQB66bTIcbX33ixZDw+UO2L5ZMbs7HUDRpYl3/9EikLtt+K+/5 ZMfUJ0T2XVZVm3F9zaanwJwh6R2IIkh88ZpUfzBok0Bmfpq3YXcdGG6Qj+qWE4MQMyUa KjnzvtXxH/UC+ewL/5279oPsC1cPX/44pkTFG36H6txoPkwHhq6hCfrBwHahIbYQQiRv zWuVmOoQI28aWXoQAM1CB1As5sfYYmIcP/ofKNqF7TK7N2sjj1yXCzCC0JRP89greQWa E26wIziaVNTkJgh9dUMlPPEr97olz3uPL02FohZLLY9TI0dQyhTKrLSkf0GW2NORsNUP FMnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=pcpoU8wpSoMpcwS6/0tkOchQqfEm3uV5GDw7XBG5GEo=; b=sXQwINvax5BZ1PKc8Bp+xCO63fnfZO20Ow2J4K85ZdCANiTttEPDMzR3QR3PEfPPDr aVk0DSkXs59iTCEHT5kTdhVInObPsqiZuvpjyEKxC9ZZBfiQbCLKPukSuXAROM8xVm7k 2uMyWLlNyGeqtp3N/O7WRU+88Wyr9bI1+HLu2PMO/qWYwne4409R8n3M8qIgpqdk3u3n 23hhE+VtZHem2lIO5AbShEPktYHlZAUzQBrxD9o0VCMS9wFK57Z2Luc/1rGYqI0k6JAv PqEiR+bP/ulnZK7nKdNBDdLf0dlTaJbtXOZjW7m7eZFg/rLxsXtsXs8xP1WW220L55k8 F8cQ== 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 i1si10510385pgn.373.2018.01.20.09.59.16; Sat, 20 Jan 2018 09:59:30 -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 S1756667AbeATR55 (ORCPT + 99 others); Sat, 20 Jan 2018 12:57:57 -0500 Received: from gate.crashing.org ([63.228.1.57]:37115 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008AbeATR5w (ORCPT ); Sat, 20 Jan 2018 12:57:52 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id w0KHuxfP000463; Sat, 20 Jan 2018 11:56:59 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id w0KHuuGT000452; Sat, 20 Jan 2018 11:56:56 -0600 Date: Sat, 20 Jan 2018 11:56:55 -0600 From: Segher Boessenkool To: christophe leroy Cc: "Aneesh Kumar K.V" , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Scott Wood , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/5] powerpc/mm: Enhance 'slice' for supporting PPC32 Message-ID: <20180120175655.GY21977@gate.crashing.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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <36e8d873-4021-4266-bf5f-287f396ba9e1@c-s.fr> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > >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. Segher