Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1395252pxy; Thu, 6 May 2021 07:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiqTDn+REwFBG3OGvvembJ15eIzdqPapzSEtiXp/loEz7/w7G04MhmkVRApZ3dBGhgvsrK X-Received: by 2002:a17:906:32d1:: with SMTP id k17mr4684120ejk.94.1620310355291; Thu, 06 May 2021 07:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620310355; cv=none; d=google.com; s=arc-20160816; b=hmG4vLp4WZVCPApnF3B1BPoegWhyF5zsRjHGTvnr0XJIzmeFV5cjeOnxf8Ied0IfAQ XYGfnQsViuQp4WFQuuXFx3ImMeZyPDXxKRL+2SgksDJSXj2gFrCvfkNg4wE56vE3PlWP 8oT5NBFt20uDwW4Q74VhEqb7Pom0U/lrloZdfO4r4M4QjDK4C6QlkiVh/jMM818aerOL jcEs0wEnwTHcWsSTY65Rici4RC3cliSLZhiy/EHEiOu+Ea4Ua3HQnsMFdmJyE3akHRNi 78jCNk/A8AsO4KSIQN3e6onQ3/DDVI/cQxL2H0ku1dlu8e4ZOL666E8V5n8HySH8FUU4 bM6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EYJF+CvXD3aBnAOU+Y0IFXIVYLLmux02f20vgzqn8HA=; b=0x4kVVgUd3lz36uTtOTGOU5F/m1/apeqe8N5PspEm4kJxuds+ShfqAII8DHRH7X15k Vc6gdOnkSnmZSmXH6eBbruMvQPR4AoeqQsiIDnVbJ/2/uv74sKdXwaxsxBqsddmOJ4fN A00uhKj7hIylLaobTELK9/LW25j3okx9o38FO/HTUEpK2kh3V/3hLOXtDbrIH5d6LCbA GEsTAMzWzuAiju8QBi4vK+WQhkQAuRAg+72G6rvtjywNKWMyV4fItpBZetvEo4JVWF9+ 1mZTCF801A5Hwiv/6JdwLYQhYs2seWbRFuViqv7zDFAPaTc7b11Vgdo4ixNRptP0tk1k 8Edg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F5/9Nqm/"; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si2359665edw.273.2021.05.06.07.12.08; Thu, 06 May 2021 07:12:35 -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=@chromium.org header.s=google header.b="F5/9Nqm/"; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234393AbhEFOIY (ORCPT + 99 others); Thu, 6 May 2021 10:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234002AbhEFOIX (ORCPT ); Thu, 6 May 2021 10:08:23 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF806C061574 for ; Thu, 6 May 2021 07:07:25 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id c17so5221849pfn.6 for ; Thu, 06 May 2021 07:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EYJF+CvXD3aBnAOU+Y0IFXIVYLLmux02f20vgzqn8HA=; b=F5/9Nqm/pfsKawCWoQRSLLilxxv4BIUx9YKwg7Xa48SlvX87tDXvKQOeFDoEy7ZSay SRU6t8H9DgJgp3Kbu6LtHLI0rFljPgRy8nwXLF8KH3k9VPfzUlK9wO81rZEG1ltrfK6M wkCLYzy8i3Cw9lsdvowJH6bXQAmkFcoRkbLOI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EYJF+CvXD3aBnAOU+Y0IFXIVYLLmux02f20vgzqn8HA=; b=o5MTGrzcEaIyzIKg20M3pH/K0KTd/awd7qE/wKGjmPEljIBOHP7SrtQ7V6uAjeswO/ Hx52bM03ntLWLjUQ+HFd1ujaaB3xL8TCPjFuwwfrAHGKXPx/VvnSp1lbjABgZooujNV5 FG8TEb1LDXkIplYVa2JrWY43ejvDl5sOTSmNd4HhM/FsMfpIwQ/beyjd9ErCxiH9QIvx blzbU7e95MdkqYSI39naUJ6BtR+qqhfmi5FPFu0WEmVGqgshKSepBpkizRdWupb5hiED Yp77YLQeEWMrDgpEEsl5WLaRoroCRuk0V3x0WxLmihph9hWiL31QPQHauXUX4KYWPN0X 854w== X-Gm-Message-State: AOAM532FJp2XoRdmN0GJVMMHrVY0gJ9PYe5IHJpRYFYx55YonRuBIut0 QBCVohzeRcRFdQkI04oz2CHb1w== X-Received: by 2002:a65:4106:: with SMTP id w6mr4512760pgp.420.1620310045377; Thu, 06 May 2021 07:07:25 -0700 (PDT) Received: from google.com ([2409:10:2e40:5100:421f:8358:b929:bc6d]) by smtp.gmail.com with ESMTPSA id t19sm2267387pjs.23.2021.05.06.07.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 07:07:24 -0700 (PDT) Date: Thu, 6 May 2021 23:07:19 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Luo Jiaxing , sergey.senozhatsky@gmail.com, rostedt@goodmis.org, john.ogness@linutronix.de, linux-kernel@vger.kernel.org, Sergey Senozhatsky , linuxarm@huawei.com, bobo.shaobowang@huawei.com Subject: Re: [PATCH] printk: stop spining waiter when console resume to flush prb Message-ID: References: <1620288026-5373-1-git-send-email-luojiaxing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for Cc-ing Petr On (21/05/06 15:39), Petr Mladek wrote: > > Many printk messages might get accumulated when consoles were suspended. > They are proceed when console_unlock() is called in resume_console(). > > The possibility to pass the console lock owner was added to reduce the risk > of softlockup when too many messages were handled in an atomic context. > > Now, resume_console() is always in a preemptible context that is safe > to handle all accumulated messages. The possibility to pass the console > lock owner actually makes things worse. The new owner might be in an atomic > context and might cause softlockup when processing all messages accumulated > when the console was suspended. > > Create new console_unlock_preemptible() that will not allow to pass > the console lock owner. As a result, all accumulated messages will > be proceed in the safe preemptible process. If we have a lot of pending messages in the logbuf, then there is something chatty - some context (task, irq) or maybe several contexts. And those contexts can continue adding messages, while we print them _exclusively_ from preemptible context only. without ever throttling down printk() callers - something that console_owner spinning and handover does for us. And those printk() callers can even preempt console_unlock_preemptible() and cause delays and lost messages. In this regard, I'm afraid, console_unlock_preemptible() is somewhat similar, IMHO, to the solution which we reverted - removal of preempt_disable() before console_unlock() in vprintk_emit(). How about this. 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.