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 A1CAE38C2A9 for ; Tue, 9 Jun 2026 22:00:55 +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=1781042457; cv=none; b=YjV2ij3zVgfEn7sAZiS1+Y+Grusj45BS69ahAzg91Ji/PC6stNVRnltjuz4nwIMuYFp4/+ujgHvf0BPCx/fuZZF6EahwPGXrbFOHz1I4c76//VyhSQ2ArB8TcosaH7mHhTlxEccIliwMqAAc1eQkcV5ey0ImUTXv9m1snwY2R0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781042457; c=relaxed/simple; bh=NZCVF6uuDzwGVwSqQjUsmpGpjI4eZDHZSW3uzzeX8tQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lE1scsyd2M8pc35Hox7UU1IfjD3M9i6YeG+o7PG2S7LHIradgmot3ADMi2zaQ8p0MpR/pJoSuOtLD9yhRU8+g0YYRdkZnR2YytUvi87z6OfrUyM6SPsJAwO8gt0eLyrVP/L0JafAfI4WVtbrSdxN8WjB9TADdBuEP/VmKn+nBd4= 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=UayPz2NW; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=nQ313D4T; 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="UayPz2NW"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="nQ313D4T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781042454; 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=9i2Af7K5yNSnpzmJpY557qOnqur0hKTAqhtHYtV96bo=; b=UayPz2NW6FZYp4db8AnroV1mcXxhU8Gwxi2oBCeiZuv1914x7EMGH4pTT4UEpolEFSWnHW RFW2GSRTqkeEb67d1B+1xe1Upl8klmWcHtvLifuBlmlV+KA/uH8y4tfPqaS3M6uA4ly+T+ Ls6sQ9KbFm6SOIm+9gndRcNeT/tHy4M= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-248-syCATsQlOHqgwu2hGo0bGQ-1; Tue, 09 Jun 2026 18:00:53 -0400 X-MC-Unique: syCATsQlOHqgwu2hGo0bGQ-1 X-Mimecast-MFC-AGG-ID: syCATsQlOHqgwu2hGo0bGQ_1781042452 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490ae3bcf4cso29001875e9.3 for ; Tue, 09 Jun 2026 15:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781042452; x=1781647252; 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=9i2Af7K5yNSnpzmJpY557qOnqur0hKTAqhtHYtV96bo=; b=nQ313D4Tywo8Vcig9JEzORcVR+b7R+v2ilBIY4s9NLj5GNP/NrnvC6cQ1UV9LuqFjH KulmbSq5D53LVcOZiK0dBP9avC+WdhvVoyXgm1dIp62Dmb/um6zYKvd0FbPnA5+dGHpU m0GR4abb7WuP8I2+OOZ5jsgEovIeclsIJIrr11s9+eEYUnCGRRf4Ovh0DHuuElD7Efdh z+O44mto0lGUvU1GJZFlV7sqUGljVGFyq9+0RICsRq3tIdhIJ7VDv++2Spp4qAiJEe3k tbsj9qVybl2fDr3eoEQcFlDQCqHRCqV0NiVPK+ryGlCWaPN0JlBjStquuoZnCG6o+vrb y74Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781042452; x=1781647252; 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=9i2Af7K5yNSnpzmJpY557qOnqur0hKTAqhtHYtV96bo=; b=nw0h7Un12HJWSh8Vm9W33gWW2yqmtmocFGW0GBD2gXEjpKaB8dhNrL9/7bSmWEkTS/ gSzovWoP0VaDEdBNuyWwF5QPS1gmS9XzIVNnWzGB3Q5rDQOObQOtKaCUBeBjPQuawYjt /y+W1UaIA8WA9ez0MlEVSSHbQ0GB7GiYxnsoQr3Flb914tbLpzLOCndSBphFbk3MDQ1/ NH1IJ2GVdwi1HFDVC8uzLNTc5ObWuZOjK/Nbo2thGeNQoI58OsGDokeVGKtgk2Vmeb3w ra6P0FCUbxewMNPV2Ku+5rN5g/yLQpC3YRa6BtT2DPgMhP+KcGRjllmGSKb2pGIX+HNu /M5Q== X-Gm-Message-State: AOJu0YwowQhjG6Y1FTFO8owQ0K61Jk8T0pcUeJ4qoA+/237EBfkYpHfx E/uqUKSS464g+6zZEaKE2BK1IkZ03LMVS/tGePHjqKNLNs4mDPL/txJzBM7ipOPoOqzXUsH81F3 KoKLXsFv6SrB4Ubh5uHCTEajp5PRMFM6/87N1Nu94lmVTnrgecQc/Pp/pklaWG8vDbw== X-Gm-Gg: Acq92OEedrindC1qrAM1EEJTPrYyB7QVVGfhOVjntNek84kCFlmMMHjwvzurU8OkKmO S+xh/HX4RRuLrIrCMPJdqhH7YSXIX9C0+406GOC25VSUPVNcC0wkpFDEOPjzyYsB/lBjopy8Wl6 Zr860F9M+7LgfAMBPnxsPm8QZNQHIMWYPGyt1f7GUuo1szamiyn7FxPfUtYTVz8Y3LrkfHz0Noi zJIcFflVLkbtn19kSnQ6ItV99Avhp5H/ziqWpLQpJPpHyF6XTmFS+d7axgWvoZN85OqC+Iy3nCc ou+Ty+rNQ3zrlPdmdZh4RNoMuRkXuu9VuTTDUGNIYDPToLAR3uanCEf9qgrOHUIrT3OOxHHFZeF Pnc922mxdfQOFy+/AiamTy+8eKNRA/dycHnqhxXVIgth/lsa4/4FbXg== X-Received: by 2002:a05:600c:45d1:b0:490:bf13:a1b with SMTP id 5b1f17b1804b1-490c260567bmr335621705e9.26.1781042451993; Tue, 09 Jun 2026 15:00:51 -0700 (PDT) X-Received: by 2002:a05:600c:45d1:b0:490:bf13:a1b with SMTP id 5b1f17b1804b1-490c260567bmr335621065e9.26.1781042451443; Tue, 09 Jun 2026 15:00:51 -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 5b1f17b1804b1-490dca8fcfbsm4818565e9.1.2026.06.09.15.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 15:00:49 -0700 (PDT) Date: Tue, 9 Jun 2026 18:00:43 -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: <20260609180022-mutt-send-email-mst@kernel.org> References: <20260609160506-mutt-send-email-mst@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: On Tue, Jun 09, 2026 at 05:44:31PM -0400, Gregory Price wrote: > On Tue, Jun 09, 2026 at 04:08:08PM -0400, Michael S. Tsirkin wrote: > > 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? > > I suppose the question is whether capacity=0 should cause a WARN (i.e. > only a bug explains that value), or if capacity=0 means something > special (i.e. use the default) and therefore that should be documented. > I don't know which of these is the case, but if it's the latter than > that deserves a comment yes. > > ~Gregory It's the default. Will document.