From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752532AbcBJQKU (ORCPT ); Wed, 10 Feb 2016 11:10:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:59327 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbcBJQKS (ORCPT ); Wed, 10 Feb 2016 11:10:18 -0500 Date: Wed, 10 Feb 2016 17:10:16 +0100 From: Petr Mladek To: Denys Vlasenko Cc: linux-kernel@vger.kernel.org, srostedt@redhat.com, Steven Rostedt , Tejun Heo , Peter Hurley , Jan Kara , Sergey Senozhatsky , Andrew Morton , Kyle McMartin , KY Srinivasan , Dave Jones , Calvin Owens Subject: Re: [PATCH] printk: avoid livelock if another CPU printks continuously Message-ID: <20160210161016.GF12548@pathway.suse.cz> References: <1454963703-20433-1-git-send-email-dvlasenk@redhat.com> <20160210144416.GE12548@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160210144416.GE12548@pathway.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2016-02-10 09:44:07, Steven Rostedt wrote: > On Wed, 10 Feb 2016 15:36:49 +0100 > Petr Mladek wrote: > > > Bcc: > > Subject: Re: [PATCH] printk: avoid livelock if another CPU printks > > continuously > > Reply-To: > > In-Reply-To: <1454963703-20433-1-git-send-email-dvlasenk@redhat.com> > > > > Hmm, playing with mail headers? Yeah. I am trying to do this reply back in the original thread. > > > + /* Good, other CPU entered "for(;;)" loop */ > > > + goto out; > > > + } > > > + } > > > + /* No one seems to be willing to take it... */ > > > + if (console_trylock()) > > > + goto again; /* we took it */ > > > + /* Nope, someone else holds console_sem! Good */ > > > > The cycle gives a big chance other CPUs to enter console_unlock(). > > It means that more CPUs might end up in the above busy cycle. > > > > It gives a chance to move the printing to another CPU. It likely > > slows down the flood of messages because the producer end up > > here as well. > > > > So, it probably works but the performance is far from optimal. > > Many CPUs might end up doing nothing. I am afraid that this is > > not the right way to go. > > Note, it's not that performance critical, and the loop only happens if > someone else is adding to the console, which hopefully, should be rare. I probably used too strong words. It is possible that the performance impact will not be critical. But the behavior is non-deterministic. I think that the approach taken by Jack is more promising. I mean the offloading of the console stuff to a workqueue. Best Regards, Petr