Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4932003imb; Thu, 7 Mar 2019 04:07:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxzcgspqJBdt2Na4sxuPjqDmEtnr5WRQSFLrBiyVaAIOI/ZuDuIf5MzdeWlzcOIbXo+v5DE X-Received: by 2002:a17:902:1008:: with SMTP id b8mr12187692pla.120.1551960457870; Thu, 07 Mar 2019 04:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551960457; cv=none; d=google.com; s=arc-20160816; b=ISjEThxZ+yJH0/zL7sXSZmRyJdc0z7JJa3uf4taZyogz9uv4oT4G9paX4fOh6q9CqP ksBYImBmTMaeSdD26u0L1ZcYAEwFf9VBBzVjJ5GF6ee3TE4THvTYe8uFOoacplBOr6Rs NLj90Lf1OY1JWqdF9+56ws8qXL/Jm46QH6BLqC4vSATEaDf9CUWsd7MzhZBFmoPEHaAH hF0TT2n0+XLE+V0kwgEAiWe1uKCGLiBAfst7yx4UtuHZnecIRYtgnpGploEYkkZEpxQO g2xyKZQk0i6g673ruGAnMvXzEHNEy1pdcc1eN3xc5KfEsU/0DPUp2pQvGIQpWdhXdidH UzPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id:date :references:subject:cc:to:from; bh=PYjX2ZhvvF7QpaUc/Pyjly4BG4cJKjsZAJan9xmqZlQ=; b=KdiRFgh1s3uSSiW6yKVPOKwF46Titn8ed4YMvYXUof7p/DNdXy3wjWXONfEkj3xPo1 0SDEI8OXM3t7Vjz7UhT0iNT6wCDSrQCf2U+pmiSzgSdhODsrZIcdm6SW/r2JGWnKY3VS rT+JFSv0D9idneJujgjj3PMHcIKmlq1vb/8WuxF/KE6FjOZnXVYEcG4iGEWh0mxGSx+3 5SB40nP7jmHysRGbPzSLonMlfVs95r4/qjigHeHiBLdFN1s3uVKrPxnN6SB/8Oa/Yg4g 7utvEQH+Y9MKAxpRiZO1oEeftBqoOMQ9yEl40x6ZxnxPtt6Q0KoBu6hzEj0+zgjHa7z9 CpBA== 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 d141si4249868pfd.81.2019.03.07.04.07.21; Thu, 07 Mar 2019 04:07:37 -0800 (PST) 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 S1726379AbfCGMG4 (ORCPT + 99 others); Thu, 7 Mar 2019 07:06:56 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:54167 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbfCGMG4 (ORCPT ); Thu, 7 Mar 2019 07:06:56 -0500 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1h1rnJ-0007Zn-8G; Thu, 07 Mar 2019 13:06:37 +0100 From: John Ogness To: Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Petr Mladek , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH v1 08/25] printk: add ring buffer and kthread References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-9-john.ogness@linutronix.de> <20190304073856.GA552@jagdpanzerIV> Date: Thu, 07 Mar 2019 13:06:34 +0100 Message-ID: <87va0uopmd.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-03-04, Sergey Senozhatsky wrote: >> + /* the printk kthread never exits */ >> + for (;;) { >> + ret = prb_iter_wait_next(&iter, buf, >> + PRINTK_RECORD_MAX, &master_seq); >> + if (ret == -ERESTARTSYS) { >> + continue; >> + } else if (ret < 0) { >> + /* iterator invalid, start over */ >> + prb_iter_init(&iter, &printk_rb, NULL); >> + continue; >> + } >> + >> + msg = (struct printk_log *)buf; >> + format_text(msg, master_seq, ext_text, &ext_len, text, >> + &len, printk_time); >> + >> + console_lock(); >> + if (len > 0 || ext_len > 0) { >> + call_console_drivers(ext_text, ext_len, text, len); >> + boot_delay_msec(msg->level); >> + printk_delay(); >> + } >> + console_unlock(); >> + } > > This, theoretically, creates a whole new world of possibilities for > console drivers. Now they can do GFP_KERNEL allocations and stall > printk_kthread during OOM; or they can explicitly reschedule from > ->write() callback (via console_conditional_schedule()) because > console_lock() sets console_may_schedule. This was the intention. Although, as I mentioned in a previous response[0], perhaps we should not loosen the requirements on write(). > It's one thing to do cond_resched() (or to let preemption to take > over) after call_console_drivers() (when we are done printing a > message to all console drivers) and another thing to let preemption to > take over while we are printing a messages to the consoles. It > probably would make sense to disable preemption around > call_console_drivers(). I could see disabling preemption and interrupts for emergency messages in the printk-kthread in order to synchronize against an irq_work secondary printer as suggested in my response[0]. But I don't see an advantage to disabling preemption in general for call_console_drivers(). It is exactly that disable_preempt() that is so harmful for realtime tasks. John Ogness [0] https://lkml.kernel.org/r/87lg1rggcz.fsf@linutronix.de