From patchwork Sun Apr 17 18:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 562879 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp1883393map; Sun, 17 Apr 2022 11:57:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3BJoI2Aii5i+w81p9mtbArphbVjqIpGtHtWzUaDNejIp5TO2W+JajtK+HoHnCeREbGrGU X-Received: by 2002:ac8:4e46:0:b0:2e1:b933:ec06 with SMTP id e6-20020ac84e46000000b002e1b933ec06mr5197986qtw.684.1650221867675; Sun, 17 Apr 2022 11:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650221867; cv=none; d=google.com; s=arc-20160816; b=tYYL//beF4R9oGrJjsHqFcDBbBNt3xO3xrRIKiTBb30Xghb3byJCuX01WDlGQ4OV1l RUOCSoT3fHRHRspidmGDjNqRTx5kmFROL5h0fmH7/yI4mXEWvgliH4P+M4/IkMQbPk34 t9x7R40VmU3K38+Iqccg5x+XbY9ngH7IakWSJ0Hdhe4IpmrELQj9gIiavmfxZ8lvYgWR mYNgCHDOq4stvKh4WxkNPXZC9Tblm7EFkb8XGncAaAxBmpX4ok9tbNmCuCY1jKQahlZS ak+ox/SPEcAvrIsuj4f4q72tkQzUxXj3vqi0s5zYIWeKtltj8jS1nlhYCJZ7U6n4WuSt od7Q== 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:message-id:date:subject:to:from:dkim-signature; bh=KYZWMLCOPqytMKjpTxt4PChntLmKz4ywnYurORPkagE=; b=zD/TKHFHqEUdiHfWRQetz9sqDvvfP1V9WKUWyse24alrLQziw2dJmpklezNiQPjlfO Q2momm9D8bDlVHdgB+VJfxbUms7eyItuLS8D3nBXQl96poaMCzkQ736Df6d2zRbSJLWX IuJ9r0Tz11SvyYlUOo7R3zT8XQ7PpKOjj6xo32Vs7lfa5kPmVzPjNrRT6fOaoq+MMqdU ipGxSOulDb7ND0ArKprYF2kkTA1RDG9e+7FMwrdUnknyNoHWBg1D3Ll/MDxwL70+u5eL hyldxU9COW1OESo7b2OA5uX3Df7LsC/lcrq3LMenu1+4r8Myd1nxkvDsSUEJnaQibfzf l08w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JxIVY3nV; 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 x27-20020a05620a099b00b0069b87940347si2145193qkx.399.2022.04.17.11.57.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Apr 2022 11:57:47 -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=JxIVY3nV; 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]:32992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngA5j-0001cN-6c for patch@linaro.org; Sun, 17 Apr 2022 14:57:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ng9fG-0000P4-37 for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:31 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:39927) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ng9fD-0001j7-QV for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:25 -0400 Received: by mail-pj1-x102a.google.com with SMTP id mp16-20020a17090b191000b001cb5efbcab6so15555238pjb.4 for ; Sun, 17 Apr 2022 11:30:21 -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:mime-version :content-transfer-encoding; bh=KYZWMLCOPqytMKjpTxt4PChntLmKz4ywnYurORPkagE=; b=JxIVY3nVJ3MUMsa7dVmmv0b3U+xljxlVhNPig5a6y7/XyVDcdha6+KfyFvfmRsZhW1 UOnXEl4l8oVMfrrGhlLeDjm0K7CzTRMKhKnZIDpzcK5BkW+yUwmT1tS7AlOMv5dRjJ6m 1dMqvGETTGnJPNjMk2ypNklVdrlBqton+XgPJ99p/r5uIvKYzUoOEZc/M56L09+wjaVi psUJyquCAjoMHnYQOaRHmWH95B89K8EuTijmlV655ooPso3zSMD5J63xv8GQiuvPhbYU izx1RNmDUyPZmm8goRUJnsCEIdHE5QyKbP7Ir8pTOANuOnnJisNoDPQbAhsSEIMP2SD/ 4Fog== 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:mime-version :content-transfer-encoding; bh=KYZWMLCOPqytMKjpTxt4PChntLmKz4ywnYurORPkagE=; b=FkJCB7UaxZZajeA1bg+hTTIT4ohCGhOkKVVxYVOwiY/wdJs0NBkm2Hv+Ds5ZSXv/jG Iz3Zo+CwMzlI7rNna8D+tp1ssJzolEqbguDaKEM2m/8yvpp4pu5ImyHYuiV6qlKRPrXa FaplVKfm9hADT1J7kmbt9/R2tRsjZHG97WWy05oGRtIK9jx85ezXwwvDr7vGmstDUlxt +IiaPNcxlVteYxH0EioPLbmtBS83wJHKMDv7FOkbRpwL5teqBn3ikaNbAyrh8HmcE34+ 9H1lY9+SOYYRIuxhQM7hgVkV7A0NAhcfw/TQjpafjWKn3E1Eh3+Rq5FQ9o/jjEpwI8OG F6sA== X-Gm-Message-State: AOAM5320qKys6buW8xbBmpW0XlkWLHy2n0PFv5N1G0dsCVXk/4n057Mc HC2Bcd5EWd1frdO/u0R3ZBaj06WBQYHcPg== X-Received: by 2002:a17:90b:1a8b:b0:1d1:a447:7419 with SMTP id ng11-20020a17090b1a8b00b001d1a4477419mr9201209pjb.169.1650220220579; Sun, 17 Apr 2022 11:30:20 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id on10-20020a17090b1d0a00b001d08a7d569csm8154011pjb.56.2022.04.17.11.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 11:30:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 00/39] Logging cleanup and per-thread logfiles Date: Sun, 17 Apr 2022 11:29:40 -0700 Message-Id: <20220417183019.755276-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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" Most of the changes here reduce the amount of locking involved in logging, due to repeated qemu_log calls, each of which takes and releases the rcu_read_lock. This makes more use of qemu_log_lock/unlock around code blocks, which both keeps the output together in the face of threads and also plays the rcu_read_lock game only once for the block. Finally, add a -d tid option to open per-thread logfiles. This can be extremely helpful in debugging user-only threads. Changes for v3: * Updates for review: - use 0x%x - use enum for valid_filename_template Changes for v2: * Rename qemu_log_lock to qemu_log_trylock to emphasize that the call is not guaranteed to succeed. * Work around a musl compilation error, caused by our own typeof_strip_qual macro not working with incomplete structs. * Use CONFIG_GETTID properly. Patches lacking review: 24-include-exec-log-Do-not-reference-QemuLogFile-dir.patch 27-util-log-Introduce-qemu_set_log_filename_flags.patch r~ Richard Henderson (39): util/log: Drop manual log buffering target/hexagon: Remove qemu_set_log in hexagon_translate_init util/log: Return bool from qemu_set_log_filename util/log: Pass Error pointer to qemu_set_log os-posix: Use qemu_log_enabled util/log: Move qemu_log_lock, qemu_log_unlock out of line util/log: Rename qemu_log_lock to qemu_log_trylock hw/xen: Split out xen_pv_output_msg *: Use fprintf between qemu_log_trylock/unlock util/log: Remove qemu_log_vprintf tcg: Pass the locked filepointer to tcg_dump_ops exec/translator: Pass the locked filepointer to disas_log hook exec/log: Remove log_disas and log_target_disas accel/tcg: Use cpu_dump_state between qemu_log_trylock/unlock target/nios2: Remove log_cpu_state from reset util/log: Use qemu_log_trylock/unlock in qemu_log util/log: Drop return value from qemu_log util/log: Mark qemu_log_trylock as G_GNUC_WARN_UNUSED_RESULT util/log: Remove qemu_log_flush util/log: Drop call to setvbuf bsd-user: Expand log_page_dump inline linux-user: Expand log_page_dump inline tests/unit: Do not reference QemuLogFile directly include/exec/log: Do not reference QemuLogFile directly include/qemu/log: Move entire implementation out-of-line sysemu/os-win32: Test for and use _lock_file/_unlock_file util/log: Introduce qemu_set_log_filename_flags bsd-user: Use qemu_set_log_filename_flags linux-user: Use qemu_set_log_filename_flags softmmu: Use qemu_set_log_filename_flags util/log: Remove qemu_log_close util/log: Rename logfilename to global_filename util/log: Rename qemu_logfile to global_file util/log: Rename qemu_logfile_mutex to global_mutex util/log: Hoist the eval of is_daemonized in qemu_set_log_internal util/log: Combine two logfile closes util/log: Rename QemuLogFile to RCUCloseFILE util/log: Limit RCUCloseFILE to file closing util/log: Support per-thread log files meson.build | 12 + include/exec/log.h | 52 +--- include/exec/translator.h | 2 +- include/qemu/log-for-trace.h | 2 +- include/qemu/log.h | 93 +------ include/sysemu/os-win32.h | 16 +- accel/tcg/cpu-exec.c | 18 +- accel/tcg/translate-all.c | 118 +++++---- accel/tcg/translator.c | 12 +- bsd-user/main.c | 54 ++-- cpu.c | 16 +- hw/net/can/can_sja1000.c | 25 +- hw/xen/xen_pvdev.c | 45 ++-- linux-user/main.c | 55 ++-- linux-user/mmap.c | 7 +- monitor/misc.c | 9 +- net/can/can_socketcan.c | 24 +- os-posix.c | 2 +- qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- scsi/qemu-pr-helper.c | 2 +- softmmu/vl.c | 21 +- storage-daemon/qemu-storage-daemon.c | 2 +- target/alpha/translate.c | 7 +- target/arm/translate-a64.c | 6 +- target/arm/translate.c | 7 +- target/avr/translate.c | 7 +- target/cris/translate.c | 7 +- target/hexagon/translate.c | 13 +- target/hppa/translate.c | 15 +- target/i386/tcg/translate.c | 22 +- target/m68k/translate.c | 7 +- target/microblaze/translate.c | 7 +- target/mips/tcg/translate.c | 7 +- target/nios2/cpu.c | 5 - target/nios2/translate.c | 7 +- target/openrisc/translate.c | 7 +- target/ppc/translate.c | 7 +- target/riscv/translate.c | 10 +- target/rx/translate.c | 7 +- target/s390x/tcg/translate.c | 11 +- target/sh4/translate.c | 7 +- target/sparc/translate.c | 7 +- target/tricore/translate.c | 7 +- target/xtensa/translate.c | 7 +- tcg/tcg.c | 184 ++++++------- tests/unit/test-logging.c | 42 ++- util/log.c | 377 +++++++++++++++++---------- 49 files changed, 724 insertions(+), 659 deletions(-)