From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796072024; b=UDHlic9mGo0fg8LnjqQRhOcc4YichZz0F6khmUeK1MmVFY17FaSFG9yYVetWV/KOis3g 8hVyRg9RWI6uCh+4Q//t4/6mSNgvncameVd3oKDduWSSbXGJC2F4PumVG7WdTIvzR66gV if0O6U60lpqEUVG4XCycgHfgCM22qm+7D4qX3DmS0jEu0FL/EoPg0bkbdwZPjQS2VEGXX l1E6F2rNGlgNWcoYLGbEHtTX89vR5JhXpMzMNtUY94L+Lq13pTBORme6yLB+VVI2wrgMy At0baq8gkYGLBUkkLtXUMaxsXbq6+vYx78NQ7ow1rOwRA9JGhCK/H8LAS/pd5WA8i6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796072024; h=DMARC-Filter:DKIM-Signature:X-MC-Rep:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:In-Reply-To:X-Mimecast-Spam-Score:X-Mimecast-MFC-PROC-ID: X-Mimecast-Originator:Content-Type:Content-Disposition; bh=YFTuGuy29WzkLdHoKOJgEGrF9uqq1gG6CGPl3+dEQnQ=; b=BVcmR71tM0urcDeujJKpEvw3Q64t8xz7+ZLT+rC7KBihuotQbeEWecgxw1v18eAOGx5n uxfY1Ot1HcTD8kFnPScLFWKPfHylmashqbT2lu4DFVZdA9ipxYkZdA5zC3tjif1OM7FKJ bL4jIVDfB/zueuIeDcTpGiZ2NIAb6wQu9CQUnLj3D+6gxRUskoqdWKi8popMl1PqVgvlj A34cXoUpfl72+AH0HMyuLWrP1PFbRa1HPrFaRfTl8fKQ256SARmKMebAE6I/TjZbwRqBf PXB37mZcLkNHuaGAJXeogK821jXj6ioDdEHNQTJyaJhYJvGo8pEASi1NRctKwRguQsQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b="cZrn/PBq"; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D935A606A31A for ; Mon, 30 Nov 2026 20:53:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D935A606A31A 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.a=rsa-sha256 header.s=mimecast20190719 header.b=cZrn/PBq DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796072022; 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: in-reply-to:in-reply-to:references:references; bh=YFTuGuy29WzkLdHoKOJgEGrF9uqq1gG6CGPl3+dEQnQ=; b=cZrn/PBqq6eERSPtvhfO8GKj8OvnufZSYBBufq2jJBN0ar0TpCh5AxOZVFX7CKEfFb0p3d xHHtGCssN+t9VlB3m9hUp4+k5iWIRK+ueVP1yI4saqhidS/bHGPminxUqSdbnYRojJclxd KY+9ZRospvaSoKKp1FrOCmqokqC+Vy8= X-MC-Rep: binary re single Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-_gw4hHlnPEqqxc2M9yDqkw-1; Mon, 30 Nov 2026 20:53:40 +0000 X-MC-Unique: _gw4hHlnPEqqxc2M9yDqkw-1 X-Mimecast-MFC-AGG-ID: _gw4hHlnPEqqxc2M9yDqkw_1796072019 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48c6a1d4034so6514271f8f.0 for ; Mon, 30 Nov 2026 12:53:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796072019; x=1796676819; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=YFTuGuy29WzkLdHoKOJgEGrF9uqq1gG6CGPl3+dEQnQ=; b=e/2ESSsDGQ2sN5g5pAtlHtEXXrqGhaAEmORnrNKN4z+jooL+qq2rLZqFAbOvQPbrrH PLczVt+8wv3RLCdxOj/xUwHgm4gPJ9xn/+PI5pFHvSEWNi++hgu6eCfEFOw4K1UZtS2O 872JZ08u/H5psJvDjuAytOUy+iZVRzpb18nIegR1yio+fc7I/o8Un5WnL/zu+Fx3PZxB tCJL64kXLAMadE7zq8Nv8j36xnb05niCk7O1RbXLRz6tmFAZTS2RdGsmMF8pmbrdEuCT 22FGddLvtEE17kH4+NHLSpT326ZBPJrG8jrUJb5kNZw59cdUAB7T+lCCOgPhTChC4jtQ YiKw== X-Forwarded-Encrypted: i=1; AL+hErEUhZKrn2fFQ7tBkKtpn8fAdO5yifwZSTwQiN76bpRCrwlueF0TlHe7gtcASaT++hqLsuR9RVu48wJXOPh8PA==@lists.linux.dev X-Gm-Message-State: APuU4Z8z9QyjQFkwiJO8g5siaZO7osb1A97ppcUpQvYZC1u9IpZfQWJG rTF0KoVIBPPSQUnRg3zQAqeTiaOsnZ6K062POi97w5DYvggia7qdI92Hc4JD0DmGwrKy3IemUg7 iSycxVNvbl/fX4VIcz7X6fsrGrZQ02GKhWuENwf/aDdru/BuQ10FIvOSn11/UYGnUgM2W X-Gm-Gg: AZFdTZdeW4zNpLcV8CcY/UdhXgbPkSAossF7scHtJdrMyvLCJ8BNNiPZbWnkFDv5Su0 9RF/n99LCDLen93xpGMzpmxDPbP27zsCE/Z0bmCXEgpFimIPs2UViLBSbFttu564PLyYYahglaM J/cmBIFie4YVbc1MXSMeSyYA3UV/4xCrTae7MN153dxQfua+mqk9JC+8xJ0e6I7sgxKlnfoHdgQ jPy7bEIDS0IHXMtNpzy5Ae0KkYYdfZeukunlyqh2V5GVxg6o+/EMHnwOKPsajLf2meJDHYZQmvW bgyrZwUQ1sHT3Er/mkAWJUEN8OrslkL4ltNaopPYV9E+RGvTdQACLy5r3u+piSCsNnc29NCTi3a M3FUPA394aDYCozEfx5f2HtxwIUV6wblRseycUd+zrP0= X-Received: by 2002:adf:e014:0:10b0:4a7:7bec:e159 with SMTP id ffacd0b85a97d-4abb400bb4fmr49857240f8f.15.1796072018670; Mon, 30 Nov 2026 12:53:38 -0800 (PST) X-Received: by 2002:adf:e014:0:10b0:4a7:7bec:e159 with SMTP id ffacd0b85a97d-4abb400bb4fmr49857220f8f.15.1796072018054; Mon, 30 Nov 2026 12:53:38 -0800 (PST) Received: from redhat.com ([2a0d:6fc0:1529:2e00:86ec:bef7:c309:ba1f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab69bf630esm68495419f8f.16.2026.11.30.12.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 12:53:36 -0800 (PST) Date: Mon, 30 Nov 2026 15:53:34 -0500 From: "Michael S. Tsirkin" To: Dragos Tatulea Cc: "eperezma@redhat.com" , Linfeng Sun , "virtualization@lists.linux.dev" , Jason Wang Subject: Re: [REGRESSION] vhost_iotlb: bound map allocation in add_range breaks vhost-vdpa on hosts with fragmented memory Message-ID: <20261130155200-mutt-send-email-mst@kernel.org> References: <0f51918f-88c9-4930-ae5a-616bbe73e7cb@nvidia.com> <20261028085839-mutt-send-email-mst@kernel.org> <808a6e4e-085d-4723-9489-f17f023949c0@nvidia.com> <20261028110041-mutt-send-email-mst@kernel.org> <20261130121224-mutt-send-email-mst@kernel.org> <847d703c-2a77-46d3-9fa8-365072af627f@nvidia.com> X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 In-Reply-To: <847d703c-2a77-46d3-9fa8-365072af627f@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6OUpCpZGPXMD3XS0lbfF4LsbubNYrDHWH5WgYZBHRBI_1796072019 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Nov 30, 2026 at 07:25:25PM +0100, Dragos Tatulea wrote: > On 30.11.26 18:16, Michael S. Tsirkin wrote: > > On Fri, Oct 30, 2026 at 02:47:13PM +0100, Dragos Tatulea wrote: > >> On 28.10.26 16:17, Michael S. Tsirkin wrote: > >>> On Wed, Oct 28, 2026 at 03:46:05PM +0100, Dragos Tatulea wrote: > >>>> On 28.10.26 14:05, Michael S. Tsirkin wrote: > >>>>> On Wed, Oct 28, 2026 at 01:44:30PM +0100, Dragos Tatulea wrote: > >>>>>> Hi, > >>>>>> > >>>>>> We've started seeing regressions for a while in our verification CI for > >>>>>> vDPA Live Migration tests. Occasionally the FW returns a syndrome > >>>>>> related to invalid mappings during device reset. > >>>>>> > >>>>>> We've narrowed this down to commit 1ed35ac7f3fe "vhost_iotlb: bound map > >>>>>> allocation in add_range" which limits the iotlbs to 2K by default. On a > >>>>>> host with fragmented memory you can get easily more than 2K entries. > >>>>>> This results in truncated/incomplete iotlbs mapped to the device and when > >>>>>> the rings happen to be outside of the first 2K mappings the FW will complain > >>>>>> because it got addresses that are not mapped. > >>>>>> > >>>>>> I'm not sure how to fix this though: > >>>>>> > >>>>>> - LLM suggests setting the 2K limit only in VA mode and using 0 as > >>>>>> before in PA mode because PA mode is limited anyway. Does this > >>>>>> work? > >>>>> > >>>>> Well no, we do need the limit in PA mode I think. > >>>>> > >>>>> But we should maybe bound from what's actually being mapped rather than > >>>>> a fixed count. e.g. X entries per pinned page? > >>>> You could have many 1 PAGE_SIZE mappings though. It wouldn't help > >>>> then. > >>> > >>> it still mostly is 1 entry=1 pinned page > >>> > >>> sharing is possible but uncommon > >>> > >>>>> Bounding by bytes instead of entry count is another option.How to get this limit from userspace though? Would RLIMIT_MEMLOCK > >>>> be an option? Although `ulimit -l unlimited` would need to be > >>>> capped to some value... > >>> > >>> guest ram no? > >>> > >>>> > >>>> Also, if the entry limit is still there some kind of precedence between > >>>> memory and entry limit needs to be decided. > >>> > >>> I'd steal a page from rlimit then use that for the entries, when out of > >>> that - steal another page. > >>> > >> Do you mean something like this [1]? > > > > I worry about poking at mm internals like this. No nice helpers > > to use? Maybe add some? At least pls Cc mm people. > > > This is a rabbit hole I don't want to get into. This issue is similar > to the old issue when the user didn't tune `ulimit -l`. The only diff > is that this is less deterministic (depends on system state + config). > > So basically the user always has to set max_iotlb_entries to some > value. > > >> Remaining questions: > >> 1) Is it ok to delete max_iotlb_entries? Or keep it initialized to max? > > > > then we need some other limit, no? > > > >> 2) Is it ok to delete the module specific max_iotlb_entries param? For > >> example mlx5_vdpa_max_iotlb_entries. I don't see much use for it ... > > > > you are the guy for mlx5. I thought it bounds some other resources? > > > It was added for mlx5 CVQ (wasn't CCed on the original patch). > I don't see why it should be different than max_iotlb_entries. > > >> 3) Shouldn't the core or the driver track holes encounter due to > >> incomplete mappings? It would be good to not give bad addresses > >> to the hw/fw... > > > > Big issue is userspace isn't really prepared to handle > > mapping errors. > > > Right. So let's not go further with this. The user will have to set > the knob accordingly. Do you disagree? > > Thanks, > Dragos I don't know that users know what to set it to, or even get any guidance about that. Can a failure in the middle maybe fail the whole mapping? -- MST