Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2712478imj; Mon, 18 Feb 2019 10:44:30 -0800 (PST) X-Google-Smtp-Source: AHgI3IavboNVB7/Xq+9L+72GPaaXzrWIn+rPPAdg2rRMAxH+vm4Xz6cpf+vghvCFiVfnrUVVxKQ3 X-Received: by 2002:a63:7e0e:: with SMTP id z14mr3063748pgc.436.1550515470477; Mon, 18 Feb 2019 10:44:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550515470; cv=none; d=google.com; s=arc-20160816; b=W3JtQzH0yUkkDy/Bd8O4IMbFTWnxdECDveZZQPquSPYi4wTCr1phSkryOgVFDD7VW5 eZexvTp6Eo0crqx/OB0dYlZVsNoo5px5K6Gxkj9gcsH89gBkd9kEKex/baTtTEUy7Og+ /kHXPa9QBnkTw57bsThqEWVz6sooMPDoMN3ht4Yd0mr+hwwKyCpvTsePGlpKf1M2xdJR DOMnCZlIukHzxv4AaqO6Mq5YIIpVonzPvvyO6XGOClULpBFNyyWSq8sGgaD4o2mYqYJY D2ADto5DOfEfPkjV1aJIjoeg24w6tgJp86o0Hdo7epfmOJpWhMzYP26jmgI2wNM5THoe 7V4Q== 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; bh=DtxKPR+qfLx8EugR1EloWNESgnyesXNJF2pDUbBr7JU=; b=qAzMvQ4A+a4OFmSmB6GEbqk+uShM3ho7C99o/XYt5/vv9D4G7/inO/J2HTggntLY+1 3Em5zvF+pqnU7crB7WoL46pw2tp2ml0axmAKaPmyUNGrWwVZdl68rbVWNEKcgmFxfdG+ zKPCYiCXxeJF3qsf6y6/bqWf5m1OUSuykNE7K9wk3hW713yEOYM6EHXkf4ELQ6VQTyV7 t3Btv2IQRMHMZOCeKrvMeWegnHbMdkXheBmOGvtMYRjW8WhHlbC/TNgEqTf86igI6qUW SyhMotUMisghKyP5TxmWBCuaL1oDE/iWDwt5GpQr3+ZMY200cGacaqfWZDz+kJN3NeQS Abmg== 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 y26si10358323pfd.25.2019.02.18.10.44.14; Mon, 18 Feb 2019 10:44: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 S1732105AbfBRPXx (ORCPT + 99 others); Mon, 18 Feb 2019 10:23:53 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33244 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729977AbfBRPXw (ORCPT ); Mon, 18 Feb 2019 10:23:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14442A78; Mon, 18 Feb 2019 07:23:37 -0800 (PST) Received: from [10.1.196.69] (e112269-lin.cambridge.arm.com [10.1.196.69]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F2E1C3F675; Mon, 18 Feb 2019 07:23:23 -0800 (PST) Subject: Re: [PATCH 06/13] mm: pagewalk: Add 'depth' parameter to pte_hole To: Mark Rutland Cc: "x86@kernel.org" , Arnd Bergmann , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Dave Hansen , Will Deacon , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , James Morse , Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" References: <20190215170235.23360-1-steven.price@arm.com> <20190215170235.23360-7-steven.price@arm.com> <20190218112350.GE8036@lakrids.cambridge.arm.com> From: Steven Price Message-ID: <7b0c6eed-102e-ff79-0f65-16bcec043a09@arm.com> Date: Mon, 18 Feb 2019 15:23:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190218112350.GE8036@lakrids.cambridge.arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/02/2019 11:23, Mark Rutland wrote: > On Fri, Feb 15, 2019 at 05:02:27PM +0000, Steven Price wrote: >> +/* If the p4ds are actually just pgds then we should report a depth >> + * of 0 not 1 (as a missing entry is really a missing pgd >> + */ > > Nit: comment style violation. This should look like: > should be: > > /* > * If the p4ds are actually just pgds then we should report a depth > * of 0 not 1 (as a missing entry is really a missing pgd > */ > >> +int depth = (PTRS_PER_P4D == 1)?0:1; > > Nit: the ternary should have spacing. > > We don't seem to do this at any other level that could be folded, so why > does p4d need special care? > > For example, what happens on arm64 when using 64K pages and 3 level > paging, where puds are folded into pgds? > > Thanks, > Mark. Yes, you are entirely correct I've missed the other potential foldings. I somehow imagined that p4d was special and was folded the opposite direction (I'm not sure why!). The best solution I can come up with is a function which will convert from the level the entry is found at, back to the 'real' level the entry was missing at. This is needed to produce the correct output in the debugfs file. Something like: static int real_depth(int depth) { if (depth == 3 && PTRS_PER_PMD == 1) depth = 2; if (depth == 2 && PTRS_PER_PUD == 1) depth = 1; if (depth == 1 && PTRS_PER_P4D == 1) depth = 0; return depth; } This should of course get folded by the compiler and not actually generate any code. Thanks, Steve