From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39F063630A0 for ; Tue, 9 Jun 2026 21:44:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781041476; cv=none; b=I1uEGX3oLnqCUMToGYqQJcC2AnzZgm+8K2S/c1R/WmV0mil2I2pj7eITl8HxvR35zQn7InnmvyeyzNwgaomqBEhIJez2FjZ5ZQ4Xkk+1CdQlzu2f+VSUuYV4k/jP5C8vvQoQrMtyST30IHml/JWU/W2Jd1yyGpddyfJpOkstSGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781041476; c=relaxed/simple; bh=ngWxxhFZyG95B9mFBhRcs3m6fn2rrKlD8/SIsytvgog=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Hky/90kJGUrIa3Ku/R09tD6pCJcR4JoOZkarNJ8tB8MeXYtpAPa/7q3wFiqtvXbK4bq4j+hSlSFKWBb9RN0ZcI9iR8Vbq5Eeg3yjHPtmG6gduzfpie8byBNmLMfvN2TCVEuIlUr+huhYshVj83L8MFsHjEYEg5YfCK+Y6ttKZKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=BA/D86LQ; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="BA/D86LQ" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-91563382bcfso696808785a.0 for ; Tue, 09 Jun 2026 14:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1781041474; x=1781646274; 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=aD/5zoYJey3JVZwJskUEOWQGpMW2wHY02NSSmxoYtHs=; b=BA/D86LQHkyiXkuA4MiSF6B7FKRmpkn7sC+etNUg1cCnuDBdFtHds2HpnMlUpDd0u4 mrKZXoiolERxAycFMvfdot1OZFe/dK10dHDu8YXjgpw++MCHxIHDMjgYRQAl6+l/5yum pJRPNC/0v8A1TlA+BK6l4f/y6t31zsVBjNhYluPYVLAazqRsVCZgYCezM0PcmaFvYQLR eGc2bm36bw2TyZoPMGorPommqCbs9kfGr+R/JlHWHwuLSDWpb/7NInjlZ/whKTmRl3sl pIcB7NHnSoXTcd6uIIrcc4aUUgZBndhKzosrZF7tmYJMPemXSaxrXVDGoCfXB/Y9aiyO dCCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781041474; x=1781646274; 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=aD/5zoYJey3JVZwJskUEOWQGpMW2wHY02NSSmxoYtHs=; b=RWeX/4U2t6ZwEB6P0L/Gdn3U7WfGIaMlDrpj/4lsvxYYy44TbFaFQ63puE62OUvDFt 5AM9kx7+/StVvAyy1GdjB/jCSfk7s3VNohiWXLDWGIWkAg5p8zJZ2m46iN2LX30M7kBo KQxGfnstD2h65dfea0UQamg3UXihzJHVdsWEEkYMs8oyVLLqk+pyWprHcbkVyZseKKyc gOCKSd1/yKBY7lq81nQqMniOW7J4PmSM9cVEhwb/E/idFPoK8CWaLn5tbdASJnJ7U/i9 2UcBKoXQNpwjuPWdbiVkPFAyoWMC0Ore8I65K4XnFH9FZYU2SRTVG3GpDQ+zsL8XoVBd KikQ== X-Gm-Message-State: AOJu0Ywk8pxHlf3Ne3oh9frMnBNuwtUI2J7dDnm8utBvkSeerb7DJXcj kgVTD4LHsdtPHLbwnWZW1tnU0z9kKeMIFnQ0bsXRmvgZI/GWrBpHsvHmHY01QKDFh0s= X-Gm-Gg: Acq92OGyt2fDkBDeY6rAnYw8OGOrabU10WY467XW0x1GFIJ0hs1aWoAjKJ1MRFJXven Lkuf2mXWa89BmW53GqB9J1syrxvFCJPII1titS+xAjWNDg3YpeJtz6I9HElZ9TDHGKqiENKu0Uo d3IK20L39Jdwb8L9FeR9nYTku3vaTzeMkoAbnQGILjnMKqwUwklNEjphzH1V2CC1sFJDji/4y5a kAKp3mt79/6G5YWwtUBfKEWwdqa88WxWRoQogCNsFzswhk1K5WDwW7BOZkbgvo5LhG/ejoDkIHx VCX63n447Uv+Tt82HDnmircWlak6VIvZoHCRBrlqLDUdWMPAf0ejJPLcr3acPbFJhMCyHcEi1dj o9t6fpj09V6BG+gorMRrzmgyUcc02lCrroLlGMTXKR966QgoZxBWE39fOkiwq31j0bddlD30nSD ORhflvEZD6WI6fZdV4RTCup93vA/KJKNPLTcmxxMpzeGsMEPrDwFKaM/OmxRVgQNUlMz9SB34Yn mD8tU/VlFHfbmmJFWMDQGgUVTH2 X-Received: by 2002:a05:620a:880e:b0:915:cda5:27ff with SMTP id af79cd13be357-915cda52bcdmr1869020485a.45.1781041474035; Tue, 09 Jun 2026 14:44:34 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9158a381abfsm2275058085a.27.2026.06.09.14.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 14:44:33 -0700 (PDT) Date: Tue, 9 Jun 2026 17:44:31 -0400 From: Gregory Price To: "Michael S. Tsirkin" 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: 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: <20260609160506-mutt-send-email-mst@kernel.org> 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