Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3814029pxb; Mon, 21 Feb 2022 06:17:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwW6vH8UQuT/IhzL2fwRglb54jTHudrZSDQIuD7QDIpMTqa2UBFMmVgu9L97o0Q6/bNh5hF X-Received: by 2002:a17:902:b183:b0:14f:c266:20d5 with SMTP id s3-20020a170902b18300b0014fc26620d5mr4057739plr.136.1645453031669; Mon, 21 Feb 2022 06:17:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645453031; cv=none; d=google.com; s=arc-20160816; b=R0rrQUDt3qJ80kmT/Jzo6XwuYHjsbPfELIYZ46weBuvF8CONT3iT0GYEZJcwegu+5b 3ijVNCzt4gZsEPtxtEDtaOckjMLq445aSoZMkLMtSp+k/fcE/cj0ywgJvQEAjvDndFhz pUne/EMiWQvG/HmFsWd+8lenvHDHWB6BKK00rLe9JKpExys9R3jf3ZnhAmYpDsAomxqk EV1zz6Bu3arCQJo6hKn+Ba7hT7NbzjAhOylyx9m3hZuId9iriZR8qozSprC9HH4i2K3L Qt91fBzmXXXaL8cZoeyUL+MM+5o4uB4FszAhqqBqdUtKDB/Mo/wl0P9TxXN41h+/X6RO 3ufA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=zHWAjERdKhywhd8GaH6dOHSxSANpKlo9Lac9wKrwFVo=; b=XMx3b2JwK86t18icOvN+IHwKM/scKI4MNekGnHVXJbgCTF7GzgojeCXUsORwhcMlwC Ad67XaUWWzMUaQHhzPbl7MVuLi+sUint/LJVVlOFsWyz/bhUhZrBg2n89ngQeyl0qfhf /mhmaqmyBZzlROvl1tBcs8/uG51dbaPwBld/ufab8PECwRgBM+Dfg3B3ILSJd8LucpRz sDVUwPGya1vlEKlMtNML3HmiiAv0U413+wcYVrsvOY6cyhX8orhfSCaVFSqEYpTeiDod OIWPhX6+tYpKpPsFU0uQrtTp0Jixkpdovm1Ke1jOlGw+UHVzHrkcdEZeq+K7JOIUfdgm 69RA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w31si18578398pgk.389.2022.02.21.06.16.56; Mon, 21 Feb 2022 06:17:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239746AbiBULJ4 (ORCPT + 99 others); Mon, 21 Feb 2022 06:09:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355672AbiBULJm (ORCPT ); Mon, 21 Feb 2022 06:09:42 -0500 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C987C3FD94 for ; Mon, 21 Feb 2022 02:38:27 -0800 (PST) Received: from fsav314.sakura.ne.jp (fsav314.sakura.ne.jp [153.120.85.145]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 21LAcAgn000134; Mon, 21 Feb 2022 19:38:10 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav314.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav314.sakura.ne.jp); Mon, 21 Feb 2022 19:38:10 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav314.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 21LAcAlI000131 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Mon, 21 Feb 2022 19:38:10 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <3a20c799-c18e-dd3a-3161-fee6bca1491e@I-love.SAKURA.ne.jp> Date: Mon, 21 Feb 2022 19:38:09 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH] workqueue: Use private WQ for schedule_on_each_cpu() API Content-Language: en-US To: Tejun Heo Cc: 0day robot , LKML , lkp@lists.01.org, kernel test robot References: <20220221083358.GC835@xsang-OptiPlex-9020> From: Tetsuo Handa In-Reply-To: <20220221083358.GC835@xsang-OptiPlex-9020> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since schedule_on_each_cpu() calls schedule_work_on() and flush_work(), we should avoid using system_wq in order to avoid unexpected locking dependency. [T1] Running RCU-tasks wait API self tests [T9] Please do not flush events WQ. [T9] CPU: 0 PID: 9 Comm: rcu_tasks_rude_ Not tainted 5.16.0-06523-g29bd199e4e73 #1 [T9] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 [T9] Call Trace: [T9] [T9] dump_stack_lvl+0x45/0x59 [T9] check_flush_dependency.cold+0x18/0x49 [T9] __flush_work+0x202/0xa00 [T9] schedule_on_each_cpu+0x1d8/0x300 [T9] rcu_tasks_kthread+0x21f/0x580 [T9] kthread+0x3a4/0x480 [T9] ret_from_fork+0x22/0x30 [T9] [T1] Performance Events: unsupported p6 CPU model 42 no PMU driver, software events only. Reported-by: kernel test robot Signed-off-by: Tetsuo Handa --- Tejun, are you OK with https://lkml.kernel.org/r/2f887679-c783-bf18-a2aa-aa9a709bfb38@I-love.SAKURA.ne.jp ? kernel/workqueue.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 8e6e64372441..6ebc6cb15c1c 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3345,10 +3345,16 @@ int schedule_on_each_cpu(work_func_t func) { int cpu; struct work_struct __percpu *works; + struct workqueue_struct *wq; works = alloc_percpu(struct work_struct); if (!works) return -ENOMEM; + wq = alloc_workqueue("events_sync", 0, 0); + if (!wq) { + free_percpu(works); + return -ENOMEM; + } cpus_read_lock(); @@ -3363,6 +3369,7 @@ int schedule_on_each_cpu(work_func_t func) flush_work(per_cpu_ptr(works, cpu)); cpus_read_unlock(); + destroy_workqueue(wq); free_percpu(works); return 0; } -- 2.32.0