Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1827973ybh; Fri, 13 Mar 2020 08:07:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vug6fuTDkV62N+Y3A4ClFTt1mivaXl0NojHL1X0kfO0sMmnxJt1H6XK2rLz2pjyaZ3sbvo3 X-Received: by 2002:a05:6808:5c4:: with SMTP id d4mr7406312oij.176.1584112044422; Fri, 13 Mar 2020 08:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584112044; cv=none; d=google.com; s=arc-20160816; b=xQAR5gdJYT3F3Py0qhleOAjwXNmD60zk2Kk7ykO306vnQI9Z6mWbnYDP0uAMmNTMHk jmdGazzweCxjZ1gcTz7Qe/VBopKqNjXCTGqVS74235FiP8ILTbIuyj0l74SYLOTlRTXk sHzN2zE6ieh+3tAprGpzMgYBjQXWKgAv20MY3qq8f/KCte6dbrufyd92M2o+c3z+az7T iIz0RsvTrMHcfQj+0LVW4ONELY21iAg22qC1JFIggrnIq34MCkDPNSpivAKGClQ7J7FS lTG4jBYs8pEq7klH4aVj8P5oGLqujQ9M76r3jHmjQk7YoJmpBUwSpSCCTQ+gn7uHbYlh BnhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zaWbB96gYfDx/0l+8L2IevvWuoFV2YRpdZacVc+cN3g=; b=bE/voTDkfbI1InyJp+mci6Q9urHSteKoX9WYZ3GGe4T8SwHe7aaqwxc/YaObaiNM5O aoM65S2JnxyxBx6VSpFNJNkNrhoV5ldzybIG7jhGJad9dqD11DzenF6BqhBLRsV7ghWq 7EdK159NNOEMn/4yqvHzzg3jSUSfg1liPJH+gUUwUIJh3/uG0o+9u3iTQKaa65iXPPyX rhRWAQWBk8p5rTsmgE1tiayWFc3nzzmxcGjmfzuuNdMOI4qovpVLzo0VF+v5qdqeU2we JpodC+zvLCfeXvxiyIJHUlP/eLURUb1Hg66hIndrt+daVhNCN4WWvk0Y/y1Nitvd+EF4 3msg== 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 q16si4796253otc.293.2020.03.13.08.07.04; Fri, 13 Mar 2020 08:07:24 -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 S1726810AbgCMPDI (ORCPT + 99 others); Fri, 13 Mar 2020 11:03:08 -0400 Received: from foss.arm.com ([217.140.110.172]:56758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbgCMPDE (ORCPT ); Fri, 13 Mar 2020 11:03:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7DC3331B; Fri, 13 Mar 2020 08:03:03 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A1893F67D; Fri, 13 Mar 2020 08:03:02 -0700 (PDT) Date: Fri, 13 Mar 2020 15:03:00 +0000 From: Catalin Marinas To: Alexander Potapenko Cc: Mark Rutland , Will Deacon , linux-arm-kernel@lists.infradead.org, LKML , Kees Cook , Andrew Morton Subject: Re: [PATCH] arm64: define __alloc_zeroed_user_highpage Message-ID: <20200313150300.GD3857972@arrakis.emea.arm.com> References: <20200312155920.50067-1-glider@google.com> <20200312164922.GC21120@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 12, 2020 at 08:59:28PM +0100, Alexander Potapenko wrote: > On Thu, Mar 12, 2020 at 5:49 PM Mark Rutland wrote: > > > > On Thu, Mar 12, 2020 at 04:59:20PM +0100, glider@google.com wrote: > > > When running the kernel with init_on_alloc=1, calling the default > > > implementation of __alloc_zeroed_user_highpage() from include/linux/highmem.h > > > leads to double-initialization of the allocated page (first by the page > > > allocator, then by clear_user_page(). > > > Calling alloc_page_vma() with __GFP_ZERO, similarly to e.g. x86, seems > > > to be enough to ensure the user page is zeroed only once. > > > > Just to check, is there a functional ussue beyond the redundant zeroing, > > or is this jsut a performance issue? > > This is just a performance issue that only manifests when running the > kernel with init_on_alloc=1. > > > On architectures with real highmem, does GFP_HIGHUSER prevent the > > allocator from zeroing the page in this case, or is the architecture > > prevented from allocating from highmem? > > I was hoping one of ARM maintainers can answer this question. My > understanding was that __GFP_ZERO should be sufficient, but there's > probably something I'm missing. On architectures with aliasing D-cache (whether it's VIVT or aliasing VIPT), clear_user_highpage() ensures that the correct alias, as seen by the user, is cleared (see the arm32 v6_clear_user_highpage_aliasing() as an example). The clear_highpage() call as done by page_alloc.c does not have the user address information, so it can only clear the kernel alias. On arm64 we don't have such issue, so we can optimise this case as per your patch. We may change this function later with MTE if we allow tags other than 0 on the first allocation of anonymous pages. -- Catalin