Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3861716ybt; Tue, 23 Jun 2020 12:38:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzITLdrWUO9HEUsu6OWkEhATMg9N49xidMT3A6GGetaRdrS1wJF8aI1Xm3YSb3SRM4iVAMH X-Received: by 2002:a17:906:8392:: with SMTP id p18mr12512603ejx.24.1592941111135; Tue, 23 Jun 2020 12:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592941111; cv=none; d=google.com; s=arc-20160816; b=Z2haYh6jHhr/SPFChhud9nCt6s6ovoQztWTKkuOOfPjL+xsCXa5Xjf0uuwryID9H0c Tgw+dlyGIiHEw7NUgNgc7Lkw1LaFUEikngB4qE3+DyZyi0tUzPyumjb3BXE1F71yE69L +1OaPwwOhvG/9u6pEAq6uWG6/CfFhhEgF2CuSx0/crS8hvfabTJRlJx3Ij/4C6KuRt3B eWo5ns32T9mpN1qhYccKb5zR6lMzgHdpoRzm79p2xGhtKo9qWCNXLJY+UVnihd/D7Oq4 zjGRQoD1HL5FW8uZOZpUpbKOYbiuw8e1A0G10lAU6DhWtNH6S/Z5c+aoyyxAaa4VhUYx norA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=OsRO0x1773bUSOXil+nwGNsxACYZ0vsoxsDz1MeIfmM=; b=QccwZzEOeJeph+JxdJaCtLJOg2Z37ksqNpFcpPy0FwmkYWYG4j6bnG3oa0CgHkkMzZ Zo+EuR8A9sz24+V45clQirQlPchdR/8VYoDYszSop1nUI+mOLK3ZDR70xcfqGkuNq7GA fQ5qpUZyC8tdCDodul6Cvq/Zy9wOHAf2JN0JmLcPZbQtk6g+YlVzcFhIvA1IAW6WOad0 xdlSssy4hh4KketTWuBXZRPi3LTGTBdcfpAH/Voyw8kHOJ8yQDOroIMx1+Ot34g6Ezry 3MfCrv3GzSBAo3Y+byGN5gUnGUWTpDII6uWy1YcB40pZTsvUIP5noOoqfVZcG3sbvu3p dOrg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm4si7207484edb.143.2020.06.23.12.38.03; Tue, 23 Jun 2020 12:38:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387492AbgFWTfo (ORCPT + 99 others); Tue, 23 Jun 2020 15:35:44 -0400 Received: from mga11.intel.com ([192.55.52.93]:11007 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733309AbgFWTfn (ORCPT ); Tue, 23 Jun 2020 15:35:43 -0400 IronPort-SDR: 2mwWk0sby4tCvc0rJNa1K8Y8icUos6UEtcwxHT1zg1gc1A9xRDDO8r6YYFYy3NGNKXWNbZL8yj 1+Sjxi+YBNbQ== X-IronPort-AV: E=McAfee;i="6000,8403,9661"; a="142430966" X-IronPort-AV: E=Sophos;i="5.75,272,1589266800"; d="scan'208";a="142430966" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2020 12:35:43 -0700 IronPort-SDR: w6DCk5L9cIhRfbhUuZT1pBFGa7B7OXBCXGDP8PbeXVBFzTrGCpF+awJ71LdnnZorr4xA6xGRJ4 xsY1D0eKysQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,272,1589266800"; d="scan'208";a="263428285" Received: from sjchrist-coffee.jf.intel.com ([10.54.74.152]) by fmsmga007.fm.intel.com with ESMTP; 23 Jun 2020 12:35:43 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/4] KVM: x86/mmu: Zapping and recycling cleanups Date: Tue, 23 Jun 2020 12:35:38 -0700 Message-Id: <20200623193542.7554-1-sean.j.christopherson@intel.com> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Semi-random, but related, changes that deal with the handling of active root shadow pages during zapping and the zapping of arbitary/old pages. Patch 1 changes the low level handling to keep zapped active roots off the active page list. KVM already relies on the vCPU to explicitly free the root, putting invalid root pages back on the list is just a quirk of the implementation. Patches 2 reworks the MMU page recycling to batch zap pages instead of zapping them one at a time. This provides better handling for active root pages and also avoids multiple remote TLB flushes. Patch 3 applies the batch zapping to the .shrink_scan() path. This is a significant change in behavior, i.e. is the scariest of the changes, but unless I'm missing something it provides the intended functionality that has been lacking since shrinker support was first added. Patch 4 changes the page fault handlers to return an error to userspace instead of restarting the guest if there are no MMU pages available. This is dependent on patch 2 as theoretically the old recycling flow could prematurely bail if it encountered an active root. v2: - Add a comment for the list shenanigans in patch 1. [Paolo] - Add patches 2-4. - Rebased to kvm/queue, commit a037ff353ba6 ("Merge branch ...") Sean Christopherson (4): KVM: x86/mmu: Don't put invalid SPs back on the list of active pages KVM: x86/mmu: Batch zap MMU pages when recycling oldest pages KVM: x86/mmu: Batch zap MMU pages when shrinking the slab KVM: x86/mmu: Exit to userspace on make_mmu_pages_available() error arch/x86/kvm/mmu/mmu.c | 94 +++++++++++++++++++++------------- arch/x86/kvm/mmu/paging_tmpl.h | 3 +- 2 files changed, 61 insertions(+), 36 deletions(-) -- 2.26.0