Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3488648pxj; Tue, 1 Jun 2021 06:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1PdPpe2e62vAKD0NMNoIyQFiYKyH8KUROFrb9PfPp2jeR4spG+n1Wkmff8o6XJADTOGko X-Received: by 2002:a05:6e02:cc5:: with SMTP id c5mr3688007ilj.152.1622554341905; Tue, 01 Jun 2021 06:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622554341; cv=none; d=google.com; s=arc-20160816; b=RKaahlc9bUkPWtDrBE8RLMvMSxW0exhsqO6F995BoktvFFNsMU2rw7/KnupRiO0QoH rEdE5QlJjAiX5JgTtekxT+YKNU+1thtFQ92JkJKIyBxKnenOBdYHrr/nq0P2iwzGyAME A1YXVV8C0nHR65rK5aKwaUn7A8B7KZnCVt0Tavbczc9Unn2UkUdpiyqv0Aht4igRie+P /2Xc14rQGZGwSRKJK0X7UQVIoTOlBBjb1p/4w1Y+jC7dgeZe0eaaHFKPjRqphCP8tQTQ rcd4+g+z4w3aJJIz1zczLuAaMVBAW+AWcPIUggJEaw0E4+nLz62K1+wc6cLU+Tg/2T06 2YDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ceM+pzGaASjItNNpKWFEaDd0DaKnxYhb/K4oaZ7JsPI=; b=nKsB1+3ZAPkhUKyPzsiPPgjwgutzPRRT75WQEuT4RaHLz1dxOE5UVjg9FAO2JBfGcc uXmcQ8pk0Rpbbt/4VUVj8+UVikTh/rzodqZBWDd+tsp8eFGStDxRWowCi2AyhutiDhdA Iymde2Jke05U1XhFvLj4gBgDZFi4mTZqLYnelsImTjsPcS7wf3xJmnrRo3g+EklviYTO oqoTvrW55kH0fXScRXaVPs7cpIcIF9I3c+ojAW9hZpF/iChB+pjDsS2OAoyph5vdV6Tv YeHKdy2TM+k5GLrKzPGgoe+y/UUbG4saoPdIYf8LXE6b/RAvEhWHVDJ+71+sGSFK0NyU tb9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LP2fsEvM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si6901023jaj.69.2021.06.01.06.32.08; Tue, 01 Jun 2021 06:32:21 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=LP2fsEvM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234038AbhFANcy (ORCPT + 99 others); Tue, 1 Jun 2021 09:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233925AbhFANcx (ORCPT ); Tue, 1 Jun 2021 09:32:53 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4CDC061574 for ; Tue, 1 Jun 2021 06:31:11 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id c3so14320670wrp.8 for ; Tue, 01 Jun 2021 06:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ceM+pzGaASjItNNpKWFEaDd0DaKnxYhb/K4oaZ7JsPI=; b=LP2fsEvMTFs8wSLGgZY1ubi1BD83fbQR+WWGlnKbnhrJzkcoYhZUlw/ZkFPHVRX2pS 1kxI8JgLhb0g3kz0pGI8o3ABqCJYAa0imQmWdnz1EWZGapSxVVG0FE8I2m7eCNFp+FhJ LX0uC4VCrnahVcOZ/Fet/aQm0qdopbZL6zqs2RlZqUjc4xKX7utUPhIEuwzdWLNG7IVz ++liR5Sn4WQaIdIQG2oJDi6hnggLc2WP6sfG4+RcODkWpixbjWvXjXfdGBeUfjYhoY1y DhzTNVl41otb4rKKFkL85f8end5tGK+CpDfjGjCeZ4NEEnEvWdsyM8i67qe/y/1t0Wyt kmQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ceM+pzGaASjItNNpKWFEaDd0DaKnxYhb/K4oaZ7JsPI=; b=M6opWu46tPQcqu3EBtNFcE6BfBHC/TV1SVzTWGRBBBP2cxcw2VCnBiWBzCoEdKEmGi AHw98JQiURbs9KMQPg0zPnDqpACMPi+G1fGXwu2Bb9sPgF68k1KXNKddFdqvHLz5tmWr sZ96iQfORVH6NX3PeifY7piMKfZ/YNjbNxMWYaysP5dAw/bocKY3R97d5XT8bnHS7pxk xLu9zGlW0l/1UvVdJBzr6iHUw+m0ApZIkBWbf6RB+U5RwgQOmFJ7N/CyboV++SCBTRRQ QvlTzyRiSGGvlAoVtJt0oCHxbri3V/7T/+ngTFpIoioBIn8etCb7pM95FZt/BdnT6dlE 0raQ== X-Gm-Message-State: AOAM530GAAXc1/fg/fUanIqeM1mJQjH8XvhjoWAexqiN41/Doovopx+c bCPIJ2SDPUeV2wTLQ1iotR5B3w== X-Received: by 2002:a5d:4003:: with SMTP id n3mr27693980wrp.173.1622554270083; Tue, 01 Jun 2021 06:31:10 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id w13sm490487wmi.4.2021.06.01.06.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jun 2021 06:31:09 -0700 (PDT) Date: Tue, 1 Jun 2021 13:31:06 +0000 From: Quentin Perret To: Marc Zyngier Cc: will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kernel-team@android.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/7] KVM: arm64: Move hyp_pool locking out of refcount helpers Message-ID: References: <20210527125134.2116404-1-qperret@google.com> <20210527125134.2116404-2-qperret@google.com> <87sg2123pj.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87sg2123pj.wl-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 01 Jun 2021 at 13:02:00 (+0100), Marc Zyngier wrote: > On Thu, 27 May 2021 13:51:28 +0100, > Quentin Perret wrote: > > > > The hyp_page refcount helpers currently rely on the hyp_pool lock for > > serialization. However, this means the refcounts can't be changed from > > the buddy allocator core as it already holds the lock, which means pages > > have to go through odd transient states. > > > > For example, when a page is freed, its refcount is set to 0, and the > > lock is transiently released before the page can be attached to a free > > list in the buddy tree. This is currently harmless as the allocator > > checks the list node of each page to see if it is available for > > allocation or not, but it means the page refcount can't be trusted to > > represent the state of the page even if the pool lock is held. > > > > In order to fix this, remove the pool locking from the refcount helpers, > > and move all the logic to the buddy allocator. This will simplify the > > removal of the list node from struct hyp_page in a later patch. > > Is there any chance some documentation could be added so that we have > a record of what the locking boundaries are? Something along the line > of what we have in arch/arm64/kvm/vgic/vgic.c, for example. Sounds like a good idea, I'll go write something. Cheers, Quentin