Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp3061434rdb; Mon, 4 Dec 2023 16:01:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGv+X/XnI5xXitTus8zPEjIuTf2MlQBCbT/Ze616ppDz/gxsqX10IN5hOBpS/ZRwG1Yy+S2 X-Received: by 2002:a17:902:f814:b0:1d0:6ffd:6108 with SMTP id ix20-20020a170902f81400b001d06ffd6108mr591365plb.42.1701734503835; Mon, 04 Dec 2023 16:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701734503; cv=none; d=google.com; s=arc-20160816; b=ZL2AHZodOlu1QRytZuxaiYBVltuvAa294HTwhhlFXVSdbcXD6ZDJBjx2+0o9NmVE3j YxYPLy4SdC05KCQBVYWshk06AcuxvJXU5Q7usg4x5yAwQR5/E//gszHhIgXrWGGxxNll t++5zgpGljMGFyxnP+PSmLKz2BDPFW2dGiCll8pNVJIRResZV5qhYNw1jbeUQvd89K3e PeDAkNn6xxqxP4h0FFNKmtWCdN1ncBe51W6IRIjFgwQwFH39MQ/T3EtXwa80YJ0T1Uf2 n9t3NDWzds5W5F8I/3AnSSQoGF45bpI3gLsBGADiv2Pcgl9huMxzbZT8SSQGp0xK3Hgu AHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=OlbvQ38xyZhR1pva7q+q80Q02GqbyPEePCP4ft47vxs=; fh=lpVtxw16JFFgCinc8IdqH9Q9hIslsKALiYLxIyo5uqw=; b=QnPnFbwaglKM5iIy8uL/U54o0je7uuM0ofEi1YzEIbvSBqGFSykVLqT3y4BR9XiE4n 3xqLzzAL92hBFO6Y53WrKFYDc67My0X5apGX5C8L26etWbu4wgb8HRt3iok+ajwjJfKd To4dDWIXqoJpT8F3xFjHAmEIjH8GhDmAMK90uGpxvF+GiqWsuBSaNmEoF37CbIYODlKF YPmZlgS7/IA6OZFD7J2xKjkuVCKwLhlcQnu2oDyIwwb9+jDqC42lA00om9mdMRIkxOh4 +oEzBuSPY7IuyGSAolXmg0pvfJqprQNhN0giqtVwf67tLmo/+tSQyg/eK9NUnD4ikZJT HImw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Nvv2ZLkl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id w12-20020a170902d3cc00b001d0513ec98csi6592365plb.224.2023.12.04.16.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 16:01:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Nvv2ZLkl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8102F807503C; Mon, 4 Dec 2023 16:01:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343594AbjLEABS (ORCPT + 99 others); Mon, 4 Dec 2023 19:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343604AbjLEABR (ORCPT ); Mon, 4 Dec 2023 19:01:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7253810F for ; Mon, 4 Dec 2023 16:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701734481; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OlbvQ38xyZhR1pva7q+q80Q02GqbyPEePCP4ft47vxs=; b=Nvv2ZLkldN//nfuqGPfhEW3Ya8LdsTWvRrUIQ3cd6g9Nzhph4MLmqyvhi2coHtRcvcEqcE Jj+jt2065FzRQiSU1mfCt832t9uCWIVCNlq/Urjr18eibr4Br0SXc/malDioGkRlOXhHW0 ZbvLZ7rWCKAK6v7L5/gTEP5invcU7+s= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-WSAa2u0RPVCJRA7obutnQg-1; Mon, 04 Dec 2023 19:01:19 -0500 X-MC-Unique: WSAa2u0RPVCJRA7obutnQg-1 Received: by mail-io1-f71.google.com with SMTP id ca18e2360f4ac-7ad60469181so342502539f.0 for ; Mon, 04 Dec 2023 16:01:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701734478; x=1702339278; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OlbvQ38xyZhR1pva7q+q80Q02GqbyPEePCP4ft47vxs=; b=H14UlpXHbCKQbsuKYgswXfLvn6oouzv+yaiNdPTd2MKTA9BL778pJuvfrH1cDtCY7R mwKbajzTE4c9AxD8iIQyKXsgDCo0yGpkuDyVpwguFisYv40/xGPKns8j2qwLYsbnlSHK fw23jNrpas46DRZV0PrdIuqyrf44Ofv9/BfdWbjsAznoprX9CvzPpRreJTdK319o+z9+ YfO6QW/k7V7O+zYTGYlhbPmlnTqdARd1Cp+yk13Fmn691JzqWBUVcS8uIG87pYK+chgB vFR+dRRzVrMCXkVRCOIRW5lCQ3PuFzoEv31U1Wh3i8yK9CzhlqvsCXABPCad+dcm1SLe a17g== X-Gm-Message-State: AOJu0YxifFBQF1r173jk47zuo6kXfxt/WGPmLlETGX1durc7ZxAUa5O4 jss9hlKPLLW0AotSAhNPJCV4YyppmjJ3frDbj4dAo6c6xtHrd5RW2qVcOc8iikYKcaN2kzvAIRw lBXOpYC524tXrjAtYdtioPwNc X-Received: by 2002:a6b:c541:0:b0:7b4:5ac5:9f15 with SMTP id v62-20020a6bc541000000b007b45ac59f15mr395516iof.11.1701734478702; Mon, 04 Dec 2023 16:01:18 -0800 (PST) X-Received: by 2002:a6b:c541:0:b0:7b4:5ac5:9f15 with SMTP id v62-20020a6bc541000000b007b45ac59f15mr395512iof.11.1701734478445; Mon, 04 Dec 2023 16:01:18 -0800 (PST) Received: from redhat.com ([38.15.60.12]) by smtp.gmail.com with ESMTPSA id 22-20020a5d9c56000000b007b35043225fsm3092323iof.32.2023.12.04.16.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 16:01:16 -0800 (PST) Date: Mon, 4 Dec 2023 17:00:52 -0700 From: Alex Williamson To: Pasha Tatashin Cc: akpm@linux-foundation.org, linux-mm@kvack.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vfio: account iommu allocations Message-ID: <20231204170052.5967e9cd.alex.williamson@redhat.com> In-Reply-To: <20231130200900.2320829-1-pasha.tatashin@soleen.com> References: <20231130200900.2320829-1-pasha.tatashin@soleen.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 16:01:41 -0800 (PST) On Thu, 30 Nov 2023 20:09:00 +0000 Pasha Tatashin wrote: > iommu allocations should be accounted in order to allow admins to > monitor and limit the amount of iommu memory. > > Signed-off-by: Pasha Tatashin > --- > drivers/vfio/vfio_iommu_type1.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > This patch is spinned of from the series: > https://lore.kernel.org/all/20231128204938.1453583-1-pasha.tatashin@soleen.com > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index eacd6ec04de5..b2854d7939ce 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -1436,7 +1436,7 @@ static int vfio_iommu_map(struct vfio_iommu *iommu, dma_addr_t iova, > list_for_each_entry(d, &iommu->domain_list, next) { > ret = iommu_map(d->domain, iova, (phys_addr_t)pfn << PAGE_SHIFT, > npage << PAGE_SHIFT, prot | IOMMU_CACHE, > - GFP_KERNEL); > + GFP_KERNEL_ACCOUNT); > if (ret) > goto unwind; > > @@ -1750,7 +1750,8 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu, > } > > ret = iommu_map(domain->domain, iova, phys, size, > - dma->prot | IOMMU_CACHE, GFP_KERNEL); > + dma->prot | IOMMU_CACHE, > + GFP_KERNEL_ACCOUNT); > if (ret) { > if (!dma->iommu_mapped) { > vfio_unpin_pages_remote(dma, iova, > @@ -1845,7 +1846,8 @@ static void vfio_test_domain_fgsp(struct vfio_domain *domain, struct list_head * > continue; > > ret = iommu_map(domain->domain, start, page_to_phys(pages), PAGE_SIZE * 2, > - IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE, GFP_KERNEL); > + IOMMU_READ | IOMMU_WRITE | IOMMU_CACHE, > + GFP_KERNEL_ACCOUNT); > if (!ret) { > size_t unmapped = iommu_unmap(domain->domain, start, PAGE_SIZE); > Applied to vfio next branch for v6.8. Thanks, Alex