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 81C54ECAAD3 for ; Fri, 9 Sep 2022 09:38:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E6A804CA03; Fri, 9 Sep 2022 05:38:37 -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 GqUvPoo35oTz; Fri, 9 Sep 2022 05:38:36 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 886804CA1B; Fri, 9 Sep 2022 05:38:36 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 15BD04CA05 for ; Fri, 9 Sep 2022 05:38:35 -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 N6C0B9jgW2vn for ; Fri, 9 Sep 2022 05:38:33 -0400 (EDT) Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 9C2174CA03 for ; Fri, 9 Sep 2022 05:38:33 -0400 (EDT) Date: Fri, 9 Sep 2022 10:38:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1662716312; 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=sbjsJsmK8eNNPB1/qbrlalcNvip2GURuJ8l1XpwCdtA=; b=w5aYW3X82xa4eYEqN9xPSlbdWVdlzhVTNhVkxtP9f3wiaVyoildIroHN4Zy7CmcTTPA9wN SoANTcLFct9zHRFs4lgnTLNq94CjWzDWlcEX4gscm56lXU4biERICyRPbokXJYe5ydUMBs el+dRzkfzb1LVpFUKALFGbST86619Q8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: David Matlack Subject: Re: [PATCH 06/14] KVM: arm64: Return next table from map callbacks Message-ID: References: <20220830194132.962932-1-oliver.upton@linux.dev> <20220830194132.962932-7-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Cc: kvm@vger.kernel.org, Marc Zyngier , linux-kernel@vger.kernel.org, Catalin Marinas , Ben Gardon , Paolo Bonzini , Will Deacon , 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 David, On Wed, Sep 07, 2022 at 02:32:29PM -0700, David Matlack wrote: > On Tue, Aug 30, 2022 at 07:41:24PM +0000, Oliver Upton wrote: > > The map walkers install new page tables during their traversal. Return > > the newly-installed table PTE from the map callbacks to point the walker > > at the new table w/o rereading the ptep. > > > > Signed-off-by: Oliver Upton > > --- > > arch/arm64/kvm/hyp/pgtable.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index 331f6e3b2c20..f911509e6512 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -202,13 +202,12 @@ static inline int __kvm_pgtable_visit(struct kvm_pgtable_walk_data *data, > > if (!table && (flags & KVM_PGTABLE_WALK_LEAF)) { > > ret = kvm_pgtable_visitor_cb(data, addr, level, ptep, &pte, > > KVM_PGTABLE_WALK_LEAF); > > - pte = *ptep; > > - table = kvm_pte_table(pte, level); > > } > > > > if (ret) > > goto out; > > Rather than passing a pointer to the local variable pte and requiring > all downstream code to update it (and deal with dereferencing to read > the old pte), wouldn't it be simpler to just re-read the PTE here? Yeah, you're right. I had some odd rationalization about this, but there's no need to force a walker to descend into the new table level as it is wasted work if another thread unlinks it. [...] > > > > + table = kvm_pte_table(pte, level); > > if (!table) { > > nit: Technically there's no reason to set @table again. e.g. This could > just be: > > if (!kvm_pte_table(pte, level)) { Sure, I'll squish these lines together. -- 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 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 1EB6DECAAD3 for ; Fri, 9 Sep 2022 09:39:43 +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=GK3pQ0LkJOOawKOaTnpHQtctWHDuEWtybTMXhsJbp9I=; b=nhq8uTm2kaskCk Kf4DEE1gqBe5LcmchTYlXKjPMhKgJrYYxT8dBoYeyuI7FUA3MVfzTMuDZKzeOy3AvrW8CTyF55qOw fFdncoox0EtAieHIwMwBZGQE2HSrGHKevgop58alYQw9C+NS4fJkoubZKtCbyUQedTg7NDYHMqlHP RG/FawsTxdxLnwovl4PVmasXw2nrGOwReearChy2LaGmTLQuRDd52tjF77rdcQBuky5DYyi6pd5e5 IJbCtbT6nUZ6cc7j0DxqNKodzpDNSWDdunyxYAtrcutttVEwcjIz+9hs0wimTOmhe/BEYNrEtNxs9 bp64QYBcCthDaYDySvLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWaTF-00F67W-RU; Fri, 09 Sep 2022 09:38:45 +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 1oWaTB-00F63n-O4 for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2022 09:38:43 +0000 Date: Fri, 9 Sep 2022 10:38:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1662716312; 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=sbjsJsmK8eNNPB1/qbrlalcNvip2GURuJ8l1XpwCdtA=; b=w5aYW3X82xa4eYEqN9xPSlbdWVdlzhVTNhVkxtP9f3wiaVyoildIroHN4Zy7CmcTTPA9wN SoANTcLFct9zHRFs4lgnTLNq94CjWzDWlcEX4gscm56lXU4biERICyRPbokXJYe5ydUMBs el+dRzkfzb1LVpFUKALFGbST86619Q8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: David Matlack Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Quentin Perret , Ricardo Koller , Reiji Watanabe , Ben Gardon , Paolo Bonzini , Gavin Shan , Peter Xu , Sean Christopherson , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/14] KVM: arm64: Return next table from map callbacks Message-ID: References: <20220830194132.962932-1-oliver.upton@linux.dev> <20220830194132.962932-7-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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-20220909_023842_340501_18BDCD57 X-CRM114-Status: GOOD ( 20.80 ) 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 David, On Wed, Sep 07, 2022 at 02:32:29PM -0700, David Matlack wrote: > On Tue, Aug 30, 2022 at 07:41:24PM +0000, Oliver Upton wrote: > > The map walkers install new page tables during their traversal. Return > > the newly-installed table PTE from the map callbacks to point the walker > > at the new table w/o rereading the ptep. > > > > Signed-off-by: Oliver Upton > > --- > > arch/arm64/kvm/hyp/pgtable.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index 331f6e3b2c20..f911509e6512 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -202,13 +202,12 @@ static inline int __kvm_pgtable_visit(struct kvm_pgtable_walk_data *data, > > if (!table && (flags & KVM_PGTABLE_WALK_LEAF)) { > > ret = kvm_pgtable_visitor_cb(data, addr, level, ptep, &pte, > > KVM_PGTABLE_WALK_LEAF); > > - pte = *ptep; > > - table = kvm_pte_table(pte, level); > > } > > > > if (ret) > > goto out; > > Rather than passing a pointer to the local variable pte and requiring > all downstream code to update it (and deal with dereferencing to read > the old pte), wouldn't it be simpler to just re-read the PTE here? Yeah, you're right. I had some odd rationalization about this, but there's no need to force a walker to descend into the new table level as it is wasted work if another thread unlinks it. [...] > > > > + table = kvm_pte_table(pte, level); > > if (!table) { > > nit: Technically there's no reason to set @table again. e.g. This could > just be: > > if (!kvm_pte_table(pte, level)) { Sure, I'll squish these lines together. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 3F18BECAAD3 for ; Fri, 9 Sep 2022 09:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231500AbiIIJim (ORCPT ); Fri, 9 Sep 2022 05:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232177AbiIIJif (ORCPT ); Fri, 9 Sep 2022 05:38:35 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F36859E89D; Fri, 9 Sep 2022 02:38:33 -0700 (PDT) Date: Fri, 9 Sep 2022 10:38:23 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1662716312; 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=sbjsJsmK8eNNPB1/qbrlalcNvip2GURuJ8l1XpwCdtA=; b=w5aYW3X82xa4eYEqN9xPSlbdWVdlzhVTNhVkxtP9f3wiaVyoildIroHN4Zy7CmcTTPA9wN SoANTcLFct9zHRFs4lgnTLNq94CjWzDWlcEX4gscm56lXU4biERICyRPbokXJYe5ydUMBs el+dRzkfzb1LVpFUKALFGbST86619Q8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: David Matlack Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Quentin Perret , Ricardo Koller , Reiji Watanabe , Ben Gardon , Paolo Bonzini , Gavin Shan , Peter Xu , Sean Christopherson , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/14] KVM: arm64: Return next table from map callbacks Message-ID: References: <20220830194132.962932-1-oliver.upton@linux.dev> <20220830194132.962932-7-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi David, On Wed, Sep 07, 2022 at 02:32:29PM -0700, David Matlack wrote: > On Tue, Aug 30, 2022 at 07:41:24PM +0000, Oliver Upton wrote: > > The map walkers install new page tables during their traversal. Return > > the newly-installed table PTE from the map callbacks to point the walker > > at the new table w/o rereading the ptep. > > > > Signed-off-by: Oliver Upton > > --- > > arch/arm64/kvm/hyp/pgtable.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index 331f6e3b2c20..f911509e6512 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -202,13 +202,12 @@ static inline int __kvm_pgtable_visit(struct kvm_pgtable_walk_data *data, > > if (!table && (flags & KVM_PGTABLE_WALK_LEAF)) { > > ret = kvm_pgtable_visitor_cb(data, addr, level, ptep, &pte, > > KVM_PGTABLE_WALK_LEAF); > > - pte = *ptep; > > - table = kvm_pte_table(pte, level); > > } > > > > if (ret) > > goto out; > > Rather than passing a pointer to the local variable pte and requiring > all downstream code to update it (and deal with dereferencing to read > the old pte), wouldn't it be simpler to just re-read the PTE here? Yeah, you're right. I had some odd rationalization about this, but there's no need to force a walker to descend into the new table level as it is wasted work if another thread unlinks it. [...] > > > > + table = kvm_pte_table(pte, level); > > if (!table) { > > nit: Technically there's no reason to set @table again. e.g. This could > just be: > > if (!kvm_pte_table(pte, level)) { Sure, I'll squish these lines together. -- Thanks, Oliver