Received: by 10.223.176.46 with SMTP id f43csp949386wra; Sat, 20 Jan 2018 07:51:18 -0800 (PST) X-Google-Smtp-Source: AH8x225DFHI9ci+l1KVVz26XNtwVoLgvS+2CxTebf4GbY6DIYY/8F/XF4O4BBNVleYO9SqF7reQ+ X-Received: by 10.98.213.130 with SMTP id d124mr2805779pfg.112.1516463478077; Sat, 20 Jan 2018 07:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516463478; cv=none; d=google.com; s=arc-20160816; b=y2SnTYwZ2T2H6iAep18ASiXTbtFDukXyn7Pb+2+QzXXMoLdfjNJ1ymep9wlWAxiPUK 3GFUjn6xugDyrPZbA7chFt0/MA0Q1IsgSTwdfp/diMn0M508WrPexJgpd/c+tqNqaTUK 5Yu2aRMoiGS6K4Nd07XdBWe59DQ/7dpG1ZgGLUXRuj1gPgmfSXXP+mGeLMybo35Dt351 A78m1IJtf3vQRcXGdtNyRxbYKZiBxiHQFkFODnG7N27TgHRV4i/IIXwDvPYBSEwI8aWB icD57Fnes3Z3RaCX6GMmaM+962O8d4Tzgi4tbMPfDX7Ba+kUwzF8Q20zNNz5vb2KMlB5 h1Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=MagvNpHJ+g9fnnKyUBxQ0BoJq6UuVIJC87Ys2LwjdYw=; b=NEZdWut2zy9eSFQD+PLYcz8umdOLq79YaXlTTHjrXxCYg8odfhI9lRcC7v+GVMDRGB zBteloKL84jW23Q+ItgqVSLAEaO9IU9avRLujmV4ZH5DFc2h3frxECWAxCNBOZSj+ENA 5Tca1K2hYL3ppSuIaZMCdVg470a2eWTBBF8w0P+Eet6ryX6hOnD/bNcEQPwY0H4i70HW veyoh7vrI11ESgzTyxOxl6lxgcrmCmIldzTGIQSfBTMQN/U+nlm5ikh9zBLTcvKlP9I1 0G2VXM0fiS3CM94An2+mVxRqCCTYhVGgRO0MVsija4Bs7UPFIbztcVf3aQCnfOUT7xAp dtuw== 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 b8si10227372pgt.572.2018.01.20.07.51.04; Sat, 20 Jan 2018 07:51:18 -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 S1756350AbeATPtn (ORCPT + 99 others); Sat, 20 Jan 2018 10:49:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:37006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754831AbeATPtg (ORCPT ); Sat, 20 Jan 2018 10:49:36 -0500 Received: from gandalf.local.home (cpe-172-100-180-131.stny.res.rr.com [172.100.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BE8021759; Sat, 20 Jan 2018 15:49:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BE8021759 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Sat, 20 Jan 2018 10:49:31 -0500 From: Steven Rostedt To: Sergey Senozhatsky Cc: Tejun Heo , Petr Mladek , Sergey Senozhatsky , akpm@linux-foundation.org, linux-mm@kvack.org, Cong Wang , Dave Hansen , Johannes Weiner , Mel Gorman , Michal Hocko , Vlastimil Babka , Peter Zijlstra , Linus Torvalds , Jan Kara , Mathieu Desnoyers , Tetsuo Handa , rostedt@home.goodmis.org, Byungchul Park , Pavel Machek , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 0/2] printk: Console owner and waiter logic cleanup Message-ID: <20180120104931.1942483e@gandalf.local.home> In-Reply-To: <20180120071402.GB8371@jagdpanzerIV> References: <20180111103845.GB477@jagdpanzerIV> <20180111112908.50de440a@vmware.local.home> <20180111203057.5b1a8f8f@gandalf.local.home> <20180111215547.2f66a23a@gandalf.local.home> <20180116194456.GS3460072@devbig577.frc2.facebook.com> <20180117091208.ezvuhumnsarz5thh@pathway.suse.cz> <20180117151509.GT3460072@devbig577.frc2.facebook.com> <20180117121251.7283a56e@gandalf.local.home> <20180117134201.0a9cbbbf@gandalf.local.home> <20180119132052.02b89626@gandalf.local.home> <20180120071402.GB8371@jagdpanzerIV> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 20 Jan 2018 16:14:02 +0900 Sergey Senozhatsky wrote: > [..] > > asmlinkage int vprintk_emit(int facility, int level, > > const char *dict, size_t dictlen, > > @@ -1849,6 +1918,17 @@ asmlinkage int vprintk_emit(int facility, int level, > > > > /* This stops the holder of console_sem just where we want him */ > > logbuf_lock_irqsave(flags); > > + > > + if (recursion_check_test()) { > > + /* A printk happened within a printk at the same context */ > > + if (this_cpu_inc_return(recursion_count) > recursion_max) { > > + atomic_inc(&recursion_overflow); > > + logbuf_unlock_irqrestore(flags); > > + printed_len = 0; > > + goto out; > > + } > > + } > > didn't have time to look at this carefully, but is this possible? > > printks from console_unlock()->call_console_drivers() are redirected > to printk_safe buffer. we need irq_work on that CPU to flush its > printk_safe buffer. So is the issue that we keep triggering this irq work then? Then this solution does seem to be one that would work. Because after x amount of recursive printks (printk called by printk) it would just stop printing them, and end the irq work. Perhaps what Tejun is seeing is: printk() net_console() printk() --> redirected to irq work printk net_console() printk() --> redirected to another irq work and so on and so on. This solution would need to be tweaked to add a timer to allow only so many nested printks in a given time. Otherwise it too would be an issue: printk() net_console() printk() -> redirected printk() -> throttled But the first x printk()s would still be redirected. and that x gets reset in this current patch at he end of the outermost printk. Perhaps it shouldn't reset x, or it can flush the printk safe buffer first. Is there a reason that console_unlock() doesn't flush the printk_safe_buffer? With a throttle number and flushing the printk_safe_buffer, that should solve the issue Tejun explained. > > how are we going to distinguish between lockdep splats, for instance, > or WARNs from call_console_drivers() -> foo_write(), which are valuable, > and kmalloc() print outs, which might be less valuable? are we going to The problem is that printk causing more printks is extremely dangerous, and ANY printk that is caused by a printk is of equal value, whether it is a console driver running out of memory or a lockdep splat. And the chances of having two hit at the same time is extremely low. > lose all of them now? then we can do a much simpler thing - steal one > bit from `printk_context' and use if for a new PRINTK_NOOP_CONTEXT, which > will be set around call_console_drivers(). vprintk_func() would redirect > printks to vprintk_noop(fmt, args), which will do nothing. Not sure what you mean here. Have some pseudo code to demonstrate with? -- Steve