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 82CC078F2B for ; Sun, 5 Jul 2026 08:34:47 +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=1783240489; cv=none; b=M2cJ5jvmmazP3/TYO3fWzddzb+kbXZuwAQdFuckdMV5FdC1NlkWkfTkR5JUyHEULVhyYbygvKTntvvI3XxN6WfKENsRXUDYXIQJmoxipvPmNn6mUF84I0hB+BoiVCKaT9UzXJkjzbt3zWqXGh1XC6VzjmHCibW5RHef72zE55HQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783240489; c=relaxed/simple; bh=aGklt9XfhyATNt2V3YXMXkU651KsIQi+Pol1FGyc7ig=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OLHREa4D+07PihpQjG92VkoXvYt+WnVhxLC0/KKPTC/hBo+Kl+MYAXew8yL+lwhUVq39AIbIDQpFBkQJgRGqcZpF6tVZZeqXjzx+b9QsR4VkvxAp/9v+58o7LrRGARvesAaDDSgJ+9pGm/2sWaWCKLly/tO+BJUR4CdMLYQ7Gq8= 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=UM9x/Rw1; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Hd9Xmk+8; 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="UM9x/Rw1"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Hd9Xmk+8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783240486; 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=hpyyGnCmoaU77sn+Ro68vpJQoBqTCnGGK+pBiKnHXwc=; b=UM9x/Rw1EsHhyasN/XqBqCW85BrjqV6ewTXJCgG1UHHhyAUGPmjiPJt2CpNsKmimOHM8jp 5u6qdMlf9dxRzzPFh1qWGl/SaTDSQJjyoroCHgIraL7g/ADhA+JRK5TP2gibdis/dIfCrS dNKKDigkoOctOQDyHc1c8wrwc4nA+VY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-aMURiZ25PVesJI1doijTRw-1; Sun, 05 Jul 2026 04:34:45 -0400 X-MC-Unique: aMURiZ25PVesJI1doijTRw-1 X-Mimecast-MFC-AGG-ID: aMURiZ25PVesJI1doijTRw_1783240484 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-493a6fe9ebdso9049745e9.0 for ; Sun, 05 Jul 2026 01:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783240484; x=1783845284; 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=hpyyGnCmoaU77sn+Ro68vpJQoBqTCnGGK+pBiKnHXwc=; b=Hd9Xmk+8nncmPAVzqp8Tl/nhbmYfde49J0svNQeVvkX9PB/bkjTfwUlEThuUHycQon oL5qgoJx6vheb5V7Z6DhD5FlqILGcU87j5KyxxbjYAhfDdlxHqozPdThdQBgdgjdDkPz adVc1OdOx+30zyEEhaH9rPKe/e2WbkcyT3/h148ROP32Va9H+I4C1c112AvCTcmUuUrr CbSe8+BGiywSU6WcFnYxuYnd0o6ncwhVXxDPnyBtZv8xckLrhoMcMPx3M3A4UFRy7ssH d1afppi2+ndvSxrfur5zVYH5Ni7TeMHdonDhmenxvfeT3fa16trzl6WiJWz6LuqzFKxQ iUHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783240484; x=1783845284; 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=hpyyGnCmoaU77sn+Ro68vpJQoBqTCnGGK+pBiKnHXwc=; b=QFRIIjpFARR6XrHyt2zsAppu86CHBAkzBiRGNc+S5dE2dlsz5WZa1knxUpTJHFMlyP RZ3Jx7dS914IjZ/NXnmX7Y4SEL+p0e1ZC6tS8FPfh0ZyNDadyJqWCo+sJYYFNMl2IMkq WfmZzQ9US5ptf7aK3Nt0c8h9QAFH/GEp/gezWjMzLq109jkRvr2ZzeSxxCVKt5p61lkn +FjX3e8tVsBZucjM/C8Am4+V48mQHvaOO+sHi/XCB/Y2knRF/QTsrQktx/+4zVzcB3+z kkk2ht0wdieFbufEF5Pp7izXDSlZDYO5mmySQ+2JHfKsQSyR4EzNLhdaD0depi8RcbIG DSqg== X-Gm-Message-State: AOJu0YzogYdP9JNsZypz+wQrKapmA3BLbHRQ6f5YIghF51/PIkKYIFgC HEtZmbmB7U8bdeX4EUWsyRcPeGr/N79MJyVyI86k3k/r6G1YwqgmzTukqnFACoknsYTEzFnyG7L SNbgKaUqa8xTpPlUAClrl3LfayILF1Fu5J+XLfxWxUt6ZYMaUTTa9nGEWmwVEG35eq9mthL1BCw == X-Gm-Gg: AfdE7cmpPU+TsYpjNyUWlN2Rw45+KAobeVi90gdE5kbuNGnZer9TxosrUYX54VO+PDv 5eHVpZzP6vljbiFeQvn+saAFHf/39x2AppKmCe+XbQoinIFzSGQD1+I9bdHBqAdeCZKtDdYcMWf YzluXWUoKv8CFlo7yJOIvaw0X9BypShONizFaeN8eVdLPtjZcJQ88b2hE9xmp02WNNv+wJiQwKE cRPeG6wl+QmKmw2qY8k1RSRrJXaPBdoodqk+6Buo2clmz8pPiCXyDlHrfZEmOKLXDdOA33ngQSW 0rpUkBDihAIkyQh8Tysah3/Ra/qoOhEQA0xKNGWGd5ywPtYKOL6r8PT2/SbMb+ANLUVt19KulcL OTBpLNEcERo/IvkmjvwdZICjEi2pBq0+j X-Received: by 2002:a05:600c:1988:b0:490:688b:f9f8 with SMTP id 5b1f17b1804b1-493d11f8067mr71136115e9.27.1783240483668; Sun, 05 Jul 2026 01:34:43 -0700 (PDT) X-Received: by 2002:a05:600c:1988:b0:490:688b:f9f8 with SMTP id 5b1f17b1804b1-493d11f8067mr71135645e9.27.1783240483110; Sun, 05 Jul 2026 01:34:43 -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-493cce1a844sm177749835e9.15.2026.07.05.01.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2026 01:34:42 -0700 (PDT) Date: Sun, 5 Jul 2026 04:34:38 -0400 From: "Michael S. Tsirkin" To: Andrew Morton Cc: linux-kernel@vger.kernel.org, "David Hildenbrand (Arm)" , Gregory Price , Zi Yan , Pankaj Gupta , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Alexander Duyck , virtualization@lists.linux.dev, linux-mm@kvack.org Subject: Re: [PATCH v3] mm: page_reporting: allow driver to set batch capacity Message-ID: <20260705042708-mutt-send-email-mst@kernel.org> References: <444c24cf39f3f3620fc90ef4695bd6b0979f4c4b.1783232420.git.mst@redhat.com> <20260705011635.9974cac7f0defec9961e85c4@linux-foundation.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: <20260705011635.9974cac7f0defec9961e85c4@linux-foundation.org> On Sun, Jul 05, 2026 at 01:16:35AM -0700, Andrew Morton wrote: > On Sun, 5 Jul 2026 02:25:13 -0400 "Michael S. Tsirkin" wrote: > > > At the moment, if a virtio balloon device has a page reporting vq but > > its size is < PAGE_REPORTING_CAPACITY (32), the balloon driver fails > > probe. > > > > But, there's no way for host to know this value, so it can easily > > create a smaller vq and suddenly adding the reporting capability > > to the device makes all of the driver fail. Not pretty. > > > > Add a capacity field to page_reporting_dev_info so drivers can > > control the maximum number of pages per report batch. > > > > In virtio-balloon, set the capacity to the reporting virtqueue size, > > letting page_reporting adapt to whatever the device provides. > > > > Capacity need not be a power of two. Code previously called out > > division by PAGE_REPORTING_CAPACITY as cheap since it was a power > > of 2, but no performance difference was observed with non-power-of-2 > > values. > > > > If capacity is 0 or exceeds PAGE_REPORTING_CAPACITY, it defaults > > to PAGE_REPORTING_CAPACITY. The 0 check and the clamping is done in > > page_reporting_register(), before the reporting work is scheduled, > > so we never get division by 0. > > Thanks. What's the priority here? Should we fix 7.2? Earlier? > > It seems that Sashiko has found a pre-existing issue, a hard-to-hit > error path thing: > > https://sashiko.dev/#/patchset/444c24cf39f3f3620fc90ef4695bd6b0979f4c4b.1783232420.git.mst@redhat.com > Ugh. Yes but it is a minor symptom actually( This is the root cause: virtio_device_ready(vdev); if (towards_target(vb)) virtballoon_changed(vdev); return 0; DRIVER_OK set almost the last thing. But, e.g.: if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { struct scatterlist sg; unsigned int num_stats; vb->stats_vq = vqs[VIRTIO_BALLOON_VQ_STATS]; /* * Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later (it can't be broken yet!). */ num_stats = update_balloon_stats(vb); sg_init_one(&sg, vb->stats, sizeof(vb->stats[0]) * num_stats); err = virtqueue_add_outbuf(vb->stats_vq, &sg, 1, vb, GFP_KERNEL); if (err) { dev_warn(&vb->vdev->dev, "%s: add stat_vq failed\n", __func__); return err; } virtqueue_kick(vb->stats_vq); } this happens before DRIVER_OK and it's quite out of spec. All of balloon initialization needs to be rethought and fixed. Maybe. After coffee. -- MST