Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp282226pxm; Wed, 2 Mar 2022 15:21:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxueo8CoIoP9BHmSGQizK+3Q4H+FcvlIcKjzeKusRwUkIINHVWuvsIJ9HGVlFUufrtHG4Fe X-Received: by 2002:a17:902:6acb:b0:150:c60:294a with SMTP id i11-20020a1709026acb00b001500c60294amr33271196plt.71.1646263278354; Wed, 02 Mar 2022 15:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646263278; cv=none; d=google.com; s=arc-20160816; b=XJs+NBLKILMn2haeNbL3Oge87YdWBOX5qZ7y1KNUzuz3PQUCQY9i1GoCBHmPdggvUV 7eUKy+0OeJGLOHB/t1xn1x1b4J0hQGYnNZ7VRGPJzBeUHgiVyDHjxvgb6HsVzV+mDpQL WRW8A3kY10XSel2HQ52GRKiNMTq33ThUXN4/K0xCF73tG/728gv++0IbUZYg2Q7hV5KA DHUa3YzyaoMbr+yGSexHThEHmqSqqNImlkZghFa05Hd9JMWHF3EG4ejziY5uoYjjD4+9 tYBabMyWzedxNqz2+7kCROqrI82SzcFbfQCmbQV1pClLKziwnW6bTEurPLFhDTJzCLmD PoLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=jCur8YrGp6z/NuQt4H+X/uS6Re1ZqnHb48KX+hfu53o=; b=Iq+kXwtfoO7vFvwuarprO5oVXs8PF0fqOkMRK+oNqa6IDgeRdj8jkYs0qXb359hHa6 wzUe5whXEpxxRyL4ZpVXrIio58zHgHtenEsOH9/tSAmgB92nCAvfgbyNPamG0LWf08w4 GZ+b74COGCiHMoRJIRtKBBWZIx1ByyP5LSoPUz9wu70ra+XfCni3WDICkIhaUzP3Pja4 DMfQ+ZNU74bO7cagEmkG5GVBS/zPc3lWXClLphJjvQBFbOGs8wjAMLIi/E2uQa133s73 k1pnTFJIg8LUjfj3Bx46pQBIX3IzCXzK6m3choTRyeC8NJFQvmCcOFePJ5lY5ejU1ktp wSrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C4GUs40M; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p3-20020a17090a2c4300b001bc3df44c9dsi303856pjm.168.2022.03.02.15.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 15:21:18 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C4GUs40M; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 501F32609; Wed, 2 Mar 2022 14:57:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240982AbiCBSVD (ORCPT + 99 others); Wed, 2 Mar 2022 13:21:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231945AbiCBSVA (ORCPT ); Wed, 2 Mar 2022 13:21:00 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DA223BCE; Wed, 2 Mar 2022 10:20:16 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id i66so1684131wma.5; Wed, 02 Mar 2022 10:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=jCur8YrGp6z/NuQt4H+X/uS6Re1ZqnHb48KX+hfu53o=; b=C4GUs40MfOQrW5sBrilqDYxQOs2FYm8f9QxL3hMm+zTP7aTJkzPLfOPhs1lzQD3CVV m377cAUO0oZ53mdaNqMWRt8gPsuU0ovUZNlwnvn08ITFVdVy73fb7u4ZK3l7YEeD3ibj Nr0sbRwJxI0AewRuDPljZiBP8Rs0uhhv5z2CHj3WgN20jslaIky90KJcGHpqmC59fdS2 Qa8nmDnuvVenMEGxLwDdlcdtqQpK9jfBGpuqs9iNzQwxXGLrJTfnLFdc9UOpYspXUFb1 YXTgzNtPfCqnJ+gr1HToZfiOJWVjSxoyE1x2VWPtIUfNECWYDubH4bGdqlIkT+Aovoja wBHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=jCur8YrGp6z/NuQt4H+X/uS6Re1ZqnHb48KX+hfu53o=; b=kiKMeovu8BWc1cFXOco+x2pGcgXzjrh3CGexFM9Oh2FW77WS2g7DePtT/+wo4++TLD fKpK+2jKKLAZ1N5fL29wNX4jppccCFfZ4m3qcVaOh1DEfapPOoUd6ppPUWI7Sq4cGnYM Igt9L0zo0hcTm53hmi0d0ndjvCmZ5TcQlA1+WOzcsSumu38a2+HAhAPd2M3ndGneWihg ihleKMItHuvCJx8rYS0FHYoUwMmqHA/sdeDKsqrLA97Rr0NmHdWFNN9XqSyfZy9tfLjG MQ9mBOdNQ9Z5K7zSzcAWbJ7INOSFTT9lsN5dUgCfyJNFHCp/FFfEVJR3fYZY+wd/bleI 5FKw== X-Gm-Message-State: AOAM533+R5aIanKciLGby/g2CeIC//xrCr9mTqJ6LBHhz3LxT6694Xdh HqHvAL9R4Zy9xM7fa6dA5fqzE68SA7U= X-Received: by 2002:a7b:c94e:0:b0:386:3694:3e78 with SMTP id i14-20020a7bc94e000000b0038636943e78mr935222wml.22.1646245215294; Wed, 02 Mar 2022 10:20:15 -0800 (PST) Received: from ?IPV6:2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e? ([2001:b07:6468:f312:5e2c:eb9a:a8b6:fd3e]) by smtp.googlemail.com with ESMTPSA id n21-20020a05600c3b9500b003830cbe90c3sm3808590wms.11.2022.03.02.10.20.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Mar 2022 10:20:14 -0800 (PST) Sender: Paolo Bonzini Message-ID: Date: Wed, 2 Mar 2022 19:20:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v3 22/28] KVM: x86/mmu: Zap defunct roots via asynchronous worker Content-Language: en-US To: Sean Christopherson Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Ben Gardon , Mingwei Zhang References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-23-seanjc@google.com> From: Paolo Bonzini In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 3/2/22 19:01, Sean Christopherson wrote: >> + */ >> + if (!refcount_read(&kvm->users_count)) { >> + kvm_mmu_zap_all(kvm); >> + return; >> + } > > I'd prefer we make this an assertion and shove this logic to set_nx_huge_pages(), > because in that case there's no need to zap anything, the guest can never run > again. E.g. (I'm trying to remember why I didn't do this before...) I did it this way because it seemed like a reasonable fallback for any present or future caller. > One thing that keeps tripping me up is the "readers" verbiage. I get confused > because taking mmu_lock for read vs. write doesn't really have anything to do with > reading or writing state, e.g. "readers" still write SPTEs, and so I keep thinking > "readers" means anything iterating over the set of roots. Not sure if there's a > shorthand that won't be confusing. Not that I know of. You really need to know that the rwlock is been used for its shared/exclusive locking behavior. But even on ther OSes use shared/exclusive instead of read/write, there are no analogous nouns and people end up using readers/writers anyway. >> It passes a smoke test, and also resolves the debate on the fate of patch 1. > +1000, I love this approach. Do you want me to work on a v3, or shall I let you > have the honors? I'm already running the usual battery of tests, so I should be able to post it either tomorrow (early in my evening) or Friday morning. Paolo