Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3635875pxv; Mon, 19 Jul 2021 05:16:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdL8wWn4+94OB/xM1sra+Vk3H2p9THhTvK6BZ3A6oRlMYzJD8wuqG5uUvmoOzrM72JMDsh X-Received: by 2002:a92:1942:: with SMTP id e2mr17603204ilm.4.1626697006871; Mon, 19 Jul 2021 05:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626697006; cv=none; d=google.com; s=arc-20160816; b=Kjhc5NrZi+KxcOGQ/6zoSCcvJc4oZ7Jg2ArC+eBX3WggbP6icv9FEHhwuBReJiiOjs 2WiL8DJd8yz4yVERlrNjGuh/23FHrZ41CSghk/xdvJhSCJM37YunbljFR2xpy76o5J6j T5H0Ag/bkN4qp0cWgpvr7WkIZ/ZZkFxrliUZQ8GS+eQjzyec1LbKd469l+JMGSLps8vN Cm+6Y5EO5/sRRokQD8Ssok5baKh7/fDfdxk/27wk7n+71fKxe1+sXWQ07BNB2DNtUUS6 BzUp4ekSWA7e75GTlL8PlOJRGdJyAScyfZebjuO4GuUAJmtGdLnSw6QX3M888R9kAe34 w0FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=9tHoP14b+KUhsGcANn1nmPA2q8tFaxMmmFLPZFytRWs=; b=cuGeGgXjoG4SQVzzHQKA+qOEhTDLBYA+y7OFhX5jriklkpqW8cdvKanyUAYPtZ9omW gDHE3AkbRA8GgO3MRjmMwfWA1F9LLAVzvixbpcLEPa047goyID4MzQBm8hsBlBSqGEVt mjETE+nzeQY5tIV+mv79rwrOzeTMeRzMEPFNRsfWAfQLkkIuQ9Wl1ivlF1Aubo2GjtTw iORi+KRA21VYkGHMPm5CUDU6ncLt6k0PoLpSxpRX7xexiinONZqYB41+LSc5Y5a4Uajt DX3pXcyT7DR799m35G4Uu2yZS/OfD03G0eK2OowI/ALXjWtEupGj3grwsTsbz800lc6Z ZNtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si11872715ilu.88.2021.07.19.05.16.34; Mon, 19 Jul 2021 05:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236780AbhGSLeL (ORCPT + 99 others); Mon, 19 Jul 2021 07:34:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:35898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236491AbhGSLeL (ORCPT ); Mon, 19 Jul 2021 07:34:11 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2AE0E60200; Mon, 19 Jul 2021 12:14:51 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1m5SAb-00EChJ-A3; Mon, 19 Jul 2021 13:14:49 +0100 Date: Mon, 19 Jul 2021 13:14:48 +0100 Message-ID: <87lf62jy9z.wl-maz@kernel.org> From: Marc Zyngier To: Quentin Perret Cc: james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, Yanan Wang Subject: Re: [PATCH 03/14] KVM: arm64: Continue stage-2 map when re-creating mappings In-Reply-To: <20210719104735.3681732-4-qperret@google.com> References: <20210719104735.3681732-1-qperret@google.com> <20210719104735.3681732-4-qperret@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: qperret@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, wangyanan55@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 19 Jul 2021 11:47:24 +0100, Quentin Perret wrote: > > The stage-2 map walkers currently return -EAGAIN when re-creating > identical mappings or only changing access permissions. This allows to > optimize mapping pages for concurrent (v)CPUs faulting on the same > page. > > While this works as expected when touching one page-table leaf at a > time, this can lead to difficult situations when mapping larger ranges. > Indeed, a large map operation can fail in the middle if an existing > mapping is found in the range, even if it has compatible attributes, > hence leaving only half of the range mapped. I'm curious of when this can happen. We normally map a single leaf at a time, and we don't have a way to map multiple leaves at once: we either use the VMA base size or try to upgrade it to a THP, but the result is always a single leaf entry. What changed? > To avoid having to deal with such failures in the caller, don't > interrupt the map operation when hitting existing PTEs, but make sure to > still return -EAGAIN so that user_mem_abort() can mark the page dirty > when needed. I don't follow you here: if you return -EAGAIN for a writable mapping, we don't account for the page to be dirty on the assumption that nothing has been mapped. But if there is a way to map more than a single entry and to get -EAGAIN at the same time, then we're bound to lose data on page eviction. Can you shed some light on this? Thanks, M. -- Without deviation from the norm, progress is not possible.