Received: by 2002:ab2:2997:0:b0:1ec:cbc4:63fb with SMTP id n23csp509955lqb; Thu, 29 Feb 2024 07:19:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcRBOvWrbWAA18L8y159FKUxJLIAD5buZ+G5FWtfOvsx1DPDuSiOxRNjlGdwWpZSmFAgk56GjMUIssPJwCbhi2I7zoZkVSw6VxWNuBxQ== X-Google-Smtp-Source: AGHT+IG1q3aqef86QMsyObUgPg4kXn4SZj8b7HdFKY9QGwUV50UfHGE7LSHsSFlJebhIFYxSq5SS X-Received: by 2002:a17:902:d3c6:b0:1d9:b8bc:fd7 with SMTP id w6-20020a170902d3c600b001d9b8bc0fd7mr1920773plb.68.1709219968973; Thu, 29 Feb 2024 07:19:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709219968; cv=pass; d=google.com; s=arc-20160816; b=yzMi+nwZAB8j8tC5UC4KBTDS0U+IdizlvnhfEk2TbFbRGXJ5wVZE91HllzzJoFaHFH MvqrncZA5FOa4eR0lN978KT4tBDHkZKdroDpGgHd6QHlrA4fKxTokN0QZ5FHsPuKVk5y oNqYUtxBt8DxtWs+cNHmJEgSm+QgFUJ6w0iOkvyFwJfnKnTIkZ+OsZjyskEX9or3uCP7 NSm5wGvlpK/qadsKAlEl5DrIqUG+nuxJfjmk9l9mGw8irIPm/++KBjsSrbGuoJ6rRzo5 QpASepalem0B+XmYCSeEXq4CL0gUCsgFdtD81ztqRnjr4xCXlJGNmMbYonXcIqo+D/Pk SNww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Yn1zce3bQ2qXb3y/QswXWKJ5LaLDdAUGuIwkbuGCZvU=; fh=TMvpptkspKPNwn5LfFJ+qaKsnr9koF9VC9w861NOMZk=; b=zRjylsSZNO5ow22vgJVN56Uw2oruo6XtmIelLD+ijgtA+ok/Qwhf5p7KIN2p6mAoPQ MZNgyYcuA1mkruyZpHOhfGGbn9O//ftdqYsjdV73VCPiRTnetKNrSRSJ7KtFehaBFYL+ q0yZedr6hqbeinZcaRgFTQWZniF8Ine1yG/Cr2dS1F9EMkCTjWwqYSBK7qzmdNkGN+Uw vZ3dnJYkT4VmgQU2QF32sPp9gcvYtUGruxibAb6xtmPQ7D6E5U/Vtz8W0396gCXzUidm GGiqFxee7xM3wid8j7AR707/F1F+wZ9eKyniHVvidddF54D3eznoYhFix/Yv/zGWTnse n7JA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=d7V7VvZQ; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-86914-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u17-20020a170902e5d100b001dccf1478c2si1486340plf.468.2024.02.29.07.19.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:19:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86914-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=d7V7VvZQ; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-86914-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A0F36283BB3 for ; Thu, 29 Feb 2024 15:19:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B15561384B6; Thu, 29 Feb 2024 15:19:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="d7V7VvZQ" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DC1E86275 for ; Thu, 29 Feb 2024 15:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709219955; cv=none; b=LGR2FCwiTw7BJXG0Df/OP3WC/LoFOFAJ1Ore0Ncwud2bjGfXGZoIr5bmRYi35j81eJiR6Vh1lQGvxsxjLuoqq94/87ck/2UTpPg7lRvj2DOkxXFeGT1whE2Iqp/I9VhL+JH6RQ21xPJePQ7kDyhAOkVbYhh6HcicrWObtDgPOts= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709219955; c=relaxed/simple; bh=8BKUzajgfT6HNmS1xP/5Vd8mKo4cmsOxiX9rNgycjXM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fbCu0/plD7yvroUYomVM57Adhn5fGeXZ9vvaAESnYYfFSU309rOLsPeYTE4w3fZw9pXCjS/pSSKl3j5p/cFCU07+8sfqxmKxZzp9zwC1hfhS9DXtLfg9l1EdmQn3hbjsBE2NM0K3TCj7S3lsWT8nKHL1LgzUN9vCAJXhRtG6x+4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=d7V7VvZQ; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a446478b04bso45924866b.3 for ; Thu, 29 Feb 2024 07:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1709219952; x=1709824752; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Yn1zce3bQ2qXb3y/QswXWKJ5LaLDdAUGuIwkbuGCZvU=; b=d7V7VvZQs3FB0yugiCm4ZBm4EEog4abnu082Bh4tJ98sPe0o5jdLzlnfjQ3gfsoVxz yQeNU7VLxH2T9WR+BAI4cgRmlHGtHACd+/koYQmnUopXJMHQEFwPvZs+T8wo9o1naWBO MdhR8KoFGP6xTNB2j0KqbfE3wQdE4+RP74PDsX2FmeJWvbJV0Ew5kUklKcHnsnxSn+/R 7P2DLwEsPx2jPfN82mJH2HU0WDvvmT9I8hFbu4FZB8u1mUtiQz1ESRV5eiWB+pr5IajH tfsj9AY5OUgIU5PJ2kkMeb/6t7zou6nD/S1sJIqxgvfDspUWjh/Q7Ex7muk32oBEb+QO tcSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709219952; x=1709824752; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yn1zce3bQ2qXb3y/QswXWKJ5LaLDdAUGuIwkbuGCZvU=; b=N7M2Ak3nulZBaCP7cTR4XaFVJCb2or7QkqKOf+H+znpglU7uWCEhSCJWWS8QfYlsYy T4q3tMp/Mc1PM0xR7zHaQOFk7G9g+zN5nE1eJ9dfuSyuBmQWZzUVAX8NIEZ6Qk5AwsW+ +ADkd/5XnAeiZdIQ6RDN4KaBpwPEzXOJV/Im1ZMMdc7sjbWaKJI8P27NwYPUV3DE3N+8 A2kZvOLr9DUhvGBxZQW8ypmUgYqaHHVNHCbnPOXyvwmCIftMZ/8zyIEde6sgI9ePAR9j //vIQ1mwvObMHbLjqyeizwuSkh4neiBvzMHYwJtBa0RKyL+Q5JgSY13c8Z0wZcoZXyHP 5MfA== X-Forwarded-Encrypted: i=1; AJvYcCWE5c/w69UQVG6HheJR+HKTrHh37DgTAaum8jSq7CU0yI2P1abzsnHFU9hW+jjcuzD/mTDU0gQpHpL2+Y8lLAGwYBWHpyxtpgHSLTxm X-Gm-Message-State: AOJu0YzeQEddfAmpmSmLugHlSiomuzoICPE+9DF2cP7GOS1ON7fm3Dbp gsNjS3RP71jV1KYiCIOSVS00oT+gMqoNFzAKsON6I5ACHzJ075Se4hnqeru9W0E= X-Received: by 2002:a17:906:fb99:b0:a44:277c:1683 with SMTP id lr25-20020a170906fb9900b00a44277c1683mr1875406ejb.53.1709219951673; Thu, 29 Feb 2024 07:19:11 -0800 (PST) Received: from alley ([176.114.240.50]) by smtp.gmail.com with ESMTPSA id tx18-20020a1709078e9200b00a431cc4bd3dsm769486ejc.182.2024.02.29.07.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 07:19:11 -0800 (PST) Date: Thu, 29 Feb 2024 16:19:09 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v2 19/26] printk: Avoid console_lock dance if no legacy or boot consoles Message-ID: References: <20240218185726.1994771-1-john.ogness@linutronix.de> <20240218185726.1994771-20-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240218185726.1994771-20-john.ogness@linutronix.de> On Sun 2024-02-18 20:03:19, John Ogness wrote: > Currently the console lock is used to attempt legacy-type > printing even if there are no legacy or boot consoles registered. > If no such consoles are registered, the console lock does not > need to be taken. > > Add tracking of legacy console registration and use it with > boot console tracking to avoid unnecessary code paths, i.e. > do not use the console lock if there are no boot consoles > and no legacy consoles. > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -3958,7 +3983,11 @@ void defer_console_output(void) > * New messages may have been added directly to the ringbuffer > * using vprintk_store(), so wake any waiters as well. > */ > - __wake_up_klogd(PRINTK_PENDING_WAKEUP | PRINTK_PENDING_OUTPUT); > + int val = PRINTK_PENDING_WAKEUP; > + > + if (printing_via_unlock) > + val |= PRINTK_PENDING_OUTPUT; > + __wake_up_klogd(val); I was thinking about handling this in wake_up_klogd_work_func(). But then I saw that __wake_up_klogd() already handled PRINTK_PENDING_WAKEUP a similar way. And it even did not queue the work when there was nothing to do. It would be nice to handle both on the same place. It would even untangle the condition in __wake_up_klogd(). Something like: static void __wake_up_klogd(int val) { if (!printk_percpu_data_ready()) return; preempt_disable(); /* * Guarantee any new records can be seen by tasks preparing to wait * before this context checks if the wait queue is empty. * * The full memory barrier within wq_has_sleeper() pairs with the full * memory barrier within set_current_state() of * prepare_to_wait_event(), which is called after ___wait_event() adds * the waiter but before it has checked the wait condition. * * This pairs with devkmsg_read:A and syslog_print:A. */ if (!wq_has_sleeper(&log_wait)) /* LMM(__wake_up_klogd:A) */ val &= ~PRINTK_PENDING_WAKEUP; /* * Simple read is safe. register_console() would flush a newly * registered legacy console when writing the message about * that it has been enabled. */ if (!printing_via_unlock) val &= ~PRINTK_PENDING_OUTPUT; if (val) { this_cpu_or(printk_pending, val); irq_work_queue(this_cpu_ptr(&wake_up_klogd_work)); } preempt_enable(); } Otherwise, it looks good. Best Regards, Petr