Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp573110rdb; Thu, 30 Nov 2023 12:09:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdlUG1dN50/MLTIGLFaQaK2xFJDkYeDuCJAPHNmr4CoxY5Poujwv5aPKN7uu0JdQrnoGS1 X-Received: by 2002:a05:6a00:6ca8:b0:6cd:e4a9:9287 with SMTP id jc40-20020a056a006ca800b006cde4a99287mr4034442pfb.8.1701374958447; Thu, 30 Nov 2023 12:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701374958; cv=none; d=google.com; s=arc-20160816; b=byE4BqEqxDuh9djpoyXBR9kTarW4bHOGAiC+k8hHgHDwa/DBinCYmxdBlqJecdyh7i R+B7bTOUsEHVBDmaSStkugaLXedSx1gGHCWLXu12gZqhPug/pZhiLvF5e4FGCVtsSdgT DqoNi2o+tlmxcK+j1+IGBOA85at33LMQgYg0dfJJcRCKNG6LDqkuHHM3VPmBTkSjcMg1 aAA3lFcP3ONmbT5ESSlx7MLew2ViwUZIMnz7tFKlIreApsPcxEC4f30PwhI7Tj9J2yuA 4RV8Wfdp1Cqgl9zmgeMOU6bcuPc1Cbc3ZmL0BXpQdpZ9L/3aueSaR7TZsZQAACcR+cHj 4RQA== 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 :message-id:date:subject:to:from:dkim-signature; bh=Be1KAg53A/Objdu3EOp617iDWrhswh7WogUdBagnrZg=; fh=Pk1gAwJ9gS4bETXEWkUIqWgrXnicpEh0VpKzU+pb8OQ=; b=YehugdOo4vhQtSK5UB0KsrcShDB9vmBOrTEcJBndfgVcbIXDNIrj1X1qWVLK60ZgAi VFn56rHDUhsE/PlkgEsTvnjtETjjwMeWjUSPpP8COd9I0ZkPlGMM1182aqQjKRAegx3n UZ7EfDSfZJn428RnmBjvm58wz5uxRKnlfe61nPNRt4xfXYuZCw+wXCA6PRW5/LmL7yLJ 5etQ6gywcguOiLSIbnOhcWxYzublcKQsGL5AyE5V34i6ESzu9O1KwbTPGIyvbj9RVk7D xhjX3S+4gbbqUSlygyEOYVh6V7vz6i68Y73BejvD7aNwxO0v5yCh3utf4KF5dZ1ytO1g 32lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=b5FIJOpV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q14-20020a62e10e000000b006cde5496ab1si1764220pfh.347.2023.11.30.12.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:09:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=b5FIJOpV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 58D0B801B893; Thu, 30 Nov 2023 12:09:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376597AbjK3UI7 (ORCPT + 99 others); Thu, 30 Nov 2023 15:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376564AbjK3UI6 (ORCPT ); Thu, 30 Nov 2023 15:08:58 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 728EB1AD for ; Thu, 30 Nov 2023 12:09:04 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-41cba6e8e65so7776431cf.2 for ; Thu, 30 Nov 2023 12:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1701374943; x=1701979743; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Be1KAg53A/Objdu3EOp617iDWrhswh7WogUdBagnrZg=; b=b5FIJOpVYc3V2YCNIasCpGTREL3vAWocW8+79kcTkTMx0nfDV+HD1T2xJmBet1i9pu rVyOq8XG7n6Y/YO4R9V6zuM9DjmwvNKMyeMoWrsmjDuN3tINbzflZJPjwVf+jr4PbdZa yukFQo/OaZti3gowl5KJ5X3bJHheD0ukYFVwvOlxjgip4PrdFNyJAZajeCT1qRgZHCpo Ria6nd/mH3TdWGxB+WsXFnBUSNOLBMzlkjOF4waX+eeEAC6dcHAA1b9aylAVkWsGekpC 4/LqhrdnoCeNX27w376QS/KneCBtzpm67TgBRyPc1Un7CiwmwzpDC9OHN+EaTjmTqEm7 9mBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701374943; x=1701979743; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Be1KAg53A/Objdu3EOp617iDWrhswh7WogUdBagnrZg=; b=knhTxD7uodUcuq18n/25PoI7/KyoZYeYnKBqnmvU5FNA2RHQxAAyebmPjEkTJHv/Dl wdxdNFbg4JedkjQ86b3v3faeTLcv8m27wFsFhOatyq0ylogiODk/xmCMPgjX7vzczkGq EyBW9mqCSIzSOV+FOPmbjj0stXmMnSwx4RSF+G6GUVAmL7tl2VVsuoHYSJ8RzMYCQgQn qRNt33XBKZ1BUaVhSEH80WYT1MMShWbg6MA3MeXjBE/Q+xPWucWNqnS1tajatW1bDOhm ETBu3lT/+BrgmtICn7ALILSz+4e8xD0mZcNCF3Rf9zoNK/TN/jhB7JDxXV0XZgmZmKSs PLFA== X-Gm-Message-State: AOJu0YzU+HxEIx6MZMTE5g8UVHxut+wL4tI2mCrW9Jm7hO2+Qk5tTG7e JOc1/ToQLdfvkwUqqi0ydXYRuBtIhpKYmj+L9MM= X-Received: by 2002:a05:622a:1389:b0:41e:1d15:69a6 with SMTP id o9-20020a05622a138900b0041e1d1569a6mr28803241qtk.31.1701374943507; Thu, 30 Nov 2023 12:09:03 -0800 (PST) Received: from soleen.c.googlers.com.com (55.87.194.35.bc.googleusercontent.com. [35.194.87.55]) by smtp.gmail.com with ESMTPSA id c7-20020ac86e87000000b0041cb8947ed2sm786258qtv.26.2023.11.30.12.09.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:09:03 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, linux-mm@kvack.org, pasha.tatashin@soleen.com, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] vfio: account iommu allocations Date: Thu, 30 Nov 2023 20:09:00 +0000 Message-ID: <20231130200900.2320829-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 30 Nov 2023 12:09:15 -0800 (PST) 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); -- 2.43.0.rc2.451.g8631bc7472-goog