Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp889084ybh; Thu, 12 Mar 2020 13:00:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vssJXfzEg2z2Q9PGBOmQ1gji2R1G+Ljm8a6Qnx+hAITxOtnncfJ+C83OAvySRBeDKF0Lodv X-Received: by 2002:a9d:74cf:: with SMTP id a15mr3341893otl.258.1584043227088; Thu, 12 Mar 2020 13:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584043227; cv=none; d=google.com; s=arc-20160816; b=fHoN7dXlx89ijwLc8hXdwb+sduEAspp1C0+FPvZgGcdg3Ndw+eO6sSUilFNP1dKzZu peDv1hvh/JNq2Tva7EJui0SNBypRUxNg3oGutcQF5DaztfnKkjesEInWfA/ocboTc9jA 3J83gL4s5hbhTXyBl52DVMLZmOV5/gXiUxxjlzGVQzm/CDCWJIJcL/UYz05DKBymPhAB aTmD3UWWSp4S7vxFkSx/YHdu3I7Mrim0HlVo5sHSdOGUh1PB17YIeBMTzPn0705ZQ+S6 CSbeD+YphBVqmkMUJtQr20pPG6fc+2iiZWVFF/XzwcIi485yjvCTbz6bnb3YzMtm6d+3 Xp0w== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Ob+DDAJoCv1eNbpOzJsx/saHpEetRfJlb0KnNJ3G6Og=; b=omBt+V9p9kEVzqk0natBzCOYoff2gWFhTaxrsSPqJ9LvNcirGVnVuJR/XJyuaQ7MjU GRalNFYenaj9wLBMZdp8brhsvU7YkRevLDkWT7nQ2OURgP8+0dLfmDInC3debVPoZdMX +vp7O2q4d8jvDKY8qikmK105wxuH7q+c/oifYv6koZogxON06jRrR2A2QABKY19Sd+jB 1KTJMdtR1xUPoE04A0o8OxN7lPPVqSnIMecg0TgHr6H5EHEwI3WWZ9ipw3QV9py+GbOk fuIRFmGU0uqSQgT5xsZgn+diJMX8p+2IVMtCbBsSMyR4eo3j5jy69n6tXKzXLK6dNSJS e48g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=X1qtGcuv; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u67si1272960oie.259.2020.03.12.13.00.13; Thu, 12 Mar 2020 13:00:27 -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=pass header.i=@google.com header.s=20161025 header.b=X1qtGcuv; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726802AbgCLT7m (ORCPT + 99 others); Thu, 12 Mar 2020 15:59:42 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35424 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbgCLT7m (ORCPT ); Thu, 12 Mar 2020 15:59:42 -0400 Received: by mail-wm1-f67.google.com with SMTP id m3so7795036wmi.0 for ; Thu, 12 Mar 2020 12:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Ob+DDAJoCv1eNbpOzJsx/saHpEetRfJlb0KnNJ3G6Og=; b=X1qtGcuvtvqFLuJpd+LP+okeBAHhenV4fi3+E47XtLVTi50WomOHJaVXJwKPrIFDNz 2cgvozUVrPAkfJ7GJYn2XZchKUpD4GXfk7rc2yCfXHtFbfM5ntfsjQjfwWnt6GkiWKPX DN6er1P1AU3isxcGno53R5S2vZ8pQgAQSPrk8emtJchUerRbWdHHszfgp6DeV03f++2Y eTMbqy3iqlNvvYRKL5hu+qAhApLzaCbPp8q8xLrSjYIJc3Puu8749dkNxIFhnI/TO1w+ Px5ldX2pwZszdBWGLq1okMV/XR7fCGe6oaoq0UvtFaYL8U3JVT+YA3vLxWWVzCs9x3+l oU6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Ob+DDAJoCv1eNbpOzJsx/saHpEetRfJlb0KnNJ3G6Og=; b=iU64dwnw9wjIgmHoa+Cz/qJs+PA58BLY2Gx7ajb+lTtAuYsr/MFFngVSytBEAHYkwi vSj7Bq/1Li55Pf+Z3H0DDypL203M0W4r54sBkbQjqvw4xz2b8FHgDPI7bTE/8o6knPx3 AZ2dCF8Z69qlIsHjrCVIm/QY+q0Zx7y6UNSygNxI2iQ3lF3WhtPVNvEGVlQ7sMwrM2Hd ok9iv3FmQUrgRAzfVf746u74DZBDKpinZAr94Y89a64J1GeRfeH1C5oT8AYt4BQzt8ff 8FVfia/CWHob//BdECQydACMu8IOsZbOfBd23iHlgDT7UiWjZyXnRZUyn/5M0kp/dRkV ESEQ== X-Gm-Message-State: ANhLgQ0YGjNpxrWRO3wd6GIRWZ659LWrAb1muwYFa+hHKGCpl/djdK8s DYDfMZcqf6RcdXaSqpx6EQVEV3+xMb0VaA3LwXWkEQ== X-Received: by 2002:a7b:cc98:: with SMTP id p24mr6032809wma.29.1584043180023; Thu, 12 Mar 2020 12:59:40 -0700 (PDT) MIME-Version: 1.0 References: <20200312155920.50067-1-glider@google.com> <20200312164922.GC21120@lakrids.cambridge.arm.com> In-Reply-To: <20200312164922.GC21120@lakrids.cambridge.arm.com> From: Alexander Potapenko Date: Thu, 12 Mar 2020 20:59:28 +0100 Message-ID: Subject: Re: [PATCH] arm64: define __alloc_zeroed_user_highpage To: Mark Rutland Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, LKML , Kees Cook , Andrew Morton Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 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=3D1, calling the default > > implementation of __alloc_zeroed_user_highpage() from include/linux/hig= hmem.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=3D1. > 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. > Thanks, > Mark. > > > > > Signed-off-by: Alexander Potapenko > > --- > > arch/arm64/include/asm/page.h | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/arch/arm64/include/asm/page.h b/arch/arm64/include/asm/pag= e.h > > index d39ddb258a049..75d6cd23a6790 100644 > > --- a/arch/arm64/include/asm/page.h > > +++ b/arch/arm64/include/asm/page.h > > @@ -21,6 +21,10 @@ extern void __cpu_copy_user_page(void *to, const voi= d *from, > > extern void copy_page(void *to, const void *from); > > extern void clear_page(void *to); > > > > +#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \ > > + alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vad= dr) > > +#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE > > + > > #define clear_user_page(addr,vaddr,pg) __cpu_clear_user_page(addr, va= ddr) > > #define copy_user_page(to,from,vaddr,pg) __cpu_copy_user_page(to, from= , vaddr) > > > > -- > > 2.25.1.481.gfbce0eb801-goog > > --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg