Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1452416pxy; Thu, 6 May 2021 08:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrp3HLWHvaP0EBJunuoP2FaBpb71IxTPOleOATGdgWYMcoTIP6tahvR6j5jcBJw+R0xR4c X-Received: by 2002:aa7:c30c:: with SMTP id l12mr5829389edq.217.1620314154112; Thu, 06 May 2021 08:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620314154; cv=none; d=google.com; s=arc-20160816; b=Qq83+k2lpYd83w+YICntHoShs0gOVALV2hxPXiFubyE4Ci3IlrxlvsdRe/azv3KstS HupOs/WHvPNQcCuhWKtUMOVmn9fE0bWWCpasbYagWrwESEovK1l+US9I7CjPdQeA+/s4 ynYaueT9204/zMcCgth1tAfYKAA5hr1Do5CfgkT0NEZCOrvwIt/o6CBLTqOgADYn1g8p /nZYvDPRP/Kfi00/psFCHrDiqRNJANTItDOtogxumVgVkNjADJSKzsJJW2MLPZwgn+NP JnfMfRe0226KKTBR66hLaDHsVPwZU4/HyGU1YFpZmcRoKWghEqOzjaDywVzufEg1hnAH azDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=mjXaRPYgibbNlztaH09GSIpAz9D/ill1Tqtt3ZMqsMI=; b=Z5/CEkkdZ1QvIaZ+Sde+S6Mft/IlRI25QgK5L6sTLUmXorwIzsQ/UV/MvIXkgdvST3 +7rJpYzhh7tN9k5QfuTb18rHA4NwnF5JtPaRYQdtoAKIMf6dudJpwvcnAAIqvQWcqiN4 GAMxq8k8radQe00g6YjrYcIAIvTHRqpi3444s9Zfbb7ost/4wak2ISoITVv5TXmShqoa as3bMJUOh7VbMIQ6ERfpJBrQgU+C6pCki4GOeqarjIDUro9/V1yQkLwUvMaNmNcIhpYY gab3POXKMNgxZEqoCOGEXsyfXmpV2WcvoHXLnwCmUln5evF/fkBHiT9HBR/n6aaQ/NSa V+SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AufxCAdb; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si2347962ejq.725.2021.05.06.08.15.29; Thu, 06 May 2021 08:15:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AufxCAdb; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235050AbhEFPPO (ORCPT + 99 others); Thu, 6 May 2021 11:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234977AbhEFPPN (ORCPT ); Thu, 6 May 2021 11:15:13 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50CBC061574 for ; Thu, 6 May 2021 08:14:15 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1620314053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mjXaRPYgibbNlztaH09GSIpAz9D/ill1Tqtt3ZMqsMI=; b=AufxCAdboeSEomhGk1TTv7j4T6zD42LThBg4cQnSgybpVs2moRr3S/TXkI3vQ0rFG+CLgi rhICELE8Y8XoJjv1K5TNBLiV51Smp6N0zW1Ig/ypxos8f4SIYT1P7ssolhu4tYa9QOSgWt bocVeclXFzSWjGOd6iRUuaWb7v32avw03YyeMMN0t/zUDkgD8hClMbPU9gbVnpcyKVryxI d81lku+O9SL8vpdfOjGBa7MQvj1v0Ljq0riRjcmDWOoc81YS9wjpRdPRexIWoUvwJmMLTE J39Vk1y5cYGQYtL2nt6ZspBVvnr8RjkowjXRnqmYy+mj7Midi1pNBf5VTVvocA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1620314053; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mjXaRPYgibbNlztaH09GSIpAz9D/ill1Tqtt3ZMqsMI=; b=kpsZtECYp8qnzgSKO0mXZf0w9r5myai//7ZNeeLcYLVDwa+ZhXYPFmorvZBeLsXC321Qi6 ytd6y8rvrZrKZEAA== To: Sergey Senozhatsky , Petr Mladek Cc: Luo Jiaxing , sergey.senozhatsky@gmail.com, rostedt@goodmis.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, bobo.shaobowang@huawei.com, Sergey Senozhatsky Subject: Re: [PATCH] printk: stop spining waiter when console resume to flush prb In-Reply-To: References: <1620288026-5373-1-git-send-email-luojiaxing@huawei.com> Date: Thu, 06 May 2021 17:14:12 +0200 Message-ID: <87h7jfzygr.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-05-06, Sergey Senozhatsky wrote: >> Can we count the number of lines that we print from the `current` context >> in console_unlock() and if after N messages there is no console_lock waiter >> waiting for the `current` to handover console lock ownership, then create >> one: schedule IRQ work that will become a console lock owner, spin on >> console lock and call console_unlock() once it acquired the ownership. >> That 'artificial' console lock owner will do the same - print N >> messages, if nothing wants to become a console lock owner then it'll >> queue another IRQ work. > > Or even simpler > > console_unlock() > { > ... > > if (printed_messages > limit && !console_lock_spinning_disable_and_check()) { > printk_safe_exit_irqrestore(flags); > > console_locked = 0; > up_console_sem(); > > defer_console_output(); > return; > } > > ... > } Or instead to keep it suspend/resume related maybe... void resume_console(void) { if (!console_suspend_enabled) return; down_console_sem(); console_suspended = 0; - console_unlock(); + console_locked = 0; + up_console_sem(); + defer_console_output(); } John Ogness