From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751706AbcBJOoN (ORCPT ); Wed, 10 Feb 2016 09:44:13 -0500 Received: from smtprelay0023.hostedemail.com ([216.40.44.23]:36240 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751589AbcBJOoK (ORCPT ); Wed, 10 Feb 2016 09:44:10 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:700:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4470:5007:6119:6238:6248:6261:6691:6742:7577:7875:7903:8531:8913:9391:9545:10004:10400:10848:10967:11026:11232:11658:11914:12043:12296:12517:12519:12555:12663:12740:13069:13180:13229:13311:13357:13436:14096:14097:14659:21080:30026:30054:30064:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: toys33_413a526e58801 X-Filterd-Recvd-Size: 2995 Date: Wed, 10 Feb 2016 09:44:07 -0500 From: Steven Rostedt To: Petr Mladek Cc: Denys Vlasenko , linux-kernel@vger.kernel.org, srostedt@redhat.com, Tejun Heo , Peter Hurley , Jan Kara , Sergey Senozhatsky , Andrew Morton , Kyle McMartin , KY Srinivasan , Dave Jones , Calvin Owens Subject: Re: Message-ID: <20160210094407.7a953c68@gandalf.local.home> In-Reply-To: <20160210143649.GH3305@pathway.suse.cz> References: <20160210143649.GH3305@pathway.suse.cz> X-Mailer: Claws Mail 3.13.1 (GTK+ 2.24.29; 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > > + if (cnt == 0) { > > + /* > > + * Other CPU(s) printk like crazy, filling log_buf[]. > > + * Try to get rid of the "honor" of servicing their data: > > + * give _them_ time to grab console_sem and start working. > > + */ > > + cnt = 9999; > > + while (--cnt != 0) { > > + cpu_relax(); > > + if (console_seq == log_next_seq) { > > This condition is true when all available messages are printed to > the console. It means that there is nothing to do at all. It is > quite late. A much better solution would be to store console_seq > to a local variable and check it is being modified by an other CPU. > Yep, I recommended the same thing. > > > + /* 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. -- Steve