From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8AB7C56202 for ; Mon, 23 Nov 2020 23:40:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7376C20719 for ; Mon, 23 Nov 2020 23:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727764AbgKWXkb (ORCPT ); Mon, 23 Nov 2020 18:40:31 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:46666 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727757AbgKWXka (ORCPT ); Mon, 23 Nov 2020 18:40:30 -0500 Received: from callcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 0ANNeMCm021450 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Nov 2020 18:40:22 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id E8BBF420136; Mon, 23 Nov 2020 18:40:21 -0500 (EST) Date: Mon, 23 Nov 2020 18:40:21 -0500 From: "Theodore Y. Ts'o" To: Saranya Muruganandam Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, Li Xi , Wang Shilong Subject: Re: [RFC PATCH v3 13/61] e2fsck: print thread log properly Message-ID: <20201123234021.GK132317@mit.edu> References: <20201118153947.3394530-1-saranyamohan@google.com> <20201118153947.3394530-14-saranyamohan@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118153947.3394530-14-saranyamohan@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Nov 18, 2020 at 07:38:59AM -0800, Saranya Muruganandam wrote: > From: Li Xi > > When multi-thread fsck is enabled, logs printed from multiple > threads could overlap with each other. The overlap sometimes > makes the logs unreadable because log_out() is used multiple times > for a single line. > > This patch adds leading [Thread XXX] to each logs if multi-thread > is enabed by -m option. Given that the leading "[Thread XXX]" is output using a separate printf, this is still going to result in potential overlapped messages: > +#ifdef CONFIG_PFSCK > +static void thread_log_out(struct e2fsck_thread *tinfo) > +{ > + printf("[Thread %d] %s", tinfo->et_thread_index, > + tinfo->et_log_buf); > + tinfo->et_log_length = 0; > + tinfo->et_log_buf[0] = '\0'; > +} > +#endif Instead of using a separate 2k buffer for each thread, why not just have a mutex so only one thread can be printing to the terminal and/or log files at one time? - Ted