Received: by 10.192.165.148 with SMTP id m20csp516538imm; Fri, 4 May 2018 14:14:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoPbK+0A3Tqfg0Wr+BZZJcteQwmadOKqANBCKrE+zg3iw6eUXjHGBXFA1NOGKr/ieNrm7wd X-Received: by 2002:a63:4245:: with SMTP id p66-v6mr23881281pga.345.1525468489325; Fri, 04 May 2018 14:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525468489; cv=none; d=google.com; s=arc-20160816; b=scddP9ojoHwNDhlYGAms/9QTFPDh0lVZ2ZyEf+gS1i3g4hGJrhiJopCf/+m43Hc4fY xnhui0jRX76CRcER6zprK2edvdzvJY2r2KKgfT3mgtcYp7GPAQilcxCcKm4JIDU+sZex Sh4Or2iTLmATDQiqy41pfHDfGP6hhNL3ipfPFJnaqEYgX2Z06GYBdAVCUln3CmAqAsZv lSuV+MPs0yUM2OYiD6yoX2rKDXaHXWEGTx8MtJI7L8jv1YX5bRIYyJGks9sunvCP8J+X CjrlqMx74lq5DxGLbqA6me3JW42dMHZgSmpm/iSNCZuzk8abx8I+TAF01wN9vjnfNhR/ ISOQ== 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:dkim-signature:arc-authentication-results; bh=oc8Sv8VzwhlVZFA2fHbisAvlCPMGK4dtEZIZUMu81mg=; b=joohzKChZ4sO3XB44/3ZyTzskQXH15qguKztbXNGggSG1edEYM/bsy4H4trUANer56 qCP13/g75pkkN3y04SRF+Nn/8nvkyZ0JKAfeTtgjjmKQPMKJVHOGbDddMaaMaXSQXMbc QMnXx02Q97VVpHje88LC6xx03ZfnN3saqSe4efVGUeT5qiaNie1ShvkIOVeQCAhuRRdX 0iSbpaqLU6bhJaqWZ03Wy0wlt0aFuCrpbJSeYZ7kMrlFbcxmuXt/FnqgGtJp8GHcHsPy PNEOmrhwena0xXBV14dgUlRou/YvLM1VhN/79y8zGcxSajGpe9kALcSbWhcbYirhRWTM v+KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=tMvpuL0B; 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 t3-v6si13624032pgp.375.2018.05.04.14.14.35; Fri, 04 May 2018 14:14:49 -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; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=tMvpuL0B; 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 S1751820AbeEDVMs (ORCPT + 99 others); Fri, 4 May 2018 17:12:48 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:55670 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751760AbeEDVMr (ORCPT ); Fri, 4 May 2018 17:12:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5s19zatppA0HKHI2UlwmkCDRszjTEsn9D2DoC04hPKs=; b=tMvpuL0BJqDQzBoAJBtXbzzfT MXa3egwOwGkDA+PJI6Rm7xHXplSbaflLMkM5n6AqIUOPfxiV93T/hyrV7/t+Mba9Rsydqt5s2FzNj cxxUlRxCNOyzNzK5af+qF0uZd4PO3+1mSK2gWMzWVBkMCTVuYESwQK7NofG6N3yx2ElApVh2CMOmR f+MfwmvoNjpMYeCmUAem2gNmKv9hTXUSr6fae8wMLFZu8c9XY1uoLKoETst/B9NLlN4Ypl64nKJR+ RAJRgL20aImTwRQKofe0ExeTCR0cTynAZcX9cXanvLnkzQozg4zp9Xmn7XxqC7r+y86I5PG+viuXY MT7LdTTKQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEi0S-0003ty-An; Fri, 04 May 2018 21:12:44 +0000 Date: Fri, 4 May 2018 14:12:44 -0700 From: Matthew Wilcox To: "Kirill A. Shutemov" 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: <20180504211244.GD29829@bombadil.infradead.org> References: <20180424154355.mfjgkf47kdp2by4e@black.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180424154355.mfjgkf47kdp2by4e@black.fi.intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. > +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. ... this is only for x86 4L and maybe 32 paging, right? It'd need to use unsigned long val[2] for PAE. I'm going to think about this some more. There's a lot of potential here.