From patchwork Tue Dec 26 18:28:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13504961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6805BC46CD3 for ; Tue, 26 Dec 2023 18:28:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D96A08D0003; Tue, 26 Dec 2023 13:28:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D46BC8D0001; Tue, 26 Dec 2023 13:28:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0DCC8D0003; Tue, 26 Dec 2023 13:28:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id ADA998D0001 for ; Tue, 26 Dec 2023 13:28:32 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 845A74023E for ; Tue, 26 Dec 2023 18:28:32 +0000 (UTC) X-FDA: 81609804864.10.99FA860 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) by imf18.hostedemail.com (Postfix) with ESMTP id E8A421C0008 for ; Tue, 26 Dec 2023 18:28:30 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=h741mqW8; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.174 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703615310; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=iVG9ArmoQ15xyAc+yxUrO+uyL/lDfCQ7yjtpIzOf96k=; b=zXlNNY5S6QJpFD0BXvJR75mgGr/GhfsepKcX6p80qxFkcaBmlJjbmbpkKESq1Sfb5kL5Yh my1ANdSzz8VVnS2iswvqMyOTyikYBY2/0lqAZc9CvB0+p7hRiCErXAE6w6USQbVe0sfTNY eVVb4WIca+uNRKPzpwlrrn47dSZmNVY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703615310; a=rsa-sha256; cv=none; b=RVHgNhX5Dy7VMac8T7hjrGfk0z7pbA5b+8fXPOTjUq0TNjB9SCktl+QzIn+AdFwJWjyIaV 0E9+C1IxsEZ9UK2ZCoZZGLmmjJeEUYTf3BWXCOgAaUowdMSUSI3VgTl1CaKktJeoic3Mae XWPoo86gXNOxSC8w/tfCKpxNRr0gIWE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=h741mqW8; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.174 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-427a3887483so36581971cf.3 for ; Tue, 26 Dec 2023 10:28:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1703615310; x=1704220110; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=iVG9ArmoQ15xyAc+yxUrO+uyL/lDfCQ7yjtpIzOf96k=; b=h741mqW8k54IU5bihOR9PU+xnDHQIwh6olBqJmQVLZGaFw0AoeXRogbMlrKT/w8MuO JrcbS/BxyuayjTvGy2/q6mdb86dqYY2JMwehYXIrs2LSwxicWHSpDkMjMgAuv+jpke73 dkFqV69taM1VQ5Kq+CBJoBTI9iq6Op98YOWzkjHpTgM1cqc4y3tKvKTgFflwK9qWvjj5 uglhQsLiQtBjQtSFKFD6dW5KXdiHkvH9noI1vz+kBL93mcwRoGjtuWqPxdJT0pxJJDoW USd+X1jYisY7kyj5upL/l0gMayW+U6PCnMFFOAQMYBt6seFeKs/Kjm/xmVIYlaCtLsro CM+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703615310; x=1704220110; 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=iVG9ArmoQ15xyAc+yxUrO+uyL/lDfCQ7yjtpIzOf96k=; b=wHX6vQZpZMtDzPUdzqd4XmdyZ9oXuXfWWUuOh9O3q112DG1T1FQZoU+caExmMFjh6+ E00pHIAG6mAVDm2YLkhAdEcNL+YGldZ1iFsX4yd7PVlxZIEYsRIg1VnG38g45r7wWHy9 t9+OR1i0lYNSVHNHruT5aGmKD7Ie15wvC4H2VcTMqkRfYB1NWdPpVBmCIAu1U5TQmxtU zCqLnWVaoHJ3AJHNGWNqjabuB+5a2XysRuT0TxIaiCK2OYZw0wefu0jVBKr30T5EP+A4 gFfc7E5pEnOlvUNBo4Ijq+B7GZ3Cww+qqx8YU3NRShtACQh9kdUtVINLtnaK+wK0kpMo WghQ== X-Gm-Message-State: AOJu0YyvdwsIkOXZlEfneYmEEJs+PB3TlU3gqXnLEXgPP83qpmG4SvRy qaIk9UVNM5e/TX+EJnbf/YYjdJocXnpC/oyPWUgXbe7Y1GY= X-Google-Smtp-Source: AGHT+IH95QHCHc+3GftDlCRw6iuKFmHCYQ8XAfaQiziiu2P452x5R8wFRpdo00E2wU0m4vpqb5AUoA== X-Received: by 2002:a05:622a:1817:b0:427:8376:a2f with SMTP id t23-20020a05622a181700b0042783760a2fmr9360806qtc.99.1703615310169; Tue, 26 Dec 2023 10:28:30 -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 cf23-20020a05622a401700b004276963b28asm6274675qtb.15.2023.12.26.10.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 10:28:29 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, linux-mm@kvack.org, pasha.tatashin@soleen.com, mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, rientjes@google.com Subject: [PATCH v2] vhost-vdpa: account iommu allocations Date: Tue, 26 Dec 2023 18:28:27 +0000 Message-ID: <20231226182827.294158-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog MIME-Version: 1.0 X-Rspamd-Queue-Id: E8A421C0008 X-Rspam-User: X-Stat-Signature: enfpu4cx9e8w8t645qyop57cqerdded9 X-Rspamd-Server: rspam03 X-HE-Tag: 1703615310-639598 X-HE-Meta: U2FsdGVkX1+OWBKFees7JjV8VSGZJutZVQXdFaw0IVT0cHyTIo4JgTF92PaH7IYwQtESmk/ST4yIHNMbYnRXiiJ8fHuKaPe9yZc09e4sIv0hxevLLKkE0uxcGSy+saTUMJ3L0mjpjHu+ZWvB49hkZ2LDb7b1llQ+bEG8nyNFDRpx9MMbEbIwiOHlaI+JuH5vRsRdchk389nXmTigDrQ7qCooEDF1cNX1LWsmnRK52Xlvx5ehTLjCVtmgai0DF3ljJ50Vob15ayC5h+j9pb8EBrwQfTPvcTFuk1ApX/SEvd66FKY5kZ5IyBA20ZwOiHC6T6K6qwG0KnY8IMqO9Ny2R0GaDK3jSFYydFi2tY3p8oh0pye+3XSnAT8hSprod+jE0iALyKz2cCh+hpBPIFVx1al6UsYyWWUuFsBlwXKTkZvV5iGrIVe9TFMe6u4O0OLqulx1ZkUvBuwbCHd0So5CoWxGVxNqO90TeLHCsYYwVhzP6B9I+/mjeK4wv0Sc7xCK5vkUze957exKoIJ2KRotacNVNDdSj1sG2TR27Sz+nSye/GwJilGyrgIKdRo8RcHzolWkUS/Pcp5XrBaF62nX9TnBL17HIKE7D5Kz8PvgUu3Ix+MzywBkHcNLkr4WD9g/WRC0x8t1uOw6HpI+CE1HTGMVpiuCH5AbGhhFQGrx7cVMj6UgGqz5GNGjujpw4xbJCBmE3uOjYGVoGzgvgWrAjiUPLe/Ab+57RcuDOZqGK401BE+UCC00EG51hwOt8igs8yjo6t2dM+h9zFD5LfJC2pHZJUGgQy1TVY9R4LnzEyFvQNsgp5TnCHWfH4+2Yf+fewhtmJKvVdaB/VzA7xfXCgHy/9wq7/RKoIfkIVmuRdbHWYvZ4mlZjDKuU5ZtDbFte0IjaIf6YqqqlKGXDlADShWQKXL5FrtvWty7tsU8ndEQdQSNgy6UFtdoaVJhfGYPYMKyJPlmUbIfFXD0MUq koCJ3dcn UF2lgBWCcM9K7kAhYKFwOUQarTpdn+UB2CJcnqM7qxqIxuba4kRp/g/vJRTw8K85RX4tV5Dvp1f04gMDZXuW2oOhDnLXruKxNvRBeaAet9D8gv8lEv2wgqh7MKTUt2H9E1I0TMOHQ783v0OpqPAb2n+b0IPBvms/jGPU2slQP17NUi1wAYQUHpQCwRu8z9ZDHyuwepN/oCeSv7zDEvHkeb2jYIj3KoKOSZxnNGZPYCKEopuJjGoyu8cN44OWJ52/FW2LR06+iPmRQbwhhPqJxo1WubixY/UBUwNHsHmfp5k9B0F33nUyGGPRuDE+xciYDQ92MKTq5FsPUU48s5Mc5MjpmGu88VAOreAioQOKblrJp5EQjB1SYmKKY2KpAmtRuuJRit+XGop0xUOZI+thK5bk8Mh3kReqCSA2+N2gtwTcjrJJZrBoFc6O1liIN98+PdgH8gX693fmdnI8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: iommu allocations should be accounted in order to allow admins to monitor and limit the amount of iommu memory. Signed-off-by: Pasha Tatashin Acked-by: Michael S. Tsirkin Acked-by: David Rientjes --- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Changelog: v1: This patch is spinned of from the series: https://lore.kernel.org/all/20231128204938.1453583-1-pasha.tatashin@soleen.com v2: - Synced with v6.7-rc7 - Added Acked-by Michael S. Tsirkin. diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index da7ec77cdaff..a51c69c078d9 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -968,7 +968,8 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, r = ops->set_map(vdpa, asid, iotlb); } else { r = iommu_map(v->domain, iova, pa, size, - perm_to_iommu_flags(perm), GFP_KERNEL); + perm_to_iommu_flags(perm), + GFP_KERNEL_ACCOUNT); } if (r) { vhost_iotlb_del_range(iotlb, iova, iova + size - 1);