From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E534C433E0 for ; Wed, 17 Jun 2020 14:45:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CC07E20810 for ; Wed, 17 Jun 2020 14:45:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC07E20810 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgroup.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6BE016B0027; Wed, 17 Jun 2020 10:45:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66E356B0028; Wed, 17 Jun 2020 10:45:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50F9A6B0029; Wed, 17 Jun 2020 10:45:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 36C786B0027 for ; Wed, 17 Jun 2020 10:45:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AFB6D29E16 for ; Wed, 17 Jun 2020 14:45:33 +0000 (UTC) X-FDA: 76938977346.20.chalk86_5b06e1526e08 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 80AA718158874 for ; Wed, 17 Jun 2020 14:45:33 +0000 (UTC) X-HE-Tag: chalk86_5b06e1526e08 X-Filterd-Recvd-Size: 4207 Received: from pegase1.c-s.fr (pegase1.c-s.fr [93.17.236.30]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Wed, 17 Jun 2020 14:45:32 +0000 (UTC) Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 49n7CX6RNmz9tyTx; Wed, 17 Jun 2020 16:45:28 +0200 (CEST) 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 z61xwnB6Yi86; Wed, 17 Jun 2020 16:45:28 +0200 (CEST) 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 49n7CX5PZhz9tyTv; Wed, 17 Jun 2020 16:45:28 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id AC4C08B80F; Wed, 17 Jun 2020 16:45:30 +0200 (CEST) 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 JE3Mk_gI3482; Wed, 17 Jun 2020 16:45:30 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0C00D8B781; Wed, 17 Jun 2020 16:45:30 +0200 (CEST) Subject: Re: [PATCH 3/3] powerpc/8xx: Provide ptep_get() with 16k pages To: Peter Zijlstra , Michael Ellerman Cc: Benjamin Herrenschmidt , Paul Mackerras , Will Deacon , Andrew Morton , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org References: <341688399c1b102756046d19ea6ce39db1ae4742.1592225558.git.christophe.leroy@csgroup.eu> <20200615132244.GR2531@hirez.programming.kicks-ass.net> <87wo45db8d.fsf@mpe.ellerman.id.au> <20200617143826.GJ2531@hirez.programming.kicks-ass.net> From: Christophe Leroy Message-ID: <0bb024ce-11aa-80dc-c7d8-d5acc5329f25@csgroup.eu> Date: Wed, 17 Jun 2020 16:45:19 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200617143826.GJ2531@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr X-Rspamd-Queue-Id: 80AA718158874 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Le 17/06/2020 =C3=A0 16:38, Peter Zijlstra a =C3=A9crit=C2=A0: > On Thu, Jun 18, 2020 at 12:21:22AM +1000, Michael Ellerman wrote: >> Peter Zijlstra writes: >>> On Mon, Jun 15, 2020 at 12:57:59PM +0000, Christophe Leroy wrote: >=20 >>>> +#if defined(CONFIG_PPC_8xx) && defined(CONFIG_PPC_16K_PAGES) >>>> +#define __HAVE_ARCH_PTEP_GET >>>> +static inline pte_t ptep_get(pte_t *ptep) >>>> +{ >>>> + pte_t pte =3D {READ_ONCE(ptep->pte), 0, 0, 0}; >>>> + >>>> + return pte; >>>> +} >>>> +#endif >>> >>> Would it make sense to have a comment with this magic? The casual rea= der >>> might wonder WTH just happened when he stumbles on this :-) >> >> I tried writing a helpful comment but it's too late for my brain to fo= rm >> sensible sentences. >> >> Christophe can you send a follow-up with a comment explaining it? In >> particular the zero entries stand out, it's kind of subtle that those >> entries are only populated with the right value when we write to the >> page table. >=20 > static inline pte_t ptep_get(pte_t *ptep) > { > unsigned long val =3D READ_ONCE(ptep->pte); > /* 16K pages have 4 identical value 4K entries */ > pte_t pte =3D {val, val, val, val); > return pte; > } >=20 > Maybe something like that? >=20 This should work as well. Indeed nobody cares about what's in the other=20 three. They are only there to ensure that ptep++ increases the ptep=20 pointer by 16 bytes. Only the HW require 4 identical values, that's=20 taken care of in set_pte_at() and pte_update(). So we should use the most efficient. Thinking once more, maybe what you=20 propose is the most efficient as there is no need to load another=20 register with value 0 in order to write it in the stack. Christophe