Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp986310img; Thu, 28 Feb 2019 11:03:06 -0800 (PST) X-Google-Smtp-Source: AHgI3IYM9mUfPRJBlzgfpxlhxRcXwrdNqhXdHEMRG0n9y2OSdcM+I6e0kwdDS+m8wVr1d5Piu8uu X-Received: by 2002:a62:1212:: with SMTP id a18mr1080371pfj.177.1551380586318; Thu, 28 Feb 2019 11:03:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551380586; cv=none; d=google.com; s=arc-20160816; b=VokEBkFq/udorK0hyhF3wAaANoI+cxpQmFFDxl7AIYVLCsRPhuac1wJaB7KP9zpO2w NPIjA2flUfcsv28yH1dQFQ3dL4FwKcnMYeJg6nGhjSaIjX04nlDB2wacYc/w2ys1AXBs 4t7tG9K2j4zGhpDgHcOr+tc6LH+Dfwts0Vc2tvQr7iwXioKQfD2Cw3Rq2z9StgRMWBCM oqbqp3p+KdhO1D/YIzeDOXd7HvD7pp4qvf+sddmVwHn1Z1cVgfvId8COANOZ8o5NJ8le Ji3FY0Gn8F3T6KB5w2sKrOY+n4e0BggSdNatUFBlixj0DPGx0mJ14NST1DHHmRUmjcEx OREQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:user-agent:content-language:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:cc:to :from:dkim-signature; bh=1G86G/5c/y6+uynIof6ueotd56OFKyafnMLXtDoktH0=; b=EGA09II5efBZE841ccbBUfjRN8p0uYv8NZWlu9Td7oMtg+xmTbwGMsiKoYZ7PnJX7i yWwmUUtM0lO+d321UhQAdfydFDtgJ1y6lAqk1AV0mq8WGfUsHQcFfAvZsnz3c5PGEaHr N9gls0iKiKvOMC4lGm1XUjDyebuzMJo2rQWkwxTIO55SiuzPYIrT+gUGCiWQhVxo8rCC 0T+ZEGRQJ1h0aYUkhi56wdV1sygEtp/7Ixdbrmvp3bzqCF5sXaGNuoWaiu7cYomizLy6 Pxy8Q6bvifiL1MCzNCQ7N48Q8a6MDz2/Ut6xBQrceDbxYfv9OEeRuvqmFkxA4dZABVUw qsTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wavesemi.onmicrosoft.com header.s=selector1-wavecomp-com header.b=Ig13ZI79; 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 l7si19443680plb.366.2019.02.28.11.02.49; Thu, 28 Feb 2019 11:03:06 -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; dkim=pass header.i=@wavesemi.onmicrosoft.com header.s=selector1-wavecomp-com header.b=Ig13ZI79; 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 S1732687AbfB1Szg (ORCPT + 99 others); Thu, 28 Feb 2019 13:55:36 -0500 Received: from mail-eopbgr810112.outbound.protection.outlook.com ([40.107.81.112]:42176 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727649AbfB1Szg (ORCPT ); Thu, 28 Feb 2019 13:55:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wavesemi.onmicrosoft.com; s=selector1-wavecomp-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1G86G/5c/y6+uynIof6ueotd56OFKyafnMLXtDoktH0=; b=Ig13ZI79xC3LA3Rhapevy/kU+Gsq5UQFhJBBK/hDQoXyNBijlQRTamsdOhTNnncBjRquZ8cXfUTa7gop4evcWaRCBS/BrOv8oWIpHm/F0nSG++Mp2/ubBNLYXFsPTDBS57gkcB5vdTFc+8OIUOD/1Eco7IkVQCSFBPz/OXOA70s= Received: from MWHPR2201MB1277.namprd22.prod.outlook.com (10.174.162.17) by MWHPR2201MB1359.namprd22.prod.outlook.com (10.174.162.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.16; Thu, 28 Feb 2019 18:55:28 +0000 Received: from MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636]) by MWHPR2201MB1277.namprd22.prod.outlook.com ([fe80::7d5e:f3b0:4a5:4636%9]) with mapi id 15.20.1643.019; Thu, 28 Feb 2019 18:55:28 +0000 From: Paul Burton To: Steven Price CC: Mark Rutland , Peter Zijlstra , Catalin Marinas , Dave Hansen , Will Deacon , "linux-mips@vger.kernel.org" , "linux-mm@kvack.org" , "H. Peter Anvin" , "Liang, Kan" , "x86@kernel.org" , Ingo Molnar , James Hogan , Arnd Bergmann , =?iso-8859-1?Q?J=E9r=F4me_Glisse?= , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" , Ard Biesheuvel , "linux-kernel@vger.kernel.org" , Ralf Baechle , James Morse Subject: Re: [PATCH v3 11/34] mips: mm: Add p?d_large() definitions Thread-Topic: [PATCH v3 11/34] mips: mm: Add p?d_large() definitions Thread-Index: AQHUzr7i/d0uU6ROnE+g9kAjsVHJ0KX0eXKAgACmggCAAHDjAA== Date: Thu, 28 Feb 2019 18:55:28 +0000 Message-ID: <20190228185526.hdryn2zsfign7vht@pburton-laptop> References: <20190227170608.27963-1-steven.price@arm.com> <20190227170608.27963-12-steven.price@arm.com> <20190228021526.bb6m3my46ohb4o6h@pburton-laptop> <74944d83-f3c0-ff02-590e-b7e5abcea485@arm.com> In-Reply-To: <74944d83-f3c0-ff02-590e-b7e5abcea485@arm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR21CA0024.namprd21.prod.outlook.com (2603:10b6:a03:114::34) To MWHPR2201MB1277.namprd22.prod.outlook.com (2603:10b6:301:24::17) user-agent: NeoMutt/20180716 authentication-results: spf=none (sender IP is ) smtp.mailfrom=pburton@wavecomp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [67.207.99.198] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 550c1196-5533-4a3f-2915-08d69dae4e26 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:MWHPR2201MB1359; x-ms-traffictypediagnostic: MWHPR2201MB1359: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1;MWHPR2201MB1359;23:APQz/DE9p4wWq6b0dZpgpoDdUz3tcNtWFG4R3?= =?iso-8859-1?Q?c0SV6754VZ1bgIRlfhf/JpFe0B9xDmVvJ980SCtXoIn6GsCluDx4ng/vga?= =?iso-8859-1?Q?Z6MBuXYzMolQlFMMjV4s8HWnG/isT/TcSlu1ATdYhqUB6Lhehb/EQfc11b?= =?iso-8859-1?Q?KppF3LNFiXAvVEXwcK1SkCfE5aXXcU2Eox6OzxgEGmFDp8rCcla5Bbti0Z?= =?iso-8859-1?Q?eUSKhtccHf50S4STr25a/mvb/Ec24qt437bV9E7jrDqDJzLkPGWpyuaUxq?= =?iso-8859-1?Q?LlG1DvGqxIdUt3hqaAy8wUsLB2H6zOBaqfN1qdiI4wDfHjs0HtDxf73v0u?= =?iso-8859-1?Q?0+8CtFQHSf/nUW3GuUz/q3Pf/BvfjxSSQWMvQcg1Hm/Z26oJDWdiojK2G/?= =?iso-8859-1?Q?5PUozKEd+mJiNVmxeu6qyUi2eOFabVK0Wu1C+XI9K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I01GQn2YHziU1Qj0dCaa0gEWf1cPDv6Xz2JV0xjCI6A2hHvtfdLH9?= =?iso-8859-1?Q?zfICz2vkZSEV4jxvkuJWxvt0BeHyn1mf4rRFoCrZObypXQLPJxE4H9XylU?= =?iso-8859-1?Q?Cc1VrDz9NxASPKqti2h0ZI/zQQCUiY5JmnOkN?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(7916004)(346002)(136003)(376002)(366004)(396003)(39850400004)(51914003)(199004)(189003)(186003)(6246003)(6486002)(486006)(11346002)(106356001)(446003)(476003)(42882007)(52116002)(53546011)(305945005)(6506007)(386003)(66066001)(93886005)(7416002)(6916009)(256004)(229853002)(478600001)(6436002)(102836004)(33716001)(76176011)(53936002)(9686003)(14444005)(6512007)(4326008)(81156014)(81166006)(25786009)(71190400001)(6116002)(8676002)(71200400001)(5660300002)(97736004)(3846002)(2906002)(1076003)(44832011)(68736007)(316002)(26005)(14454004)(8936002)(54906003)(99286004)(7736002)(105586002)(58126008);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR2201MB1359;H:MWHPR2201MB1277.namprd22.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: wavecomp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: sQdOpLduEp5xt+4qfJPbXOED9r3yioy1Wm4u843ee1EHOpDndmuGOWtHeeEtfv7fmvwKXnrqYQ/WdZPeolaf87flYadfVSP0Q02VGgzMHyl0kRAOREUwzDb7DHDhSE2MJ+atyIHKdNIRJ984narfxtSwpjcYIrzJ6J0lMFwHJNAwnTn3Idkyz5nDJP/hzUBnuV3sLFcaGf9QVMr9H4ql6tzAhAkRY+x2XgCCbVYVmDHBAy2B7By8rTX5T+JkwV2mSn8ZIeepb/MPFnunBlvSZ91Q6DsXQBgpl39gRSNh4h3oPrpxRaie9ioPH/gaMTRYwvro7ji8pnMi9Wm/+F9GVMo6yOyTJcisaR0x3TD8dpWuaErqJ+/ZEilf5J+MFevYHeLLbG+C4ldpsP80HzkUOwSKiJiUYPD3YpLV6RmHfNE= Content-Type: text/plain; charset="iso-8859-1" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: mips.com X-MS-Exchange-CrossTenant-Network-Message-Id: 550c1196-5533-4a3f-2915-08d69dae4e26 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 18:55:27.9917 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 463607d3-1db3-40a0-8a29-970c56230104 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR2201MB1359 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, On Thu, Feb 28, 2019 at 12:11:24PM +0000, Steven Price wrote: > On 28/02/2019 02:15, Paul Burton wrote: > > On Wed, Feb 27, 2019 at 05:05:45PM +0000, Steven Price wrote: > >> For mips, we don't support large pages on 32 bit so add stubs returnin= g 0. > >=20 > > So far so good :) > >=20 > >> For 64 bit look for _PAGE_HUGE flag being set. This means exposing the > >> flag when !CONFIG_MIPS_HUGE_TLB_SUPPORT. > >=20 > > Here I have to ask why? We could just return 0 like the mips32 case whe= n > > CONFIG_MIPS_HUGE_TLB_SUPPORT=3Dn, let the compiler optimize the whole > > thing out and avoid redundant work at runtime. > >=20 > > This could be unified too in asm/pgtable.h - checking for > > CONFIG_MIPS_HUGE_TLB_SUPPORT should be sufficient to cover the mips32 > > case along with the subset of mips64 configurations without huge pages. >=20 > The intention here is to define a new set of macros/functions which will > always tell us whether we're at the leaf of a page table walk, whether > or not huge pages are compiled into the kernel. Basically this allows > the page walking code to be used on page tables other than user space, > for instance the kernel page tables (which e.g. might use a large > mapping for linear memory even if huge pages are not compiled in) or > page tables from firmware (e.g. EFI on arm64). >=20 > I'm not familiar enough with mips to know how it handles things like the > linear map so I don't know how relevant that is, but I'm trying to > introduce a new set of functions which differ from the existing > p?d_huge() macros by not depending on whether these mappings could exist > for a user space VMA (i.e. not depending on HUGETLB support and existing > for all levels that architecturally they can occur at). Thanks for the explanation - the background helps. Right now for MIPS, with one exception, there'll be no difference between a page being huge or large. So for the vast majority of kernels with CONFIG_MIPS_HUGE_TLB_SUPPORT=3Dn we should just return 0. The one exception I mentioned is old SGI IP27 support, which allows the kernel to be mapped through the TLB & does that using 2x 16MB pages when CONFIG_MAPPED_KERNEL=3Dy. However even there your patch as-is won't pick up on that for 2 reasons: 1) The pages in question don't appear to actually be recorded in the page tables - they're just written straight into the TLB as wired entries (ie. entries that will never be evicted). 2) Even if they were in the page tables the _PAGE_HUGE bit isn't set. Since those pages aren't recorded in the page tables anyway we'd either need to: a) Add them to the page tables, and set the _PAGE_HUGE bit. b) Ignore them if the code you're working on won't be operating on the memory mapping the kernel. For other platforms the kernel is run from unmapped memory, and for all cases including IP27 the kernel will use unmapped memory to access lowmem or peripherals when possible. That is, MIPS has virtual address regions ((c)kseg[01] or xkphys) which are architecturally defined as linear maps to physical memory & so VA->PA translation doesn't use the TLB at all. So my thought would be that for almost everything we could just do: #define pmd_large(pmd) pmd_huge(pmd) #define pud_large(pmd) pud_huge(pmd) And whether we need to do anything about IP27 depends on whether a) or b) is chosen above. Or alternatively you could do something like: #ifdef _PAGE_HUGE static inline int pmd_large(pmd_t pmd) { return (pmd_val(pmd) & _PAGE_HUGE) !=3D 0; } static inline int pud_large(pud_t pud) { return (pud_val(pud) & _PAGE_HUGE) !=3D 0; } #else # define pmd_large(pmd) 0 # define pud_large(pud) 0 #endif That would cover everything except for the IP27, but would make it pick up the IP27 kernel pages automatically if someone later defines _PAGE_HUGE for IP27 CONFIG_MAPPED_KERNEL=3Dy & makes use of it for those pages. Thanks, Paul