Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp570653imm; Fri, 27 Jul 2018 02:07:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpexrreeZP+mC2pio21l+gbR/BXGuNLmZlnBIbeDApT42MESfmL+3UygBNflNOcaTTI1kcBL X-Received: by 2002:a65:498c:: with SMTP id r12-v6mr5420099pgs.112.1532682448214; Fri, 27 Jul 2018 02:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532682448; cv=none; d=google.com; s=arc-20160816; b=StwBZK+W4YHjZeOmTAye6DzCLKoF225628KMVcSEV5BnjDMT5wsJcw0Vpu5jbcRMdV XZK5eS/2icn1t7DEYst3s7u+azeUNSpo926wPQkQ9cZkEzhTge/EQyZtQKCVqVWxJsjz 50OOgY9Q6ueyCETUj/hJBzl8x8zHI26QqRL/H5a2wKH8qDaeCvTL7MprwK075c3DEhK3 kg6+KcTdC2h/OB4lcZycP/5+b9x4t6gdDvQivYi9b/RqImGt0blR2vgH6kXIxdySxFi3 XjEHgC+efVO2a231gL2OAFSti4oqFm3AjSurwSk9icqcvyossvWzloLINlUBUYng73Ml LvfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=G2/OzZXFOoORTCzdavrcWZNqqc/O+cxkOtKOTVvo3Pk=; b=z+e1JA5dCHzxQznr4i33kjTNRVORjmv2NCAzTZ60XOq8Tqd/DgceYnvngsl+/M+T/g OORKcsPMGoUclzilRDbwgKAIn+4BXT2RheEt8fpRChaG2jjFERSYliAkMYaVrVmG0TLU L0FBMCtEfIZgwtxnzNtvoa8y4L8lcisXinnmdYD6mQIf99mnrvVIj++VWCC42vzh7f/u R/C7buzwnMAz7/HbjA3h1ZT2ZiHGRTLjJJ1Rq8lao9UkzNrqvgM1nggYZyxmxIfgBFQQ TLob+bL+bInYx4IuEoRIA0KS8ALhZSr5pskQpGRiCZdaeAkm7spof2jCSFN2IF8xlNPL zyzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si3221224plb.444.2018.07.27.02.07.13; Fri, 27 Jul 2018 02:07:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730597AbeG0K0a (ORCPT + 99 others); Fri, 27 Jul 2018 06:26:30 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:51225 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729498AbeG0K0a (ORCPT ); Fri, 27 Jul 2018 06:26:30 -0400 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1fiygl-0003Bu-Ss; Fri, 27 Jul 2018 11:05:31 +0200 Date: Fri, 27 Jul 2018 11:05:31 +0200 From: Sebastian Andrzej Siewior To: Pintu Kumar Cc: Thomas Gleixner , linux-rt-users@vger.kernel.org, open list , linux-arm-kernel@lists.infradead.org Subject: Re: [PREEMPT_RT]: Using printk-rt-aware.patch in non-rt kernel Message-ID: <20180727090531.k3skngkw6qhr7utt@linutronix.de> References: <20180726153857.abxfebvxjcp4jqgx@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-07-26 23:38:05 [+0530], Pintu Kumar wrote: > > > Is there a way we can fix this issue on non-rt kernel? > > I would guess that a wakeup to klogd would fix it. > > > Sorry, can you elaborate more about "wakeup to klogd". > I wanted to try it and check. Something like this should do the work. diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 179ad787a08c..411f9ed5f051 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1927,6 +1927,8 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c return log_store(facility, level, lflags, 0, dict, dictlen, text, text_len); } +static void printk_flush_pending_output(void); + asmlinkage int vprintk_emit(int facility, int level, const char *dict, size_t dictlen, const char *fmt, va_list args) @@ -2026,6 +2028,9 @@ asmlinkage int vprintk_emit(int facility, int level, */ if (may_trylock && console_trylock_spinning()) console_unlock(); + else if (!may_trylock) + printk_flush_pending_output(); + migrate_enable(); } @@ -2987,6 +2992,13 @@ static DEFINE_PER_CPU(struct irq_work, wake_up_klogd_work) = { .flags = IRQ_WORK_LAZY, }; +static void printk_flush_pending_output(void) +{ + /* preemption or interrupts need to be disabled */ + __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT); + irq_work_queue(this_cpu_ptr(&wake_up_klogd_work)); +} + void wake_up_klogd(void) { preempt_disable(); Sebastian