Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp45370pxj; Fri, 7 May 2021 03:24:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGF5ceaiFmEaRr9sjGKm9wXpaIoPy4YycVqwLJI5C06kbvZBIapsGhxPab6qxzuDOHUVTs X-Received: by 2002:a17:902:a9c1:b029:ef:d4:b296 with SMTP id b1-20020a170902a9c1b02900ef00d4b296mr5720582plr.20.1620383043813; Fri, 07 May 2021 03:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620383043; cv=none; d=google.com; s=arc-20160816; b=Rl+4dAHgMg0xQfa4z5+KpO4JI1hNEmuBq8/fYjSbxKHHJ+toc2fgNhq43P/PGMSpYU yhzJy8M4tSiml3iNnNK8e0P9ZqEnHGFdJ6vZWETN7E4XhbeEDOi4nQbdTFBtBdp0Ettq FU8Ggw10VouHvdcwEv7MsIskBP9+Q78Nv1IpIcalwa4iQpp9ZYTGMZt4dezklFhZpQiP 2y9kum3XevQgcoBhZF2xTRPYAgwLJbBNW43nUvqwmH0mPgMDJpauhGrKZoo7k9976S5o s04N5nuYxdyHZuF5EeN6ZJfSjbKPaFxYnwVSCGeNYG732gRsYMs8PfWaFeRrBlQhHyV7 Pong== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=PHHmaGUfb6ZNGxcGZGUxdB1ET6orubb0CAMo+TnG+d4=; b=FIULmwa6Sb19DIoA40NrTYpSBo1mmnbMz+tZ5Y3tcFyFkKLGrnbOKAKdVtRfSZRAAT TcwOTYm51IJJQK9K4WneKi6fhZbdU+mt+zXnL/kB4fQ0VW+nYSjBcZ28wlUI1HeWzrIx 7VAB3WrN+lAcu3mVrAD7sIWKDsqIFcL5YRUNiu4yhwLwGaphzfXJi8IcER9CgDq/rpKl fY8aXi0ZAaPmgVGsDsMZikcUco0h8a7vby+LfTQVZtcFpgOkcHiCwUP+RsQfAcY05AeL EQlLInNdiF2ZBJhNLZxFpdfsmPGW2oz6AVtlKMdVrW/b8A8DT2uUjmqvbKZ/W3AvpIsd LDmg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si7753809pgl.385.2021.05.07.03.23.51; Fri, 07 May 2021 03:24:03 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233167AbhEGHem (ORCPT + 99 others); Fri, 7 May 2021 03:34:42 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:17141 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbhEGHef (ORCPT ); Fri, 7 May 2021 03:34:35 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Fc2Cs5wXVzqSqW; Fri, 7 May 2021 15:30:17 +0800 (CST) Received: from [127.0.0.1] (10.40.192.131) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Fri, 7 May 2021 15:33:26 +0800 Subject: Re: [PATCH] printk: stop spining waiter when console resume to flush prb To: Sergey Senozhatsky , Petr Mladek CC: , , , , , References: <1620288026-5373-1-git-send-email-luojiaxing@huawei.com> From: luojiaxing Message-ID: <72443c6d-b70b-0e36-bab0-87705a1d8019@huawei.com> Date: Fri, 7 May 2021 15:33:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.40.192.131] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/6 22:12, Sergey Senozhatsky wrote: > On (21/05/06 23:07), 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; > } Hi,  Sergey, I test this,  it works. But, I have a doubt. If the log buffer exceeds limit, we can schedule IRQ work to become the console lock owner and let current context return. So why not just let the IRQ work process the console output without limit? To be clear, driver call printk() only care about the correct sequence of timestamps and does not care when the print is output. Actually, I wonder if the driver can only cache the print and queue the output tasks to a workqueue to return, and then return directly? I don't know if this is a stupid idea, because I'm not familiar with printk. Thanks Jiaxing > ... > } > > . >