From nobody Sun Dec 22 03:15:39 2024 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (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 EAFB61D86C9 for ; Sat, 21 Dec 2024 03:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734752023; cv=none; b=ByArJMKZoLYobUkzC6IwHk0D8vgr/zCBDY60c6kBRo8ey4jAq41oCNvMZ6VQ+8s5xQqTgV3peZQ2C//uferarKRcshSmiIN5KU11CMiORYDo3xLs8XtNogNG+SMJTvoKL8lhDENyi1gXwqT9kTo4Wq+Eb6Wt4MoR9XWRbSHO3ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734752023; c=relaxed/simple; bh=1RrEv71Ix4G/NitHLy0okWidc5QahRBXE/IPLwJQzVc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rNvnCL21t8S6NOS86wIr3kIYNvaCaR4jYnAGJcNVrL47g7l4bE/fjD9md63GhqhGOPYDplKHXvWWZJQ8A5a0F4UHL1CtlhBWPmq08lgY4t1sF7LPqFmFoaI+FiKrL2hthFeR+XMlQeQFZ1leKvZvt6iLLGArOzjmSN07iLYgxzo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=WVPduzhw; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="WVPduzhw" Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id DE3133F689 for ; Sat, 21 Dec 2024 03:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1734752017; bh=UH+BBa+34oarxAUGIoPwD94S9GCmmy/3HzyVbySzyaY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WVPduzhwdehGokO3d9+BW9+OaBo30aU0OzDDj3sEtwrQkvAMlVhJ2F2IyrzKL0ns6 BmRrKbklMPi6H0np5p9u7TgOGLZZsCOwA+dz5m24rGHvERhxsTKY8m9vQbMJcRzAHe cf8/hJW32LXaORgeiPKeiUNQ9B42+yW5y0IZ4UoG2xH5m9Y1rICfmKmcqtenjhZMXt CdqWG51dZ3aYsHEbM/vXPigIFbGmuKKJrpQc/V//K7hHVe0eKHUKbhyuKjWNZSbHfh EYejYAG1GIA8xbW5JXQDR6H8U658CPqUsBFRyOU0D/cOawHCpjL6pBtmhYl2HTWpDI ZTbPsp8wBDEOg== Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7289afa200aso3101398b3a.0 for ; Fri, 20 Dec 2024 19:33:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734752016; x=1735356816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UH+BBa+34oarxAUGIoPwD94S9GCmmy/3HzyVbySzyaY=; b=enf1Eh8y2frf3eytK9RMr4c1vtCP7rYQ8oDX7Z1z33ITtI5c+k303Fepw36Hte5rjU v2MSiEuWYZJFMZPiN6uWMwQfqWxRTeBbaa12WO/DYjY65N/6LeZg2MjlrK3JL24PFUo8 e+5veOuQoKA3qPmHhJJnHQl/ULyE7wfkcMiZ1i/2kkPdU2PRUwxYol75ynmSXA2Idev+ fFSeVwqrWfeYLbM+f9cHM//08kBvheYSO/pHvJWqG4zjkVSNjcoRahQf0bBgLgH/t8FS 2qdM6FSGYAdqmVgcOiGn2s5wcj4xaP5i1WuyWwy4fA0Bz+A62qGGsXnFEoXnO3RVJNBk 588Q== X-Forwarded-Encrypted: i=1; AJvYcCVk5r3Fw8s0sa35ZOz7TOClFHB7LoYBBr1dq0mIioGKGcTInAAELArDWBTAmbVPdSKGuB4Bd6Eo3L389c8=@vger.kernel.org X-Gm-Message-State: AOJu0YyzQmqW+B2wxMIzW9gnEskcYGs/KCds0F/2/5kwDzJvGLunQG6+ WHhxC9ij2lw0sVnm1XqaxNFuzY2fOmOLKAkNe7XoFd3NnH/hf7eSek21slgr3alezQM+6w81CNA Vpn2EINYJjmwEga3kzlvASRWkAA0UXP0VX6AmluAIUa1uvA3SfXXPx7BcL90l65Vk0032f7oyHn E461vmsD0HBw== X-Gm-Gg: ASbGncv4Mw9GKCZUVBtAbGRMdY94e/E3pGg1dMtiDPFMinX2vL7Zdww8wYwi1fmt6xh h8KmP3ts123qfKU0RYPcB/s3iri5gZfdCDDPZ8CuxO8YXDfMJNBnUag9zu89qNdiLOSov1I7aLE 6kDOXVjZLpqS27Jhn2UHBs1xe8LptnzargsX3DEFyhX17zQd3wHIFaO1K0324fyrROAVbxQM/96 zEe880HYsbBtVzpp3U33XcJeZj/com9G2ZcvZKsquJYahzJmI6GQeih X-Received: by 2002:a05:6a20:d045:b0:1db:f642:8d8b with SMTP id adf61e73a8af0-1e5e084ca80mr9176417637.45.1734752015927; Fri, 20 Dec 2024 19:33:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0F3IjP8On2mdtF9jLFuNUI+uNdfQWiRvRMexj+sJZcvnF+OhimUjhmi9F0LetMeVi9rui9A== X-Received: by 2002:a05:6a20:d045:b0:1db:f642:8d8b with SMTP id adf61e73a8af0-1e5e084ca80mr9176396637.45.1734752015602; Fri, 20 Dec 2024 19:33:35 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:3630:b0a:8446:1dba]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8157e2sm4011665b3a.26.2024.12.20.19.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 19:33:35 -0800 (PST) From: Koichiro Den To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] vmstat: disable vmstat_work on vmstat_cpu_down_prep() Date: Sat, 21 Dec 2024 12:33:20 +0900 Message-ID: <20241221033321.4154409-1-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Even after mm/vmstat:online teardown, shepherd may still queue work for the dying cpu until the cpu is removed from online mask. While it's quite rare, this means that after unbind_workers() unbinds a per-cpu kworker, it potentially runs vmstat_update for the dying CPU on an irrelevant cpu before entering atomic AP states. When CONFIG_DEBUG_PREEMPT=3Dy, it results in the following error with the backtrace. BUG: using smp_processor_id() in preemptible [00000000] code: \ kworker/7:3/1702 caller is refresh_cpu_vm_stats+0x235/0x5f0 CPU: 0 UID: 0 PID: 1702 Comm: kworker/7:3 Tainted: G Tainted: [N]=3DTEST Workqueue: mm_percpu_wq vmstat_update Call Trace: dump_stack_lvl+0x8d/0xb0 check_preemption_disabled+0xce/0xe0 refresh_cpu_vm_stats+0x235/0x5f0 vmstat_update+0x17/0xa0 process_one_work+0x869/0x1aa0 worker_thread+0x5e5/0x1100 kthread+0x29e/0x380 ret_from_fork+0x2d/0x70 ret_from_fork_asm+0x1a/0x30 So, for mm/vmstat:online, disable vmstat_work reliably on teardown and symmetrically enable it on startup. Signed-off-by: Koichiro Den --- v1: https://lore.kernel.org/all/20241220134234.3809621-1-koichiro.den@canon= ical.com/ --- mm/vmstat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4d016314a56c..0889b75cef14 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2148,13 +2148,14 @@ static int vmstat_cpu_online(unsigned int cpu) if (!node_state(cpu_to_node(cpu), N_CPU)) { node_set_state(cpu_to_node(cpu), N_CPU); } + enable_delayed_work(&per_cpu(vmstat_work, cpu)); =20 return 0; } =20 static int vmstat_cpu_down_prep(unsigned int cpu) { - cancel_delayed_work_sync(&per_cpu(vmstat_work, cpu)); + disable_delayed_work_sync(&per_cpu(vmstat_work, cpu)); return 0; } =20 --=20 2.43.0