Received: by 10.223.185.116 with SMTP id b49csp3551138wrg; Tue, 6 Mar 2018 00:37:17 -0800 (PST) X-Google-Smtp-Source: AG47ELuPyJdg1JKrL5xW37nPEE1yBT/dmG1qgg6Zvyylc+BWl4dE0m0xlwkNGId06mYtcrkjB6Zf X-Received: by 2002:a17:902:720b:: with SMTP id ba11-v6mr16286924plb.148.1520325436936; Tue, 06 Mar 2018 00:37:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520325436; cv=none; d=google.com; s=arc-20160816; b=euc1tbR79WJAefxOHsf/Xfp631yxLVtThLVPKPWYOLaZd/hw/EpOrxgWE7Ik0Xf/VS AUnxJw2ht2T6lA9niONOsDj3E5RuMILDbKW+sp6eU67UA76SzWw2ym8nZEIKudTCw0wk sVeNqQk48hhT8z8kRhDkxUisD5DfFJBikE1Er/mZsX9CpqdjVCsORfKATyxpFxlkP3dU w/Xu1bP4fbstqwomRhkzJ/+GN5We9nhOX0/GsvVZJj2yZ7uyEWVZBdjF+/d4Buw4NTKz XGwuBRzA+zPiFFP4eFBk2FB6qbKnFwrF/VVlF5NrybfH1G0VbwGoS2yi+XQXBLER9x1r AW7g== 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=HSCYx6VLIbA8deIZQUVWQnaFevM+FBzOpbXvLe2am3M=; b=zqQPX/YjZrV99++UtmwnDdfRXK9pcgkz4/9GTh8JmKxdl4g/8BKui4pfabXX/CBuzj JQ6Aic3somvsJLdiUx9wno06qDL8thAv8RJuUrHsH9ZYQvscJn355cDmVmpYdvMi1+Dm ZZJtL/VJS1G6OylPETzojm++tCR35CBz9YH9f7B1SmDCeroYNH5XgYlNdSsGaQfxd6W+ deVjzdFU48/5TAARCIDEtH5RZJ+pXq3UcuBw20YEapnipCWmGUDp8EfSzFuUQVl0261P tKAVigJdY1YdxJgi59T7orTcY3C1d8QCVnahNd4dBYj/JQ8hhp+iA/gw1aSfaVcNPKjx f5uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=zFGbUn0M; 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 i124si9493182pgc.589.2018.03.06.00.37.02; Tue, 06 Mar 2018 00:37:16 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=zFGbUn0M; 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 S1753285AbeCFIen (ORCPT + 99 others); Tue, 6 Mar 2018 03:34:43 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:35000 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750792AbeCFIem (ORCPT ); Tue, 6 Mar 2018 03:34:42 -0500 Received: by mail-wm0-f53.google.com with SMTP id x7so20481033wmc.0 for ; Tue, 06 Mar 2018 00:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=HSCYx6VLIbA8deIZQUVWQnaFevM+FBzOpbXvLe2am3M=; b=zFGbUn0ML/Je+3igG92epHnIrJV8bQmJFOD7oZdmFKZmaRRq/o9VDMaP/Y5Xy7t96B J/PQ99ITpehU+1hDUUj/fRbWX1Adl21V10osp7QHSvXiWsRSBGAY3jdFejyB1PEB8SVz hRom+SoNpTVaMdfhhpHYim3GNpRpFwpiovDE08kIJC8CywPiMt3n+eszMuwWvn4lzI5B nG1VDGs5Lf42KM9ho6x5qQ37QlbkShVBZQA1KDAHFIGkIW8JXk5OC+6NFhIK6SNE6LVT 2EJmzoBdQOZMOLLmIRSYrutC9TpduYiEGwwvh9T1ky3BhpxjoEaZqDM/RsScLJULfe1t 33yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HSCYx6VLIbA8deIZQUVWQnaFevM+FBzOpbXvLe2am3M=; b=oi0Fqhg5r0bcoSixYyWYpwuM/bWY1o1qX98mhMmEA+h3ZrnBluwcTQmg6QQo5DOzrn 82uso83zp/02NPHBMX0BRaXyUfEbQOxWKqmUr4dHP19J0hkVgkn/MZJ7vhAPJUNVrmHQ ygo4Kxn7j/Wrz4G1fMQ/69pdUCkRSt/TgvmVkQBhHXDdGOH+9poGImLGg2/xwq6eSpdn Lv9klHAUXso8DTVaN98Yu5XYA7z5J2yspcBLACp3APzope7035Zqdy3A0Fb5ECNxRwbr TTpTdw3sMGPMGvjAEs1/eqIpSC0AtkTk0htMkeVFZEvJYBfzKt/zLGfEk1dhmyEgfKfs C6CA== X-Gm-Message-State: APf1xPCHu1QOLcKPW/f8HgYwUv6KyQ5oN9ql0aPMw8uBYHa+pLL2Xv7C hpZ/X4sfAzAcHZRR7J661FsDFg== X-Received: by 10.80.163.7 with SMTP id 7mr22147950edn.258.1520325281001; Tue, 06 Mar 2018 00:34:41 -0800 (PST) Received: from node.shutemov.name ([86.57.210.234]) by smtp.gmail.com with ESMTPSA id y14sm4977854ede.18.2018.03.06.00.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 00:34:40 -0800 (PST) Received: by node.shutemov.name (Postfix, from userid 1000) id D072E648D520; Tue, 6 Mar 2018 11:34:25 +0300 (+03) Date: Tue, 6 Mar 2018 11:34:25 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: "Kirill A. Shutemov" , Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky , Kai Huang , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC, PATCH 18/22] x86/mm: Handle allocation of encrypted pages Message-ID: <20180306083425.gwt7j5cxtd6vrd3r@node.shutemov.name> References: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> <20180305162610.37510-19-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180223 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 05, 2018 at 11:03:55AM -0800, Dave Hansen wrote: > On 03/05/2018 08:26 AM, Kirill A. Shutemov wrote: > > -#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ > > - alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr) > > #define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE > > +#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ > > +({ \ > > + struct page *page; \ > > + gfp_t gfp = movableflags | GFP_HIGHUSER; \ > > + if (vma_is_encrypted(vma)) \ > > + page = __alloc_zeroed_encrypted_user_highpage(gfp, vma, vaddr); \ > > + else \ > > + page = alloc_page_vma(gfp | __GFP_ZERO, vma, vaddr); \ > > + page; \ > > +}) > > This is pretty darn ugly and also adds a big old branch into the hottest > path in the page allocator. > > It's also really odd that you strip __GFP_ZERO and then go ahead and > zero the encrypted page unconditionally. It really makes me wonder if > this is the right spot to be doing this. > > Can we not, for instance do it inside alloc_page_vma()? Yes we can. It would require substantial change into page allocation path for CONFIG_NUMA=n as we don't path down vma at the moment. And without vma we don't have a way to know which KeyID to use. I will explore how it would fit together. -- Kirill A. Shutemov