From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 847D7390CAC for ; Wed, 1 Apr 2026 14:39:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775054383; cv=none; b=T+hoMCei/xzeGxuyy9u1uq/n23fMQdnMgQA/ltN7ilKwUZfZcwx7nP0/X9JACW3BH+wCzScXt9fIoZswHxqQfk9nTQeNEGgxYMs2STQkvUfwbkoK+/Y+MJy7h38KtRrr+/gsKS0J8TzbFXdpNrtM9cITzDJLYvdTkL9L5wl4Pms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775054383; c=relaxed/simple; bh=KO4PKIQywrnrQfCEu0NvBif0/dcvAU2YdJz87uLZCGc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AiAN/vc3RjuqkT2yqfwKg3Rfd5VE0xZSeNxsN6q7Gcn0fCGBeJtiiM+JG3SE9UOc2dexljgD6Afw7NHi3pAGgLrIwQ1eVOn+JmJfw78GEuO6wMzDpAwW52+qpto5gGoo6uk0T1hcM3fOcFKEfd/EE/VVdjC5iMaWwXcU/bfJO2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=MbiMBtFd; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="MbiMBtFd" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kz9xdstn7TOu/urPKjmoJJTfAwSQj9gbccp6E1YBcZQ=; b=MbiMBtFd8sy6bcBTxzwXGMGp4y SLdX++76Av545JJkZ//03Vg21lujlT85vY6KO5Z855vZfxhnWaDUWgG3vcxDzZRqfo5IeGcS8AKf9 a6jNEJQggp204zXYKicDBoATturVJ2GrWdb0TN9l3DZazjFu+Ey7VIlC/keQl6VDYVJYodBsft33D DXpX8uySUXHLeALPE3lzasNYyOvJ8yf7mpXkrOdRJidWpWTwWtTO3bMbrsIeMgzuqD2L4RdF0g7EY TGcweAEORZOYQmydBCJngjoRdTrekqAXHXqgA1DYGdEnrvodj/JkVzNrwzm3prfPZ0ikMvfKiv90S q4VD+Srw==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1w7wjH-0033XU-0D; Wed, 01 Apr 2026 14:39:33 +0000 Date: Wed, 1 Apr 2026 07:39:28 -0700 From: Breno Leitao To: Johannes Weiner Cc: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kas@kernel.org, shakeel.butt@linux.dev, usama.arif@linux.dev, kernel-team@meta.com Subject: Re: [PATCH] mm/vmstat: spread vmstat_update requeue across the stat interval Message-ID: References: <20260401-vmstat-v1-1-b68ce4a35055@debian.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: X-Debian-User: leitao Hello Johannes, On Wed, Apr 01, 2026 at 10:25:35AM -0400, Johannes Weiner wrote: > On Wed, Apr 01, 2026 at 06:57:50AM -0700, Breno Leitao wrote: > > +static unsigned long vmstat_spread_delay(void) > > +{ > > + unsigned long interval = sysctl_stat_interval; > > + unsigned int nr_cpus = num_online_cpus(); > > + > > + if (nr_cpus <= 1) > > + return round_jiffies_relative(interval); > > + > > + /* > > + * Spread per-cpu vmstat work evenly across the interval. Don't > > + * use round_jiffies_relative() here -- it would snap every CPU > > + * back to the same second boundary, defeating the spread. > > + */ > > + return interval + (interval * (smp_processor_id() % nr_cpus)) / nr_cpus; > > smp_processor_id() <= nr_cpus, so > > return interval + interval*cpu/nr_cpus > > should be equivalent, no? nr_cpus is the number of online CPUs, while smp_processor_id() is the CPU id. If you offline a CPU, then smp_processor_id() might be bigger than num_online_cpus() My goal was to linearly shift the timer and avoid creating gaps when removing certain CPUs. Thanks for the review, --breno