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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16FE7C433F5 for ; Fri, 12 Nov 2021 14:59:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAA0B61104 for ; Fri, 12 Nov 2021 14:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235157AbhKLPCB (ORCPT ); Fri, 12 Nov 2021 10:02:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32148 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231553AbhKLPCA (ORCPT ); Fri, 12 Nov 2021 10:02:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636729149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kuacD5vLivfi9Vhd+sJjK4H2SVQwcnyZPhr4Pvq0lJw=; b=bNHnVVaIhauQSA4QRq43C2xLuiwd7jryt+pn7p4ooZC9yhzcmG/dQ54yhn3tJXab/I8hZI a3NMJOXIoXgCSUMdnn2jqfDgzZJN/+PJMySQ5ULFgbleR75zO5DCiUcXcM8a88H+GoOmUd uVRfQMGrQyRSdge1+9WpqJ7eKDL7KD8= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-1Jwery6eOcyaJBZxdvILnQ-1; Fri, 12 Nov 2021 09:59:07 -0500 X-MC-Unique: 1Jwery6eOcyaJBZxdvILnQ-1 Received: by mail-ed1-f69.google.com with SMTP id o15-20020a056402438f00b003e32b274b24so8416244edc.21 for ; Fri, 12 Nov 2021 06:59:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kuacD5vLivfi9Vhd+sJjK4H2SVQwcnyZPhr4Pvq0lJw=; b=oRC/nDE/CaS1UYrYrif+kFc0jvZirf8R8vLQ1LOcIWldrrVAKtnqJWF+mKPDA2thDM CWVuuNTR/uv8VcVvWtbdE16x5OZUusCjJUZ3bQQiyFhSV48w8cHqptz95S7EJp/WXYhx gvDIHsM/QpGvkcYs8jvZV8q/Dxx4lkDC2okO2kkd4VrEWHrcRDLVZCVQyY7LzShDO/2h qVlsfn/DoG8+oNvl6QeYV+1AD/wVOuH50dILct7EqW+hlrZ0KrJoiU99Jx5Uj1avjQht TgbbFS4pGZrJFFTuKKCGCO3Da/N2xVYhHoPaXIsYZVIpTDbzddK/XS593Bhm3KqmB37H 6G+g== X-Gm-Message-State: AOAM531eTr8sr3CHgrv5chWDVZhbLPgrUF0y64svghzT8+UWbkYzZtY4 c1xJH/oDDG+Zq+pA7fxuQf+IgXzYRGXRhJ1bDKG4xxbXioGC3nGBEBITn7dRBviCifFJOJoLGW6 ukkepPjp1OXF+ykUbE2N643uNTm06qsUrUr7jKoaP X-Received: by 2002:a17:906:6bc4:: with SMTP id t4mr19691819ejs.259.1636729146773; Fri, 12 Nov 2021 06:59:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1anZwyuhVXMwe01ZXVT6KbWAadtmbZmDfi8OET+3NT+57gF/KYJ3gEvo2cvgh1oD2Mbo+rUGynLBJOHRkUEA= X-Received: by 2002:a17:906:6bc4:: with SMTP id t4mr19691794ejs.259.1636729146574; Fri, 12 Nov 2021 06:59:06 -0800 (PST) MIME-Version: 1.0 References: <20211111195904.618253-1-wander@redhat.com> <20211111195904.618253-2-wander@redhat.com> <20211112145755.GX641268@paulmck-ThinkPad-P17-Gen-1> In-Reply-To: <20211112145755.GX641268@paulmck-ThinkPad-P17-Gen-1> From: Wander Costa Date: Fri, 12 Nov 2021 11:58:55 -0300 Message-ID: Subject: Re: [PATCH v2 1/1] printk: suppress rcu stall warnings caused by slow console devices To: "Paul E . McKenney" Cc: Sergey Senozhatsky , Wander Lairson Costa , Petr Mladek , Steven Rostedt , John Ogness , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 12, 2021 at 11:58 AM Paul E. McKenney wrote: > > On Fri, Nov 12, 2021 at 11:42:39AM -0300, Wander Costa wrote: > > On Thu, Nov 11, 2021 at 10:42 PM Sergey Senozhatsky > > wrote: > > > > > > On (21/11/11 16:59), Wander Lairson Costa wrote: > > > > > > > > If we have a reasonable large dataset to flush in the printk ring > > > > buffer in the presence of a slow console device (like a serial port > > > > with a low baud rate configured), the RCU stall detector may report > > > > warnings. > > > > > > > > This patch suppresses RCU stall warnings while flushing the ring buffer > > > > to the console. > > > > > > > [..] > > > > +extern int rcu_cpu_stall_suppress; > > > > + > > > > +static void rcu_console_stall_suppress(void) > > > > +{ > > > > + if (!rcu_cpu_stall_suppress) > > > > + rcu_cpu_stall_suppress = 4; > > > > +} > > > > + > > > > +static void rcu_console_stall_unsuppress(void) > > > > +{ > > > > + if (rcu_cpu_stall_suppress == 4) > > > > + rcu_cpu_stall_suppress = 0; > > > > +} > > > > + > > > > /** > > > > * console_unlock - unlock the console system > > > > * > > > > @@ -2634,6 +2648,9 @@ void console_unlock(void) > > > > * and cleared after the "again" goto label. > > > > */ > > > > do_cond_resched = console_may_schedule; > > > > + > > > > + rcu_console_stall_suppress(); > > > > + > > > > again: > > > > console_may_schedule = 0; > > > > > > > > @@ -2645,6 +2662,7 @@ void console_unlock(void) > > > > if (!can_use_console()) { > > > > console_locked = 0; > > > > up_console_sem(); > > > > + rcu_console_stall_unsuppress(); > > > > return; > > > > } > > > > > > > > @@ -2716,8 +2734,10 @@ void console_unlock(void) > > > > > > > > handover = console_lock_spinning_disable_and_check(); > > > > printk_safe_exit_irqrestore(flags); > > > > - if (handover) > > > > + if (handover) { > > > > + rcu_console_stall_unsuppress(); > > > > return; > > > > + } > > > > > > > > if (do_cond_resched) > > > > cond_resched(); > > > > @@ -2738,6 +2758,8 @@ void console_unlock(void) > > > > retry = prb_read_valid(prb, next_seq, NULL); > > > > if (retry && console_trylock()) > > > > goto again; > > > > + > > > > + rcu_console_stall_unsuppress(); > > > > } > > > > > > May be we can just start touching watchdogs from printing routine? > > > > > Hrm, console_unlock is called from vprintk_emit [0] with preemption > > disabled. and it already has the logic implemented to call > > cond_resched when possible [1]. > > > > [0] https://elixir.bootlin.com/linux/latest/source/kernel/printk/printk.c#L2244 > > [1] https://elixir.bootlin.com/linux/latest/source/kernel/printk/printk.c#L2719 > > So when we are having problems is when console_may_schedule == 0? > Exactly. > Thanx, Paul >