From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751745AbeAZRlv (ORCPT ); Fri, 26 Jan 2018 12:41:51 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51514 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751349AbeAZRlu (ORCPT ); Fri, 26 Jan 2018 12:41:50 -0500 Date: Fri, 26 Jan 2018 17:41:45 +0000 From: Catalin Marinas To: Marek Szyprowski Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Bartlomiej Zolnierkiewicz , Will Deacon , Inki Dae , Russell King Subject: Re: [RFC 2/2] arm64: compat: cacheflush syscall: process only pages that are in the memory Message-ID: <20180126174145.6gtfjjoxb57d7qwt@armageddon.cambridge.arm.com> References: <20180126111441.29353-1-m.szyprowski@samsung.com> <20180126111441.29353-2-m.szyprowski@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180126111441.29353-2-m.szyprowski@samsung.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 26, 2018 at 12:14:41PM +0100, Marek Szyprowski wrote: > @@ -32,23 +33,36 @@ > static long > __do_compat_cache_op(unsigned long start, unsigned long end) [...] > + if (follow_page(vma, start, 0)) { > + ret = __flush_cache_user_range(start, start + chunk); > + if (ret) > + goto done; > + } This looks pretty expensive for pages already in memory. Could we do some tricks with the AT instruction in __flush_cache_user_range() so that we skip the flushing if the page isn't there? We know that when a page is mapped, the cache will get cleaned/invalidated via set_pte_at() + sync_icache_dcache(), so the only problem of a race is flushing the caches twice for a page. If a page gets unmapped after AT, we may bring it back through the cache ops. -- Catalin