Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1454498rdb; Tue, 30 Jan 2024 21:25:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUdPF38E27+ta0fcdAyoBPQdb+vXBZgulaZ7zIiBqYpwsNgAiTlCtWzQCphHF3BhhkAh3t X-Received: by 2002:a25:874c:0:b0:dc2:4418:75e2 with SMTP id e12-20020a25874c000000b00dc2441875e2mr705734ybn.40.1706678740662; Tue, 30 Jan 2024 21:25:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706678740; cv=pass; d=google.com; s=arc-20160816; b=ktDNbEFMqdFeBRN1JBa2DCYZMVNC8IibeIGma44t/mjcwDi863eSVUSHGYhZJi7kfa DTcI+/MgHS+z84W8xTo1/Yzidf3iOf0v9+XuCHQuyUrtlpk+fK7UZrkRgn50XVaRlPAV fVyrFLodpovSmHhubwMRGvbwQk5spX5cufAV2YivHDsC5SStPpIZ+WQ9liWH9gg2aSg2 0X6r96mTE4JMfGLyJ4EJSiTUrhb1BVq7cBzCNkIFqs8ocX012jl6UftMWRigVqQQ2GgZ ZgtfzDSNu6qrhf8MtyZen0JMcjrWbDM1RKjgE73J5QLVCdd3hzVasm32QRLh948khRa0 lmNw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=TTXpXgtPeeVhrdOdhIk8nNLkr9CBMpKYwR4zxmHgbns=; fh=eOjw150k/gm1gaPlRVQ+o40cuIJ/0THIgGGrHAslg14=; b=iUgd9qT0idwbMGBfSnxuSV7wX0wy2dV9bdwQ6qpKM3AfgmL6rS+tyrUPiRIlEIr2Vd acvt/v82grDnAJmnEJSPOCfD9+bDw4mQ6IofDdbTyME8dSD4Dfn7BXs6WDneRBEO2dPP qhawl0C42rcVneOdreQ+KlobwjDm/0nXqxWHvQfx3d09HVi7S6Y2Uv8mmi5UpUPzjGeL uu43bSOM31gErZguhhzEldcjhTKtYDnJsspxFHeT57Ni3Ssy2RrEz4P7atuoMpQAUBJq 6NwDagakcVPQ16PWWwu+zGzubiHzZ6qH2dn94qoys2SCEnqdTZkH/4zTh9eM0ApzW/oP lQzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="aJP1/CVT"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-45767-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCU/AL+tdtocLQkftMh4N3vIHHrMlIovgUycEZBOBY2z33y48Z2GE4kVW1hMyxwgwR5FN1WqpyRfnjTEXkDTzEWPK69KzEqKJ9pYykLbkg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cm8-20020a056a020a0800b005b8ebaa2937si9186650pgb.47.2024.01.30.21.25.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:25:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45767-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="aJP1/CVT"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-45767-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45767-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4E495286F1C for ; Wed, 31 Jan 2024 05:25:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF4623D57A; Wed, 31 Jan 2024 05:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aJP1/CVT" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 4ED163D54C for ; Wed, 31 Jan 2024 05:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706678733; cv=none; b=aX30ovJngxvcYEUPk6OChT+Q6g2usQrUsijx07sAR1DTn0mntppp+iNAoxKj5yICg9/kWwBSWiaW66QJmNqNvwopfOa5NzTByHVMQTDT0x3nZrkic3jZAkszxIRC7D+oQZJ1RLxwe7nXjRSvwecH4fHU4rQrbRwB3zRnHdw3uMQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706678733; c=relaxed/simple; bh=KrJkwg/Yk/VDDPMR1EDcBt7+8G59kzjP1vjjfPRVmeY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rJcEnSs9wmsNb5+8z5Iy7dIWjla2SNKVBVjSqEzG9W/ltJfRh8aKZolj67P9qDcpcbcAG4wKVEg9Yzr8qc3WnRoTAxD4NW6eDjBH8LDlQqfAA+2GuxboqPh4DsQ48FvfPYXQBQ4r6W8q2VKnXWgRHcrl5loe2gFgSSu2NTamm/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aJP1/CVT; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d9198034acso6825435ad.0 for ; Tue, 30 Jan 2024 21:25:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706678730; x=1707283530; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=TTXpXgtPeeVhrdOdhIk8nNLkr9CBMpKYwR4zxmHgbns=; b=aJP1/CVTW0zo/ZusLP0CkYBM4zFijXTGq41iAYBDnH0MKW0QbcuKEEEBdnK+vwVnyT 0mOPlwLNKjwEOnnctuasU2Fhm4AuKLn2LdYHR8Hy5UsSHEEUFZBNZlCzGPkEYJShstab Ye0Bpf2lA0e3FVIShcFhsM285b8a9GrsF9ukavkWki120a3it3aCIISuAYQ4HCwrmJpm OgRQLEueT0GSxvOIjkJBDndcXAaO8b8yuxulfzHdRbJLOz8MhbL3jq6ftHt0dz8CrzY4 TrOqTlFl0/O/6LNBBR+SPlXyiIBqSjRUTHBm7Q7j9fCfIuuI+iKqrIRykC7zla/GEevh wBug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706678730; x=1707283530; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TTXpXgtPeeVhrdOdhIk8nNLkr9CBMpKYwR4zxmHgbns=; b=uvD8+8Cr+3mNgb49kIdSmvP5REoebf6cwoaPDyTtpbsEuzbCYOZcpUve5+xtxu1BCi qfSo1gTjUwMjQpqepFOIwm6rgzlVycbYWsCTdovnQTeaVpu00qxgCb126hQ7q1CwmrUo 7nw47p3jqCUY8H6XdH/VCLSuDYsM3xtuveoaOWPNafYOmIFJ3WUKcFWIVL3nAE2u97c0 3bcuyoeR6v0KUJFN+TPNncnovGNC0GLOsDf8eIOw9UONvYhtz+cX0jhuel2QlpPLTsD8 v4m0YNL7fwdrLctqR3rlw2PEqIE3bZqwVnJ+rXMJy2SjmYcRQrpiIUOXoT34ICsv8wjq W0+w== X-Gm-Message-State: AOJu0Yz7XYiMUtrV5Q3yNjD1oa2t98tLrRTL3VBM5HQ/ALeeq6HENpc8 qJZo4hc2tSPJshtf3SAO0JXyvrymF5W0owmG4joClLUvVJf10aLJX61XMkn9QkY= X-Received: by 2002:a17:903:234c:b0:1d8:f4d4:9aa4 with SMTP id c12-20020a170903234c00b001d8f4d49aa4mr864053plh.16.1706678730273; Tue, 30 Jan 2024 21:25:30 -0800 (PST) Received: from localhost (dhcp-141-239-144-21.hawaiiantel.net. [141.239.144.21]) by smtp.gmail.com with ESMTPSA id mi3-20020a170902fcc300b001d8ef6eea72sm4027355plb.209.2024.01.30.21.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 21:25:29 -0800 (PST) Sender: Tejun Heo Date: Tue, 30 Jan 2024 19:25:28 -1000 From: Tejun Heo To: Marek Szyprowski Cc: Lai Jiangshan , linux-kernel@vger.kernel.org, Naohiro.Aota@wdc.com, kernel-team@meta.com Subject: [PATCH wq/for-6.9] workqueue: Avoid premature init of wq->node_nr_active[].max Message-ID: References: <20240125170628.2017784-1-tj@kernel.org> <20240125170628.2017784-10-tj@kernel.org> <91eacde0-df99-4d5c-a980-91046f66e612@samsung.com> 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: From 28596c7850a72ee82dc33758f81b71b4e8954c73 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 30 Jan 2024 19:06:43 -1000 System workqueues are allocated early during boot from workqueue_init_early(). While allocating unbound workqueues, wq_update_node_max_active() is invoked from apply_workqueue_attrs() and accesses NUMA topology to initialize wq->node_nr_active[].max. However, topology information may not be set up at this point. wq_update_node_max_active() is explicitly invoked from workqueue_init_topology() later when topology information is known to be available. This doesn't seem to crash anything but it's doing useless work with dubious data. Let's skip the premature and duplicate node_max_active updates by initializing the field to WQ_DFL_MIN_ACTIVE on allocation and making wq_update_node_max_active() noop until workqueue_init_topology(). Signed-off-by: Tejun Heo --- Hello, This doesn't seem to be causing immediate problems but let's nip it in the bud. Applied to wq/for-6.9. Thanks. kernel/workqueue.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 31c1373505d8..ffb625db9771 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -386,6 +386,8 @@ static const char *wq_affn_names[WQ_AFFN_NR_TYPES] = { [WQ_AFFN_SYSTEM] = "system", }; +static bool wq_topo_initialized __read_mostly = false; + /* * Per-cpu work items which run for longer than the following threshold are * automatically considered CPU intensive and excluded from concurrency @@ -1510,6 +1512,9 @@ static void wq_update_node_max_active(struct workqueue_struct *wq, int off_cpu) lockdep_assert_held(&wq->mutex); + if (!wq_topo_initialized) + return; + if (off_cpu >= 0 && !cpumask_test_cpu(off_cpu, effective)) off_cpu = -1; @@ -4356,6 +4361,7 @@ static void free_node_nr_active(struct wq_node_nr_active **nna_ar) static void init_node_nr_active(struct wq_node_nr_active *nna) { + nna->max = WQ_DFL_MIN_ACTIVE; atomic_set(&nna->nr, 0); raw_spin_lock_init(&nna->lock); INIT_LIST_HEAD(&nna->pending_pwqs); @@ -7400,6 +7406,8 @@ void __init workqueue_init_topology(void) init_pod_type(&wq_pod_types[WQ_AFFN_CACHE], cpus_share_cache); init_pod_type(&wq_pod_types[WQ_AFFN_NUMA], cpus_share_numa); + wq_topo_initialized = true; + mutex_lock(&wq_pool_mutex); /* -- 2.43.0