From patchwork Wed Dec 1 20:41:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 520071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69C88C433EF for ; Wed, 1 Dec 2021 20:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353006AbhLAUpT (ORCPT ); Wed, 1 Dec 2021 15:45:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352909AbhLAUof (ORCPT ); Wed, 1 Dec 2021 15:44:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58B0CC061748; Wed, 1 Dec 2021 12:41:14 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BFDDEB81F49; Wed, 1 Dec 2021 20:41:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7973AC53FD2; Wed, 1 Dec 2021 20:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391271; bh=4y5hReX9l2hsG6EBXTxO7rccJ7/0dmlqmFS2ZJV98SQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=NVNhW/VPFdMgSTPEOCZSqXvGPtPqRmaigbBFZ5vk0EdTG5dwjLa9s4YX3tPJ2YNBl TwsUB/xhqZwn3kmSGQ6wrDQNHDbd6uYO4Cg3MmgQ9kurDskRBFu69DX/sQfc+rHCUk 3utCcXeZNdPPykgY3o68fZ+TbWB4vfaXECOAsFT3uVWiV4u4gV1NojyzGGGS3BEKi0 vikFac1FHyaLOvGjcneQ6wiOAtlBEwLnmhqAt/4iXDDH18ipnNHzQWWPqN3mHmCH1l 2Vxgf+rYhG0w8Y2UazmB8HkusHlE3UlfPxh+eRdYxXpL1hvWdIlT58/OYHm41cMR1Z O0J6SbHwX0Mlw== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Cc: Mike Galbraith , stable-rt@vger.kernel.org Subject: [PATCH RT 1/8] mm, zsmalloc: Convert zsmalloc_handle.lock to spinlock_t Date: Wed, 1 Dec 2021 14:41:01 -0600 Message-Id: <8dd83edff24aac9dd53fdbadc7c767c3e9379ea2.1638391253.git.zanussi@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Mike Galbraith v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream 5.10 commit f2d9006d27c9b12563b8e577951ff5021f3b36b2 ] local_lock_t becoming a synonym of spinlock_t had consequences for the RT mods to zsmalloc, which were taking a mutex while holding a local_lock, inspiring a lockdep "BUG: Invalid wait context" gripe. Converting zsmalloc_handle.lock to a spinlock_t restored lockdep silence. Cc: stable-rt@vger.kernel.org Signed-off-by: Mike Galbraith Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Tom Zanussi --- mm/zsmalloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e64eca4b0601..9fc494fe70ea 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -81,7 +81,7 @@ struct zsmalloc_handle { unsigned long addr; - struct mutex lock; + spinlock_t lock; }; #define ZS_HANDLE_ALLOC_SIZE (sizeof(struct zsmalloc_handle)) @@ -368,7 +368,7 @@ static unsigned long cache_alloc_handle(struct zs_pool *pool, gfp_t gfp) if (p) { struct zsmalloc_handle *zh = p; - mutex_init(&zh->lock); + spin_lock_init(&zh->lock); } #endif return (unsigned long)p; @@ -926,7 +926,7 @@ static inline int testpin_tag(unsigned long handle) #ifdef CONFIG_PREEMPT_RT struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - return mutex_is_locked(&zh->lock); + return spin_is_locked(&zh->lock); #else return bit_spin_is_locked(HANDLE_PIN_BIT, (unsigned long *)handle); #endif @@ -937,7 +937,7 @@ static inline int trypin_tag(unsigned long handle) #ifdef CONFIG_PREEMPT_RT struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - return mutex_trylock(&zh->lock); + return spin_trylock(&zh->lock); #else return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle); #endif @@ -948,7 +948,7 @@ static void pin_tag(unsigned long handle) #ifdef CONFIG_PREEMPT_RT struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - return mutex_lock(&zh->lock); + return spin_lock(&zh->lock); #else bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle); #endif @@ -959,7 +959,7 @@ static void unpin_tag(unsigned long handle) #ifdef CONFIG_PREEMPT_RT struct zsmalloc_handle *zh = zs_get_pure_handle(handle); - return mutex_unlock(&zh->lock); + return spin_unlock(&zh->lock); #else bit_spin_unlock(HANDLE_PIN_BIT, (unsigned long *)handle); #endif From patchwork Wed Dec 1 20:41:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 519579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CB1FC433F5 for ; Wed, 1 Dec 2021 20:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353033AbhLAUp1 (ORCPT ); Wed, 1 Dec 2021 15:45:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352977AbhLAUoh (ORCPT ); Wed, 1 Dec 2021 15:44:37 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35075C06174A; Wed, 1 Dec 2021 12:41:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7F036CE1DED; Wed, 1 Dec 2021 20:41:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C44CDC53FCD; Wed, 1 Dec 2021 20:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391272; bh=fg9HL5x9TTG1Jo2tV+0s1T0gAtxsJ85PiqajQWHSV4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=ZlraEEuhPFP/uYxAbfvg1jz+y1IaluV42juj/hSTKDQPUWnuE6HXyGEntEOzSJ0P/ VkT212io1cY2RCEn3w5BT1TkVYs4st9aykVqiGRTayBWdEWDKyUvgT30JWhRbUg1Eo 6FXtE7pdKphfMLL1DCzzU+taBaRXwalae52KySmUu2rX3kh+fiZ6o0ev3Zjz67Joa3 atY7aZhjNf830qnNgVQEJDK+smVQNz04+j1zAiuJU+Ls0vV9hzqtEeL6fRfl9rlEH5 QIanr9GU4Bp8d1z66kATwalbR05UvBCHNs+0eG7d1JL1KcIw2Bw8UqKUzT1Seg7WEa v0ZWAOgwH7Wfw== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Cc: stable-rt@vger.kernel.org Subject: [PATCH RT 2/8] sched: Switch wait_task_inactive to HRTIMER_MODE_REL_HARD Date: Wed, 1 Dec 2021 14:41:02 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Sebastian Andrzej Siewior v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 39609ed79d420e0b966e16a1d695733c2d3b9a7f ] With PREEMPT_RT enabled all hrtimers callbacks will be invoked in softirq mode unless they are explicitly marked as HRTIMER_MODE_HARD. During boot kthread_bind() is used for the creation of per-CPU threads and then hangs in wait_task_inactive() if the ksoftirqd is not yet up and running. The hang disappeared since commit 26c7295be0c5e ("kthread: Do not preempt current task if it is going to call schedule()") but enabling function trace on boot reliably leads to the freeze on boot behaviour again. The timer in wait_task_inactive() can not be directly used by an user interface to abuse it and create a mass wake of several tasks at the same time which would to long sections with disabled interrupts. Therefore it is safe to make the timer HRTIMER_MODE_REL_HARD. Switch the timer to HRTIMER_MODE_REL_HARD. Cc: stable-rt@vger.kernel.org Link: https://lkml.kernel.org/r/20210826170408.vm7rlj7odslshwch@linutronix.de Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Tom Zanussi --- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9b32fbded588..022c7b78642d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2158,7 +2158,7 @@ unsigned long wait_task_inactive(struct task_struct *p, long match_state) ktime_t to = NSEC_PER_SEC / HZ; set_current_state(TASK_UNINTERRUPTIBLE); - schedule_hrtimeout(&to, HRTIMER_MODE_REL); + schedule_hrtimeout(&to, HRTIMER_MODE_REL_HARD); continue; } From patchwork Wed Dec 1 20:41:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 520070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D36DC433EF for ; Wed, 1 Dec 2021 20:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353055AbhLAUpb (ORCPT ); Wed, 1 Dec 2021 15:45:31 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:34032 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352973AbhLAUoh (ORCPT ); Wed, 1 Dec 2021 15:44:37 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1B7A9B81F49; Wed, 1 Dec 2021 20:41:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E94C2C53FCF; Wed, 1 Dec 2021 20:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391273; bh=xhGJRz9BulQnvsOgFE2Mr1fKCRSkEYqt5PpRCrxkWL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=CZ578Q3NDDUSWRMjBPndP9vGk/2xQTprej9Eb3FXs0gBkhHZG7AJTM4uEfAe7fMwC kgk9J28qvfwMFgVLggUyDsRi4w7JfkpbGB6PDwQLaaH6F7oPc9CDMqg+vhbZSVRFqF T1WVy24hJadazQdN6Z26JrhF/u+auYWPtBIVqUpYfi31p7/N3rU0ZkcfljGHM4E9GR s2nOyySFP4aaUNTBsuxhG0QYcJhjdtuEHYJ5MjfQgUNAyqHphWJbubZBiIVSIFSJ5w e9Y0qtjKupu0bGFUD+gUavf7Nj7mv2Mpok7YlYz4FL1aJdMO59aGJfDVN5d1LefsnS JRrPQwS1j8Olg== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Cc: stable-rt@vger.kernel.org Subject: [PATCH RT 3/8] preempt: Move preempt_enable_no_resched() to the RT block Date: Wed, 1 Dec 2021 14:41:03 -0600 Message-Id: <9d8babfb7cbd1d5639c50b352d32cf5ab6f83daf.1638391253.git.zanussi@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Sebastian Andrzej Siewior v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 1a45b3551ef852193c3d338888132c4925d0690d ] preempt_enable_no_resched() should point to preempt_enable() on PREEMPT_RT so nobody is playing any preempt tricks and enables preemption without checking for the need-resched flag. This was misplaced in v3.14.0-rt1 und remained unnoticed until now. Point preempt_enable_no_resched() and preempt_enable() on RT. Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Tom Zanussi --- include/linux/preempt.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/preempt.h b/include/linux/preempt.h index adb085fe31e4..bbc3592b6f04 100644 --- a/include/linux/preempt.h +++ b/include/linux/preempt.h @@ -211,12 +211,12 @@ do { \ preempt_count_dec(); \ } while (0) -#ifdef CONFIG_PREEMPT_RT +#ifndef CONFIG_PREEMPT_RT # define preempt_enable_no_resched() sched_preempt_enable_no_resched() -# define preempt_check_resched_rt() preempt_check_resched() +# define preempt_check_resched_rt() barrier(); #else # define preempt_enable_no_resched() preempt_enable() -# define preempt_check_resched_rt() barrier(); +# define preempt_check_resched_rt() preempt_check_resched() #endif #define preemptible() (preempt_count() == 0 && !irqs_disabled()) From patchwork Wed Dec 1 20:41:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 519578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD0FAC433F5 for ; Wed, 1 Dec 2021 20:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352927AbhLAUpc (ORCPT ); Wed, 1 Dec 2021 15:45:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352975AbhLAUoi (ORCPT ); Wed, 1 Dec 2021 15:44:38 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D90C06175A; Wed, 1 Dec 2021 12:41:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 73FDFCE2105; Wed, 1 Dec 2021 20:41:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13EAFC53FD0; Wed, 1 Dec 2021 20:41:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391275; bh=u7hDbDByWYfT0TX0W3OHC3WM8OBJ/lrCMsCnd08PHIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=bzqexLznTw7eifiMaUbFNhSjDXnaFMdYCRsBnL94R0vJXvOy1JIvLIGzFe9J8FIKF goDWWE5ZeTmV0sAMauilCwnZXxEAnFB1oOZZ4cb3ssIkD61QBwLNuH2FqxND2jv2WV lIvoltR27E8bdy/IECR3/ezQBwHvB684iiiHfqgEawIcjaibMht6KAf+BBqwzDHKrz 2dx+k7s4a5KqxQlhPTY8al2uM0O3btosQ0Ovxd+h5HI2U+BK2pTZK6WCWkP2pYDABy org2Owk/Fi5APfUyLfmjhU7II9nG9xbLM4SKijvuyspNqmdj6eewBiH4OFyLxHV73V CDHMht83/Fu6w== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Cc: stable-rt@vger.kernel.org, Mel Gorman Subject: [PATCH RT 4/8] mm: Disable NUMA_BALANCING_DEFAULT_ENABLED and TRANSPARENT_HUGEPAGE on PREEMPT_RT Date: Wed, 1 Dec 2021 14:41:04 -0600 Message-Id: <0421bbd936f2b617164726e47825ce243f0fa5ee.1638391253.git.zanussi@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Sebastian Andrzej Siewior v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit aae93144898af113331668f53f80cb83f5a07360 ] TRANSPARENT_HUGEPAGE: There are potential non-deterministic delays to an RT thread if a critical memory region is not THP-aligned and a non-RT buffer is located in the same hugepage-aligned region. It's also possible for an unrelated thread to migrate pages belonging to an RT task incurring unexpected page faults due to memory defragmentation even if khugepaged is disabled. Regular HUGEPAGEs are not affected by this can be used. NUMA_BALANCING: There is a non-deterministic delay to mark PTEs PROT_NONE to gather NUMA fault samples, increased page faults of regions even if mlocked and non-deterministic delays when migrating pages. [Mel Gorman worded 99% of the commit description]. Link: https://lore.kernel.org/all/20200304091159.GN3818@techsingularity.net/ Link: https://lore.kernel.org/all/20211026165100.ahz5bkx44lrrw5pt@linutronix.de/ Cc: stable-rt@vger.kernel.org Cc: Mel Gorman Signed-off-by: Sebastian Andrzej Siewior Acked-by: Mel Gorman Link: https://lore.kernel.org/r/20211028143327.hfbxjze7palrpfgp@linutronix.de Signed-off-by: Tom Zanussi --- init/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/Kconfig b/init/Kconfig index 266802704c06..c733392fe237 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -769,7 +769,7 @@ config NUMA_BALANCING bool "Memory placement aware NUMA scheduler" depends on ARCH_SUPPORTS_NUMA_BALANCING depends on !ARCH_WANT_NUMA_VARIABLE_LOCALITY - depends on SMP && NUMA && MIGRATION + depends on SMP && NUMA && MIGRATION && !PREEMPT_RT help This option adds support for automatic NUMA aware memory/task placement. The mechanism is quite primitive and is based on migrating memory when From patchwork Wed Dec 1 20:41:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 520069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20899C433F5 for ; Wed, 1 Dec 2021 20:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353079AbhLAUpe (ORCPT ); Wed, 1 Dec 2021 15:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352960AbhLAUol (ORCPT ); Wed, 1 Dec 2021 15:44:41 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A16B3C061761; Wed, 1 Dec 2021 12:41:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id EDD95CE1DED; Wed, 1 Dec 2021 20:41:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 438DBC53FCC; Wed, 1 Dec 2021 20:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391276; bh=ie+rHXtHrUJO2uja2y5OVbalZjaKsOdco+591qQQ0S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=GeagFzHAEGIA9MICMldYqzaFOreDKNBShKyUzXkdCqpuc5Il8y2wJw1OE74GwTxsB P2YYCYA1ZyFm7rxEa6avS4kATXKvnNVciOVHp1Y6FZy2O3lFhmuUgj++QYiiA4bPg2 l0YEjWweNLIB6tgZPJDH4cq8DTRUh2ST/0zDvTRUwnCaPjh7jKR/6HRY+fYCiIxduC eHXEEsqN2fTVTlnJ9xdQQs2mbobLBX0Rqc+/DwCpXFVUM2WXinPer3VQIkqhJjwjm5 +75q4OYHqRQWuz1WHGF6XeuWCN4Tezwhg+RaD1mtUCoa+HPdTHBsveeQn1cxxaJfA5 I6noGTxL3V9pA== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Cc: stable-rt@vger.kernel.org Subject: [PATCH RT 5/8] fscache: Use only one fscache_object_cong_wait. Date: Wed, 1 Dec 2021 14:41:05 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Sebastian Andrzej Siewior v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 74920695ab51a6d180dcd6554193cc8427758360 ] In the commit mentioned below, fscache was converted from slow-work to workqueue. slow_work_enqueue() and slow_work_sleep_till_thread_needed() did not use a per-CPU workqueue. They choose from two global waitqueues depending on the SLOW_WORK_VERY_SLOW bit which was not set so it always one waitqueue. I can't find out how it is ensured that a waiter on certain CPU is woken up be the other side. My guess is that the timeout in schedule_timeout() ensures that it does not wait forever (or a random wake up). fscache_object_sleep_till_congested() must be invoked from preemptible context in order for schedule() to work. In this case this_cpu_ptr() should complain with CONFIG_DEBUG_PREEMPT enabled except the thread is bound to one CPU. wake_up() wakes only one waiter and I'm not sure if it is guaranteed that only one waiter exists. Replace the per-CPU waitqueue with one global waitqueue. Fixes: 8b8edefa2fffb ("fscache: convert object to use workqueue instead of slow-work") Reported-by: Gregor Beck Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Tom Zanussi --- fs/fscache/internal.h | 1 - fs/fscache/main.c | 6 ------ fs/fscache/object.c | 11 +++++------ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h index d09d4e69c818..b557eb2263d2 100644 --- a/fs/fscache/internal.h +++ b/fs/fscache/internal.h @@ -95,7 +95,6 @@ extern unsigned fscache_debug; extern struct kobject *fscache_root; extern struct workqueue_struct *fscache_object_wq; extern struct workqueue_struct *fscache_op_wq; -DECLARE_PER_CPU(wait_queue_head_t, fscache_object_cong_wait); extern unsigned int fscache_hash(unsigned int salt, unsigned int *data, unsigned int n); diff --git a/fs/fscache/main.c b/fs/fscache/main.c index e1f1083b61a5..00367233ef8a 100644 --- a/fs/fscache/main.c +++ b/fs/fscache/main.c @@ -41,8 +41,6 @@ struct kobject *fscache_root; struct workqueue_struct *fscache_object_wq; struct workqueue_struct *fscache_op_wq; -DEFINE_PER_CPU(wait_queue_head_t, fscache_object_cong_wait); - /* these values serve as lower bounds, will be adjusted in fscache_init() */ static unsigned fscache_object_max_active = 4; static unsigned fscache_op_max_active = 2; @@ -139,7 +137,6 @@ unsigned int fscache_hash(unsigned int salt, unsigned int *data, unsigned int n) static int __init fscache_init(void) { unsigned int nr_cpus = num_possible_cpus(); - unsigned int cpu; int ret; fscache_object_max_active = @@ -162,9 +159,6 @@ static int __init fscache_init(void) if (!fscache_op_wq) goto error_op_wq; - for_each_possible_cpu(cpu) - init_waitqueue_head(&per_cpu(fscache_object_cong_wait, cpu)); - ret = fscache_proc_init(); if (ret < 0) goto error_proc; diff --git a/fs/fscache/object.c b/fs/fscache/object.c index cfeba839a0f2..c93860274f2f 100644 --- a/fs/fscache/object.c +++ b/fs/fscache/object.c @@ -807,6 +807,8 @@ void fscache_object_destroy(struct fscache_object *object) } EXPORT_SYMBOL(fscache_object_destroy); +static DECLARE_WAIT_QUEUE_HEAD(fscache_object_cong_wait); + /* * enqueue an object for metadata-type processing */ @@ -815,12 +817,10 @@ void fscache_enqueue_object(struct fscache_object *object) _enter("{OBJ%x}", object->debug_id); if (fscache_get_object(object, fscache_obj_get_queue) >= 0) { - wait_queue_head_t *cong_wq = - &get_cpu_var(fscache_object_cong_wait); if (queue_work(fscache_object_wq, &object->work)) { if (fscache_object_congested()) - wake_up(cong_wq); + wake_up(&fscache_object_cong_wait); } else fscache_put_object(object, fscache_obj_put_queue); @@ -842,16 +842,15 @@ void fscache_enqueue_object(struct fscache_object *object) */ bool fscache_object_sleep_till_congested(signed long *timeoutp) { - wait_queue_head_t *cong_wq = this_cpu_ptr(&fscache_object_cong_wait); DEFINE_WAIT(wait); if (fscache_object_congested()) return true; - add_wait_queue_exclusive(cong_wq, &wait); + add_wait_queue_exclusive(&fscache_object_cong_wait, &wait); if (!fscache_object_congested()) *timeoutp = schedule_timeout(*timeoutp); - finish_wait(cong_wq, &wait); + finish_wait(&fscache_object_cong_wait, &wait); return fscache_object_congested(); } From patchwork Wed Dec 1 20:41:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 519577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD087C433EF for ; Wed, 1 Dec 2021 20:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353091AbhLAUpg (ORCPT ); Wed, 1 Dec 2021 15:45:36 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:43872 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352957AbhLAUol (ORCPT ); Wed, 1 Dec 2021 15:44:41 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 372DDCE2102; Wed, 1 Dec 2021 20:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90A12C53FD0; Wed, 1 Dec 2021 20:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391277; bh=ACBzh+o2miqbby9pnmbvnefEjwo6AwbT8tO0QoE7F34=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=BWufx23986sfuXnYxk5SQFnj6yLPLTpatOUjIS4o04GrZV6w93Owya1Xi/PZLKP2g VOmoKVpsliHWoGbcUoQVghSfe8D7nF2LCMSUH1aGBnuIfsy/ASWbzWVM+YvqK6hFgr eOp7c+ZNWhUCudranf6LmJT2Zkxf4K9+A9KFEMaeHpPwPb3SEFTxbzg2dZWJqAZnF2 JMbTVB0etR+he2Oc5ipOt1rKtbXPrj8owmXIgYm0FdqvMoG1XIAu3e4eIXgYV+m3+U eoc/XdU1SXX475SjrLW2A8RZkuAuD33BNmRz/Vfl4hmnAf/D2pqEWfGCq/57pilVfx rhKMhs0pDbdog== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Subject: [PATCH RT 6/8] fscache: Use only one fscache_object_cong_wait. Date: Wed, 1 Dec 2021 14:41:06 -0600 Message-Id: <688eb6554dbe14f0bb09d0b622d7120fefa52742.1638391253.git.zanussi@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Sebastian Andrzej Siewior v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 514342eb43a760575d6d9a366506a41ab7ec4888 ] This is an update of the original patch, removing put_cpu_var() which was overseen in the initial patch. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Tom Zanussi --- fs/fscache/object.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/fscache/object.c b/fs/fscache/object.c index c93860274f2f..959384c91f79 100644 --- a/fs/fscache/object.c +++ b/fs/fscache/object.c @@ -823,8 +823,6 @@ void fscache_enqueue_object(struct fscache_object *object) wake_up(&fscache_object_cong_wait); } else fscache_put_object(object, fscache_obj_put_queue); - - put_cpu_var(fscache_object_cong_wait); } } From patchwork Wed Dec 1 20:41:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 520068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB28BC433EF for ; Wed, 1 Dec 2021 20:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352983AbhLAUph (ORCPT ); Wed, 1 Dec 2021 15:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353019AbhLAUon (ORCPT ); Wed, 1 Dec 2021 15:44:43 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28211C061756; Wed, 1 Dec 2021 12:41:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 75294CE210A; Wed, 1 Dec 2021 20:41:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCA5FC53FD2; Wed, 1 Dec 2021 20:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391278; bh=0eEPhATQ1R0Bm7TG0MGwB3OXGgPxjzOA4WGmxHXHbSs=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=Rtu9b1EGVGU5EqCTQD6vt76bXHzANyMMrC199fogdUY3vLzxdwrccBYKIdBaPIXHb NORQbDPOH+qYQZNSq8woLOSjggB6AHG4n+B12XIlvVRg3v+ZqeqUo8lpqc8UsAGPA9 SSprK8C7ufBxmAJ07ko99Cy6lDu/cW/mTPyuP1cwlzxHc3InYMQPHQaiYyZkQVeOYl tOtJSF1jkEU3Wvjxf0BawLb1ghx0Uk464A5GVmamDcVbEmUgYfJjQcwrylM9o4KCg1 5oe1h1ZhdF2vTSaGyV8T69DrDksD4oBYaw/zE9Sdod9NKE9VWhIrRyi7nFhwaSMEmi hdKlD0UFgJECA== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Subject: [PATCH RT 7/8] locking: Drop might_resched() from might_sleep_no_state_check() Date: Wed, 1 Dec 2021 14:41:07 -0600 Message-Id: <2343af990554e062b1b93fddf610ce78a4a001de.1638391253.git.zanussi@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Sebastian Andrzej Siewior v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream 5.10 commit e88f48e796b2286b565ee95ca8c46f32e051cd8c ] might_sleep_no_state_check() serves the same purpose as might_sleep() except it is used before sleeping locks are acquired and therefore does not check task_struct::state because the state is preserved. That state is preserved in the locking slow path so we must not schedule at the begin of the locking function because the state will be lost and not preserved at that time. Remove might_resched() from might_sleep_no_state_check() to avoid losing the state before it is preserved. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Tom Zanussi --- include/linux/kernel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index f5ec1ddbfe07..fac917085516 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -229,7 +229,7 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset); do { __might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) # define might_sleep_no_state_check() \ - do { ___might_sleep(__FILE__, __LINE__, 0); might_resched(); } while (0) + do { ___might_sleep(__FILE__, __LINE__, 0); } while (0) /** * cant_sleep - annotation for functions that cannot sleep From patchwork Wed Dec 1 20:41:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Zanussi X-Patchwork-Id: 519576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40803C433FE for ; Wed, 1 Dec 2021 20:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353126AbhLAUpm (ORCPT ); Wed, 1 Dec 2021 15:45:42 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:43888 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353020AbhLAUoo (ORCPT ); Wed, 1 Dec 2021 15:44:44 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8B87CCE1DED; Wed, 1 Dec 2021 20:41:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB6DFC53FCF; Wed, 1 Dec 2021 20:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638391279; bh=ERuVyUB0Dw+gqopVgRcEFB6TKIIwtdk9P9zkGW2KS00=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=RbC7f9f6jntVAOAYYbNmiv2bDBlvEGWZLbxEF/HU/UeAQRYZcQ4sY2ng9m7mYivkj fdLhdTGQ8CmjmqWvlF40IjlI9zKpNHPSuSRO62+KR3L7QtUyh76aQwuM0L0TB4vKHz c4xUXfU8ghdvIKFMvLJeJ52aDoOGG2oS6E/p5mrf3SLN6iwicXyehW1cNDWYK/OCmq uMyvb5QPqELm+czj7JP8/rsNB5FjGQk2CgDc4dJNtS64NI+5Er+mA11hZ989G55U5X cC3a6dlLnOE77a3M3hHybn2bBlX/TcmgfWVvWqDNlrK+r0f/gwxBvAbMpRvS9511rK 0Ce1JHLVMozXA== From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Clark Williams , "Luis Claudio R. Goncalves" , Tom Zanussi Subject: [PATCH RT 8/8] Linux 5.4.161-rt67-rc1 Date: Wed, 1 Dec 2021 14:41:08 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org From: Tom Zanussi v5.4.161-rt67-rc1 stable review patch. If anyone has any objections, please let me know. ----------- Signed-off-by: Tom Zanussi --- localversion-rt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localversion-rt b/localversion-rt index d42c0971b041..6f295236237c 100644 --- a/localversion-rt +++ b/localversion-rt @@ -1 +1 @@ --rt66 +-rt67-rc1