Received: by 10.192.165.148 with SMTP id m20csp543355imm; Fri, 4 May 2018 14:50:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpUuAAPjVwCoUrLc8KkcgojN3hlFI9HXuy8tyolaFAYV7sqbxNqssNJVUiXd0AzMLH6RGW8 X-Received: by 2002:a17:902:8b82:: with SMTP id ay2-v6mr26134795plb.295.1525470622916; Fri, 04 May 2018 14:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525470622; cv=none; d=google.com; s=arc-20160816; b=x+ibxMx5fubNJUSx5jDTJkrSEZxt2It4pTb8YEVh/9ECxn/hLMTc/as44xoEfuWHmD MC0tOE+kheZRFxqtnkTXSgVyCarEzUyVmRYFypDvRrfELcEJE/PRczW3g41eZK+J00+a 3Lk/Yid4DcJubJTz7Ybf8QY0qZL5mrqsr3ck3Vnsv/+Esck9P2b0CdLj+oarQcOWarE0 LEIXYnHejR1dtlzT51WJ7fhhhYPXgML61PPmyxsoiXrXPfRk2WrCyBMa9JI1Lb3Px8Wg oxuP7jAgTy2U0JR8Re7eoP089AJvzrFJXAjZ8qsqRHZC03D8j+IoB1xaXx+0/vP0pzLF IM6A== 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=AAoR1cNiSQKpfhWd6HvPRghF2gjgS1jRzGeaFMDCxiU=; b=tLACnGy37MfbtdD6Ly1VQlAUi1aWlAgxEQ3p3hmQyBqcdCAcQUudiUKDSET3JRu/fY owUFP4oTyjTuXhFUpwEz8DiaVUyRJDNq76ccZIsQynL21tv/a1UsfQnSgnOJYXdaUPG4 AWUxF3/pJqswoTSfFORUb+cBCuJs6H1u2rNCd4+mBDMvjybVHQa1NVavIC7g1V+NOXTT mmRJ47G04FnRSwM2DgX09hYhRaJiJeQ6PoEzqdwvxEbDFQrAbdxJXs2foXiQuQhE8Zpx eoOTAsAQoTDi9aM8NUnlcI3OxE3S3QqfCpte6+Sd85ukC/+hqHs5o9AYKTAQwCScOZYr bIUw== 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 ay8-v6si16935290plb.244.2018.05.04.14.50.08; Fri, 04 May 2018 14:50:22 -0700 (PDT) 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 S1751839AbeEDVtl (ORCPT + 99 others); Fri, 4 May 2018 17:49:41 -0400 Received: from mga01.intel.com ([192.55.52.88]:14009 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbeEDVtk (ORCPT ); Fri, 4 May 2018 17:49:40 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2018 14:49:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,363,1520924400"; d="scan'208";a="38525640" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 04 May 2018 14:49:37 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 04A9D82; Sat, 5 May 2018 00:49:36 +0300 (EEST) Date: Sat, 5 May 2018 00:49:36 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: Andrew Morton , Michal Hocko , Linus Torvalds , Andy Lutomirski , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: Proof-of-concept: better(?) page-table manipulation API Message-ID: <20180504214936.v62knybljdvcnifq@black.fi.intel.com> References: <20180424154355.mfjgkf47kdp2by4e@black.fi.intel.com> <20180504211244.GD29829@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180504211244.GD29829@bombadil.infradead.org> User-Agent: NeoMutt/20170714-126-deb55f (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 04, 2018 at 09:12:44PM +0000, Matthew Wilcox wrote: > On Tue, Apr 24, 2018 at 06:43:56PM +0300, Kirill A. Shutemov wrote: > > +struct pt_ptr { > > + unsigned long *ptr; > > + int lvl; > > +}; > > On x86, you've got three kinds of paging scheme, referred to in the manual > as 32-bit, PAE and 4-level. You forgot 5-level :) (although it's not in the manual yet, so fair enough) > On 32-bit, you've got 3 levels (Directory, Table and Entry), and you can > encode those three levels in the bottom two bits of the pointer. With > PAE and 4L, pointers are 64-bit aligned, so you can encode up to eight > levels in the bottom three bits of the pointer. I didn't thought about this. Thank you. > > +struct pt_val { > > + unsigned long val; > > + int lvl; > > +}; > > I don't think it's possible to shrink this down to a single ulong. > _Maybe_ it is if you can squirm a single bit free from the !pte_present > case. I don't think it worth it. It gets tricky quickly. > ... this is only for x86 4L and maybe 32 paging, right? It'd need to > use unsigned long val[2] for PAE. I didn't look at 32-bit at all. But 4L and 5L [kinda] work. > I'm going to think about this some more. There's a lot of potential here. Thanks for the input. -- Kirill A. Shutemov