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.129.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 8FE7F420882 for ; Mon, 6 Jul 2026 13:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783342804; cv=none; b=MCxPLNjuFiGTvbXyPyvKO2mpjCAiD6UsfYiCgl0E6Rs1nPdlRtf2STC+vCsVA+7+qo9nQZ7e80xx13sjPPJzC9bOkolJ2WqpwI3jgmfR0KHwT7oSCQ+moxWIwRcbRugG/j1/QjEJdoAa6RQZ7FK2bufr7d0Bh2iqKJqFNLou93A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783342804; c=relaxed/simple; bh=3u09jUh7gLp5iv+UmhDqp0BEuE3lOYgqyKuJNhryqts=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XLTKyCJlYWP9dXrqxXtx8AlKk0fBFueUc5kkLMUaHPLDE8udKFYdSh+kHFgvQS6/lE0g27bZ5yIPF9qFgAxU8ZnltBKD72Y4WdJpqGFBlbYd71FBMLb4g141GvUz+QPYnccTN8Va5rKFdyMx1OhhGih7s4rdDzU2yT0O1pjbNm0= 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=KRmcX5dr; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=C8vvXXDQ; arc=none smtp.client-ip=170.10.129.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="KRmcX5dr"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="C8vvXXDQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783342801; 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=GV9yo9jBEBI28o7XznZuNHujDFZwTfJarP6O8dyD09o=; b=KRmcX5drb3QrsIMsOUZ3+JwbPN1H5Suv5EgvuEltFq0DLWd3agG/R9jtkIM3FiT2yX2hK+ 0/J1QbluleKrlteihoo2bGJWA87kuIl58M8kFqP242GkFb1WLitjnVybiuTq7yHxtH6RlI 9j3S06KwNPBRfEds42i/ztG8K6061gI= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-T9so3fLVM4u1qdEVt-L16w-1; Mon, 06 Jul 2026 09:00:00 -0400 X-MC-Unique: T9so3fLVM4u1qdEVt-L16w-1 X-Mimecast-MFC-AGG-ID: T9so3fLVM4u1qdEVt-L16w_1783342799 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-470cb859d96so1538046f8f.3 for ; Mon, 06 Jul 2026 06:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783342799; x=1783947599; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=GV9yo9jBEBI28o7XznZuNHujDFZwTfJarP6O8dyD09o=; b=C8vvXXDQtGqIUq0pg5ZVONSF0tRJxHuhmToWb2Z1SSjVK8G1Qvrx6qSV4gpWI9vF1q HwvyYYdnBKEz/f8GITsw/icGvQKV9LoptRdjW2O5dSsMEVXg5efJuBhcPDMiCioh7oui 8+rlhK6SemL1BuHsAVIQJ0mWVtUUJ2g+pzy4y98maBYfWRPFzp+bvXcyOhHhx0cpwSmP eRc2uQurmogOW+s+73F+e6CaY0Rz/giK7fGk7xkNFTXT+o4/RBbA8VguEynE9gLUhVE9 5+MJe6IW8K1VTzIgV5KPzTXBRsSk0pQ3/mRAGT9cGpeHUzj8ajza/G6C2g3Sqapb0nYH fMVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783342799; x=1783947599; h=in-reply-to: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=GV9yo9jBEBI28o7XznZuNHujDFZwTfJarP6O8dyD09o=; b=hmeW3mCpCSa058pzTCU0hkpuM9LamnnDoMIPEqpDNh2oGsq1dTZFW2BrOY1ObpgNmu ZcURXmAUjUfWBCJJ1/mW8rGgc43agp3He+ev49DtMBXxW0ohRq06SCqhoX1CJl5Vo3tX GcZYKpBjTnfou8uDneXheu+LGVfRhOe+ofp6+7jCKBGEXXs4lmJqh7GgvOYt9zDg9h/v 9thjMvegl9T+q/jAnjxEaD4HgtgBLWjuYRbe7i5lR4r4qGkpRGyKOb1r3PXHpf/yEN6s 7HSgndojKyj3Dj9Lp86zSgKkLnqnxVvSa9qOuPAqTRHYUsM/ZAMNgwylj3KjwuxQ5AIc SPbw== X-Gm-Message-State: AOJu0YyeDhCi/ZBd9I/gLDh5ea2mam9Zhiqxxv937ZoRL9qD9z0s82By 8ARLWNQ8RiZYep8L0DYwbK5VIzTit2tpKOFaCrmofRi2O9L/EvFnm/L9FXzFeV0RMJua64P+Ria zSvHN3FcMovpjHHFiQRwnHLlmnZzuk4dJ3OpE64ZK1stm/cN/URr+4ZA1s92PEhLWjg== X-Gm-Gg: AfdE7cmaPGOc62/nz5FymMxdQI+fC7J+zl4mhrrU71g3YXSgZ/ziTezx83ekjzzCYM1 FHr0/Ex2xHkwDKPuTtgdBwB2rJzkwmISjMkPpKjsEzuK8FFyxr2RLYiv0Ef0GFxizZHLZ6h9QYr JxoDzlEM4cRgGLuKVyv8dhIXz3kDDSeZKgOpfmgTdC80QPjIIJK1tpBoo+oOZYLoawZalPncCVW JchxFLCTd2NeCCPjnRSxw6VOLIRTLTaIcz2BNA32Gu6Tm5g8z4Bvn149KQ8/7vSUmtRvmidUKX4 h0Jncg/TPXzF9LnQLHLGndVfdpR5pa216R7WPLIudW5T78RFN1xvmvv+P/eXIJtQL+qFObEFMqV oEbcpDiez/izUvQk6cQfUDHo0xZaD7Typ X-Received: by 2002:a05:600c:a00a:b0:492:7142:f46e with SMTP id 5b1f17b1804b1-493df038767mr4416475e9.2.1783342799067; Mon, 06 Jul 2026 05:59:59 -0700 (PDT) X-Received: by 2002:a05:600c:a00a:b0:492:7142:f46e with SMTP id 5b1f17b1804b1-493df038767mr4416205e9.2.1783342798623; Mon, 06 Jul 2026 05:59:58 -0700 (PDT) Received: from redhat.com (IGLD-80-230-68-31.inter.net.il. [80.230.68.31]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493ccdabda3sm287154295e9.5.2026.07.06.05.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 05:59:57 -0700 (PDT) Date: Mon, 6 Jul 2026 08:59:53 -0400 From: "Michael S. Tsirkin" To: "David Hildenbrand (Arm)" Cc: linux-kernel@vger.kernel.org, Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Adam Litke , Rusty Russell , virtualization@lists.linux.dev, Andrew Morton , linux-mm@kvack.org Subject: Re: [PATCH v2] virtio_balloon: prime stats vq after virtio_device_ready() Message-ID: <20260706070936-mutt-send-email-mst@kernel.org> References: <2f0d0de033f3005d3b985883be3e5cf37b3f6c42.1783278596.git.mst@redhat.com> <13794c5e-375a-4fc5-84b4-a637d077f8a0@kernel.org> <20260706042207-mutt-send-email-mst@kernel.org> <6b8e4ad3-6909-4d0a-89a4-104a5ad9fe79@kernel.org> <20260706044122-mutt-send-email-mst@kernel.org> <24336f56-1024-4c9b-8653-b1a4658b627c@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <24336f56-1024-4c9b-8653-b1a4658b627c@kernel.org> On Mon, Jul 06, 2026 at 10:57:33AM +0200, David Hildenbrand (Arm) wrote: > On 7/6/26 10:43, Michael S. Tsirkin wrote: > > On Mon, Jul 06, 2026 at 10:38:18AM +0200, David Hildenbrand (Arm) wrote: > >>> > >>> Yes. > >>> > >>> > >>> Why not? > >> > >> I was wondering whether the spec would state something about that. > > > > Sorry I do not get the question. Virtio API expects > > callers to serialize calls for each VQ. So this just prevents the work > > from running and accessing the VQ while probe calls add_buf/kick. > > I'll add a comment explaining that. > > But it has nothing to do with the spec. > > The device is clearly not properly initialized yet. > > Yet, we expect that we get a stats_request() callback that would try to > queue_work(). And IIUC, the stats_request() will be directly issued by the device. With an in-spec device, it can happen right after virtio_device_ready. We could defer it a bit, but I don't see what this gets us, and this also protects against any out of spec ones. > In QEMU, that would mean that balloon_stats_poll_cb() runs, which would do a > > if (s->stats_vq_elem == NULL) { > ... > return > } > > virtqueue_push(s->svq, s->stats_vq_elem, 0); > virtio_notify(vdev, s->svq); > > > That's why I'm confused :) First the spec says there could be interrupts for no reasons right after DRIVER_OK. Second there are situations in which qemu might consume a buffer without a kick and then an interrupt races with the kick. > -- > Cheers, > > David