From patchwork Wed Jan 10 20:40:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 187069 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1043865dyi; Wed, 10 Jan 2024 12:42:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEckxBlMMdqPPlxIAEZFL+DahPgi5UEjmCx/gKJbtSbAQ5tp8Jo25uwnRs2OPr6jhSy1M8/ X-Received: by 2002:a17:907:3c0f:b0:a27:af7:bba5 with SMTP id gh15-20020a1709073c0f00b00a270af7bba5mr49549ejc.22.1704919379711; Wed, 10 Jan 2024 12:42:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704919379; cv=none; d=google.com; s=arc-20160816; b=cUmdVlX2tCNZo1uMuFQcSFCbkw5J7qNONOM07T0tpYnUy8fVBUR2nsnYZWza64b6yZ a7RktB7syuQYTw0NYEJKMEvoNtOPQ3TVI3ShcKyJpcNFfrGlAY1geoSlAXHM//1n97X8 CF8mzIVt7TScX84QqrR4L0iPG7NfWRaZpDgaWtal2BF91iaUphPis6iCVVuaAAlV5l2x wgZiChAL+iArd5fIf2/JYoKF5SyDFE2OPB9KlgHtwknYJoz9nV0dyG2wk5T4Gw/K6oZw ZZrLifkS1QdtbkWzhhrNnmhf5ypMOh8RJUWBUDyqJVBeFvM+Mg/MsxSI2CDemN+EP2at RtgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=942sXqvaN/YRz+5JZ7VDvcQeVeKMBRPm66kgeJtsQ+o=; fh=NLOUc4UpZ/0A9JrieYT9bxhjFpxay5qeZXON7PgxqoM=; b=JtecE5tKTr3rDUNJ7KDE09511rEeE5Z47A0G1AnMSaASZ/lYZjd1rGL5WNJYjuWGbU +dNT9WVkLooQuhkI4t3p9r11y80/wWOCAwiZnXwOSMMy43EyV+cIKm1nS7pqySeBt9L3 O1IKA7nuJcuXrVNZcCLhMf5HjWCqT+Fz9MGb/0ccFSMmxncb9wpg5pP9RG5h89cyCcZD LUqfMbttxYEvM/bTZY78BQpakXbg+4NlvXXFcPzgU4qdrHFU200RIFIPVSV9W4n2Nak3 UDI9tnjg1wydNIut3dEd32aab1U490qO/DrIvqdnNu09jk09tPWzS9jN0SB4P9096vFx lIpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=gCI+N7HB; spf=pass (google.com: domain of linux-kernel+bounces-22755-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22755-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l16-20020a1709061c5000b00a29b8bce8absi2014670ejg.1039.2024.01.10.12.42.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:42:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22755-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=gCI+N7HB; spf=pass (google.com: domain of linux-kernel+bounces-22755-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22755-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 53FA01F232AB for ; Wed, 10 Jan 2024 20:42:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 571C94F88E; Wed, 10 Jan 2024 20:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="gCI+N7HB" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 508734EB3A for ; Wed, 10 Jan 2024 20:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40AIEK96001454; Wed, 10 Jan 2024 20:40:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=942sXqvaN/YRz+5JZ7VDvcQeVeKMBRPm66kgeJtsQ+o=; b=gCI+N7HB3jkpEu0c/s6uCDQ75z+yo382dhvlRZrT5FmVjpxye0UkkQZ6GkWmJCeYFUW8 R2Ua0vSSzXXu+RLwBAvC80fTLUurym+q9pENZG8oPGAT0Q+DOy6in3hIsCMK8fyQCmYf A+R0DLmB1ohxf7TGxMXAaGILQCJgqj3lXZRcEt1S/MUmlcINlk2rfTGO2gq351y8pUhJ YuDgmyIgN/ZygHNrYK3AzkYM/WQ21b3tvZPlJ9tG3J+HHU3eJl57ZyaJZnVP9YBHFfUN 2pzBRNAw9kbnnU0PmYMcu1FUFz/tNCm7Iys0cNoW1LmUNkAhrrnsXUvvFBuhGZrdyYJ4 zw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vhvgm8x67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:19 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40AJGHj8030139; Wed, 10 Jan 2024 20:40:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vfutp5x74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:18 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40AKeGrR005067; Wed, 10 Jan 2024 20:40:18 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vfutp5x5e-2; Wed, 10 Jan 2024 20:40:17 +0000 From: Steve Sistare To: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Si-Wei Liu , Eugenio Perez Martin , Xuan Zhuo , Dragos Tatulea , Eli Cohen , Xie Yongji , Steve Sistare Subject: [RFC V1 01/13] vhost-vdpa: count pinned memory Date: Wed, 10 Jan 2024 12:40:03 -0800 Message-Id: <1704919215-91319-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> References: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-10_10,2024-01-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=985 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401100163 X-Proofpoint-GUID: MBKjZoLFFMSDreR2dbLPd74JjlZNwlV9 X-Proofpoint-ORIG-GUID: MBKjZoLFFMSDreR2dbLPd74JjlZNwlV9 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787737543301895235 X-GMAIL-MSGID: 1787737543301895235 Remember the count of pinned memory for the device. Signed-off-by: Steve Sistare --- drivers/vhost/vdpa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index da7ec77cdaff..10fb95bcca1a 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -59,6 +59,7 @@ struct vhost_vdpa { int in_batch; struct vdpa_iova_range range; u32 batch_asid; + long pinned_vm; }; static DEFINE_IDA(vhost_vdpa_ida); @@ -893,6 +894,7 @@ static void vhost_vdpa_pa_unmap(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, unpin_user_page(page); } atomic64_sub(PFN_DOWN(map->size), &dev->mm->pinned_vm); + v->pinned_vm -= PFN_DOWN(map->size); vhost_vdpa_general_unmap(v, map, asid); vhost_iotlb_map_free(iotlb, map); } @@ -975,9 +977,10 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, struct vhost_iotlb *iotlb, return r; } - if (!vdpa->use_va) + if (!vdpa->use_va) { atomic64_add(PFN_DOWN(size), &dev->mm->pinned_vm); - + v->pinned_vm += PFN_DOWN(size); + } return 0; }