From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 ACADA350D4D for ; Mon, 19 Jan 2026 09:39:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815567; cv=none; b=V4w5zg+s5xJgdMuDR/sVIsfQYRAI5Z90j4kMrHro+GdbbhOtPBBT1q6XvJyQKFvPRKm8VS2xAX9b8BkOc0dbX9nhK25iWNXkIvx62mNaTbRIUpNgCxM0QyK2wypg5oYIHXI+FIUFjTiSYw1W5TMfsh0Tkk9c8QPvp8zdyaPPh58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768815567; c=relaxed/simple; bh=PK23E4LbAZyB80y9PT5PlqOxzIUOmcAumiKThlM4djw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Jbm6ABTJBzB6xN7cVGyMgL60G9108cz4rxlSK8STDOnTaM5X0DS9ZTXcY0myglouJIZIPID/B9ffZmBDlv+PUDl6SWdDXZZfe7wYM3xVGBfFODpMa8DCa0A8g9CKxREnqjaHotjf5vHTjaPUYFCeoX1Uzbh3Atl4jj/MQtTMkzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=KE3UozL3; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=QQbBvmAs; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KE3UozL3"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="QQbBvmAs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768815564; 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=/3GM8FPdhRriZq6AO20diaaV+30mJHwkaKlJ0PtdWcA=; b=KE3UozL3qS/mhljDInSOsLnGIGaU9cVWFpel+3XlLer7X4cgpIl+BILk04IoNpregobO/N Uzr51xa98wldgSorNNhxlH01jVLQyXFgUyoZGEM2dAvJZ6cIR8oi1wZFuhhOIkJ1QJ3FFn KBPXFQLaGfFIoj0XhSLJpkjG9VVbj2U= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-ZhwcEGTsNH22j5wJd-ToNQ-1; Mon, 19 Jan 2026 04:39:22 -0500 X-MC-Unique: ZhwcEGTsNH22j5wJd-ToNQ-1 X-Mimecast-MFC-AGG-ID: ZhwcEGTsNH22j5wJd-ToNQ_1768815562 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43102ac1da8so3448873f8f.2 for ; Mon, 19 Jan 2026 01:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768815561; x=1769420361; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=/3GM8FPdhRriZq6AO20diaaV+30mJHwkaKlJ0PtdWcA=; b=QQbBvmAsumskmUS+GXE2qW32gDOj6l0n6nYjdKBR832vwIbe4uU3RONtU+KuJ08cmK /nlUqT53mLJlcCwrZ2Dq3Tvy0Vj65pv0JY6Kq+mT1MnPCj2FgHErB7w9t3IiOzilRhA1 W5uIXbZ6XOEhl1HbA4Q8n/OLOAgVF63LVkkhaLoFItDY7KHafN3OoXyc34ntIuXD213z pzYNbAKt+r6DyI9RgzJPSSOJJ9BhJvk+Ak2RBAI2NxNEM1lRqF2K499nFTxlnVlaZL6f FpF4NfNUizhFlCojeSQSmd2g5yx+KPm6TtpuKMRpjNOD5oLXXcqqsvaXrRhK/+TtZ2HL NtwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768815561; x=1769420361; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/3GM8FPdhRriZq6AO20diaaV+30mJHwkaKlJ0PtdWcA=; b=aLvq9mWQg5CtMsf7QRRIM2VWO70oyV3uFbojMbhI09iNp9PPT5af5o6YORgFLeyPlM XVIQpNUREPsv7GHbEHZ1CW3lzt6r+qP60yBmJMzU4QdJIfQkbQWwXYGNhhoq3M/JPPVL t7b9xHt+i05QtgQC9hfao+IwZg05WGrMlELKgQc8rIPWKsGOhLIkNk/Ju0YsHNwpDgz+ qezqTqilUONwGnwOxEZGuY4elWFHjceeq220lgJKlEsXo5jRFiN+d91ob6t/zSVXn/sZ 31/6XcBLYXBaJ2C2puqe3mZEjpViibOPA76pUhZWHJoZWsBidMBv99lStG2dkC2LYrn4 /KBg== X-Forwarded-Encrypted: i=1; AJvYcCWwfg3rpK3zzTkv2E4bvIxoA232ww44uulgtOYfFwGqsgz4BtyPJOFdHwln3OcKCT1ZpliaOWPmyEkyYWo=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9P2ry7opsk62MMDFhj32SekRmwTspgA3zYHTtFjqBH1ZEjFHR w9aOebaSmEAyQ3AnTCbnFDGR+FqPN7PCHU/kSIscugLyM0WwYuZupbzPpSVNgk1Heol2bgTFP4N xgQSi50Gqi8FpYqsjtBzz8VQxNHuk88m9Rw4IL1FoVoZuWXoXzYqbhqvH0TcKu2wB/A== X-Gm-Gg: AY/fxX4wwraBcqYzTrUbKdVzzhfkIt+wuQhz4lsx5Ab5tcwnrD+0vOdHsgDKuFfH+U/ LIedyTunOBESujj0WuH5ywzhtd0LrshZ+aMQhZx84UWoIHNVPX/V+M4zZUrAK0i0lYW899F/UE5 AWPl3E3OKFbycyzCYmqGinKU5HuSJBKVJIBOC31jlCCtiLNl2+Z2GQ7H4hPBx3wLk3mLQazUfPd U/H2ablUcGISrbrTgxwjWxQd7dQu8whHydi5+n7jp0kppXYAhkCaImnUJI5E9bKcI1kcPGz7sAP XRBW+9AoaSZKYyT84/ESgLxYpAGT9g6HuoL4UCgnaUdgOdiYjY9P2KDAA515olQrXG4DkQT3yMf Vz5Cx1ILKuuG5R13iYWZWqX3aZ0K1gfg= X-Received: by 2002:a05:600c:3114:b0:46e:4a30:2b0f with SMTP id 5b1f17b1804b1-4801e348326mr132243715e9.29.1768815561277; Mon, 19 Jan 2026 01:39:21 -0800 (PST) X-Received: by 2002:a05:600c:3114:b0:46e:4a30:2b0f with SMTP id 5b1f17b1804b1-4801e348326mr132243355e9.29.1768815560841; Mon, 19 Jan 2026 01:39:20 -0800 (PST) Received: from redhat.com (IGLD-80-230-35-22.inter.net.il. [80.230.35.22]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4801fd3bcd2sm84408095e9.1.2026.01.19.01.39.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jan 2026 01:39:20 -0800 (PST) Date: Mon, 19 Jan 2026 04:39:17 -0500 From: "Michael S. Tsirkin" To: Jason Wang Cc: Eugenio Perez Martin , Laurent Vivier , linux-kernel@vger.kernel.org, Xuan Zhuo , Maxime Coquelin , Cindy Lu , virtualization@lists.linux.dev, Yongji Xie , Stefano Garzarella Subject: Re: [PATCH v14 11/13] vduse: add vq group asid support Message-ID: <20260119043804-mutt-send-email-mst@kernel.org> References: <20260116140455.1560491-1-eperezma@redhat.com> <20260116140455.1560491-12-eperezma@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jan 19, 2026 at 04:34:11PM +0800, Jason Wang wrote: > On Mon, Jan 19, 2026 at 4:10 PM Eugenio Perez Martin > wrote: > > > > On Mon, Jan 19, 2026 at 8:17 AM Jason Wang wrote: > > > > > > On Fri, Jan 16, 2026 at 10:05 PM Eugenio Pérez wrote: > > > > > > > > Add support for assigning Address Space Identifiers (ASIDs) to each VQ > > > > group. This enables mapping each group into a distinct memory space. > > > > > > > > The vq group to ASID association is protected by a rwlock now. But the > > > > mutex domain_lock keeps protecting the domains of all ASIDs, as some > > > > operations like the one related with the bounce buffer size still > > > > requires to lock all the ASIDs. > > > > > > > > Signed-off-by: Eugenio Pérez > > > > > > > > --- > > > > Future improvements can include performance optimizations on top like > > > > ore to RCU or thread synchronized atomics, or hardening by tracking ASID > > > > or ASID hashes on unused bits of the DMA address. > > > > > > > > Tested virtio_vdpa by adding manually two threads in vduse_set_status: > > > > one of them modifies the vq group 0 ASID and the other one map and unmap > > > > memory continuously. After a while, the two threads stop and the usual > > > > work continues. Test with version 0, version 1 with the old ioctl, and > > > > version 1 with the new ioctl. > > > > > > > > Tested with vhost_vdpa by migrating a VM while ping on OVS+VDUSE. A few > > > > workaround were needed in some parts: > > > > * Do not enable CVQ before data vqs in QEMU, as VDUSE does not forward > > > > the enable message to the userland device. This will be solved in the > > > > future. > > > > * Share the suspended state between all vhost devices in QEMU: > > > > https://lists.nongnu.org/archive/html/qemu-devel/2025-11/msg02947.html > > > > * Implement a fake VDUSE suspend vdpa operation callback that always > > > > returns true in the kernel. DPDK suspend the device at the first > > > > GET_VRING_BASE. > > > > * Remove the CVQ blocker in ASID. > > > > > > > > The driver vhost_vdpa was also tested with version 0, version 1 with the > > > > old ioctl, version 1 with the new ioctl but only one ASID, and version 1 > > > > with many ASID. > > > > > > > > > > Looks good overall, but I spot a small issue: > > > > > > int vduse_domain_add_user_bounce_pages(struct vduse_iova_domain *domain, > > > struct page **pages, int count) > > > { > > > struct vduse_bounce_map *map, *head_map; > > > ... > > > > > > /* Now we don't support partial mapping */ > > > if (count != (domain->bounce_size >> PAGE_SHIFT)) > > > return -EINVAL; > > > > > > Here we still use domain->bounce_size even if we support multiple as, > > > this conflicts with the case without userspace memory. > > > > > > > I don't follow you. My understanding from the previous discussion is > > that the bounce size is distributed evenly per AS. Should we just have > > a global bounce buffer size and protect that the amount of added > > memory of all domains is less than that bounce size? > > I meant we require bounce_size / nas to be the size of the bounce > buffer size of each AS. > > But for userspace registered memory, it requires bounce_size per AS. > > Thanks I don't really understand what you are saying here, either. Could you explain what your suggestion is? > >