From nobody Tue Dec 2 00:25:44 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 34B873019B1 for ; Tue, 25 Nov 2025 10:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764066454; cv=none; b=G9EN6Kerya6NdLa6R/UpfhOZWkyR/pJopN7EP0poYMjBTzWpIiLAM9UWXQ4a8wujCWF+PbElyFmPoZ3OtfFEMBjUhmZv59WTnwUdUqsxq4zQDLR+nDYEW2E56441ICM7zgtNI1VcfF6owMpcirY/rdtPq8L1utX6mxWtJDZqtEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764066454; c=relaxed/simple; bh=uK9Sa+XvT4KpWkunHPAESa4qgGZT/fz0bpQ37+5YScU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cXp80j+QLsyWqSouYD5g6NrB9A5ccAoPOQPQedd+Jzi58P44m533/2QEp7QOi8znlo5Ewwsg1vB7Ul7kEFCwBxfRQbIhFxE1A+WrBUMo9ZJNvH+7fT9drOe//ncDdhPqb4WDrVvPHJSHs8MJIwlgJKn753msIHjq83jKu3QjdmQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=afbzEdZI; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="afbzEdZI" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-29812589890so62655115ad.3 for ; Tue, 25 Nov 2025 02:27:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764066452; x=1764671252; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WAUCWl4NAY4zfEf+4hAzpnac2qoKFFTi9Yh2T1tUV1I=; b=afbzEdZIoagZpgUSSggmTzM9gtw9BiAqEq9I3UiALApPSpoYK9QWDyOA9n3lDMqRn6 mO+i5GZGX/4ab4ivrEEEc7HgSPQZwZ/DAT8RnQJJivFEjsO4p/iyjCqovAGyf4QkGwmw HxagpqJCSOp0b6khMT+1BiZi4KSyCkaDWrwRtvOtZ6tCvgqVo8+Mzwb7M+aN0I6mmNCZ BarNvQNJTK/1wsyQP7a1KIlKp/XEzQdSq3ACaITzeb1a+8VzY4HsRdbCeGpIs7sOmgFo ebyrWJ5wAiXE/yxtuykSCQgiiCt8ITZi0zy9aCfxtmZ9XGFjTPOxLz9hLKRP5xUdvBEh zygQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764066452; x=1764671252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WAUCWl4NAY4zfEf+4hAzpnac2qoKFFTi9Yh2T1tUV1I=; b=KGKXr6QibD0gOd8lCg0PCpQXxz5xSOigmjZ7UtPbvlRL8T6tTpS2jF9LgTpUtDZyna lMD4pTr+YkT8w7tXS7pnxWkJFabH9Icw24rkaj76kPFLUgREcverxy0fr+96NCu9gpdC NmfRUwjIKbTn2+hR4McoPaGbo52dQKGQwHD6YClMXvpkYDyWOYoREXGCU1QC7WZW5ppq i9WTr99UswgI38/7/RfBaraZ98HnnMGRI/+QzdCMl97CyzWmLMPaZmk8IYXjLsDr1QGw 4s1mv+lq2qQWIRkciyAeecZHEFUawyq5Y8LUUzOpvmnbYEqvqXCUZuxoAmJw2NCM2QyB u7SQ== X-Gm-Message-State: AOJu0YzOv6mWobJY6PQRpuAt+VjbQZU+ZBUFNvhMo2dkf7nkuesDKAgJ m4sNGYp7vFs+dDFNWc8I4yR1CjhZEDbtdh70O3BNw/QeqWRtOWhXvlZ4CXudj0dN X-Gm-Gg: ASbGncvciqpJstuSH0lp8BprIqlbqKdfp+0B1P1PP80sdrw10bOx4+6ztKT+CyVZhcb N4eZw+n5mV69kJDKoAHS07A82pzx55myVTHy9AVV5EfYrfGtm7gygND/MgBESyWD6LqiMG777mZ cNJZug+3tm0AyCjFVu+B7GL7AE8P6Xs/bKyTTzK7jy29MTetjYLyixMN4ZAbT8xicyDdQDbZnLY sSUnknVFpqcimqLHVVnru7+WGpPCKMnXmN6g7iC+bVuzGTlR10NwgQRoW+A0onQTYzf/53pj4z4 wt6NGk9JH+M/0PONuzB+7YJkFOYDyK3rylfeHh5tVbYGpG/1QzKVjMdisKE7eZN13zARAy2pbyH Ph07SxOcuPAcDCjDi16QjPGKMZkFKtLgYm/hgBxR11Mi1ix67yANwq5XaB0oZO9hSFbNXs0Vb0I mVJRhbq1jy7H4= X-Google-Smtp-Source: AGHT+IFc8/BrooumewHnmmOZDZg/HbhVO+rR6BjEcyyBF1gkcEy9q4DM0uXCMt5RklDuW6jVYb8zdg== X-Received: by 2002:a17:903:110c:b0:298:ea9:5732 with SMTP id d9443c01a7336-29b6bf64a07mr41281175ad.41.1764066452055; Tue, 25 Nov 2025 02:27:32 -0800 (PST) Received: from localhost ([240b:4000:bb:1700:7b36:494d:5625:5a1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29b5b25c104sm163732285ad.54.2025.11.25.02.27.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Nov 2025 02:27:31 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Lai Jiangshan Subject: [PATCH 1/2] workqueue: Use pwq->work_color for wq_barrier Date: Tue, 25 Nov 2025 18:31:24 +0800 Message-Id: <20251125103126.684929-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20251125103126.684929-1-jiangshanlai@gmail.com> References: <20251125103126.684929-1-jiangshanlai@gmail.com> 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" From: Lai Jiangshan wq_barrier work items are internal and do not count as user work items. They do not participate in flush_workqueue() except for a sanity check, since wq_barrier owns the PWQ reference. Therefore, any work color is acceptable; just use the latest pwq->work_color. See the commit d812796eb390 ("workqueue: Assign a color to barrier work items"). Signed-off-by: Lai Jiangshan --- kernel/workqueue.c | 9 ++------- kernel/workqueue_internal.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 253311af47c6..4d817c7144cf 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3187,7 +3187,6 @@ __acquires(&pool->lock) if (worker->task) worker->current_at =3D worker->task->se.sum_exec_runtime; work_data =3D *work_data_bits(work); - worker->current_color =3D get_work_color(work_data); =20 /* * Record wq name for cmdline and debug reporting, may get @@ -3308,7 +3307,6 @@ __acquires(&pool->lock) worker->current_work =3D NULL; worker->current_func =3D NULL; worker->current_pwq =3D NULL; - worker->current_color =3D INT_MAX; =20 /* must be the last step, see the function comment */ pwq_dec_nr_in_flight(pwq, work_data); @@ -3796,7 +3794,6 @@ static void insert_wq_barrier(struct pool_workqueue *= pwq, { static __maybe_unused struct lock_class_key bh_key, thr_key; unsigned int work_flags =3D 0; - unsigned int work_color; struct list_head *head; =20 /* @@ -3826,19 +3823,17 @@ static void insert_wq_barrier(struct pool_workqueue= *pwq, */ if (worker) { head =3D worker->scheduled.next; - work_color =3D worker->current_color; } else { unsigned long *bits =3D work_data_bits(target); =20 head =3D target->entry.next; /* there can already be other linked works, inherit and set */ work_flags |=3D *bits & WORK_STRUCT_LINKED; - work_color =3D get_work_color(*bits); __set_bit(WORK_STRUCT_LINKED_BIT, bits); } =20 - pwq->nr_in_flight[work_color]++; - work_flags |=3D work_color_to_flags(work_color); + pwq->nr_in_flight[pwq->work_color]++; + work_flags |=3D work_color_to_flags(pwq->work_color); =20 insert_work(pwq, &barr->work, head, work_flags); } diff --git a/kernel/workqueue_internal.h b/kernel/workqueue_internal.h index f6275944ada7..76d2d99b26ab 100644 --- a/kernel/workqueue_internal.h +++ b/kernel/workqueue_internal.h @@ -32,7 +32,6 @@ struct worker { work_func_t current_func; /* K: function */ struct pool_workqueue *current_pwq; /* K: pwq */ u64 current_at; /* K: runtime at start or last wakeup */ - unsigned int current_color; /* K: color */ =20 int sleeping; /* S: is worker sleeping? */ =20 --=20 2.19.1.6.gb485710b