From patchwork Sun Mar 20 17:11:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 553178 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp874127mag; Sun, 20 Mar 2022 10:14:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3v+au0YL+r9syQ1FduOsd1T9drRaXlKW2w2SCotoJG/nbflDxPnioBh2BtW6XW9HLgpbf X-Received: by 2002:a0c:e6c5:0:b0:42c:d5f:7e4c with SMTP id l5-20020a0ce6c5000000b0042c0d5f7e4cmr13539256qvn.93.1647796442102; Sun, 20 Mar 2022 10:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647796442; cv=none; d=google.com; s=arc-20160816; b=AXG1MLvp3r/rw9BJ1S3aao/rt57TpzYRRgLv9zv+fSwiaaD44fBTFo/et02fqL6ybb v9dhFpcjvz7SyqLD3yzgnqOPWol42jr0UwxdJHoQeR5T7FvxPtZgX2zNf1Pc2ZbnVZzh ZgKswYYnI1TuA9TgEcSm9zJUcgN0XKF4jUrzaKSfGKiURYImxCSnbJwF5RyloB2/SEiV B1ILD6ZyFRbhMj9DFW2fwM+TEYtiWPKIrNEvtI0jCWOIJrcG38HL2ZjFtRm76yPfpEXO LB4ci5jNMsmsGQWb8DwxvIJFZzk7CnqbOOO7BSB+0uZCt5QIQueuSYnjhEmQz99sbir/ YuLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0QkXC8NBloa4lQ1dJr9n5F8IaX751sw3OjPlQ3q4G5M=; b=ggD21vnG67EWAttO8lrjb7MoWy6DRI3VzDEZUOwWUbph1vOX7fMz2cfP/bXrMj3H/I Fyc5YGQPJThdbCMlHPo5ShkFqYyvY1GkigxDZbM3Vk/R9LRklSk548mLNoiEgeIQ3T2f Y9Ym25rH6t4WBXa5nipS5hvlT54TTCuVt0TOIE8G35w1ta7DxO83n4zyG9fDSTyLStsv wvkMZV8aVLBFTpDmWhba8rtDzrt5CtlX9Et4x6V8IbQBydN7tO5hls43+3gvi+zSyj/G yBvVlsZCoECiD7/Z87pCOnm6o7bjE9jo3oWm/GqnOXbTI2dFsJwZ4WubNF494aSjhyBt WGRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUNtxrAr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d22-20020a0cb2d6000000b00440e46a7c85si1278664qvf.291.2022.03.20.10.14.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Mar 2022 10:14:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IUNtxrAr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nVz7x-0008Lj-Nw for patch@linaro.org; Sun, 20 Mar 2022 13:14:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nVz5h-0008Jb-NB for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:41 -0400 Received: from [2607:f8b0:4864:20::1034] (port=56074 helo=mail-pj1-x1034.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nVz5f-0003Pm-Fm for qemu-devel@nongnu.org; Sun, 20 Mar 2022 13:11:41 -0400 Received: by mail-pj1-x1034.google.com with SMTP id e3so11256262pjm.5 for ; Sun, 20 Mar 2022 10:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0QkXC8NBloa4lQ1dJr9n5F8IaX751sw3OjPlQ3q4G5M=; b=IUNtxrArwdd6X13tTr7XaTLoskrITi858kDgSZzVI20oFinaGMzllLB2rOu8mpn/zY bRY/7/NOH75+hAFWcDESbPg5Yw3yNH4+s7vF6scnuqPQvD6o35QOLVxZm2e7rFb0Jyu3 mLtHN05YkIeIMnPXhUW2epT9gpkJqOF0kkmBXDwriBfYkGunPU8kvbafstue+/mBwJN/ eE985p9ir0ha8241XV1TC7EMaFCQwIbAJW6eWNRiCS7XrGZC768ViEkbER/8IS7xDWfw TxVcjWDnicy5JzgmTJEnRmgkXnL3D+tMwtB2uJIrlPkPgjorQ5cr4nsey11X1zbeq0bu NVNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0QkXC8NBloa4lQ1dJr9n5F8IaX751sw3OjPlQ3q4G5M=; b=JjsFbG+WWVNGyqm7HHkTdEJ0HJF2pQ3IG66qPYZ0WKribnnlBbSsdmIx8Xp1s03Nr4 jL1QRxSSaeEOT/zPYvKVLKNMGvQC6KtBfjHOgBXSoQoevyJhLDi3cyUHayheIwdSNrfF 53fR/QMDyf8eO4/PoGGskPGjQriAVTWY8RYzBksea/U4l/ePzVhnhGgvyWnhTJi09uGK CE0qqsGG3vuuZDgealu0kY4+j9FIIqfbjvsmS9rOL9CzwKAwgvPX2V/+dpNQNUjCa8zp Tv+xyeluPk381OMtI2CGM4jwcLQ3mS08d7gdmuQhNsRgVdh1eWGqAQIrz5iChUZzI7On 1cSA== X-Gm-Message-State: AOAM53097cAzovaia8ORc00UBWOrEYdPAStAD94kCnPvfcLUPlUZxhYt NbYezKL738BZ72Q5ZCG4e3VKwFUb+SM6lw== X-Received: by 2002:a17:90b:1642:b0:1c6:c6d0:fbfa with SMTP id il2-20020a17090b164200b001c6c6d0fbfamr11556396pjb.218.1647796297552; Sun, 20 Mar 2022 10:11:37 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id q12-20020a17090aa00c00b001bc6f1baaaesm17149697pjp.39.2022.03.20.10.11.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Mar 2022 10:11:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL for-7.1 01/36] util/log: Drop manual log buffering Date: Sun, 20 Mar 2022 10:11:00 -0700 Message-Id: <20220320171135.2704502-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220320171135.2704502-1-richard.henderson@linaro.org> References: <20220320171135.2704502-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1034 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This buffering was introduced during the Paleozoic: 9fa3e853531. There has never been an explanation as to why we may not allow glibc to allocate the file buffer itself. We certainly have many other uses of mmap and malloc during user-only startup, so presumably whatever the issue was, it has been fixed during the preceeding 18 years. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- include/qemu/log.h | 1 - bsd-user/main.c | 1 - linux-user/main.c | 1 - util/log.c | 21 ++++----------------- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 9b80660207..08b0cd0bb3 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -148,7 +148,6 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; void qemu_set_log(int log_flags); -void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); diff --git a/bsd-user/main.c b/bsd-user/main.c index 88d347d05e..08f43af235 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -405,7 +405,6 @@ int main(int argc, char **argv) } /* init debug */ - qemu_log_needs_buffers(); qemu_set_log_filename(log_file, &error_fatal); if (log_mask) { int mask; diff --git a/linux-user/main.c b/linux-user/main.c index fbc9bcfd5f..2b06350688 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -679,7 +679,6 @@ int main(int argc, char **argv, char **envp) log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); if (log_mask) { - qemu_log_needs_buffers(); qemu_set_log(log_mask); } diff --git a/util/log.c b/util/log.c index 2ee1500bee..ffa66a267e 100644 --- a/util/log.c +++ b/util/log.c @@ -72,8 +72,6 @@ static void qemu_logfile_free(QemuLogFile *logfile) g_free(logfile); } -static bool log_uses_own_buffers; - /* enable or disable low levels log */ void qemu_set_log(int log_flags) { @@ -121,29 +119,18 @@ void qemu_set_log(int log_flags) assert(!is_daemonized()); logfile->fd = stderr; } - /* must avoid mmap() usage of glibc by setting a buffer "by hand" */ - if (log_uses_own_buffers) { - static char logfile_buf[4096]; - setvbuf(logfile->fd, logfile_buf, _IOLBF, sizeof(logfile_buf)); - } else { #if defined(_WIN32) - /* Win32 doesn't support line-buffering, so use unbuffered output. */ - setvbuf(logfile->fd, NULL, _IONBF, 0); + /* Win32 doesn't support line-buffering, so use unbuffered output. */ + setvbuf(logfile->fd, NULL, _IONBF, 0); #else - setvbuf(logfile->fd, NULL, _IOLBF, 0); + setvbuf(logfile->fd, NULL, _IOLBF, 0); #endif - log_append = 1; - } + log_append = 1; qatomic_rcu_set(&qemu_logfile, logfile); } } -void qemu_log_needs_buffers(void) -{ - log_uses_own_buffers = true; -} - /* * Allow the user to include %d in their logfile which will be * substituted with the current PID. This is useful for debugging many