Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp895928rdb; Thu, 15 Feb 2024 21:12:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXm3jchYKU/+y/Wx/AgGf2zer3iNeeQA1pJ7SRASpxqCFkO/JDjpAQk97upRLHnJS3jgK15/qvj7isVePrskqjusUpa7VVLPUn5LeN6bw== X-Google-Smtp-Source: AGHT+IFJdIgUc7njewiBiMk1ipAe7G0p4Sf5dQXVovs9UUcbb/TmUfxfnOsL0ahowPSGo95MRPj+ X-Received: by 2002:a05:6a00:9383:b0:6e1:2ba5:6c47 with SMTP id ka3-20020a056a00938300b006e12ba56c47mr3272743pfb.9.1708060326822; Thu, 15 Feb 2024 21:12:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708060326; cv=pass; d=google.com; s=arc-20160816; b=C/Bb1mlZAv4ThGS29sdzwcpT5IpOprAFWmFtNG6DZS6hThvDQumyyJAGAJlPUjC+jW emhzcfWgXQeujWa1y66GCYW3degIqcy4aEK6SIp8LOrqGywNVCfQQjzNsygu6iB+Bujw +3N0lALP30D1NwYBk4stA0dJb+ZbO6kDk8VZKr/0vyyDtsPXTsvKScPZ/l3+DcPBEc+6 yFNIz1RmJHfZnjy1CsnTeTkE4L7NHyavxlPg3g6vPaaM9gziO7l5Qpu1wxY7n+ZZayiJ MyU0ejtP4bYqwhRtcn0O6cc+0wGpX4zs/C6ISy5SoA5WPo3ZpOBN+hAnY36WngFlvfRG KUtA== 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=osRd6e0938TIuqccy/3nmWVE3X+VrWpnZGag3nbS18c=; fh=Ac2DahPYl3NzdrTKT0v+NASNQ0ocFJI6kExE8PkK948=; b=doGf6XZ+VYpbYcRfBpl52heiIamCRT98uLWvjwDJD4B5nlmIdfBHC0AlYzchraPYPn LIUi13ZWGkBJrdxptRK/7oTFfpbr0Cn4FACVqn7PWG+cu4qmo3NbJWIdtHlwNw3JUayC 8wn01Y35A0Lsygnryap61RSR3xpz1on9vwfvINPEiwaQ2gXTqxJ4+btvoQHsjzOND5fd gaM3IO6X5qFspjWkwvSIsGWoWVk171OBh7nxyODDNmIHXpDdko7jEd1IjxwGAjW7lfin r4bb4CComzMN3vIgxAcl6WI9udI43Vx6tdtf6X4g9oOeniFnygjU2E4A1XvB/v2bdVAn DZdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hPBUpLS4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-68062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id fa29-20020a056a002d1d00b006e0733b3429si2429546pfb.340.2024.02.15.21.12.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 21:12:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hPBUpLS4; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-68062-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68062-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C95DCB21951 for ; Fri, 16 Feb 2024 05:10:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BEBC12E5D; Fri, 16 Feb 2024 05:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hPBUpLS4" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 D9EE263CF for ; Fri, 16 Feb 2024 05:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708060205; cv=none; b=cbC/ySP2omkBS1ZV54UVblyYK/kbLJ7Z+IP7n/KPxfb7NB+xQwpNnxn26+6FWTAZshv9SYCXOqeU/S34HTfXFKdYrAdaw5XJ9vJT4XZjabK1X7Y0noxeexY1nokRKW93Z5gXDgYPA1ibul8gOhrOKnUYutu22RtHuOLJg6Ed934= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708060205; c=relaxed/simple; bh=iV4xyfoj4RAGaEV3TwSlOffEIYtm/b/aiUVQz4Pjzf4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ppDdkVKKbxTf+vWDNYUbkhgHy8QMZ4jmDgxv9T2gspY10/5SZagNUtSdnhsxtMJVRc4kuyodUBGPlvjMwmATtpLbnv851/pVeuF10JF2OshMLGnqgwPxRbic2y/JrsKRUmkmn0w3H2DgzMAKAFtzMYEhJDBTA1fW2fsZg1nvIog= 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=hPBUpLS4; arc=none smtp.client-ip=209.85.214.177 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-f177.google.com with SMTP id d9443c01a7336-1d51ba18e1bso17028725ad.0 for ; Thu, 15 Feb 2024 21:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708060203; x=1708665003; 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=osRd6e0938TIuqccy/3nmWVE3X+VrWpnZGag3nbS18c=; b=hPBUpLS4cBBiTV70H8F1iCPSfqNikpM/VvHSjhNnE2a/819s4orgUQptu6iV2xCAFD 42SIRkL4qOIykNBWzGEqnEUHaVdCUeQK8cPCyNEiaLNy2nRCLzlbEBsOBTH1ovDsKvbW 0o6oa9SYHF78IoG2TtGe3bcIUM3zyj1Xm6wYu7/ux9EvC0Fc6HnmnkfCz9+tFtLsQCtb TEB9ePashq4W89zBvIXPeXI49+wQI90BrtiJRiNsu02AgUDcjNYL50dUtaBYVka/z+ZM asOP2D+DxkpCjZMxtk9IL3XuJz2xE2xZHkdKJ1dDzKAvrZqLCkle9abn7qooIdan+IbT 2j+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708060203; x=1708665003; 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=osRd6e0938TIuqccy/3nmWVE3X+VrWpnZGag3nbS18c=; b=WcikG8IGXnNu7kf9URKsOjrf0UnJkOHhGtrJluifsHu8o+8nN46rzOhRNtoeeWvJYx k8VAhcTgyk/sjMpAlAMWWX0dSc8VZgpUSKMM62xs3wQ9Pf5IRTUjrwC+jYTkF28ylcc7 tlyDsqfmjyriyZiVqJMchi8X4gMGf85I0qwhl4/iPZiiDfP9IZV4d2SwdNvEh84SgBQ9 2iHAGPFPgcrMkWCjmLemcDZSU/eza4qXnhLTuQdY9iV4lcB9Qy7blKhjpO1QPFBABS+j uz+tQRXmI6gDkin/uPlY/BHUU9liMYJ3+G0audRuKPKpRwG6eB/q9nXI4+3IsaKTqNv/ xX6Q== X-Gm-Message-State: AOJu0Yyt+svQ4VjGNqtOg8NbANYarC+tse2WZ8AxqiESnjKrqnI5+uK5 6B05MnGzUIlji7AIB3Mc0MozEGGMOnWvJXgHb3O/PjCZrynOQEBW X-Received: by 2002:a17:902:aa84:b0:1d9:c17b:43f3 with SMTP id d4-20020a170902aa8400b001d9c17b43f3mr3587876plr.15.1708060202909; Thu, 15 Feb 2024 21:10:02 -0800 (PST) Received: from localhost (dhcp-141-239-158-86.hawaiiantel.net. [141.239.158.86]) by smtp.gmail.com with ESMTPSA id bi11-20020a170902bf0b00b001db499c5c12sm2084701plb.143.2024.02.15.21.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 21:10:02 -0800 (PST) Sender: Tejun Heo Date: Thu, 15 Feb 2024 19:10:01 -1000 From: Tejun Heo To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, Naresh Kamboju , Anders Roxell , Peter Zijlstra , Valentin Schneider , Sebastian Andrzej Siewior , Stephen Rothwell Subject: [PATCH v2 wq/for-6.9] workqueue, irq_work: Build fix for !CONFIG_IRQ_WORK Message-ID: References: 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: 2f34d7337d98 ("workqueue: Fix queue_work_on() with BH workqueues") added irq_work usage to workqueue; however, it turns out irq_work is actually optional and the change breaks build on configuration which doesn't have CONFIG_IRQ_WORK enabled. Fix build by making workqueue use irq_work only when CONFIG_SMP and enabling CONFIG_IRQ_WORK when CONFIG_SMP is set. It's reasonable to argue that it may be better to just always enable it. However, this still saves a small bit of memory for tiny UP configs and also the least amount of change, so, for now, let's keep it conditional. Verified to do the right thing for x86_64 allnoconfig and defconfig, and aarch64 allnoconfig, allnoconfig + prink disable (SMP but nothing selects IRQ_WORK) and a modified aarch64 Kconfig where !SMP and nothing selects IRQ_WORK. v2: `depends on SMP` leads to Kconfig warnings when CONFIG_IRQ_WORK is selected by something else when !CONFIG_SMP. Use `def_bool y if SMP` instead. Signed-off-by: Tejun Heo Reported-by: Naresh Kamboju Fixes: 2f34d7337d98 ("workqueue: Fix queue_work_on() with BH workqueues") Cc: Stephen Rothwell --- Hello, Unfortunately, the previous patch triggers Kconfig warnings when IRQ_WORK is selected by something else but !CONFIG_SMP. This one seems to do the right thing in all cases. Naresh, Anders, can you please test it again? Thanks. init/Kconfig | 2 +- kernel/workqueue.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 8df18f3a9748..0d21c9e0398f 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -106,7 +106,7 @@ config CONSTRUCTORS bool config IRQ_WORK - bool + def_bool y if SMP config BUILDTIME_TABLE_SORT bool diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 04e35dbe6799..6ae441e13804 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1209,6 +1209,20 @@ static struct irq_work *bh_pool_irq_work(struct worker_pool *pool) return &per_cpu(bh_pool_irq_works, pool->cpu)[high]; } +static void kick_bh_pool(struct worker_pool *pool) +{ +#ifdef CONFIG_SMP + if (unlikely(pool->cpu != smp_processor_id())) { + irq_work_queue_on(bh_pool_irq_work(pool), pool->cpu); + return; + } +#endif + if (pool->attrs->nice == HIGHPRI_NICE_LEVEL) + raise_softirq_irqoff(HI_SOFTIRQ); + else + raise_softirq_irqoff(TASKLET_SOFTIRQ); +} + /** * kick_pool - wake up an idle worker if necessary * @pool: pool to kick @@ -1227,15 +1241,7 @@ static bool kick_pool(struct worker_pool *pool) return false; if (pool->flags & POOL_BH) { - if (likely(pool->cpu == smp_processor_id())) { - if (pool->attrs->nice == HIGHPRI_NICE_LEVEL) - raise_softirq_irqoff(HI_SOFTIRQ); - else - raise_softirq_irqoff(TASKLET_SOFTIRQ); - } else { - irq_work_queue_on(bh_pool_irq_work(pool), pool->cpu); - } - + kick_bh_pool(pool); return true; } -- 2.43.2