Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934851AbaKNBSI (ORCPT ); Thu, 13 Nov 2014 20:18:08 -0500 Received: from mail-vc0-f179.google.com ([209.85.220.179]:64451 "EHLO mail-vc0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934693AbaKNBSE (ORCPT ); Thu, 13 Nov 2014 20:18:04 -0500 MIME-Version: 1.0 In-Reply-To: <20141114005833.GA1572@node.dhcp.inet.fi> References: <1415644096-3513-1-git-send-email-j.glisse@gmail.com> <1415644096-3513-4-git-send-email-j.glisse@gmail.com> <20141110205814.GA4186@gmail.com> <20141110225036.GB4186@gmail.com> <20141114005833.GA1572@node.dhcp.inet.fi> Date: Thu, 13 Nov 2014 17:18:03 -0800 X-Google-Sender-Auth: 1PVHshXMH18MgyrwqrEvRVzc5Q4 Message-ID: Subject: Re: [PATCH 3/5] lib: lockless generic and arch independent page table (gpt) v2. From: Linus Torvalds To: "Kirill A. Shutemov" Cc: Jerome Glisse , Andrew Morton , Linux Kernel Mailing List , linux-mm , Joerg Roedel , Mel Gorman , "H. Peter Anvin" , Peter Zijlstra , Andrea Arcangeli , Johannes Weiner , Larry Woodman , Rik van Riel , Dave Airlie , Brendan Conoboy , Joe Donohue , Duncan Poole , Sherry Cheung , Subhash Gutti , John Hubbard , Mark Hairgrove , Lucien Dunning , Cameron Buschardt , Arvind Gopalakrishnan , Shachar Raindel , Liran Liss , Roland Dreier , Ben Sander , Greg Stoner , John Bridgman , Michael Mantor , Paul Blinzer , Laurent Morichetti , Alexander Deucher , Oded Gabbay , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 13, 2014 at 4:58 PM, Kirill A. Shutemov wrote: > On Thu, Nov 13, 2014 at 03:50:02PM -0800, Linus Torvalds wrote: >> +/* >> + * The 'tree_level' data only describes one particular level >> + * of the tree. The upper levels are totally invisible to the >> + * user of the tree walker, since the tree walker will walk >> + * those using the tree definitions. >> + * >> + * NOTE! "struct tree_entry" is an opaque type, and is just a >> + * used as a pointer to the particular level. You can figure >> + * out which level you are at by looking at the "tree_level", >> + * but even better is to just use different "lookup()" >> + * functions for different levels, at which point the >> + * function is inherent to the level. > > Please, don't. > > We will end up with the same last-level centric code as we have now in mm > subsystem: all code only cares about pte. You realize that we have a name for this. It's called "reality". > It makes implementing variable > page size support really hard and lead to copy-paste approach. And to > hugetlb parallel world... No, go back and read the thing. You're confusing two different issues: looking up the tree, and actually walking the end result. The "looking up different levels of the tree" absolutely _should_ use different actors for different levels. Because the levels are not at all guaranteed to be the same. Sure, they often are. When you extend a tree, it's fairly reasonable to try to make the different levels look identical. But "often" is not at all "always". More importantly, nobody should ever care. Because the whole *point* of the tree walker is that the user never sees any of this. This is purely an implementation detail of the tree itself. Somebody who just *walks* the tree only sees the final end result. And *that* is the "walk()" callback. Which gets the virtual address and the length, exactly so that for a super-page you don't even really see the difference between walking different levels (well, you do see it, since the length will differ). Now, I didn't actually try to make that whole thing very transparent. In particular, somebody who just wants to see the data (and ignore as much of the "tree" details as possible) would really want to have not that "tree_entry", but the whole "struct tree_level *" and in particular a way to *map* the page. I left that out entirely, because it wasn't really central to the whole tree walking. But thinking that the levels should look the same is fundamentally bogus. For one, because they don't always look the same at all. For another, because it's completely separate from the accessing of the level data anyway. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/