Received: by 10.223.185.116 with SMTP id b49csp2938108wrg; Mon, 5 Mar 2018 11:05:06 -0800 (PST) X-Google-Smtp-Source: AG47ELtNxKt3GCE1oXBpuL2d32b6jSA9qQnPIpXLpoK8vg17LYp5kUCi+qhnwqRdb/V1X9l0HdSw X-Received: by 10.98.178.17 with SMTP id x17mr16528315pfe.2.1520276706657; Mon, 05 Mar 2018 11:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520276706; cv=none; d=google.com; s=arc-20160816; b=chYzatb7UksPRiUCCNKJrsD1YKQUZ7sCMg4owgejyPSO9gLPEg7uCSZYcLsPrETCzX /CICppu7MWZT4TAv0s3tBF8K8ASu8KWfyVzTR253v16eHPJlXQ3wnZTXo8zEh2kuRceP g5ngs5xEYIzgxHw0X2NA1+ILxgFDkyvhRa5xVaYvBsHCuw42KaaJJOqtOmvh0xqVqvoP t6Wi2x1Sn+lklNl+GPlPMdpa0TG3pQ5Zwn9XJ6DPwrEYnSzno7uVbHKyqi/SLpHKPtq3 s5SLSSR0fTjZ0OLQ7+hKWQ7vGnryZZ62ebsihgbVXcYnv7vNlbJpQtpIvsjutJWKqF2a YsHQ== 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:cc:references:to:subject:arc-authentication-results; bh=BN+Y0nzhdEnlWe8WW/OY8tDk5qZE93j5kFlBtba0G0g=; b=HXLqHWak1F6EIJMtpp9pIRosmyFzmVuv7RMc+Croyqj6fQN4nxKRGQgCbKKMxqbgF7 3os+6SF7v6G35U8MUkFi0UlJmOoxuF3sLmNpsv+S6DSFXpnpnGUQ4lKXnfq8d0cMW0uY gNXrJCnnQhBw1AWz83hEzVuNwfmJ30gw4ccEkqVqOSfY9LJebQoiyxcFXksCGncBh+o4 2JC/ebQTeke7m8L6Mk/A+7pQGjIQYmaGvOcYIzLFtyIGR4UcbQ+XmwIoqC+7F9fXJec6 C6U2HrSK9oVV0iyGLF0bAlZfPFwDBlOGXCKwfM0fCqi4zxIv780FPa499lXc9tDBlO07 FByQ== 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 u190si8690253pgc.532.2018.03.05.11.04.51; Mon, 05 Mar 2018 11:05:06 -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 S1752440AbeCETD6 (ORCPT + 99 others); Mon, 5 Mar 2018 14:03:58 -0500 Received: from mga14.intel.com ([192.55.52.115]:16961 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751838AbeCETD4 (ORCPT ); Mon, 5 Mar 2018 14:03:56 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2018 11:03:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,428,1515484800"; d="scan'208";a="32574101" Received: from ray.jf.intel.com (HELO [10.7.201.16]) ([10.7.201.16]) by orsmga003.jf.intel.com with ESMTP; 05 Mar 2018 11:03:56 -0800 Subject: Re: [RFC, PATCH 18/22] x86/mm: Handle allocation of encrypted pages To: "Kirill A. Shutemov" , Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky References: <20180305162610.37510-1-kirill.shutemov@linux.intel.com> <20180305162610.37510-19-kirill.shutemov@linux.intel.com> Cc: Kai Huang , linux-kernel@vger.kernel.org, linux-mm@kvack.org From: Dave Hansen Message-ID: Date: Mon, 5 Mar 2018 11:03:55 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180305162610.37510-19-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()?