Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp771077ybh; Wed, 11 Mar 2020 10:27:10 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtAqTuGvZzPrWcZks6MatLmen4+u2b6bStlf3VmwG+a4vNLp5PyvcQLATmO8AQKJKjibFsF X-Received: by 2002:a05:6830:1d7:: with SMTP id r23mr1703233ota.153.1583947630543; Wed, 11 Mar 2020 10:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947630; cv=none; d=google.com; s=arc-20160816; b=GMvzxv2j6tulsmxiyOfxneTmpRq5KhEWUsJYfCpUDUxWLmrQDLLAkWS2mv4YTfTibz tvQ96A1+tPN/GDL3i4ClPnYWkZs/GPfnKvoh1zMkw/WOC0fkZSNrNDDN2cTVmhfVh5Vf 1Ks/dkxLkV0KBEWjfmvEoent4W4ASQTM6EJoudj0dJQES8+NX03K7Jmo+AM9+db6wCcC jB0Nkc76Ww/KNgBDjttsPeuMqIIBGmwsw6QBF9jj91wgyuk7/1G2WR+wNsNm1azrJ4Rj dLpMmQHwOVFSHsWEY0ot0DsmGPyXYraDXfAkkqQYDQW80RVhLkMUsKv6It6AFRymuTiu 3XOA== 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=RzfMHHMjkbP1oXq0rLMU/jPhp/hZ6Ul6msKfx9WpSyM=; b=RcUXMEjY7VxyMIE79FFhAi1w9G8pl8HtkOz8tHV4wqDN+oS9gI9u138SJVTJ2BlM4J UgR5/bUgoPMt9/WUnEH0F8rDw0mjCpMdLS/rsKyKTslZY/KEknkc+YDX2Oh9edRPO8E5 6ufKl2xE98+nR9W6XOe5JCgAa6e5zzR3oUi9WWjXADSnW8klOpc4N163s4NW/Cm12hHx 4/gDtKreafpexr9RKkq0OwsBkM1BzwOCwc445HOblDnFqwLejrkAGeIs//p21aOjdj9j 8PNXgmpNi80xh2y/owYypINMPx8b/dw4NgW6C2R7kXz1m1k8r9gKXOHc3ui5CgmWGa1Y lD4g== 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 d8si403718oom.65.2020.03.11.10.26.58; Wed, 11 Mar 2020 10:27:10 -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 S1730494AbgCKR0h (ORCPT + 99 others); Wed, 11 Mar 2020 13:26:37 -0400 Received: from foss.arm.com ([217.140.110.172]:52486 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730193AbgCKR0h (ORCPT ); Wed, 11 Mar 2020 13:26:37 -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 7FC8C1FB; Wed, 11 Mar 2020 10:26:36 -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 0166D3F6CF; Wed, 11 Mar 2020 10:26:33 -0700 (PDT) Date: Wed, 11 Mar 2020 17:26:31 +0000 From: Catalin Marinas To: Arnd Bergmann Cc: Russell King - ARM Linux admin , Nishanth Menon , Santosh Shilimkar , Tero Kristo , Linux ARM , Michal Hocko , Rik van Riel , Santosh Shilimkar , Dave Chinner , Linux Kernel Mailing List , Linux-MM , Yafang Shao , Al Viro , Johannes Weiner , linux-fsdevel , kernel-team@fb.com, Kishon Vijay Abraham I , Linus Torvalds , Andrew Morton , Roman Gushchin Subject: Re: [PATCH] vfs: keep inodes with page cache off the inode shrinker LRU Message-ID: <20200311172631.GN3216816@arrakis.emea.arm.com> References: <671b05bc-7237-7422-3ece-f1a4a3652c92@oracle.com> <7c4c1459-60d5-24c8-6eb9-da299ead99ea@oracle.com> <20200306203439.peytghdqragjfhdx@kahuna> <20200309155945.GA4124965@arrakis.emea.arm.com> <20200309160919.GM25745@shell.armlinux.org.uk> <20200311142905.GI3216816@arrakis.emea.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 Wed, Mar 11, 2020 at 05:59:53PM +0100, Arnd Bergmann wrote: > On Wed, Mar 11, 2020 at 3:29 PM Catalin Marinas wrote: > > > > - Flip TTBR0 on kernel entry/exit, and again during user access. > > > > > > This is probably more work to implement than your idea, but > > > I would hope this has a lower overhead on most microarchitectures > > > as it doesn't require pinning the pages. Depending on the > > > microarchitecture, I'd hope the overhead would be comparable > > > to that of ARM64_SW_TTBR0_PAN. > > > > This still doesn't solve the copy_{from,to}_user() case where both > > address spaces need to be available during copy. So you either pin the > > user pages in memory and access them via the kernel mapping or you > > temporarily map (kmap?) the destination/source kernel address. The > > overhead I'd expect to be significantly greater than ARM64_SW_TTBR0_PAN > > for the uaccess routines. For user entry/exit, your suggestion is > > probably comparable with SW PAN. > > Good point, that is indeed a larger overhead. The simplest implementation > I had in mind would use the code from arch/arm/lib/copy_from_user.S and > flip ttbr0 between each ldm and stm (up to 32 bytes), but I have no idea > of the cost of storing to ttbr0, so this might be even more expensive. Do you > have an estimate of how long writing to TTBR0_64 takes on Cortex-A7 > and A15, respectively? I don't have numbers but it's usually not cheap since you need an ISB to synchronise the context after TTBR0 update (basically flushing the pipeline). > Another way might be to use a use a temporary buffer that is already > mapped, and add a memcpy() through L1-cache to reduce the number > of ttbr0 changes. The buffer would probably have to be on the stack, > which limits the size, but for large copies get_user_pages()+memcpy() > may end up being faster anyway. IIRC, the x86 attempt from Ingo some years ago was using get_user_pages() for uaccess. Depending on the size of the buffer, this may be faster than copying twice. -- Catalin