Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5012846rwd; Tue, 30 May 2023 13:15:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5VEH9Cs42aOhaFe4PiAxyitAKnAkEkF2SIvQO2SMC7dFYeBwHHy+/TeloGoek9l1/1FRgp X-Received: by 2002:a05:6a00:234a:b0:63f:120a:1dc3 with SMTP id j10-20020a056a00234a00b0063f120a1dc3mr3731983pfj.0.1685477718622; Tue, 30 May 2023 13:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685477718; cv=none; d=google.com; s=arc-20160816; b=pD7it3kZJg7alDlJVSZuYGcbz8xV5w3w+RONwy46j9vcFCP0eP0/PKw0GH14aFRkVj 74UJD/w/JUzZ06HRaPVwHa7DPbfRqadjHpcG/2GzdtUGJVxCKHToM8UGHlmBTSVA6gBe UlAI14GeQh16JHo0kklDgNXMT/KhjwwWqWT8ERrnAEt3HTG4A3q6Lc0fFu4S8ei6Zqhc uzjlQCbeTbzbxECBGLpbs9n5VuzQDv8zU67EGfp5l6twLRu+cwZco7q3D3eKdv2CYmPC 1yJSxa6EZXOjPiXyd7SG7Id2Gjfh2Vkar1qmLUpq9A4juO/Hb6zmfCcsmf3QYTq6+1ER HcaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tnJw+gna055xgPY4k/D+ZQZ+/+poCudJDicda2AGR3k=; b=GfgBnaHko7Q5OSrxpe17Q6i3IMjOGMGXZdiokLZgpWNvNbXjkyMbDOSSffKl0Jr5nA bJZPln/PSP5v9oFwofFV0MevFtuQMKCPKDB8EUNa/R/hGr6CVZd2HTmaHuzUbbKH7K+v iSv/O7sr0xgYeWm0ApLOhfWz6ybUJsT+dhKddaKeVJq5LbV8mwTJN2RqFdTviXkfaDdG OcGL7/e0PSfNxjdfHhufI3m4MY4HLOTZsaD9vHE6M+S2jvO1+SVU+RXY2DrsctBWEOr/ IHrU8dIJc+G/ey7LoIjlPYtIB18WenyL5WyneQMOIMjrmK1MzEAB8ZZFmAhedJ+iawux +jyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DtfynU88; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020aa79e49000000b0063b7c4435c0si2303510pfq.54.2023.05.30.13.15.06; Tue, 30 May 2023 13:15:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DtfynU88; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231610AbjE3UHj (ORCPT + 99 others); Tue, 30 May 2023 16:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231130AbjE3UHh (ORCPT ); Tue, 30 May 2023 16:07:37 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 768F4F9 for ; Tue, 30 May 2023 13:07:33 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-3f6a6e9d90dso57911cf.0 for ; Tue, 30 May 2023 13:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685477252; x=1688069252; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tnJw+gna055xgPY4k/D+ZQZ+/+poCudJDicda2AGR3k=; b=DtfynU88O3z0/4oFgDiYM7qy14b7RLg4yomBzxL0dog8TFdWbHyo2tpb/B1SOYXfmp NSRsIG+eVwPFOobh1xJCt8kwErPgylGUweOcutP0ywct+6P+S2IjeaikfhAUmhYPV+uH Mv+j09gZh5WjQDA3Z/2Gy9TgffLJonGspryTqmY7mSq0d2Id3AeV0HEZ5ulNgRW7LXMq 4JCJAWgEwKAWSjc16VpDrPx50NJw92bJUlL+d9zw+H+Lfu/l9dON3ftxIU/zENGgXs4K 1cHj3nLx36gvePguvMtotajaF04WFwISrYvt1J6cDwX3ikwzIPGkd33waRKuVJi8J5gu uXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685477252; x=1688069252; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tnJw+gna055xgPY4k/D+ZQZ+/+poCudJDicda2AGR3k=; b=Dw3y2IUYr9GWeXSbQ25bxdwSvKN1kxwxCA9G8Vmv9ANH48OPOU0aJQQ6O7PbGrn0kh +bt5XCnfdqamXXl+qm3bd4rtAxG0Dlig0VolVskP9NekrF+YjC8/0DamIfLXpwxzIf9Q HFkzMawMislZFFwfs8l9IiupLDSDYoVdIvUq8enzmXN0DBFJQ25QjzJQLzITvZWd87uT +43IADWB/8UvGe0FBKb2Xq7qsNKnzi5xuv+lj0O96P3Zp8MrUYtIXu7pWaAgR+85MsaZ R3AE79n8pBalcMiy3SiXaPX6wcmH6O2mhA75X79/UdE/Y6wDEcEX4S9rTjHYcuj6hcK9 E98w== X-Gm-Message-State: AC+VfDxUShZKLYXKVarJVLZr1/GruD/u67pxwPKHVwdh1qOl73zkeYtb K/GbYXHvRjAO2KonOTDaonNO7fAzVhJ7heoFFVusag== X-Received: by 2002:a05:622a:1012:b0:3ef:2f55:2204 with SMTP id d18-20020a05622a101200b003ef2f552204mr6506qte.6.1685477252408; Tue, 30 May 2023 13:07:32 -0700 (PDT) MIME-Version: 1.0 References: <20230526234435.662652-1-yuzhao@google.com> <20230526234435.662652-5-yuzhao@google.com> In-Reply-To: From: Yu Zhao Date: Tue, 30 May 2023 14:06:55 -0600 Message-ID: Subject: Re: [PATCH mm-unstable v2 04/10] kvm/arm64: make stage2 page tables RCU safe To: Oliver Upton Cc: Andrew Morton , Paolo Bonzini , Alistair Popple , Anup Patel , Ben Gardon , Borislav Petkov , Catalin Marinas , Chao Peng , Christophe Leroy , Dave Hansen , Fabiano Rosas , Gaosheng Cui , Gavin Shan , "H. Peter Anvin" , Ingo Molnar , James Morse , "Jason A. Donenfeld" , Jason Gunthorpe , Jonathan Corbet , Marc Zyngier , Masami Hiramatsu , Michael Ellerman , Michael Larabel , Mike Rapoport , Nicholas Piggin , Paul Mackerras , Peter Xu , Sean Christopherson , Steven Rostedt , Suzuki K Poulose , Thomas Gleixner , Thomas Huth , Will Deacon , Zenghui Yu , kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-trace-kernel@vger.kernel.org, x86@kernel.org, linux-mm@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 30, 2023 at 1:37=E2=80=AFPM Oliver Upton wrote: > > Hi Yu, > > On Sat, May 27, 2023 at 02:13:07PM -0600, Yu Zhao wrote: > > On Sat, May 27, 2023 at 12:08=E2=80=AFPM Oliver Upton wrote: > > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtabl= e.c > > > index 3d61bd3e591d..bfbebdcb4ef0 100644 > > > --- a/arch/arm64/kvm/hyp/pgtable.c > > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > > @@ -1019,7 +1019,7 @@ static int stage2_unmap_walker(const struct kvm= _pgtable_visit_ctx *ctx, > > > kvm_granule_size(ctx->= level)); > > > > > > if (childp) > > > - mm_ops->put_page(childp); > > > + mm_ops->free_removed_table(childp, ctx->level); > > > > Thanks, Oliver. > > > > A couple of things I haven't had the chance to verify -- I'm hoping > > you could help clarify: > > 1. For unmapping, with free_removed_table(), wouldn't we have to look > > into the table we know it's empty unnecessarily? > > As it is currently implemented, yes. But, there's potential to fast-path > the implementation by checking page_count() before starting the walk. Do you mind posting another patch? I'd be happy to ack it, as well as the one you suggested above. > > 2. For remapping and unmapping, how does free_removed_table() put the > > final refcnt on the table passed in? (Previously we had > > put_page(childp) in stage2_map_walk_table_post(). So I'm assuming we'd > > have to do something equivalent with free_removed_table().) > > Heh, that's a bug, and an embarrassing one at that! > > Sent out a fix for that, since it would appear we leak memory on > table->block transitions. PTAL if you have a chance. > > https://lore.kernel.org/all/20230530193213.1663411-1-oliver.upton@linux.d= ev/ Awesome.