Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3032013imj; Mon, 11 Feb 2019 12:37:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IZPou0P+h881pgnvNtT61a7PzDeit3T0x6eNl9EOfrIOWLfHtBiKd7vJm3hq9/klQ8zketH X-Received: by 2002:a63:1408:: with SMTP id u8mr64524pgl.271.1549917471976; Mon, 11 Feb 2019 12:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549917471; cv=none; d=google.com; s=arc-20160816; b=MExDhLndGZ0K7A15p8zQ7H0mxln5MYFTh5l8PyQ9YEHVoFnMrTBSN4SqDzGPkAm6aK neagoeI2MKlWWyiqw2A1HWJpintNvEbPY4vtBIXAuA7y4ABjlXMokp+lB9IVS8vsxx5J 0PPQ8k01dT2zv8avD1N7nBUb4UvK3olugcinPuTtJ2J/uE35N8IX0G0cWfUXTi0cwcaK hkyHui5MT3edaaQ/FuhAXFqRzvjrwRGMfqOhLyUkos0MhUOsa3IICX8BTzIxTRJw2mkO RrEBoUZpfXCH5ApJ2rO9BdUFzcoCsyBLpU95oJJdHHFxOeriM2CRsfErz2ce85h0sIcM TxfA== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=TzCwq6tui24inIp47692ugtJAeN4QgQAFadC59B8j5Q=; b=zVr2u6gxrfnXwj6PF0qTK1rtHkUXF268kkgx85O1DgQypCCa+ERIOSyptMXDlkybyl UXabWDI4/qMlAfzRYXXP4dWtX8Y7m9bxPSDpP7cvX80mYbCI4NTNdvq85ws7BDWB/Q65 6xBbcc1OiLpwN/ECjBkhTHPxfykRlEB7kw7OowRpAFNQxfK7udGmemdcrdHtwbB5OCnJ 2GVdHwK5XQzY3I9XgeXfD0boWX0NK4m6zVHLWnTqdJV4uuLfJQuckj+rvXVgGFF/+9bp QqxPCXE2SK7aMI55JMFTHFrDf9TKptRzzWk83A8G4vr/AQol9tQEMubEtJWgCx6aeQR3 K4fA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id l3si9274505pgp.285.2019.02.11.12.37.36; Mon, 11 Feb 2019 12:37:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731769AbfBKSaO (ORCPT + 99 others); Mon, 11 Feb 2019 13:30:14 -0500 Received: from mga09.intel.com ([134.134.136.24]:58990 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727968AbfBKSaN (ORCPT ); Mon, 11 Feb 2019 13:30:13 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2019 10:30:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,359,1544515200"; d="scan'208";a="137749085" Received: from ahduyck-desk1.jf.intel.com ([10.7.198.76]) by orsmga001.jf.intel.com with ESMTP; 11 Feb 2019 10:30:10 -0800 Message-ID: <58e57acd628f2d6535fc45a028af50855158fda6.camel@linux.intel.com> Subject: Re: [RFC PATCH 2/4] kvm: Add host side support for free memory hints From: Alexander Duyck To: "Michael S. Tsirkin" , Dave Hansen Cc: Alexander Duyck , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, rkrcmar@redhat.com, x86@kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, pbonzini@redhat.com, tglx@linutronix.de, akpm@linux-foundation.org Date: Mon, 11 Feb 2019 10:30:10 -0800 In-Reply-To: <20190211124203-mutt-send-email-mst@kernel.org> References: <20190204181118.12095.38300.stgit@localhost.localdomain> <20190204181546.12095.81356.stgit@localhost.localdomain> <20190209194108-mutt-send-email-mst@kernel.org> <39c915a7-e317-db01-0286-579230f37da2@intel.com> <20190211124203-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-2.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-02-11 at 12:48 -0500, Michael S. Tsirkin wrote: > On Mon, Feb 11, 2019 at 09:41:19AM -0800, Dave Hansen wrote: > > On 2/9/19 4:44 PM, Michael S. Tsirkin wrote: > > > So the policy should not leak into host/guest interface. > > > Instead it is better to just keep the pages pinned and > > > ignore the hint for now. > > > > It does seems a bit silly to have guests forever hinting about freed > > memory when the host never has a hope of doing anything about it. > > > > Is that part fixable? > > > Yes just not with existing IOMMU APIs. > > It's in the paragraph just above that you cut out: > Yes right now assignment is not smart enough but generally > you can protect the unused page in the IOMMU and that's it, > it's safe. > > So e.g. > extern int iommu_remap(struct iommu_domain *domain, unsigned long iova, > phys_addr_t paddr, size_t size, int prot); > > > I can elaborate if you like but generally we would need an API that > allows you to atomically update a mapping for a specific page without > perturbing the mapping for other pages. > I still don't see how this would solve anything unless you have the guest somehow hinting on what pages it is providing to the devices. You would have to have the host invalidating the pages when the hint is provided, and have a new hint tied to arch_alloc_page that would rebuild the IOMMU mapping when a page is allocated. I'm pretty certain that the added cost of that would make the hinting pretty pointless as my experience has been that the IOMMU is too much of a bottleneck to have multiple CPUs trying to create and invalidate mappings simultaneously.