Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1536043pxb; Tue, 8 Feb 2022 21:28:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5c2MC7r1OzCX45RhMXP/LUARbzB4W03LBFHHaXPSiTBUhYQv+PyOEZmITYOKAUnYyL6ja X-Received: by 2002:a65:6283:: with SMTP id f3mr629245pgv.552.1644384513982; Tue, 08 Feb 2022 21:28:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644384513; cv=none; d=google.com; s=arc-20160816; b=pLAdfTox2KhHtr271cBVzhEBI2+nKd5VDA4lFlnhPj33h01ZtW7xlyZDNI1lO/Tqq4 K6waYU1rbZaHNRKDfgapvabc/9yqTx7fGLo8oj/J69FDXwtyo3yaHde+u4Y6qPvjbVMf qhx6/AdJm9BzF1wdXlcBvuyseSuGZCOjvLKPLW/9Vjgv0KjnhCiNyUSYSE0rigLwXLkv FfXeA1/NZwSPnDlhUhXLRFmO/p/rtHzY6z/v0GIzDsOtXne+gssuz/VL32vTkij5tS9S N8ag27nUuWLbkz0aI+cWFyEGaYAGJWABI8l8pJPpceLR9IkWQpg7Fm/jyYqCRlvxzWkT OcYg== 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=91NCb5EYzhKuUKp45uli6bWUtNYygLxTpv0v3uA27sw=; b=GavdkNyyozOkxis/3f6kQK+YAsr6JLsCk8Xej6gnoLBpZjqn7Km8U1N99LA3BW5Mjt 8lWKbihVgMit0YTAvzNecrRTeahuzufjYUL8Yjb87yKEE+5FNmxPUU57BJ4uuFTYbfDA LPIIJ7502MsX3XZBc0bL7grSP2LvSv3VkDEUB9zqK+6LeM4+49JHnFxeTReIHCvXJlft eI7T7FX9YHW7jmGlsu7VCoCEK/xP0nnnuOfCANp0b1M/swd/VbDpp47+rU0qAluQJJVS 1SZBzAfdTdKEUL5/Co+dnlRpFEGHvYl03+A4KUos8l88haiITjh+lR99W7Ae6CQ+kH/j DM/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CU8VEHfQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y14si11694140pll.376.2022.02.08.21.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 21:28:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CU8VEHfQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E5D96C03326E; Tue, 8 Feb 2022 21:27:48 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345430AbiBHCQI (ORCPT + 99 others); Mon, 7 Feb 2022 21:16:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345506AbiBHCPX (ORCPT ); Mon, 7 Feb 2022 21:15:23 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92215C0401D1 for ; Mon, 7 Feb 2022 18:15:20 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id c3so12629918pls.5 for ; Mon, 07 Feb 2022 18:15:20 -0800 (PST) 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=91NCb5EYzhKuUKp45uli6bWUtNYygLxTpv0v3uA27sw=; b=CU8VEHfQz9jVkk1c6wJRXsKSB2I+vbMObObLLyLNFjd+VjxdrQBj+KZiVNu3q08t3D RApgG6wN3M/Upu1lQkKgzCl1+5cut8jj1M23oA0YXQVGlp2iBtVvECFjjzxz6X+l1X3i dqAQ0LLi3aXxwjC6+YiwHofT25bh8Jy2rFd+I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=91NCb5EYzhKuUKp45uli6bWUtNYygLxTpv0v3uA27sw=; b=PtMbmtv14KeZpQw59gbDxI9Op/5BJt5AUPjhw2FEZHpHr+ELQfhZp6SrS6Zb0F5zRy sNNUgsjHMhA52/6YAXX6uz+QMxGmyD+3bBr+YTINFtOzLzOKOB9mrpVETKzAKypJzjmC 2v9IHnDnW7AU7BqQomZr9nHGNmWe+2//w+NlIGzuDduaHl9jRbJOgQnCHQ4NicWPVv4i A6I+nXS6Oy9cM1Ky16MWjJq69jN+6DcAi9+6CLTRdFE+qLC5fy49QYdB0rZ8r7n++CdS gtBsA5c0FXVROwyDhCzG7ZGu9ga9ucgSKZQM75F4CkKwe/7ubO8t86E9ExNsKNGfD4j/ 2u7Q== X-Gm-Message-State: AOAM532TNYwJzleyO04v3qspfdnYkFaz2iRNmqJh2Pk5+W/Lg1TmCUv8 qfrjGOepGTP6rQWLqBEq3Tw/u3Yb/1LZnw== X-Received: by 2002:a17:902:6942:: with SMTP id k2mr2483316plt.133.1644286520072; Mon, 07 Feb 2022 18:15:20 -0800 (PST) Received: from google.com ([2401:fa00:8f:203:892d:3c06:3dca:f230]) by smtp.gmail.com with ESMTPSA id s42sm14215487pfg.146.2022.02.07.18.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 18:15:19 -0800 (PST) Date: Tue, 8 Feb 2022 11:15:15 +0900 From: Sergey Senozhatsky To: Stephen Brennan Cc: Sergey Senozhatsky , Petr Mladek , Steven Rostedt , linux-kernel@vger.kernel.org, John Ogness Subject: Re: [PATCH v3 4/4] printk: Drop console_sem during panic Message-ID: References: <20220201185802.98345-1-stephen.s.brennan@oracle.com> <20220201185802.98345-5-stephen.s.brennan@oracle.com> <87v8xuea4j.fsf@stepbren-lnx.us.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87v8xuea4j.fsf@stepbren-lnx.us.oracle.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (22/02/04 10:53), Stephen Brennan wrote: > Sergey Senozhatsky writes: > > On (22/02/01 10:58), Stephen Brennan wrote: > >> +/* > >> + * Return true when this CPU should unlock console_sem without pushing all > >> + * messages to the console. This reduces the chance that the console is > >> + * locked when the panic CPU tries to use it. > >> + */ > >> +static bool abandon_console_lock_in_panic(void) > >> +{ > >> + if (!panic_in_progress()) > >> + return false; > >> + > >> + /* > >> + * We can use raw_smp_processor_id() here because it is impossible for > >> + * the task to be migrated to the panic_cpu, or away from it. If > >> + * panic_cpu has already been set, and we're not currently executing on > >> + * that CPU, then we never will be. > >> + */ > >> + return atomic_read(&panic_cpu) != raw_smp_processor_id(); > >> +} > >> + > >> /* > >> * Can we actually use the console at this time on this cpu? > >> * > >> @@ -2746,6 +2765,10 @@ void console_unlock(void) > >> if (handover) > >> return; > >> > >> + /* Allow panic_cpu to take over the consoles safely */ > >> + if (abandon_console_lock_in_panic()) > >> + break; > > > > Sorry, why not just `return` like in handover case? > > We need to drop console_sem before returning, since the whole benefit > here is to increase the chance that console_sem is unlocked when the > panic_cpu halts this CPU. Yes, that makes sense. > in the handover case, there's another cpu waiting, and we're essentially > transferring the console_sem ownership to that cpu, so we explicitly > return and skip the unlocking portion. > > Does this need some comments to clarify it? No. Everything looks good. Thanks.