Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2146069iof; Tue, 7 Jun 2022 21:17:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4C8JqjKEikWRiNFGs0Fs09CK/pADAqNgH6XmzRjjR1e6+TDlHqVD7uOsV4+j9NHp6WxRk X-Received: by 2002:a17:90a:8914:b0:1dc:20c0:40f4 with SMTP id u20-20020a17090a891400b001dc20c040f4mr71116092pjn.11.1654661836574; Tue, 07 Jun 2022 21:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661836; cv=none; d=google.com; s=arc-20160816; b=IyUIVm898G254Hk3zPucKdVTVAOGyrrTWl4x/KKAR4Z+IXOS/TZOsHFvWQ2Bh7KKrz dAbuu2uevBEGnz7LGdkZufvdw+n8u4NLSbGXXRv6ztVHw7mkzmr3uoHgp7sW7WSdnr54 +PIki5I9Zc31DNgtpB05P6ZsitZfcj65JUGZT0IJqaf465/T487dWStUQzL35Y4FewTH KwwVVCM3LhjTa3BtVb0/l3aisNzdKrE0MeTRe+tee8OtgGrybfrDnQr1sIESaT0TWql4 2ExxYqUd2pPgFQxaJa47zMOpBh0U8EhNLonbEbi0PC80sj3U/WU5szXsAX/WG5R+0vKT brUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mdEmSFUO2twnd3wLdZVge1ODljvqA3kTxw+YiJqjznU=; b=HPgih1KIpVWmPrkOugJ9gbGRzLgLAXn9T0KKJtwzkWjThYrGWbcOgVt1X8RPZZoGyM hS0nrcygDbH0bSJbKsPxKPhHtdkcC9uhVTRDBWA5eCtmSACVt52HMwr6wRFm5fWutDNL PZf/5dH9LPESWMPI8/sNJA3FRcdKu+8FArEwJ0IfZZccLfwv85AtP1rYvyVCaby9xIy0 0BzqicJ7bEbSLtX8kNl6KBLgyQfUHFgHSYG1zvtVgV9C5qv2CMsh2C/z5d5og1M784dt Kfoj/q0ip9/YT4l4BNZR2plEWIEdVsz8fEGfSwL/Ie6tJj1gnBpm77zA27fx+dTo5ucb /vHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e53pWkPM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q12-20020a170902f78c00b001678b6bde1asi6828515pln.330.2022.06.07.21.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:17:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e53pWkPM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 580BF18F87E; Tue, 7 Jun 2022 20:48:29 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377912AbiFGUzP (ORCPT + 99 others); Tue, 7 Jun 2022 16:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358864AbiFGTxS (ORCPT ); Tue, 7 Jun 2022 15:53:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2CF25C59; Tue, 7 Jun 2022 11:22:54 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id BCD296006F; Tue, 7 Jun 2022 18:22:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD482C34115; Tue, 7 Jun 2022 18:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654626173; bh=1uaTTfwT9pRZAFyjX8pnO9QKdbRItDK/BYxL3WuGbZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e53pWkPMz7NOfVF8FTf1KxaRPk69NRIJG+PHYv8TCp81kZjKR8cECAukwwybQ5o2j jktQgHHze+2lbTp+9ZmhPm+1d3Ixyz3ybNEZvrrwNmbapgGeW5VUv+BDNRj/j603ax JNHnbbzpbIwDUcyuOtHfMC3S8JEgrsAu3LG7ji8M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , John Ogness , Petr Mladek , Sasha Levin Subject: [PATCH 5.17 282/772] printk: use atomic updates for klogd work Date: Tue, 7 Jun 2022 18:57:54 +0200 Message-Id: <20220607164957.335498853@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: John Ogness [ Upstream commit 2ba3673d70178bf07fb75ff25c54bc478add4021 ] The per-cpu @printk_pending variable can be updated from sleepable contexts, such as: get_random_bytes() warn_unseeded_randomness() printk_deferred() defer_console_output() and can be updated from interrupt contexts, such as: handle_irq_event_percpu() __irq_wake_thread() wake_up_process() try_to_wake_up() select_task_rq() select_fallback_rq() printk_deferred() defer_console_output() and can be updated from NMI contexts, such as: vprintk() if (in_nmi()) defer_console_output() Therefore the atomic variant of the updating functions must be used. Replace __this_cpu_xchg() with this_cpu_xchg(). Replace __this_cpu_or() with this_cpu_or(). Reported-by: Sebastian Andrzej Siewior Signed-off-by: John Ogness Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/87iltld4ue.fsf@jogness.linutronix.de Signed-off-by: Sasha Levin --- kernel/printk/printk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 833e407545b8..74c92dd70c80 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3230,7 +3230,7 @@ static DEFINE_PER_CPU(int, printk_pending); static void wake_up_klogd_work_func(struct irq_work *irq_work) { - int pending = __this_cpu_xchg(printk_pending, 0); + int pending = this_cpu_xchg(printk_pending, 0); if (pending & PRINTK_PENDING_OUTPUT) { /* If trylock fails, someone else is doing the printing */ @@ -3264,7 +3264,7 @@ void defer_console_output(void) return; preempt_disable(); - __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT); + this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT); irq_work_queue(this_cpu_ptr(&wake_up_klogd_work)); preempt_enable(); } -- 2.35.1