From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id F41D0ECAAD3 for ; Thu, 15 Sep 2022 08:36:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 75D824BC7C; Thu, 15 Sep 2022 04:36:04 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@linux.dev Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3UbG5JJKyZOp; Thu, 15 Sep 2022 04:36:03 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 324B74BC68; Thu, 15 Sep 2022 04:36:03 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2EDEB4BC57 for ; Thu, 15 Sep 2022 04:36:02 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P11go3RSPMmP for ; Thu, 15 Sep 2022 04:36:00 -0400 (EDT) Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id C48704BBD4 for ; Thu, 15 Sep 2022 04:36:00 -0400 (EDT) Date: Thu, 15 Sep 2022 09:35:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1663230959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=os9IwzMucLgvaJoFDfZwUuHXyNMsYUbmD+UZT0aPk50=; b=E/tahtjhO+Blv3iPVh0DxXR5+zb1T97qHYNma9aXxibWOSflrt9ii0ORnnylzqS95STLGn Gh7oKiN3KOeCQIoh0ZfJlrIdL1p5P1FHPH7PfI8p5/7KX7mI3kzN0fevcLDPdQo2cm/wYR YUqtx80pvv6k24UTJFIyckf3Eb1J3Qw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Subject: Re: [PATCH v3 01/25] KVM: arm64: Move hyp refcount manipulation helpers to common header file Message-ID: References: <20220914083500.5118-1-will@kernel.org> <20220914083500.5118-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220914083500.5118-2-will@kernel.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Cc: Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, Catalin Marinas , Chao Peng , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Will, On Wed, Sep 14, 2022 at 09:34:36AM +0100, Will Deacon wrote: > From: Quentin Perret > > We will soon need to manipulate 'struct hyp_page' refcounts from outside > page_alloc.c, so move the helpers to a common header file to allow them > to be reused easily. > > Signed-off-by: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/hyp/include/nvhe/memory.h | 18 ++++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 19 ------------------- > 2 files changed, 18 insertions(+), 19 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h > index 592b7edb3edb..418b66a82a50 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h > @@ -45,4 +45,22 @@ static inline int hyp_page_count(void *addr) > return p->refcount; > } > > +static inline void hyp_page_ref_inc(struct hyp_page *p) > +{ > + BUG_ON(p->refcount == USHRT_MAX); > + p->refcount++; > +} > + > +static inline int hyp_page_ref_dec_and_test(struct hyp_page *p) > +{ > + BUG_ON(!p->refcount); > + p->refcount--; > + return (p->refcount == 0); > +} > + > +static inline void hyp_set_page_refcounted(struct hyp_page *p) > +{ > + BUG_ON(p->refcount); > + p->refcount = 1; > +} It might be good to add a comment mentioning the hyp_pool::lock must be held to update refcounts, as that part is slightly less clear when the helpers are hoisted out of page_alloc.c With that: Reviewed-by: Oliver Upton -- Thanks, Oliver _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B74E7ECAAD3 for ; Thu, 15 Sep 2022 08:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbiIOIgS (ORCPT ); Thu, 15 Sep 2022 04:36:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbiIOIgD (ORCPT ); Thu, 15 Sep 2022 04:36:03 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3603B550A5 for ; Thu, 15 Sep 2022 01:36:01 -0700 (PDT) Date: Thu, 15 Sep 2022 09:35:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1663230959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=os9IwzMucLgvaJoFDfZwUuHXyNMsYUbmD+UZT0aPk50=; b=E/tahtjhO+Blv3iPVh0DxXR5+zb1T97qHYNma9aXxibWOSflrt9ii0ORnnylzqS95STLGn Gh7oKiN3KOeCQIoh0ZfJlrIdL1p5P1FHPH7PfI8p5/7KX7mI3kzN0fevcLDPdQo2cm/wYR YUqtx80pvv6k24UTJFIyckf3Eb1J3Qw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Sean Christopherson , Vincent Donnefort , Alexandru Elisei , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Mark Rutland , Fuad Tabba , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 01/25] KVM: arm64: Move hyp refcount manipulation helpers to common header file Message-ID: References: <20220914083500.5118-1-will@kernel.org> <20220914083500.5118-2-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220914083500.5118-2-will@kernel.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Will, On Wed, Sep 14, 2022 at 09:34:36AM +0100, Will Deacon wrote: > From: Quentin Perret > > We will soon need to manipulate 'struct hyp_page' refcounts from outside > page_alloc.c, so move the helpers to a common header file to allow them > to be reused easily. > > Signed-off-by: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/hyp/include/nvhe/memory.h | 18 ++++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 19 ------------------- > 2 files changed, 18 insertions(+), 19 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h > index 592b7edb3edb..418b66a82a50 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h > @@ -45,4 +45,22 @@ static inline int hyp_page_count(void *addr) > return p->refcount; > } > > +static inline void hyp_page_ref_inc(struct hyp_page *p) > +{ > + BUG_ON(p->refcount == USHRT_MAX); > + p->refcount++; > +} > + > +static inline int hyp_page_ref_dec_and_test(struct hyp_page *p) > +{ > + BUG_ON(!p->refcount); > + p->refcount--; > + return (p->refcount == 0); > +} > + > +static inline void hyp_set_page_refcounted(struct hyp_page *p) > +{ > + BUG_ON(p->refcount); > + p->refcount = 1; > +} It might be good to add a comment mentioning the hyp_pool::lock must be held to update refcounts, as that part is slightly less clear when the helpers are hoisted out of page_alloc.c With that: Reviewed-by: Oliver Upton -- Thanks, Oliver From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 587BFECAAA1 for ; Thu, 15 Sep 2022 08:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ih0SZCS2n2TPjXX/GVGh/EH41FbWooZWmELxKwfZZ+E=; b=u9iRna188jM05A 9/Wx/8wnUfQchmtY8SizfilQEsHzvcM5XzgcfLYAUnXrj5sjvQHAeHKSyrM5R+twRMNNi0U02ORFN 53q7Cm0uCZ/qNanJu4fuo8Dw2alFgNnEJgHGV7tZeBl/q2a/cbTxoqvD7ZEBksVn7CF9LGA5GIL7Z IxixfiEuL6Psezq4JKw1ZnnnkPCaNIcD7Y38tqwvo+hhcLBP0CjS9ULlIskpGEXwEKru+j2Avpt+v 4icjdGU5kmvn27gH323yZYqeORtH14S3KOOS1P/7OIvnAXbinRlT4h/Sr09IpiJq5XTBGzIYq984P mNGsxONF6gO1ehcnPP4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYkLz-0042DI-UO; Thu, 15 Sep 2022 08:36:12 +0000 Received: from out0.migadu.com ([94.23.1.103]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYkLs-0041Uu-Pq for linux-arm-kernel@lists.infradead.org; Thu, 15 Sep 2022 08:36:10 +0000 Date: Thu, 15 Sep 2022 09:35:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1663230959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=os9IwzMucLgvaJoFDfZwUuHXyNMsYUbmD+UZT0aPk50=; b=E/tahtjhO+Blv3iPVh0DxXR5+zb1T97qHYNma9aXxibWOSflrt9ii0ORnnylzqS95STLGn Gh7oKiN3KOeCQIoh0ZfJlrIdL1p5P1FHPH7PfI8p5/7KX7mI3kzN0fevcLDPdQo2cm/wYR YUqtx80pvv6k24UTJFIyckf3Eb1J3Qw= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Sean Christopherson , Vincent Donnefort , Alexandru Elisei , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Mark Rutland , Fuad Tabba , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 01/25] KVM: arm64: Move hyp refcount manipulation helpers to common header file Message-ID: References: <20220914083500.5118-1-will@kernel.org> <20220914083500.5118-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220914083500.5118-2-will@kernel.org> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220915_013607_872253_51AB52DB X-CRM114-Status: GOOD ( 17.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Will, On Wed, Sep 14, 2022 at 09:34:36AM +0100, Will Deacon wrote: > From: Quentin Perret > > We will soon need to manipulate 'struct hyp_page' refcounts from outside > page_alloc.c, so move the helpers to a common header file to allow them > to be reused easily. > > Signed-off-by: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/hyp/include/nvhe/memory.h | 18 ++++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 19 ------------------- > 2 files changed, 18 insertions(+), 19 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/include/nvhe/memory.h b/arch/arm64/kvm/hyp/include/nvhe/memory.h > index 592b7edb3edb..418b66a82a50 100644 > --- a/arch/arm64/kvm/hyp/include/nvhe/memory.h > +++ b/arch/arm64/kvm/hyp/include/nvhe/memory.h > @@ -45,4 +45,22 @@ static inline int hyp_page_count(void *addr) > return p->refcount; > } > > +static inline void hyp_page_ref_inc(struct hyp_page *p) > +{ > + BUG_ON(p->refcount == USHRT_MAX); > + p->refcount++; > +} > + > +static inline int hyp_page_ref_dec_and_test(struct hyp_page *p) > +{ > + BUG_ON(!p->refcount); > + p->refcount--; > + return (p->refcount == 0); > +} > + > +static inline void hyp_set_page_refcounted(struct hyp_page *p) > +{ > + BUG_ON(p->refcount); > + p->refcount = 1; > +} It might be good to add a comment mentioning the hyp_pool::lock must be held to update refcounts, as that part is slightly less clear when the helpers are hoisted out of page_alloc.c With that: Reviewed-by: Oliver Upton -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel