From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (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 D1CA939E183 for ; Thu, 14 May 2026 09:24:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778750645; cv=none; b=DazWy7oMxTccIngLyiesOhGajkNqLxEwuzAsaTS2kRKXfNROY8UD4LCkCzWGAxUzGbetMw8ddlD9eHZL6sPsIGnBVexDtdWkj+A96YPBxcoB8otns3iSnV108Nf2OivAyA0Fhngwtr/Ajf6l6tEW419FLIvXUk9b7IeUY4tOB+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778750645; c=relaxed/simple; bh=d2gujyyE2uouAmoQ9ktcqkqGMNEh0b4TeWYUWq9TmxI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=joEn8CjPHgEB+Rd5jFuVF3uwtULLsZ1G3Y6kemCpj1y2le1ySN69ybd/IoXbfeHl40Bcevq2qXtNRZ0UgvAWkVi6C9/wGOIi2dK6QdlDxppI2EbYu7GI1iw/4J0CX6mr/wWnDFHz9q/7CG6M3/co6CoXA3BOA9WVGDllY1PfM5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ZJU+OEPM; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ZJU+OEPM" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-43fe608cb92so4856613f8f.2 for ; Thu, 14 May 2026 02:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1778750642; x=1779355442; 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=T1uaWjXJQBmKZWFIYXd5mE7pLFpJbMVtBzHSffq1k1k=; b=ZJU+OEPMuIvZbfj9SNxKaCRWbHqDHPggySQsLN1u04EP4TInGkffBo6g0QjiMGW3Vh Tm4KxJ2CZK+Q2W6+8AZsAd+Z9EdrgCztuVJdKz9CxHnCJwRx5noxvO4AmN/2yIKJOtP3 aQkqaz5HOc8qzHK7kW6RaCoJW/poVQw7KqTDc88lbKYvA2SfYuOyI4zNyvWNG0bw1wQY mtm2lT6FkdTiEytPrQgvLziPn5098EUK4k/px3SDpXhgJBb9mI2YhU2q7QGgKuOo1v3H d3iMDJY80fo8nE4s2CSWEXDh4fgy9G5L14DyTCcLEs+J1YO8ysycIb4BGlLtCYZ55uG+ yC7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778750642; x=1779355442; 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=T1uaWjXJQBmKZWFIYXd5mE7pLFpJbMVtBzHSffq1k1k=; b=Hf49iD0XduZwzMCksjnLWRLC6B2cvOdknMul6E78gGRwq6j2XRLA9wHb22Cd8jRLxy 1bT8bqGjb/u+A1Cpw/zBVe0896WqTS3N+MuuSg/fPoqGwzzgGiPCY3VbapJboMu0V4Ad giro6nl+oGZzbJ2ONbbjcCSU6gfv76q1Qn7TYYQ9CV2Qxcw+iHB3Crm0dApTFr8X8lpk zETdm26As0DBP8jIzUF9Ar0j8uiv+3AdmCJwT+SoQSF3mrdR9baCCVQzNgZox5n21YPy PfPffxapfo1dbmDt3/ma4VDR6FARxPhqf16Cp+OFXxjlrWqLoUeZvR8lo/WrwilgOHJe X8QA== X-Gm-Message-State: AOJu0Yz1ItW9LC9i8pjZ+v4Euzti9qFvvxVrxBXLEY8ts8Jl3hEgC45l OHR64ueNTqaoULHfzgj2MCqTxsasdySGsU1y5+XGhAlNwuPvtpJB5+Jqa6PmpByBMYoY2zlDXJm ziRoCZZw= X-Gm-Gg: Acq92OHML+VLSocGtWn5gRHINDF/V5qDDZ87vuIIXDH78F7aF5LxeKyATbLO0b3x9WH Anj2OxdJR50gU6DBKY/gQKGAANnn6C15qsikR10DoT+ot3cNLV2/L3PHZgGBYuH2Gph18cWz8pL lO3bCWOTfA2hYspROgjaQsvRGSiCrHx3yhdUQnuAqhmCXP/btKycuLc8uelreU/Qn7FI88TK8lv +8kSpjGafBbIHQoifUXWPefyxNlWOpw3HxFoyp5dLXevW61jRYLtOmYrDNqlGYiHrdf7+h2+3gG dyCy70XCnHg/tBwBgsBrC4w50Qw2k0lu+pf83moivj4YzFQq8a/HU/xBUKX9H7r18rJpP7Ki+zx TtcYg1v2yuMIo4OyMh+53iIWPVjeI5+L6ZHWJN5N4kIptgsH+rpuuLjiVgDjVfxu4wX3PUCsQYd N3X12v7+8bM9BQZwSKS+l8MR9a8Ce+yDnYagVJcMCaHc5/znM= X-Received: by 2002:a05:6000:2c06:b0:43d:75a2:44aa with SMTP id ffacd0b85a97d-45c5ac5372fmr11244656f8f.43.1778750641908; Thu, 14 May 2026 02:24:01 -0700 (PDT) Received: from localhost.localdomain ([2a00:6d43:105:c401:e307:1a37:2e76:ce91]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45d9ec3acf7sm5353467f8f.12.2026.05.14.02.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2026 02:24:01 -0700 (PDT) From: Marco Crivellari To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Frederic Weisbecker , Sebastian Andrzej Siewior , Marco Crivellari , Michal Hocko , Breno Leitao Subject: [RFC PATCH 2/2] workqueue: Add warnings and ensure one among WQ_PERCPU or WQ_UNBOUND is present Date: Thu, 14 May 2026 11:23:54 +0200 Message-ID: <20260514092354.125149-3-marco.crivellari@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260514092354.125149-1-marco.crivellari@suse.com> References: <20260514092354.125149-1-marco.crivellari@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently there are no checks in order to enforce the use of WQ_PERCPU and avoid this flag is used if WQ_UNBOUND is already present. So act as following: - if neither of them is present, set WQ_PERCPU - if both are present, remove WQ_PERCPU Along with this change, print a warning, so that the code still uses both or neither of them, can be changed. Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/ Suggested-by: Tejun Heo Signed-off-by: Marco Crivellari --- kernel/workqueue.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 80d9c91ae606..80e6efb4aa52 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5882,6 +5882,24 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt, pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n", wq->name); + /* + * One among WQ_PERCPU and WQ_UNBOUND must be set, but not both. + * - If neither is set, default to WQ_PERCPU + * - If both are set, default to WQ_UNBOUND + * + * This code can be removed after workqueue are unbound by default + */ + if (!(flags & (WQ_UNBOUND | WQ_PERCPU))) { + pr_warn_ratelimited("workqueue: %s is using neither WQ_PERCPU or WQ_UNBOUND. " + "Seting WQ_PERCPU.\n", wq->name); + flags |= WQ_PERCPU; + } + else if((flags & WQ_PERCPU) && (flags & WQ_UNBOUND)) { + pr_warn_ratelimited("workqueue: %s uses both WQ_PERCPU and WQ_UNBOUND. " + "Dropped WQ_PERCPU, keeping WQ_UNBOUND.\n", wq->name); + flags &= (~WQ_PERCPU); + } + if (flags & WQ_BH) { /* * BH workqueues always share a single execution context per CPU -- 2.54.0