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 4BBEF346FA0 for ; Tue, 9 Jun 2026 20:08:19 +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=1781035701; cv=none; b=DOV0aS9tVs8met4FuBWINDPlwZsIyQ50mDC0QbgGa115kycjPXaq9zukgx8/uAJo4cwchsCl/ryZzMx7vKNytnD8TCJ2HcM33Bj+/aHDxWGoeFkg79q8WEibDdEkuWg9xrRsTHTjM7TQyImH2FPoa+Lkz3Pi8UVVMoNFqhq0Qpo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781035701; c=relaxed/simple; bh=aRhTNbcdgNaPA36R/O4/F4M3VXSutv6ZmcYauBSyGgc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VBhPUtUW5iqiSZmzj/nYggeyh4IayR0G7RRt0zwGVIawPdyJbCgWvuY3dirxAPNICa/8adoeTGXhOSJ5e6te0m1NYUt6FSLnxAw3+lBtnJL+HyILaMyzviSJxAz2W+VHg6L7yGLwiZvFUdtbsE2TvGwFHOGV+QaLdeVTuNxEj7Y= 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=Y6L2DFGO; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ISeLQ7bo; 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="Y6L2DFGO"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ISeLQ7bo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781035698; 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=zl9Z0aJ29Hn9v0DTruTbP6W/2+UyB2iIzr0q5S84UYA=; b=Y6L2DFGOB5ovTYac4Ib5Mo5Ppk5YBvCkO0WgQb8r+OoqYmyG6Il3qo3HFb1cFSPjhPXYMG R4v9z8QZmDpPkiIdzvv+92vWxhODPrXkci6bjHrMbUHYltIQhCtuvZ4FSPUSzpr5bWggbq OZIfrXtB5oRI4QuLTefdE1GmxUHl0XI= 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-59-8_w-lNBcNw2PYjfZ9FNXGw-1; Tue, 09 Jun 2026 16:08:17 -0400 X-MC-Unique: 8_w-lNBcNw2PYjfZ9FNXGw-1 X-Mimecast-MFC-AGG-ID: 8_w-lNBcNw2PYjfZ9FNXGw_1781035696 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-45ef93c359fso4853745f8f.0 for ; Tue, 09 Jun 2026 13:08:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781035696; x=1781640496; 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=zl9Z0aJ29Hn9v0DTruTbP6W/2+UyB2iIzr0q5S84UYA=; b=ISeLQ7boQxA5siPfriJQBUIh+QP4eOjaeJJkbsgjqOFJn1odNbxxSTzvFjU54nxOuR K61OBO6UWN+qmyP5qc74DIa01ADEEIHwVEy+6Dk+SKVIp1epYj+sbCyPGvvAs5U2FZvR yv2y32raQ77+PWaVVAx9487wXDiPWptyAH1Qnkh3HYN/C0sUjMYWkpM0PSgE9n3pd2Bz wfIXiljclLW4hSv6RNAPHAOWqsYVsMyRdDbyB19ukHiQaeKuu9MEk8QYbCuA7laX2zhv rCYXl09O//xFcMdobsNkUpHz8OKVz/ROmcPcu4jCanQmveFoloOysg2nJ9e4htWkScSj W+VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781035696; x=1781640496; 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=zl9Z0aJ29Hn9v0DTruTbP6W/2+UyB2iIzr0q5S84UYA=; b=oXXrNyWQ+msp+HAlKwrKe2A3TNWkVkMSN8rCsgJZmVjkZ7pvQUgmtrmg7Emo5ddDkV m43sEjM1pjo5vyemIyRhcAbXCg8EXjxez9GdEc+UXSWOGr11vhk2qAw45sIeTcv2bBW9 DfDb59fD/4A3V6jRu5pVLvoy2Xar2wffuB4DvgrwMLR+lanjm2xNoP2CX1K6Q3UDMUFY zRiNbhkTuSK1nC3HLZx4JxMPwh/1MoyPB6B6GGs3ETq6kPNNEkGo2LymGM8+5pclXoQb aG1b7ik7x5v/o1oPpgjYnBrFw26C9VA+whB0qdY/I07RZG/1Wa5/B17rJAJaVt29ggMq pX4g== X-Gm-Message-State: AOJu0Yzyvko3WDqmWdz9d41p43L6c2IDoVijMxgQlp6Dm24tUVdsrWLC yrrrjgljb9+n+Rs+Cu5rbc8RH60Gg+qGw9XeCLeug+U2V7nLK8pa7a2ubHOYVkysgdGjBKJ7Hx5 g4K1KldXtRyVhFY0pwBvWaWukzXztia7m4/nMY4ddiAKtYJG/GnUbvGnLfgR/RlWDAQ== X-Gm-Gg: Acq92OEqaJqYMtYWRYIvMs3HXc9Rrw+6XdFxACRHEArpM55eL4qlPauM/nYM9Z5neHT lzEAF+9zw1G2Jjknaq2rlTpxip+wgkrIQMO4yW75BN/z+1uiKe5WzOmaEWRLfaEisTBQ5UKcopz PGVrBND9ji2ndwKgDbMDePkTgQtnB8FdgRvSL4z01qkXdHJFwhEbrb+dE2Ytkt7sQvjuQ9O9TFo UCJPn1/W9XXxiPh1tVZ6mBfqfux5IuqKkdfNKNOsERnnoNA1/Y364uZG3VqEgO+KpIVO1uXrau/ iHamEgHCPt41u3DbHBZjRqvbMkvBoZuHWKSsflPGloiarpQ23aKdQ2Qn4vVX0Y+ax2FsrehHNrY PjEIjXaE1526DT6lzDVaihPftkLon7zeMZSe7J77ajjxRqbQZCeLpjQ== X-Received: by 2002:a05:600c:8216:b0:490:c2a3:23cf with SMTP id 5b1f17b1804b1-490c2a323f0mr333475125e9.34.1781035695674; Tue, 09 Jun 2026 13:08:15 -0700 (PDT) X-Received: by 2002:a05:600c:8216:b0:490:c2a3:23cf with SMTP id 5b1f17b1804b1-490c2a323f0mr333474535e9.34.1781035695117; Tue, 09 Jun 2026 13:08:15 -0700 (PDT) Received: from redhat.com (IGLD-80-230-85-71.inter.net.il. [80.230.85.71]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f345209sm68785532f8f.17.2026.06.09.13.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 13:08:14 -0700 (PDT) Date: Tue, 9 Jun 2026 16:08:08 -0400 From: "Michael S. Tsirkin" To: Gregory Price Cc: linux-kernel@vger.kernel.org, Miaohe Lin , "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Muchun Song , Oscar Salvador , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli , Naoya Horiguchi , Alexander Duyck Subject: Re: [PATCH splitout] mm: page_reporting: allow driver to set batch capacity Message-ID: <20260609160506-mutt-send-email-mst@kernel.org> References: 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: On Tue, Jun 09, 2026 at 01:44:37PM -0400, Gregory Price wrote: > On Tue, Jun 09, 2026 at 11:53:20AM -0400, Michael S. Tsirkin wrote: > > --- a/mm/page_reporting.c > > +++ b/mm/page_reporting.c > > @@ -174,10 +174,10 @@ page_reporting_cycle(struct page_reporting_dev_info *prdev, struct zone *zone, > > * list processed. This should result in us reporting all pages on > > * an idle system in about 30 seconds. > > * > > - * The division here should be cheap since PAGE_REPORTING_CAPACITY > > - * should always be a power of 2. > > + * The division here uses integer division; capacity need > > + * not be a power of 2. > > */ > > - budget = DIV_ROUND_UP(area->nr_free, PAGE_REPORTING_CAPACITY * 16); > > + budget = DIV_ROUND_UP(area->nr_free, prdev->capacity * 16); > > > > Initial look - is there a div-by-0 here? I noticed the old check > prevents this from being (0 * 16), but i don't see (on first pass) > the same check anywhere. > > Unless this line below always forces the above to be a > PAGE_REPORTING_CAPCAITY if it's set to 0. It does, does it not? > > + if (!prdev->capacity || prdev->capacity > PAGE_REPORTING_CAPACITY) > > + prdev->capacity = PAGE_REPORTING_CAPACITY; > > + > > It's worth making this corner condition a little more obvious. > > The code intends for > > if (capacity == 0) > capacity = PAGE_REPORTING_CAPACITY > > but that's not reflected in the changelog as a default value. > > When happens if a driver sets (capacity=0) either on purpose (???) what would the purpose be? if you don't want reporting do not register. > or > because there's a bug (???) exactly ??? since where are we practicing defensive programming in kernel APIs? > and then page_reporting.c forces it up to > 32? > > There's something to improve here. > > ~Gregory So I'll update the commit log to mention PAGE_REPORTING_CAPACITY. And maybe a comment near capacity field? Should be enough? -- MST