From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BDFC194A54 for ; Mon, 6 Jan 2025 10:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736157890; cv=none; b=IXkE1QtRtFbkjm3OvKqeNqTksrNfdEVeAjICTZuq0jKbOlQRY8pBEoGVuhiOOs7ylx+wXh+2id771rk56Ichhm1/jbqP5dXk8YH7Kk4y5EHCxNifTjI+Viz56lstEMcIyX0xxcnNNSNlM0mNBavwAX/20v2OHpgjTN86bevA+38= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736157890; c=relaxed/simple; bh=nBH3q3S8sOnKs4bXs7yqspGDyqtx6+q25qjw7Ut8d1Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WaY+pm3aFse1tETGy2d9stOQwqDw7aNUdRK9uEwEfI0tEV9PmTjzCAMoULCAzvrOxqniurEv2LjL68rM6J3EabFnA6QYQgWOpsOu6cRMKW4HjRWeDXFhIsp97SC0SevaPhOrHiyMzaK/MAuQnGo4cRYuO795eZuIQIz6/0GsbfU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E261D143D; Mon, 6 Jan 2025 02:05:15 -0800 (PST) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 708CA3F59E; Mon, 6 Jan 2025 02:04:46 -0800 (PST) Date: Mon, 6 Jan 2025 10:04:43 +0000 From: Mark Rutland To: Koichiro Den Cc: Lorenzo Stoakes , linux-mm@kvack.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] vmstat: disable vmstat_work on vmstat_cpu_down_prep() Message-ID: References: <20241221033321.4154409-1-koichiro.den@canonical.com> <2q7ge6cgzeowqffyn6w6ed4trhaaumv5ubdgud2tsoolen7wpw@4akuomhbacyh> 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: <2q7ge6cgzeowqffyn6w6ed4trhaaumv5ubdgud2tsoolen7wpw@4akuomhbacyh> On Sat, Jan 04, 2025 at 01:00:17PM +0900, Koichiro Den wrote: > On Fri, Jan 03, 2025 at 11:33:19PM +0000, Lorenzo Stoakes wrote: > > Hi, > > > > I observed a warning in my qemu and real hardware, which I bisected to this commit: > > > > [ 0.087733] ------------[ cut here ]------------ > > [ 0.087733] workqueue: work disable count underflowed > > [ 0.087733] WARNING: CPU: 1 PID: 21 at kernel/workqueue.c:4313 enable_work+0xb5/0xc0 FWIW, I hit similar when testing v6.13-rc6 defconfig on arm64, when booting secondaries I always get a splat (trimmed): | ------------[ cut here ]------------ | workqueue: work disable count underflowed | WARNING: CPU: 1 PID: 21 at kernel/workqueue.c:4317 enable_work+0xfc/0x108 | Modules linked in: | CPU: 1 UID: 0 PID: 21 Comm: cpuhp/1 Not tainted 6.13.0-rc6 #1 | Hardware name: linux,dummy-virt (DT) | [...] | Call trace: | enable_work+0xfc/0x108 (P) | enable_delayed_work+0x10/0x1c | vmstat_cpu_online+0x88/0xbc | cpuhp_invoke_callback+0x10c/0x208 | cpuhp_thread_fun+0xb0/0x1a0 | smpboot_thread_fn+0x20c/0x234 | kthread+0x110/0x114 | ret_from_fork+0x10/0x20 | ---[ end trace 0000000000000000 ]--- [...] > In my current view, the simplest solution would be to make sure a local > vmstat_work is disabled until vmstat_cpu_online() runs for the cpu, even > during boot-up. The following patch suppresses the warning: > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 0889b75cef14..19ceed5d34bf 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -2122,10 +2122,14 @@ static void __init start_shepherd_timer(void) > { > int cpu; > > - for_each_possible_cpu(cpu) > + for_each_possible_cpu(cpu) { > INIT_DEFERRABLE_WORK(per_cpu_ptr(&vmstat_work, cpu), > vmstat_update); > > + /* will be enabled on vmstat_cpu_online */ > + disable_delayed_work_sync(&per_cpu(vmstat_work, cpu)); > + } > + > schedule_delayed_work(&shepherd, > round_jiffies_relative(sysctl_stat_interval)); > } FWIW, the above solves the warning for me. Mark.