From patchwork Wed Apr 20 18:05:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563970 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4401146map; Wed, 20 Apr 2022 11:10:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPKbR8bdgEs/G+04fcEO1ihyASb0jEgiq8GQnn3WGAXAkqvySu1BjvGIb0RJlN0G+cOG6w X-Received: by 2002:a25:330b:0:b0:644:b341:e9dc with SMTP id z11-20020a25330b000000b00644b341e9dcmr20626669ybz.254.1650478253706; Wed, 20 Apr 2022 11:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478253; cv=none; d=google.com; s=arc-20160816; b=x5xfnQdYF0ZirbPefQpRczNGXvARObMbWd/mZzwXqNff7EzfEXXs8VIGc8j3qthvam s85dH63PKoL83D8IHQn4fkf2YmfxyezfAA2olYY4CVScSmbYeZ1Vli+Bmm1BuOFwvO27 6BcnQ9xj21zQRd7try8T6EFQYv7dOSwJATodCeok+rZAyJJgg76YX8Qn+S199xDoPii8 NOtbMnOeCKAiY279HiJDRJHMdsxurM3XASKbVK2cUU07vFuMqU63UcpftdTeFc3O+jED 8InteqITusYCNpU+652Ba8dmd7nLHZOcWLbhC3j997x68Xe6xM+q6fdEIdLSOhUCpj9k CFTg== 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=1EvO7DptCQKG7ltKeFYJuF4bJOAsl84mmallsluEFGk=; b=zsH27G1gR1uP4yT85pAZnFOd4OwBDu/CLv7zISa4rWwPLYqC+TI7lhi5pT/5tI4pWr kTvKi25raKuN0dEIITPOlM31JZMk1K+YPKEDNrnCTpoVE/ulMThRCW/9+aksBghEQDyR Z6oD0pWWcDCC7TZEr3bDqq2rmjtV6PgmRNpLXAtY1Wlcah51hXSkuHPboNa1Q+zRakod bIew6qeHiMZhXMRDmaVU1d+9GQxtDavQjgK7Q31H3YfFtBSZVC5U9PhDv0OilxElhwqe 07ujIonE5UaSdzJHEJkdOftcCYOPn3xB+qDCawQo5KjEdCQ54HBLEjidCs7ED1DNVsxQ 9jiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yb9pJcrs; 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 193-20020a2504ca000000b0063d95041efesi500793ybe.661.2022.04.20.11.10.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:10:53 -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=yb9pJcrs; 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]:34102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEmz-0003qG-31 for patch@linaro.org; Wed, 20 Apr 2022 14:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEie-0005FX-55 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:24 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:42602) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEic-0001AS-8z for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:23 -0400 Received: by mail-pj1-x1031.google.com with SMTP id z6-20020a17090a398600b001cb9fca3210so2778041pjb.1 for ; Wed, 20 Apr 2022 11:06: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=1EvO7DptCQKG7ltKeFYJuF4bJOAsl84mmallsluEFGk=; b=yb9pJcrstO5elkIWJGdlXhApKnmVQx+0T+YG6+QJpDdk5WzUkaTEcNRfwwTx3lJ+rQ +YWAQtm6ryNYnDjjLY6p/kF9aC/a6MT+hAOWFuDFqP0ckntuQky8dbIqLdoh3VG/G0Lz 6rp2nGOj9cCSSgPX2opwTqRkMfyYrjDtHN2bvDUj8wJyg6nSrO9OvtSrRJdF2YYqFugO ZOvFWbaKrW6j/0eUqF/4zmuohatGA7uKjJRUB1BJ4NHZDrQ0ju7e7vNyL7JjzBwy9WCj VQI4POrcK5yBPbe39ObYgY9l4WW2jdQbUVrt2QwqZfQWJpMOaWCc88s+B2TRZUWTffSk lmnQ== 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=1EvO7DptCQKG7ltKeFYJuF4bJOAsl84mmallsluEFGk=; b=ptM6oSysRr+L0Dl2lFVh3V17a3j73YCM5KtcCsVoVeSsWiWqaXbx9oiQW6SCPNeUgi kRqOCqzxBt4+rV0PgtzOj69SyNWMMg1VlSJrMX5KZKUrXiTV5pFm50mS2PkKRu9PIsgr w69uSpX+dBLLF/qQYNn0v4ELu6wWYYdJd+HLR6WNKo7sYNFs8SgBHT2ur12ERqaVWEuH Feep1IjXxPwhNgHREMSOhBRchc8sdMTdXskrtQti2zeYzYvD386jiidLT1GeV6HAsRtC x0r19xuZSJHam1VYDuECHOQoSDSP5GNoe3VdXyA0jmudZFhk23uyxHDV9oaJ/KXlDnzy kkXg== X-Gm-Message-State: AOAM533P2ncLUMd2JEFy90upYkCXTbY9K0ag1UZ/SGCDWtrO9akNLPfK 7501+R9ZYtG63As7H3OWrw3RdZlpEBzEMg== X-Received: by 2002:a17:90b:1bd0:b0:1d2:a488:7af0 with SMTP id oa16-20020a17090b1bd000b001d2a4887af0mr5808449pjb.125.1650477981004; Wed, 20 Apr 2022 11:06:21 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 01/39] util/log: Drop manual log buffering Date: Wed, 20 Apr 2022 11:05:40 -0700 Message-Id: <20220420180618.1183855-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: =?utf-8?q?Alex_Benn=C3=A9e?= 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-2-richard.henderson@linaro.org> --- 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 5739c7e6d8..ed59ebd4a2 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 From patchwork Wed Apr 20 18:05:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563968 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4400164map; Wed, 20 Apr 2022 11:09:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1+VKhH6rf4/2g8KPXQ9tpIIiTDN6vnmknR1G0zU2XDFW1bM/5R+G9X9PnFMQu5NwOpPkC X-Received: by 2002:a05:6902:114b:b0:644:cf4a:d6bd with SMTP id p11-20020a056902114b00b00644cf4ad6bdmr19773431ybu.646.1650478181460; Wed, 20 Apr 2022 11:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478181; cv=none; d=google.com; s=arc-20160816; b=mBQV05uoiVeHId23c5sLnYBU2seNUkAwXtJmK2nC1IXKcCDoPR9VUOoP8KEYu/3JnN ArGo19+ZInJsZX8hbGWTj14Iu+rc8aewK/o5XGUgwKLXaN7wTvvp2PmsUfvw4SON689E rv58R1d3sE1DRfcjjbIrSHen6i3J8EMM9iYI7cSiQP/jq0JgFYStsesYfE/3amENSFJ8 4WTK+pNnxGySRV5ZXp6x4tUF0Wo1Eis/e3B7/8tPWDCsE03B+HFiPLKd2LcRmD63U5Z6 DBUd2Q4vesgodPXzn4HQ4KSIsudHpzidOqUa0TTSBb6M2WAyFnH4k/usRzvZKhVAPJc8 lV9A== 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=kPstaIQPIw+2x97scwvcI65CdFqpKkQGr7FCT5ZeuMo=; b=zK2Tfz7qBle7XPWGakpF5mhaAQIBVlRGNnMUoo1In7Y9XTC4XfnfWewnRYittCPMnG mfszJUP+3d/1soWEhr7P+zrFcsdLXVHfGpZQO8gMbSxUuVocvjrJGBbNh5RkixHYx919 OTrY7ch1CRstOLzlQMWZr8yAutWPKX9oEQS0Y0NfVbVzALAxyHkfZBfpRh8z0onFPmvp MG6qtqEgP6GtJ3CdHm3CjeOFBOsjVxIzDFzBd4blV7qlcINHcl607H/iEkUXBjvX4jBv 75oAirTzgUX7Ml9wtb/mJrkzXW5UKV+y7K1WuuF1BW1U5ADi5qGvF6U6qOpEtPzD+03p uq9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dtI+af1+; 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 p123-20020a254281000000b00641e29c0464si551869yba.667.2022.04.20.11.09.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:09:41 -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=dtI+af1+; 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]:58660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhElo-0001CU-SX for patch@linaro.org; Wed, 20 Apr 2022 14:09:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEif-0005Gz-EO for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:25 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:34700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEid-0001AX-6k for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:25 -0400 Received: by mail-pj1-x102a.google.com with SMTP id d23-20020a17090a115700b001d2bde6c234so3926251pje.1 for ; Wed, 20 Apr 2022 11:06:22 -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=kPstaIQPIw+2x97scwvcI65CdFqpKkQGr7FCT5ZeuMo=; b=dtI+af1+EmvVO0e+WwYYHbwI+83G4fGMsmGIX87mxC95wHf+XbclDd9hVujM/XMQVN Nm+MOanDjwovJJkXmMkvAAbSCi28sH89uJyRYtxNA7zWtL1E1eJUh8L4SJ14MdL+sEAs KNEdp5rN8+67UPwfJe8bK7vooiWXqeyfYYnha9hYjUd43jjYgzIwE8cbVw5LUlB+dwRF pRJZU4f26CztXFT/BSIUoOvu0sWjq1mMJ+KQAcs6s1hQLFvlESPBq7A8W+5rsqYt4H7O dtb5xXvh2nW7YAl3zEXoLiHwmcTEXsw0OU1bcpbXWsZ/deVJm08D6OgRQdm5go8+Zpba apGA== 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=kPstaIQPIw+2x97scwvcI65CdFqpKkQGr7FCT5ZeuMo=; b=go5B0iuluV9oKNUZlykMhVENkcvvpVxjbZFeComDNcAooxELKr0VAhhlsSFltc82G5 KI27vBrrZ5RQqylhwMXSXBU6vNgSK42+PsshXYfgumPpr82qJ5UtbHonruMgukDAsxBf qSvU4TrXepjTALPAyTs/ZkHqbBsMeyr9QAyzqQG81OqKdIFeP62obHTDjwgEkRlc8wLi ehPx/G9tZCCFlwuYod6sRIW01Aa+JHKwVdsPl52oELfMVJUWTS09auBmErgQ3lWnmORs UEPqIvQVz7ueRVmKFa72xZStyrbkQ7/nFDvaPhkyvYM3Eo9VBVUtHDDZDtZfXBEnngXA hLFQ== X-Gm-Message-State: AOAM531ltZ/2f+Mj3l4WLQxEN8SmyjO5rky9gXyo8GJOxIpajT5j9ond XDl5Dg6bH5qirilrPWsXLvkpd3QhgzNLzQ== X-Received: by 2002:a17:90a:af98:b0:1d4:67d4:d122 with SMTP id w24-20020a17090aaf9800b001d467d4d122mr4403111pjq.166.1650477981963; Wed, 20 Apr 2022 11:06:21 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 02/39] target/hexagon: Remove qemu_set_log in hexagon_translate_init Date: Wed, 20 Apr 2022 11:05:41 -0700 Message-Id: <20220420180618.1183855-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This code appears to be trying to make sure there is a logfile. But that's already true -- the logfile will either be set by -D, or will be stderr. In either case, not appropriate here. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-3-richard.henderson@linaro.org> --- target/hexagon/translate.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index b6f541ecb2..98f1452cad 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -874,12 +874,6 @@ void hexagon_translate_init(void) opcode_init(); - if (HEX_DEBUG) { - if (!qemu_logfile) { - qemu_set_log(qemu_loglevel); - } - } - for (i = 0; i < TOTAL_PER_THREAD_REGS; i++) { hex_gpr[i] = tcg_global_mem_new(cpu_env, offsetof(CPUHexagonState, gpr[i]), From patchwork Wed Apr 20 18:05:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563969 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4401139map; Wed, 20 Apr 2022 11:10:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw16ljxnsFCjJlD96DqUgTrllUDPzcbCXtCv+Jvnvd8SjGoZVcubo/5qHKhwxBNDvyUtnxe X-Received: by 2002:a05:6638:1907:b0:328:5e9f:efd9 with SMTP id p7-20020a056638190700b003285e9fefd9mr11530712jal.181.1650478252910; Wed, 20 Apr 2022 11:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478252; cv=none; d=google.com; s=arc-20160816; b=so51w5gybHXj1c3c18IvNbfPaPzTQGNVYU1woIZDNaYZt83X/7UjCdrX+lA5JWFA9P Sl9TXt4xlJqURjRGvWO4HSeCXYnqp//DlFZxVZziNZGJGRt5nFXVSnnjRkLAdmRmuapn IQfxIgpAad4wIuTt9DG9hzOAxP1TZkBwidnLGWSnBBIzTySxE7zXOFIWIMIswQBKiqwa PFcuvezfUDLlXp2RTB6RsyEuSr62FLci+ogK8O4jilYbtmffdbBmTfAJOsVU8PlXtr0W utkTyYLCa7gkM8/ybddr9pPoxMLDhMgWC4ryH1jBfrepk+F+3mJhBrudstAsUk+TrmUL dd0g== 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=qOdUv5mfLIRRq/G3CLO50Ev+VYpnxZy+//PQdRqaMNk=; b=PnB+Y0g2YCxq6ifviJuUxKlP645P1EOzcj1WmHzeg+w5/cJQYIVdJVsS9WhsHVaG2Q PLbgdiY3sb9YITtB09OqDFwm0lmOUZAiVup2Q3Qw5+9gimUDR+lC58XsEYrfT+vmbGLa ImVmOeD8aV1kQlvWa7Ge6/c/hCaQPxUs8pS7j3VxXOFK3jlkqa3+ycZ6UnzXBv8Iz+wJ 9ky1RqR6VbnUemc9L+quiYUE9/N32tn5FLkVQNn/pmNQK5MTLWEoumzRk/l5RvGbuI0X k2UKoSllcpgWHPporJu8b8uyzY2MrE0lTUIKbON4kn6m+mA9k87bZp9TapolAyG8yeBd LLdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="J+/HG7uu"; 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 v39-20020a05663835a700b0032a7496feaasi257685jal.139.2022.04.20.11.10.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:10:52 -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="J+/HG7uu"; 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]:34020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEmy-0003nP-EE for patch@linaro.org; Wed, 20 Apr 2022 14:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEif-0005Hm-TM for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:26 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:36398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEie-0001Ah-Ah for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:25 -0400 Received: by mail-pj1-x102f.google.com with SMTP id ga4-20020a17090b038400b001d4b33c74ccso1746707pjb.1 for ; Wed, 20 Apr 2022 11:06:23 -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=qOdUv5mfLIRRq/G3CLO50Ev+VYpnxZy+//PQdRqaMNk=; b=J+/HG7uuivAl4Wbn573ogI+SnNn59jNB5r5E8WdbO66d1ALxfcDf8ZQcS4wPsMbdJ/ F2HgvBTCrzx4keYNw1ZoQpQFMksjBDr0k/CjJE7hKa50/k3fNQjlfDekmuTqknZvPX57 sPhhm28rLmrCSpgpPR1iq++yoXEqVV+fr8J/wkc00WZnoyDJ/dDdHVErW8sDl2DE/16F XiVQY5LQXHCE7gjAqDOgVIrddJdmaf2SJzQs8lrKx8XmSCENzcSsKDlmqV2iXYNTDW5g GXjvWKiEccy21gMSECbuBJ8g0LIa9tNlkGjsCvxL/o5c59DUhKoi8/tppdjLsFwG/szz 15xA== 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=qOdUv5mfLIRRq/G3CLO50Ev+VYpnxZy+//PQdRqaMNk=; b=ZYS482yK+g9dimyiiuukuWefHOpCZdLSl0F7S+K9to42Dg+YK4x3NKRGZY8gM0zd0Q ZFP8OogvOypEiVbgnlAm6WI9iEVjiDyIlPas88mB+8Y/pC4VAA+1N/xWz6+ydDSGPQAA yZP8qC5nLrGhWdSrz8qiZJ/pzZ+HpbgaXh5NI3XX3NuF1WLOlkLBOSx6vm1scE8CinDM n9jUOROweLGabpzrUfAnnH9f5FgzdkelYwlyGuwRghIIpaOxYwqM6fhIxoTs0wieo0nX GBz/fE4swMl3XuNW18/dtpRBLocuRaEZ6pN1u1QA+mYA/c1VnYqZbYzj0n2D/HBVDqxh zd1g== X-Gm-Message-State: AOAM532bXQN5VFBMVhXZ9uwvPcJRlJZbEPIfN8qLdRJoVnVsIPULcFdx q8GHAaPc102D1GSwtQxz7bizGTbDBaikLg== X-Received: by 2002:a17:902:ecd0:b0:159:572:af3a with SMTP id a16-20020a170902ecd000b001590572af3amr14052970plh.77.1650477982954; Wed, 20 Apr 2022 11:06:22 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 03/39] util/log: Return bool from qemu_set_log_filename Date: Wed, 20 Apr 2022 11:05:42 -0700 Message-Id: <20220420180618.1183855-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102f.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Per the recommendations in qapi/error.h, return false on failure. Use the return value in the monitor, the only place we aren't already passing error_fatal or error_abort. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-4-richard.henderson@linaro.org> --- include/qemu/log.h | 2 +- monitor/misc.c | 3 +-- util/log.c | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index ed59ebd4a2..fabfbe41da 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -148,7 +148,7 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; void qemu_set_log(int log_flags); -void qemu_set_log_filename(const char *filename, Error **errp); +bool 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); int qemu_str_to_log_mask(const char *str); diff --git a/monitor/misc.c b/monitor/misc.c index b0fc0e5843..4b68fcd346 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -419,8 +419,7 @@ static void hmp_logfile(Monitor *mon, const QDict *qdict) { Error *err = NULL; - qemu_set_log_filename(qdict_get_str(qdict, "filename"), &err); - if (err) { + if (!qemu_set_log_filename(qdict_get_str(qdict, "filename"), &err)) { error_report_err(err); } } diff --git a/util/log.c b/util/log.c index ffa66a267e..a838686a18 100644 --- a/util/log.c +++ b/util/log.c @@ -138,7 +138,7 @@ void qemu_set_log(int log_flags) * * filename may be NULL. In that case, log output is sent to stderr */ -void qemu_set_log_filename(const char *filename, Error **errp) +bool qemu_set_log_filename(const char *filename, Error **errp) { g_free(logfilename); logfilename = NULL; @@ -149,7 +149,7 @@ void qemu_set_log_filename(const char *filename, Error **errp) /* We only accept one %d, no other format strings */ if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { error_setg(errp, "Bad logfile format: %s", filename); - return; + return false; } else { logfilename = g_strdup_printf(filename, getpid()); } @@ -160,6 +160,7 @@ void qemu_set_log_filename(const char *filename, Error **errp) qemu_log_close(); qemu_set_log(qemu_loglevel); + return true; } /* Returns true if addr is in our debug filter or no filter defined From patchwork Wed Apr 20 18:05:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563972 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4402230map; Wed, 20 Apr 2022 11:12:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIMUXrP28W2lDaKtklqXRPp3xGH+qKvYH5rJ9uwCxCNFEIvFQiJjRJq94YMVu6tCM9ARjL X-Received: by 2002:a25:264d:0:b0:645:5c56:e475 with SMTP id m74-20020a25264d000000b006455c56e475mr2666607ybm.220.1650478342221; Wed, 20 Apr 2022 11:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478342; cv=none; d=google.com; s=arc-20160816; b=nidx7B7XavYJQ8Aarz7jdQ42DDX1gduOrdKnMPShOvOG3oN140yoaZnRSL8hCIFjdh wgtugW5qOmfWbmipoB6QTwOKEps8QTkQkQFaj4etAPf/G1cqOBjfjuQGINESJcoH3clw eEMsWH/iZ75JJf+Y7pJPg/oX8L8E/ywRu/Jm3D+aZKxIlyYFQmnyyuDIL6qGCX2cUFpc 5oM+XVDURe+JeRDGS1nMs3mHiXZoY3K+H+RFJ9gXTYFwE4p0yuxfgrt7uQDbyZpiyOq3 2byXXke+aB9TSQQR6Y0kET5Om5SxBe1KwdVze/8uROPOQvCuirtem6rNJd5VsCxm3lMC Cv8A== 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=WCPmwypoKHZcoHiWNjxrenUSP19FCOQHDS6/A6+BTTo=; b=Vv3s+qiyUC/eG6WoA80zESOI469EV3jp2o9HfkKyDF+zTxz6ft+wYnRYE4do4h3CdB TOHrw3UCTyMRwv6rLpYktBjoStl00uHdZEG6j3rzhnDEW0zEaqajT9dnK1EWpDYQiFrD AzrySSTRByKrgtH3+v2gwjdHSLNnylqNc8NcCVytEj6NxOK5KoGNi/pdOgAstSe3UKEU c9sys+d8LaEgfj7xzdm6KsP7ZU1UcNX/jHBBpBISXkSXhw8WjTlrsbXp0GGQY55TgAI7 OGWmxqVtHQNx7AnsHbDC4Bxnz1RowTjR4J+4fCkQFgoryliQuZehhsX7BwM/xZN46CFc RBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lJceh7h/"; 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 b190-20020a2534c7000000b0063dce7ac427si615945yba.371.2022.04.20.11.12.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:12:22 -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="lJceh7h/"; 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]:39332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEoP-0007dz-JV for patch@linaro.org; Wed, 20 Apr 2022 14:12:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEih-0005Kc-Ee for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:30 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:39774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEif-0001Ay-G9 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:27 -0400 Received: by mail-pf1-x429.google.com with SMTP id l127so2683577pfl.6 for ; Wed, 20 Apr 2022 11:06:25 -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=WCPmwypoKHZcoHiWNjxrenUSP19FCOQHDS6/A6+BTTo=; b=lJceh7h/srxWqWfJp4f/1LbAq/uJSkd94hV4837avBTWStmv9NMHy9Lrqfr1nDIKJ3 pyHZsfyNLPj3XT/4SXhrxLe5o/3ZZoU0ysz9o+L4zMwsOhJ3b/0vZ0JOT47FV6NhqZTS x50d+A2AgH19uMP2dkGx8ombc952OaDoITaBx0uviKpJcPSzDH02eUJSAGYN6dbBMBoE GvivpKbRnj4InzRB47cqtSc71uqQ7DyZ/f5mqaC3fAOub9QjZzfhJDKhIXe/Uuj+A/lb /eMUQX3EdO4SW7cR+IggCrfNCPPZ4F55lsopNZRDYY5gRE5goZszVYD1c10A2kqJz04F REZg== 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=WCPmwypoKHZcoHiWNjxrenUSP19FCOQHDS6/A6+BTTo=; b=n0qEEHe2tyuQvra1FBWkYgPpQQUNPvbVULnbOxog7UFSPNYoCfMjuCJT2JJhnbhFsX ncAyjbFWFOgwPhpu51+dWQEVeKoWUFGTUId7ht4uw922OzKCWV9hzHUbwgAbicvquEAF dcp/TPifLq1WAsgz+OnL5kchzHDbU9Rz3I0ptXJ764OtiJI+A37c9HLhkEuZKIYO7/u+ Dzp2WWo1Kl91JMthoVPx8+/Aw5ja9EyOkAyibVYePZO7C30duCazHyRAvQQCRwfBu09f mkcMVqo202tXQlNwoGdF3/i9oFdFC6SsJi0vrGBR1B9nJC1sWH2x6HJKaiLLUT+Ie6Jw trcA== X-Gm-Message-State: AOAM533r/NdWrDY1e7nLiDLMK8qkC70ZH/nMSktS+AaoYJTF3AV2W+yB eR4pwpbdjhQtAYyKOB1T6tVx5GeZx2KAHA== X-Received: by 2002:a63:d50d:0:b0:3aa:45e3:345f with SMTP id c13-20020a63d50d000000b003aa45e3345fmr7287651pgg.621.1650477984001; Wed, 20 Apr 2022 11:06:24 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/39] util/log: Pass Error pointer to qemu_set_log Date: Wed, 20 Apr 2022 11:05:43 -0700 Message-Id: <20220420180618.1183855-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not force exit within qemu_set_log; return bool and pass an Error value back up the stack as per usual. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-5-richard.henderson@linaro.org> --- include/qemu/log.h | 2 +- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- monitor/misc.c | 6 +++++- qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- scsi/qemu-pr-helper.c | 2 +- softmmu/vl.c | 4 ++-- storage-daemon/qemu-storage-daemon.c | 2 +- tests/unit/test-logging.c | 2 +- util/log.c | 12 ++++++------ 12 files changed, 22 insertions(+), 18 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index fabfbe41da..0b892f5e90 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -147,7 +147,7 @@ typedef struct QEMULogItem { extern const QEMULogItem qemu_log_items[]; -void qemu_set_log(int log_flags); +bool qemu_set_log(int log_flags, Error **errp); bool 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 08f43af235..0c8aa1ae90 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -414,7 +414,7 @@ int main(int argc, char **argv) qemu_print_log_usage(stdout); exit(1); } - qemu_set_log(mask); + qemu_set_log(mask, &error_fatal); } if (optind >= argc) { diff --git a/linux-user/main.c b/linux-user/main.c index 2b06350688..6aed4929ab 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -679,7 +679,7 @@ int main(int argc, char **argv, char **envp) log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); if (log_mask) { - qemu_set_log(log_mask); + qemu_set_log(log_mask, &error_fatal); } if (!trace_init_backends()) { diff --git a/monitor/misc.c b/monitor/misc.c index 4b68fcd346..33372b93cc 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -428,6 +428,7 @@ static void hmp_log(Monitor *mon, const QDict *qdict) { int mask; const char *items = qdict_get_str(qdict, "items"); + Error *err = NULL; if (!strcmp(items, "none")) { mask = 0; @@ -438,7 +439,10 @@ static void hmp_log(Monitor *mon, const QDict *qdict) return; } } - qemu_set_log(mask); + + if (!qemu_set_log(mask, &err)) { + error_report_err(err); + } } static void hmp_singlestep(Monitor *mon, const QDict *qdict) diff --git a/qemu-img.c b/qemu-img.c index 116e058675..ef3224a9d4 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5443,7 +5443,7 @@ int main(int argc, char **argv) exit(1); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); /* find the command */ for (cmd = img_cmds; cmd->name != NULL; cmd++) { diff --git a/qemu-io.c b/qemu-io.c index eb8afc8b41..38321a27a3 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -634,7 +634,7 @@ int main(int argc, char **argv) exit(1); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); /* initialize commands */ qemuio_add_command(&quit_cmd); diff --git a/qemu-nbd.c b/qemu-nbd.c index 713e7557a9..bf9c5fedce 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -804,7 +804,7 @@ int main(int argc, char **argv) exit(1); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); socket_activation = check_socket_activation(); if (socket_activation == 0) { diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index f281daeced..1f2a84c534 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -1001,7 +1001,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } trace_init_file(); - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); #ifdef CONFIG_MPATH dm_init(); diff --git a/softmmu/vl.c b/softmmu/vl.c index 46aba6a039..fe9de2f896 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2570,9 +2570,9 @@ static void qemu_process_early_options(void) qemu_print_log_usage(stdout); exit(1); } - qemu_set_log(mask); + qemu_set_log(mask, &error_fatal); } else { - qemu_set_log(0); + qemu_set_log(0, &error_fatal); } qemu_add_default_firmwarepath(); diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c index eb72407257..1398f0443d 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -392,7 +392,7 @@ int main(int argc, char *argv[]) if (!trace_init_backends()) { return EXIT_FAILURE; } - qemu_set_log(LOG_TRACE); + qemu_set_log(LOG_TRACE, &error_fatal); qemu_init_main_loop(&error_fatal); process_options(argc, argv, false); diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 05703a4e51..d071400ebc 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -122,7 +122,7 @@ static void test_logfile_write(gconstpointer data) * In cases where a logging backend other than log is used, * this is needed. */ - qemu_set_log(CPU_LOG_TB_OUT_ASM); + qemu_set_log(CPU_LOG_TB_OUT_ASM, &error_abort); file_path = g_build_filename(dir, "qemu_test_log_write0.log", NULL); file_path1 = g_build_filename(dir, "qemu_test_log_write1.log", NULL); diff --git a/util/log.c b/util/log.c index a838686a18..bab4d29ecb 100644 --- a/util/log.c +++ b/util/log.c @@ -73,7 +73,7 @@ static void qemu_logfile_free(QemuLogFile *logfile) } /* enable or disable low levels log */ -void qemu_set_log(int log_flags) +bool qemu_set_log(int log_flags, Error **errp) { bool need_to_open_file = false; QemuLogFile *logfile; @@ -103,9 +103,9 @@ void qemu_set_log(int log_flags) if (logfilename) { logfile->fd = fopen(logfilename, log_append ? "a" : "w"); if (!logfile->fd) { - g_free(logfile); - perror(logfilename); - _exit(1); + error_setg_errno(errp, errno, "Error opening logfile %s", + logfilename); + return false; } /* In case we are a daemon redirect stderr to logfile */ if (is_daemonized()) { @@ -129,6 +129,7 @@ void qemu_set_log(int log_flags) log_append = 1; qatomic_rcu_set(&qemu_logfile, logfile); } + return true; } /* @@ -159,8 +160,7 @@ bool qemu_set_log_filename(const char *filename, Error **errp) } qemu_log_close(); - qemu_set_log(qemu_loglevel); - return true; + return qemu_set_log(qemu_loglevel, errp); } /* Returns true if addr is in our debug filter or no filter defined From patchwork Wed Apr 20 18:05:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563973 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4402869map; Wed, 20 Apr 2022 11:13:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxz9X9W9KlhnIHa6NhJbX5j7fAvFnOof4sEpTyf/LqSzVWZL6RfqCC+ew9GbyWSAR7xhqQV X-Received: by 2002:a25:f505:0:b0:624:f6f9:7bf3 with SMTP id a5-20020a25f505000000b00624f6f97bf3mr20074383ybe.465.1650478401383; Wed, 20 Apr 2022 11:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478401; cv=none; d=google.com; s=arc-20160816; b=kBSlUck+cZ+kxFSH+MJnwVsXrZF4AXkcCwsDN+ri0K7GMNWPlnKS/gNj8P+9mga0nb rJytLUN32zObCui/FEmwBRc19LA3POWiDvgb96rH7IEHf1rlMV6a8s97IsFzlXTOcpM8 IqksmXCI7C3r63d1xA0osUNUiyWFW9IoOL9Gu38tjUKb5ZqhrS7WDYVZ9whQLbhbkyxw yVmxgPxApE+O7s3olKstceLPx4uBw/lLYy3jJSP3CkUWteTObytVlK5+4xSsqA8xkpj/ Zf/dp4Mg3lz4t1S/UNJSVmPueJQJbstm8Fs1DG/mh6CWfZMyuKqKGCGuJBPt2KhKoK3q qDSw== 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=9Acrdd8Fm08SC2Pv9DkKl+01rcq3tkQdmCCMEajfWbE=; b=bb5XGuuUm0l6hg0qgk2HADaLa+PcdO095fVZqMZPPgPNcyTGdVK2hZtmishHB5lzqX 7oPPKR1vU0ORvImn6UFExNVtpSxUc1KQqDCDoCrteL7X6iqLvh4jydPTmxAbgVLkkldf MGjWJtrbmS8+7w1QUWsT0fbDjO4cktM8kZ9Z5JYnkmD3D06sr63jiU8LCHmXIZ+Ex3oO C7TrVVlH4YGk5q4uXeG3OtikyziBrvF2FLQ7R7Jd1oAlf9ZwsqCq84a9pbb0lpZtkwzC FCbTTKwf7cJ54gw4wDarUVef6qLm52FWVXT0TJ3U7JhqgsPdbT1eVbThboJQwFkcgz/6 wkQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v4Wr19uf; 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 u125-20020a0dd283000000b002ec34074889si565415ywd.344.2022.04.20.11.13.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:13:21 -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=v4Wr19uf; 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]:42734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEpM-0001Yk-Re for patch@linaro.org; Wed, 20 Apr 2022 14:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEih-0005Kd-I4 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:30 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:35435) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEig-0001B6-3r for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:27 -0400 Received: by mail-pl1-x630.google.com with SMTP id b7so2525366plh.2 for ; Wed, 20 Apr 2022 11:06:25 -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=9Acrdd8Fm08SC2Pv9DkKl+01rcq3tkQdmCCMEajfWbE=; b=v4Wr19ufbUX3KmnVoQbvzqg5KQkDOfHvzNLNIXrerpRLPtDD9WRWpuZTY3xm9RKMJh iB6Di7Dkr3+ZprDgnnaP7IOCdL8H5iLI0KYuDvqi7ejHuNquYypZJLNWcn7zzQjFRbDp 9EOsIWF0e3YruvngcE5IFbC7u9Zat1E8cou/sAZZTsbwVhGmVGpW8Ag3QhedjDqOL9jX HjowrYmPJ1t7Lap+0DVnlAZvdoqyhIuT+4N8dwMi/IXKcWzkU0ycvp13Rr0AH9KhCxu2 r/oUOsxit18INI+EeKtkXuxIhCy5I7jyL4SYqHayYYFVQaBrYyfmz7eR/5DD+LRIYMeR MEhA== 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=9Acrdd8Fm08SC2Pv9DkKl+01rcq3tkQdmCCMEajfWbE=; b=bq8FUYWRZMjgzinLDhFX9mIqFUMUVcfjyCN22Xzi81stc30WfPGDHRRb0kRLOMbzgz UHFHA5tCFHad9yJ6XtuqAQuMeH55t+BIZup7JsaLU9+Rw4VtihhOU+JI76esY3lO111y AAWy1Hbl7w5k5Iu5VisWeMYEz8e7Cstnm8Sg/9hTYbzwaZhW1Fr7vGnwJMOTdKvIjTda bMBOWG0JeMdFvgUPVo7ps4BZSIdQlQ3bJyZv6G4LwuMXu93g0AIAYdO7SxzSQwSoqgf2 GUWJWLEF+1iXRflLEeTu6w+cCAl6o7syfJl4fEdE1QLdyw9MSoo0Cb31UJ6dyV8Ho/rI 6nkg== X-Gm-Message-State: AOAM530NDr+A8LCsyTZGXN4Z/vYYC6WxLnSRK/CEh3+1KH+kkoPO7IKt 68snt633cYoSidcWvo2cCZ+Bak0mgAr5WA== X-Received: by 2002:a17:903:2487:b0:159:bce:4e1a with SMTP id p7-20020a170903248700b001590bce4e1amr12182604plw.4.1650477984860; Wed, 20 Apr 2022 11:06:24 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 05/39] os-posix: Use qemu_log_enabled Date: Wed, 20 Apr 2022 11:05:44 -0700 Message-Id: <20220420180618.1183855-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not reference qemu_logfile directly; use the predicate provided by qemu/log.h. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-6-richard.henderson@linaro.org> --- os-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os-posix.c b/os-posix.c index ee765f047d..faf6e6978b 100644 --- a/os-posix.c +++ b/os-posix.c @@ -291,7 +291,7 @@ void os_setup_post(void) dup2(fd, 0); dup2(fd, 1); /* In case -D is given do not redirect stderr to /dev/null */ - if (!qemu_logfile) { + if (!qemu_log_enabled()) { dup2(fd, 2); } From patchwork Wed Apr 20 18:05:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563967 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4398852map; Wed, 20 Apr 2022 11:08:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt1q4+UFoC+fecVzNv1aITj4j+zs30XwHLPf6IdbBZk3h8c68vTY0ybYXkttd3s32REaGn X-Received: by 2002:a5b:803:0:b0:633:749f:9acd with SMTP id x3-20020a5b0803000000b00633749f9acdmr21914386ybp.236.1650478084078; Wed, 20 Apr 2022 11:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478084; cv=none; d=google.com; s=arc-20160816; b=0NOZ6uHE8oDUlbAEuWwV/kOzvZzrRUOnFunHdqnhJW+zHoygn4l9cYt46szJPk2Njx N/GeZJLqQt2cISMjXc12ngJ2b2GspgPLyKdzIf0BGMKOiA1k+cZd3yQFpbwU/SK5j7xL QOD6vKB5C6Q40H6djdHVrUeP1ql+jIm5GhOhHq9nsdBAC5Ze1JDhgnA6b0UN4IA9NwFw METMnce/SFsUT8B5kwcvkK0oRpjehTrjdhFfUIvFhprc/Wht6lbDeccXkm6agl0LGtgh y4VwWZrRT+n1x7eEgK4eherkHFKHMctUi2f6abgPfcuuBq1aCsmreGOk1nDrzoSsL5q2 5qag== 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=WTPANaSXVUPEAI7mIQ7snDqLyeiuuNYxhMnMuIg6itw=; b=iKPeNilqP93FSiTysM31feaa9H2JTqgxeo0IDHgk4cLKEWDr4u0eWgDR3BWyTWt5+c fxQCcdCHmkXIxWy21OXhsMeGg5Q1Vtn6i/MQQEBpiAieIiL4WzSSRViJZ+V9JatsKyDC AMr9HlqIv+qznwOPvSjHOz3zlgRC+IIkDpozJMZvsa2JtZX9TTscE+ve77jqQZlG0SZT bxPa/1DJ6YwPRAP0QJRBeUBKjCPDu0MYhOLBzENfb5Z4EcvT0VuQfHzqfemHILXdJeGG nhvZLXUm4LNFEgdX/oQp1ErV2i5CCQVYgaes07KeSO3QZT9siu7Pb2vH1pMQT0niKog9 ljYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QV1YunUi; 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 g188-20020a8120c5000000b002f4d2875cf3si311381ywg.340.2022.04.20.11.08.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:08:04 -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=QV1YunUi; 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]:53374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEkF-0005RC-EH for patch@linaro.org; Wed, 20 Apr 2022 14:08:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEij-0005Kh-2g for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:30 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:46003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEih-0001BN-0a for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:28 -0400 Received: by mail-pf1-x42d.google.com with SMTP id h1so2658804pfv.12 for ; Wed, 20 Apr 2022 11:06:26 -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=WTPANaSXVUPEAI7mIQ7snDqLyeiuuNYxhMnMuIg6itw=; b=QV1YunUi0aBko59BN3IP28wGpWxZ17+liBOmoU8aNEiuHzARonyVTOim78JofFARPv NXQwtYWDVQIGFEUSwHn/FVaXgx4oY0n4EVWJyNRVgmQ8fVPhbhjDyzWnANfHFpWGeEN+ p+VtSRcXbfXsxuO6iN6g5ItvWJ9f1m6sexoam49F7ciIFduBSqt67TenqKQeOOfJ9suW k8Q7M4AhBPIP8qzz3bHfBV8UzK3DgBdlwH7kZTtbygjmc9W6XZ6NrHfO2hgnI+ktrQkv H4pAaJRYkYAWxfEXfz0NnUQb/NutGwJGATgkCCrj6vb5K2uIqqhhu68rU617AgfZ/9pf ZfAQ== 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=WTPANaSXVUPEAI7mIQ7snDqLyeiuuNYxhMnMuIg6itw=; b=Wmhd0pzYUEEifNpwycPtpJ3PKjARIrw/h0IG6z+mI5My77cBlgFtm8jwrY7HIEjHdM Xg0zscUWc/bI2x8l49OWZFwiAssCOBLTTYXWsxTSGe+EO5gzwm5+zzjUcgaXFWU0Ccko /uPwLerl6O8T24iDWHleHdGu6U0HbxA0nILFezMpdGUtkYcv+GHCJtUuWeKbdoMYMJ4R 50nFv4n/T6GSZqTpJhPEc6IvTFWw1SeihRibGFeybs5mvRLpze6gk8lyPeULBvDv/RJN NnX07DZp/UKY3b/qCyG7b0MpCrL2OWWe3ESB++GGZ3pcESOcy0SRcO29Tpks0tpDwlGQ hN5A== X-Gm-Message-State: AOAM53364cXxvtu9cGoxOC8+B2l7smEUkTl99tQEDAq6P5tk+YLyITQH ao9zHXElwyhCxihrtQzPMeA4YolqGE9rTg== X-Received: by 2002:a63:e90a:0:b0:3aa:2c41:87b4 with SMTP id i10-20020a63e90a000000b003aa2c4187b4mr9851081pgh.118.1650477985625; Wed, 20 Apr 2022 11:06:25 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/39] util/log: Move qemu_log_lock, qemu_log_unlock out of line Date: Wed, 20 Apr 2022 11:05:45 -0700 Message-Id: <20220420180618.1183855-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-7-richard.henderson@linaro.org> --- include/qemu/log.h | 28 +++------------------------- util/log.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 0b892f5e90..6a6b1efce5 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -65,32 +65,10 @@ static inline bool qemu_log_separate(void) /* LOG_STRACE is used for user-mode strace logging. */ #define LOG_STRACE (1 << 19) -/* Lock output for a series of related logs. Since this is not needed - * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we - * assume that qemu_loglevel_mask has already been tested, and that - * qemu_loglevel is never set when qemu_logfile is unset. - */ +/* Lock/unlock output. */ -static inline FILE *qemu_log_lock(void) -{ - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - qemu_flockfile(logfile->fd); - return logfile->fd; - } else { - return NULL; - } -} - -static inline void qemu_log_unlock(FILE *fd) -{ - if (fd) { - qemu_funlockfile(fd); - } - rcu_read_unlock(); -} +FILE *qemu_log_lock(void); +void qemu_log_unlock(FILE *fd); /* Logging functions: */ diff --git a/util/log.c b/util/log.c index bab4d29ecb..1a3121610a 100644 --- a/util/log.c +++ b/util/log.c @@ -34,6 +34,29 @@ int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; +/* Lock/unlock output. */ + +FILE *qemu_log_lock(void) +{ + QemuLogFile *logfile; + rcu_read_lock(); + logfile = qatomic_rcu_read(&qemu_logfile); + if (logfile) { + qemu_flockfile(logfile->fd); + return logfile->fd; + } else { + return NULL; + } +} + +void qemu_log_unlock(FILE *fd) +{ + if (fd) { + qemu_funlockfile(fd); + } + rcu_read_unlock(); +} + /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) { From patchwork Wed Apr 20 18:05:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563971 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4401153map; Wed, 20 Apr 2022 11:10:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMsqZUYnngDlB/3iLUHciAkFa2FCYYolVsm8C5QoBh8s7y4jRLmWy1g+Z8l4eC/KM3qpSg X-Received: by 2002:a5b:f0b:0:b0:63c:bd4e:2b60 with SMTP id x11-20020a5b0f0b000000b0063cbd4e2b60mr21233408ybr.473.1650478254125; Wed, 20 Apr 2022 11:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478254; cv=none; d=google.com; s=arc-20160816; b=LCoy9wSlIQVcwi01Y74O0GsQ6wc6VntM1ZuIBNJLU/N/jd6GGI4tRw3LDRuX0kA3jZ 4edySlrpXsTmNC/nmk3Yit58wbmDti0M7iIsXrJoc6PeMWPtLf2EgEaL1Kwii2Mnp34E j5y6gKcIdl4Js6MYrdjsiW837ebFzQAvSgiV6rFp9Qx7ZuFGhnqg5vftG2xQXbmGE2U1 /sOj6vjU/sRhiw0KyhXKWMIZN6V8B2yH3Qge0aOvqfWSFtT4KNlOJWjxjbTrSsOMuPYX gya+4H36ZXwpFW+yw92SOk7/psBIpbzqv8pJk616hnmI/Cpm6r8pTGvsUrt3kyj5kHMl bdZA== 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=D1crAV8qM3lUOm/60yk2vLKxM13f73TQkwkg3i3emao=; b=EQcPrWBfTctmaAPAnlmWB4UX68KWC3xO1MJG8L8a9zLTs57zcSIWdVeeg+M7CTl77p 0YZHAYqpO/RbfK/IMaoRPHMnwYDxPZXVXNgdpWGfe/Y77H+sk91fClNyFIdsodnvbO6R 9rxtEPx9Hp+AScv1ANvLHFelTSxV7n5/Ggr88ys1ixXp29fyk3zPDlU976QWKUURmg5H 0JtF9qibmFWDmrb11Y+d+P9HdvFgd3dtO95PBxcdj91xkl4QqkdyhboFgFwit5eZ5Nav nrOWmNU0486QVGZsh7CKXtBTLTMfrxPobGwEWtRIjxrowH9bSZ/eTVDyr3OrcvtB/3Cl 9pOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iuDHN92O; 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 j6-20020a0de006000000b002ec31af0156si582903ywe.189.2022.04.20.11.10.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:10:54 -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=iuDHN92O; 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]:34086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEmz-0003pz-JK for patch@linaro.org; Wed, 20 Apr 2022 14:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEik-0005Ko-Am for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:30 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:35564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEii-0001BZ-6o for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:29 -0400 Received: by mail-pg1-x531.google.com with SMTP id r83so2340661pgr.2 for ; Wed, 20 Apr 2022 11:06:27 -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=D1crAV8qM3lUOm/60yk2vLKxM13f73TQkwkg3i3emao=; b=iuDHN92OkRmc8Dl3VHjD67nffHtpdQwDu8XnupGugZND+IeQFrEKgsRonfJp5vMNdn tKTb0SWFbxthpZ9pAWPPK5K+cVtDkpazkVJva9EF7fdcWPCbj/bAQj34UzXhA9nEkEg3 SDNe0mAXDMC6ghynfofrDRXd9UNpI/FqYNLZal8G1wxnEMcNryooISzpQtCEgLcEA1nt ktVp7Sac2MFItqY0M/yEG4EP9IY7lWNLNAkUVAdi8tlDPk5a2J6hWDZrze21Ht9kN2oN XRMbIccWRrmW3qxQ+sUyaLWdLRBDCsT1hYWCbWYR+1cLzkCBOCiRCLVGTpO0o62dsG5L 2aKQ== 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=D1crAV8qM3lUOm/60yk2vLKxM13f73TQkwkg3i3emao=; b=cBGtmImnp3QoI/ic1RUrnhDKzXjBzAypastulssfwr1sA2t2tnbk8eWm5fKBMdFBd3 8u7CDYfG75U3892ev6WNy8PYOODWF+Iromydu22FS/roxYDVJRTfhYDjW8vNhEq154fK X7EINr+sAlQKx6JAMUXvoIxCcVyfIT6foz82kMiuJLIDKnHJAzzzG+eAIdL4RAFf3BZD WAgSKMZRyieKhsNx27rornOmN4SphcVw+wgJofDdg1RswFgWFr1umQui3Qq8Fk/TuBfA 1AHeYgsCuQvyQJZm6fS+/VO2aFXqkqSF4qm9urqW7v5MhRxK3uM3XxOY5eJcJ98RB4UY Jddw== X-Gm-Message-State: AOAM532pcugov9Z5JYpxc6ViVE1SZDH67AddbXAISWZt+evz8PW46jKI 8Epwz3OseUQTjHV2weYQ97hny173CHCmpQ== X-Received: by 2002:a05:6a02:18b:b0:399:365e:f09c with SMTP id bj11-20020a056a02018b00b00399365ef09cmr20716002pgb.238.1650477986730; Wed, 20 Apr 2022 11:06:26 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 07/39] util/log: Rename qemu_log_lock to qemu_log_trylock Date: Wed, 20 Apr 2022 11:05:46 -0700 Message-Id: <20220420180618.1183855-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This function can fail, which makes it more like ftrylockfile or pthread_mutex_trylock than flockfile or pthread_mutex_lock, so rename it. To closer match the other trylock functions, release rcu_read_lock along the failure path, so that qemu_log_unlock need not be called on failure. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-8-richard.henderson@linaro.org> --- include/exec/log.h | 2 +- include/qemu/log.h | 2 +- accel/tcg/cpu-exec.c | 2 +- accel/tcg/translate-all.c | 2 +- accel/tcg/translator.c | 2 +- cpu.c | 2 +- hw/net/can/can_sja1000.c | 2 +- net/can/can_socketcan.c | 2 +- target/i386/tcg/translate.c | 2 +- tcg/tcg.c | 8 ++++---- tests/unit/test-logging.c | 2 +- util/log.c | 6 ++++-- 12 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 3c7fa65ead..fb595d1eb7 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -71,7 +71,7 @@ static inline void log_disas(const void *code, unsigned long size) /* page_dump() output to the log file: */ static inline void log_page_dump(const char *operation) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); if (logfile) { qemu_log("page layout changed following %s\n", operation); page_dump(logfile); diff --git a/include/qemu/log.h b/include/qemu/log.h index 6a6b1efce5..d090faf22a 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -67,7 +67,7 @@ static inline bool qemu_log_separate(void) /* Lock/unlock output. */ -FILE *qemu_log_lock(void); +FILE *qemu_log_trylock(void); void qemu_log_unlock(FILE *fd); /* Logging functions: */ diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 083ada76b1..f61b056571 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -214,7 +214,7 @@ static inline void log_cpu_exec(target_ulong pc, CPUState *cpu, #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); int flags = 0; if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index a6e03c1e50..5937d6b7b2 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1527,7 +1527,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); int code_size, data_size; const tcg_target_ulong *rx_data_gen_ptr; size_t chunk_start; diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index f06c314266..1506755f3c 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -139,7 +139,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(db->pc_first)) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("----------------\n"); ops->disas_log(db, cpu); qemu_log("\n"); diff --git a/cpu.c b/cpu.c index 0fef70e18e..9db144761d 100644 --- a/cpu.c +++ b/cpu.c @@ -399,7 +399,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) fprintf(stderr, "\n"); cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP); if (qemu_log_separate()) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("qemu: fatal: "); qemu_log_vprintf(fmt, ap2); qemu_log("\n"); diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 3ba803e947..300313dfb8 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -247,7 +247,7 @@ int can_sja_accept_filter(CanSJA1000State *s, static void can_display_msg(const char *prefix, const qemu_can_frame *msg) { int i; - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("%s%03X [%01d] %s %s", prefix, diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c index 4b68f60c6b..4a505643e9 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -76,7 +76,7 @@ QEMU_BUILD_BUG_ON(offsetof(qemu_can_frame, data) static void can_host_socketcan_display_msg(struct qemu_can_frame *msg) { int i; - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("[cansocketcan]: %03X [%01d] %s %s", msg->can_id & QEMU_CAN_EFF_MASK, msg->can_dlc, diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 3ba1c99fff..f3cffee520 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2580,7 +2580,7 @@ static void gen_unknown_opcode(CPUX86State *env, DisasContext *s) gen_illegal_opcode(s); if (qemu_loglevel_mask(LOG_UNIMP)) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); target_ulong pc = s->pc_start, end = s->pc; qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc); diff --git a/tcg/tcg.c b/tcg/tcg.c index f8542529d0..abe4ef7799 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -756,7 +756,7 @@ void tcg_prologue_init(TCGContext *s) #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("PROLOGUE: [size=%zu]\n", prologue_size); if (s->data_gen_ptr) { size_t code_size = s->data_gen_ptr - s->code_gen_ptr; @@ -4200,7 +4200,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #ifdef DEBUG_DISAS if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP) && qemu_log_in_addr_range(tb->pc))) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("OP:\n"); tcg_dump_ops(s, false); qemu_log("\n"); @@ -4245,7 +4245,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #ifdef DEBUG_DISAS if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND) && qemu_log_in_addr_range(tb->pc))) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("OP before indirect lowering:\n"); tcg_dump_ops(s, false); qemu_log("\n"); @@ -4266,7 +4266,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) #ifdef DEBUG_DISAS if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT) && qemu_log_in_addr_range(tb->pc))) { - FILE *logfile = qemu_log_lock(); + FILE *logfile = qemu_log_trylock(); qemu_log("OP after optimization and liveness analysis:\n"); tcg_dump_ops(s, true); qemu_log("\n"); diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index d071400ebc..4c595356ae 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -162,7 +162,7 @@ static void test_logfile_lock(gconstpointer data) * our handle remains valid for use due to RCU. */ qemu_set_log_filename(file_path, &error_abort); - logfile = qemu_log_lock(); + logfile = qemu_log_trylock(); g_assert(logfile); fprintf(logfile, "%s 1st write to file\n", __func__); fflush(logfile); diff --git a/util/log.c b/util/log.c index 1a3121610a..6b7b358573 100644 --- a/util/log.c +++ b/util/log.c @@ -36,15 +36,17 @@ static GArray *debug_regions; /* Lock/unlock output. */ -FILE *qemu_log_lock(void) +FILE *qemu_log_trylock(void) { QemuLogFile *logfile; + rcu_read_lock(); logfile = qatomic_rcu_read(&qemu_logfile); if (logfile) { qemu_flockfile(logfile->fd); return logfile->fd; } else { + rcu_read_unlock(); return NULL; } } @@ -53,8 +55,8 @@ void qemu_log_unlock(FILE *fd) { if (fd) { qemu_funlockfile(fd); + rcu_read_unlock(); } - rcu_read_unlock(); } /* Return the number of characters emitted. */ From patchwork Wed Apr 20 18:05:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563976 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4403775map; Wed, 20 Apr 2022 11:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQsDga1XKR5qCkfKhvL7+2LRDujnYWsLV+mqe72yOLiEr6m0nN9tZPUdsvZ1DUeoB/3tIi X-Received: by 2002:a25:9e81:0:b0:624:3b8a:514b with SMTP id p1-20020a259e81000000b006243b8a514bmr21313754ybq.266.1650478476640; Wed, 20 Apr 2022 11:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478476; cv=none; d=google.com; s=arc-20160816; b=Vuqiwqy4Pp58kNs0rUlDv96bCP43oHEqcz4xMrxD+8UP9QUnn0r9V3my1F0y/6C2me fJ6e0KNkkk4VpRoZ6FE9q/sKI49rcI4C8bbwW0FLtH/5k+HDcO6mosfn7NgDCFdlKEFX nRDThfBm9aH6/r61nguFaC7ioZtGAUHb92ecWIudtmNUIMWr7ZUr1QIM6FYcGdhOHCaC 7qj9tM4JS3gefbubflEmaK9JvKmmMCs9/acxfT2cH0acA7DOKtgujlUXCZazuuLJPocr Lp4OCLwSqQu6Nlltv1a/vDNZATjxqgKwNA+UkCXaEpIYFBpwm652z0Nfs2/h3QCxOwjb uITQ== 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=/7lsVTmyGDucjIzypVl9G9xgzg0WOWvjikiRtOmHVOc=; b=Nh+1jwA5zeX0+umPj8hQD/gguIJzX4kOGUbjQKDQhGZ6CPAeMWiErdhd3UmZh6oI4I Z7JB3/+26/n9TG8Ixs/ZXp2wm5BUXrwlFQ3QKD7NyLEcqQCzyuOa0ahSMCs7UZ8PCUyK iRbksd0wvMYXfXfrbLfzLykvqQgh74r3m9nI8PMor2MdIc0L5bgtOQyCmFlHBjYKtfYR wMMruwEnYLHjz+kow38hO4fTuaKZgPl3agDm2YLP2OswBiTqSbYPJtZYzp+k0j9uXZp5 L/ZEFytYkIsa268f4FXpS1J5E54L7iH9l3YvyqNdwpgJayCtcBGqlWmzMIPE25xBpQIZ 7bgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ySJ+ZUil; 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 e132-20020a251e8a000000b00641408b2069si637439ybe.297.2022.04.20.11.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:14:36 -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=ySJ+ZUil; 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]:47894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEqa-00051t-4Z for patch@linaro.org; Wed, 20 Apr 2022 14:14:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEil-0005M9-N2 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:31 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:51785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEij-0001Bm-VC for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:31 -0400 Received: by mail-pj1-x1031.google.com with SMTP id bg24so2681555pjb.1 for ; Wed, 20 Apr 2022 11:06:28 -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=/7lsVTmyGDucjIzypVl9G9xgzg0WOWvjikiRtOmHVOc=; b=ySJ+ZUilQ47RcPjl8V2CyNsUKb9kZZaJXdkWEjy+aYGBBQ6OvWSHWBjm4Z4JDHQ0Rs deb/KDcNbfOr7UPrOsota38sByvRIlJTKiIYr5J+XTZzBXxYyNgGqM9Wsk2qHi+21DuH 19vUBkEBikELxwSZLYkmAwzpyitPAdcI9p2jI02UQ3ds2j2XKF98uSgRuT0fXzPxvUWe Lz0QiGNxFdqXA4DDaQNaEdH2ypXDZLpPeTTrVbcbLGQyXw/+iXy1a6Nk9IXEJouFejLW ftOdX+DmQ0DrA8YA52Fa0xf+4PqJCIKI+cHkIs1Euhp1XN0OPWyohqE1SMXbNiA6OmOW P9+g== 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=/7lsVTmyGDucjIzypVl9G9xgzg0WOWvjikiRtOmHVOc=; b=vMU+7uFfhFL1c6GWIxoPFKBs8wBq4FVNFeQ8NjFjLGkKLU/ilI7GmsXrBJlsoL4clS ata/4gp+SiRsCCmp9bNhTGopWWtjxw5/O2VUA341b4Kz5zeJOykR3HpEgwxjPpKn0fR9 gATLpRmKdcTRyXfkvNobwgu5St6yPvWjl7fLhS7ibJo7sUX0zhvv7rhmKf7HRGkkwqNJ 50rlfSAd0ATmejFmUmraESYOfBmKsfZcZ5cAJ+2vHCzk+Q4LUp/OMXi4G7WNSN+mbewf 8G+BbJEfUv2AE2O4S2Va/Ms4ofdQ2n2ABySz1TyfQbjdPzAw+qZeXpSxP2q/8XXWm4MZ 3enQ== X-Gm-Message-State: AOAM533CWKUBEWQkygXk6OBbUVujDGJG2xacXnIoW7VAoAen12k5mFlb 32hoKwK27uMmevA+nW354WlnKz3xEt1Grw== X-Received: by 2002:a17:902:7298:b0:158:3a08:3163 with SMTP id d24-20020a170902729800b001583a083163mr21475596pll.133.1650477987924; Wed, 20 Apr 2022 11:06:27 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 08/39] hw/xen: Split out xen_pv_output_msg Date: Wed, 20 Apr 2022 11:05:47 -0700 Message-Id: <20220420180618.1183855-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Do not replicate the individual logging statements. Use qemu_log_trylock/unlock instead of qemu_log directly. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-9-richard.henderson@linaro.org> --- hw/xen/xen_pvdev.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 8ab458922a..0423c61158 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -196,34 +196,38 @@ const char *xenbus_strstate(enum xenbus_state state) * 2 == noisy debug messages (logfile only). * 3 == will flood your log (logfile only). */ +static void xen_pv_output_msg(struct XenLegacyDevice *xendev, + FILE *f, const char *fmt, va_list args) +{ + if (xendev) { + fprintf(f, "xen be: %s: ", xendev->name); + } else { + fprintf(f, "xen be core: "); + } + vfprintf(f, fmt, args); +} + void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, const char *fmt, ...) { + FILE *logfile; va_list args; - if (xendev) { - if (msg_level > xendev->debug) { - return; - } - qemu_log("xen be: %s: ", xendev->name); - if (msg_level == 0) { - fprintf(stderr, "xen be: %s: ", xendev->name); - } - } else { - if (msg_level > debug) { - return; - } - qemu_log("xen be core: "); - if (msg_level == 0) { - fprintf(stderr, "xen be core: "); - } + if (msg_level > (xendev ? xendev->debug : debug)) { + return; } - va_start(args, fmt); - qemu_log_vprintf(fmt, args); - va_end(args); + + logfile = qemu_log_trylock(); + if (logfile) { + va_start(args, fmt); + xen_pv_output_msg(xendev, logfile, fmt, args); + va_end(args); + qemu_log_unlock(logfile); + } + if (msg_level == 0) { va_start(args, fmt); - vfprintf(stderr, fmt, args); + xen_pv_output_msg(xendev, stderr, fmt, args); va_end(args); } qemu_log_flush(); From patchwork Wed Apr 20 18:05:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563977 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4405584map; Wed, 20 Apr 2022 11:16:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwufU5aKLgB8wHfmVL/BkGPp7j18bZldwwthLS1cmNlII2B5kqgSuJH+Lcycl1PMTbtP24z X-Received: by 2002:a25:4055:0:b0:641:636e:18dd with SMTP id n82-20020a254055000000b00641636e18ddmr20437658yba.389.1650478609425; Wed, 20 Apr 2022 11:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478609; cv=none; d=google.com; s=arc-20160816; b=Q7zsDA+fEoSmvyUc5iz2P7TD20+4wN3HiGQStRt/YiFuWqfPCwHL6Cl0NtMFNbmTse 3muaPTnotvBhUnX5irsiQY2TPUqhHEHD+BVrGn0IEKDesbp1yKsbGIdD16xz79mAGWkI DKSMBA2swJtURAkh7E6rjNsTUVAqjmlBRy2UdvXqOzHAFbwqCsmm02bMnljDLzvOXQHU Oot7B2IBLqegmpMKteoaA/5GF8yqEDgyRc79uh00V6A/AXKGlsHAzL9cfswrKoL4sI6b I3Ey9yQPlkb4dqZiBQykX2HUEcN4NZ+u13bIswzoWvQO+4GU3k5M4sAyIgBMX2p0Eks9 LnPQ== 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=5oHI/1iTsxWnflDMgUgS30KGq6uciCnHCKb7fL7h1d8=; b=mfHpZ5sX0jKVU1lShVhR9MAgngMnhQQhk9ZKuxUeHT8jH+pPOARJ9kbflFuuD0Wlup 916puS5p4+RnnbgyrWJi8bQtLR5lt63ZDNtPaWuAoaw78zoYFA4rT8N8VVwGfs8ql5ay Mg6O1ujt/fXjQCLg1t8/NNFsk69kXTFwoArhHYQ58mU3UkGSEFltS0B7hublRjl5Gz7I b7Ttf144XP00hl81dO8CM/6MkrmR8dGOFwDTatMq4bNKTBSgqBv+s9ZZL1WxgSbGvZKr LuRfXlvPJGR+aHc0hBm48nOup2/rOwgswtB0fB5Wo5plm3mGHMZTU7eM7xrD3cs5tOo7 xDeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wlGHkc/C"; 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 d141-20020a25e693000000b006454068e75fsi512633ybh.698.2022.04.20.11.16.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:16:49 -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="wlGHkc/C"; 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]:51202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEsi-0007Nf-TY for patch@linaro.org; Wed, 20 Apr 2022 14:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEim-0005NA-Sb for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:33 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:37381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEik-0001Bz-Gx for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:32 -0400 Received: by mail-pg1-x52a.google.com with SMTP id x191so2328158pgd.4 for ; Wed, 20 Apr 2022 11:06:30 -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=5oHI/1iTsxWnflDMgUgS30KGq6uciCnHCKb7fL7h1d8=; b=wlGHkc/CdPhqoqR6RNf8jJUa75OSGoeiSBwuBwONPFr26yLk3YYGheA+9UgR5W0Fv/ 86UpFw831wdfIXtN5ZpPisH0j797wKsboTow/xZB2L/jETqR8UACd6IUi637f52/b68P JG7ZAnQYs0nJ+Z9TAjdGN6q3dVdRjXQms9G3OLeSTRJ3ZSw3DFGyxQer2pkaoDDoZ8Nv UYjKxALyuI/tr+uajXq7UAOCFMHHC0tptjNpOsBxO/w4a+aHQmQ02DXT9OPIlHSlK3Fp q6hEdpLadG2sBP7UTHpR6Tn1PO5Yb0FhUeaJjrOuuTYSm7NmzDUhgt+rfij1ulg0csQw hW9Q== 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=5oHI/1iTsxWnflDMgUgS30KGq6uciCnHCKb7fL7h1d8=; b=2mM1nkpRpMR722FDBbS20wDS9LsIajLwDyXdGhoMEoIlw2pn+FxgC4BEa3hw275+i9 wb+ezwbQQ0DhaKmxZhoLSz+PTNIPp6k99tffFPctcQMRODX2FyqazhsyAWlk1J4pJu/C Und9QqojeKKvZ5J9exAW9YYTPsppaGA7TKMdDtKFk1PW3fFhz1sFjjaIjP6LeB4YrD7D 89exL4yKOvnTS4wPdyrYcwRn6cJ1GKjwL2iYE9DZQ153xB3ox/MXcHmkMAR8h15dR93V OciuliszlNXBS2c6mFMJMK/wzBKNOUuNOZUxbVlHX1LR9YaVCFHeBgNh/cD5tR+b+5ta /Lhg== X-Gm-Message-State: AOAM5312FJJ8Ge8xQRToKuc5jc1IbNaGSxXBDF+A16pB2+vJ3su6srcv 85LyFw38wvDGYAt1u7TG563MbdLuIqfUmw== X-Received: by 2002:a63:ed05:0:b0:39d:4f84:1fe3 with SMTP id d5-20020a63ed05000000b0039d4f841fe3mr20344424pgi.420.1650477989142; Wed, 20 Apr 2022 11:06:29 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/39] *: Use fprintf between qemu_log_trylock/unlock Date: Wed, 20 Apr 2022 11:05:48 -0700 Message-Id: <20220420180618.1183855-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Inside qemu_log, we perform qemu_log_trylock/unlock, which need not be done if we have already performed the lock beforehand. Always check the result of qemu_log_trylock -- only checking qemu_loglevel_mask races with the acquisition of the lock on the logfile. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-10-richard.henderson@linaro.org> --- include/exec/log.h | 2 +- accel/tcg/cpu-exec.c | 16 ++--- accel/tcg/translate-all.c | 117 +++++++++++++++++++----------------- accel/tcg/translator.c | 10 +-- cpu.c | 14 +++-- hw/net/can/can_sja1000.c | 24 ++++---- net/can/can_socketcan.c | 23 ++++--- target/i386/tcg/translate.c | 14 +++-- tcg/tcg.c | 74 +++++++++++++---------- 9 files changed, 162 insertions(+), 132 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index fb595d1eb7..648f4d2263 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -73,7 +73,7 @@ static inline void log_page_dump(const char *operation) { FILE *logfile = qemu_log_trylock(); if (logfile) { - qemu_log("page layout changed following %s\n", operation); + fprintf(logfile, "page layout changed following %s\n", operation); page_dump(logfile); } qemu_log_unlock(logfile); diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index f61b056571..8b7f9a3065 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -215,16 +215,18 @@ static inline void log_cpu_exec(target_ulong pc, CPUState *cpu, #if defined(DEBUG_DISAS) if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) { FILE *logfile = qemu_log_trylock(); - int flags = 0; + if (logfile) { + int flags = 0; - if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { - flags |= CPU_DUMP_FPU; - } + if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { + flags |= CPU_DUMP_FPU; + } #if defined(TARGET_I386) - flags |= CPU_DUMP_CCOP; + flags |= CPU_DUMP_CCOP; #endif - log_cpu_state(cpu, flags); - qemu_log_unlock(logfile); + log_cpu_state(cpu, flags); + qemu_log_unlock(logfile); + } } #endif /* DEBUG_DISAS */ } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 5937d6b7b2..6230f3c022 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1528,68 +1528,75 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { FILE *logfile = qemu_log_trylock(); - int code_size, data_size; - const tcg_target_ulong *rx_data_gen_ptr; - size_t chunk_start; - int insn = 0; + if (logfile) { + int code_size, data_size; + const tcg_target_ulong *rx_data_gen_ptr; + size_t chunk_start; + int insn = 0; - if (tcg_ctx->data_gen_ptr) { - rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); - code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr; - data_size = gen_code_size - code_size; - } else { - rx_data_gen_ptr = 0; - code_size = gen_code_size; - data_size = 0; - } - - /* Dump header and the first instruction */ - qemu_log("OUT: [size=%d]\n", gen_code_size); - qemu_log(" -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n", - tcg_ctx->gen_insn_data[insn][0]); - chunk_start = tcg_ctx->gen_insn_end_off[insn]; - log_disas(tb->tc.ptr, chunk_start); - - /* - * Dump each instruction chunk, wrapping up empty chunks into - * the next instruction. The whole array is offset so the - * first entry is the beginning of the 2nd instruction. - */ - while (insn < tb->icount) { - size_t chunk_end = tcg_ctx->gen_insn_end_off[insn]; - if (chunk_end > chunk_start) { - qemu_log(" -- guest addr 0x" TARGET_FMT_lx "\n", - tcg_ctx->gen_insn_data[insn][0]); - log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_start); - chunk_start = chunk_end; + if (tcg_ctx->data_gen_ptr) { + rx_data_gen_ptr = tcg_splitwx_to_rx(tcg_ctx->data_gen_ptr); + code_size = (const void *)rx_data_gen_ptr - tb->tc.ptr; + data_size = gen_code_size - code_size; + } else { + rx_data_gen_ptr = 0; + code_size = gen_code_size; + data_size = 0; } - insn++; - } - if (chunk_start < code_size) { - qemu_log(" -- tb slow paths + alignment\n"); - log_disas(tb->tc.ptr + chunk_start, code_size - chunk_start); - } + /* Dump header and the first instruction */ + fprintf(logfile, "OUT: [size=%d]\n", gen_code_size); + fprintf(logfile, + " -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n", + tcg_ctx->gen_insn_data[insn][0]); + chunk_start = tcg_ctx->gen_insn_end_off[insn]; + disas(logfile, tb->tc.ptr, chunk_start); - /* Finally dump any data we may have after the block */ - if (data_size) { - int i; - qemu_log(" data: [size=%d]\n", data_size); - for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) { - if (sizeof(tcg_target_ulong) == 8) { - qemu_log("0x%08" PRIxPTR ": .quad 0x%016" TCG_PRIlx "\n", - (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); - } else if (sizeof(tcg_target_ulong) == 4) { - qemu_log("0x%08" PRIxPTR ": .long 0x%08" TCG_PRIlx "\n", - (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); - } else { - qemu_build_not_reached(); + /* + * Dump each instruction chunk, wrapping up empty chunks into + * the next instruction. The whole array is offset so the + * first entry is the beginning of the 2nd instruction. + */ + while (insn < tb->icount) { + size_t chunk_end = tcg_ctx->gen_insn_end_off[insn]; + if (chunk_end > chunk_start) { + fprintf(logfile, " -- guest addr 0x" TARGET_FMT_lx "\n", + tcg_ctx->gen_insn_data[insn][0]); + disas(logfile, tb->tc.ptr + chunk_start, + chunk_end - chunk_start); + chunk_start = chunk_end; + } + insn++; + } + + if (chunk_start < code_size) { + fprintf(logfile, " -- tb slow paths + alignment\n"); + disas(logfile, tb->tc.ptr + chunk_start, + code_size - chunk_start); + } + + /* Finally dump any data we may have after the block */ + if (data_size) { + int i; + fprintf(logfile, " data: [size=%d]\n", data_size); + for (i = 0; i < data_size / sizeof(tcg_target_ulong); i++) { + if (sizeof(tcg_target_ulong) == 8) { + fprintf(logfile, + "0x%08" PRIxPTR ": .quad 0x%016" TCG_PRIlx "\n", + (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); + } else if (sizeof(tcg_target_ulong) == 4) { + fprintf(logfile, + "0x%08" PRIxPTR ": .long 0x%08" TCG_PRIlx "\n", + (uintptr_t)&rx_data_gen_ptr[i], rx_data_gen_ptr[i]); + } else { + qemu_build_not_reached(); + } } } + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } #endif diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 1506755f3c..af8798f98b 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -140,10 +140,12 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) && qemu_log_in_addr_range(db->pc_first)) { FILE *logfile = qemu_log_trylock(); - qemu_log("----------------\n"); - ops->disas_log(db, cpu); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "----------------\n"); + ops->disas_log(db, cpu); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif } diff --git a/cpu.c b/cpu.c index 9db144761d..ded4173d40 100644 --- a/cpu.c +++ b/cpu.c @@ -400,12 +400,14 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP); if (qemu_log_separate()) { FILE *logfile = qemu_log_trylock(); - qemu_log("qemu: fatal: "); - qemu_log_vprintf(fmt, ap2); - qemu_log("\n"); - log_cpu_state(cpu, CPU_DUMP_FPU | CPU_DUMP_CCOP); - qemu_log_flush(); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "qemu: fatal: "); + vfprintf(logfile, fmt, ap2); + fprintf(logfile, "\n"); + cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); + qemu_log_flush(); + qemu_log_unlock(logfile); + } qemu_log_close(); } va_end(ap2); diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 300313dfb8..23d634af6f 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -249,19 +249,21 @@ static void can_display_msg(const char *prefix, const qemu_can_frame *msg) int i; FILE *logfile = qemu_log_trylock(); - qemu_log("%s%03X [%01d] %s %s", - prefix, - msg->can_id & QEMU_CAN_EFF_MASK, - msg->can_dlc, - msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", - msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); + if (logfile) { + fprintf(logfile, "%s%03X [%01d] %s %s", + prefix, + msg->can_id & QEMU_CAN_EFF_MASK, + msg->can_dlc, + msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", + msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); - for (i = 0; i < msg->can_dlc; i++) { - qemu_log(" %02X", msg->data[i]); + for (i = 0; i < msg->can_dlc; i++) { + fprintf(logfile, " %02X", msg->data[i]); + } + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } static void buff2frame_pel(const uint8_t *buff, qemu_can_frame *frame) diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c index 4a505643e9..a6388563c3 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -77,18 +77,21 @@ static void can_host_socketcan_display_msg(struct qemu_can_frame *msg) { int i; FILE *logfile = qemu_log_trylock(); - qemu_log("[cansocketcan]: %03X [%01d] %s %s", - msg->can_id & QEMU_CAN_EFF_MASK, - msg->can_dlc, - msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", - msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); - for (i = 0; i < msg->can_dlc; i++) { - qemu_log(" %02X", msg->data[i]); + if (logfile) { + fprintf(logfile, "[cansocketcan]: %03X [%01d] %s %s", + msg->can_id & QEMU_CAN_EFF_MASK, + msg->can_dlc, + msg->can_id & QEMU_CAN_EFF_FLAG ? "EFF" : "SFF", + msg->can_id & QEMU_CAN_RTR_FLAG ? "RTR" : "DAT"); + + for (i = 0; i < msg->can_dlc; i++) { + fprintf(logfile, " %02X", msg->data[i]); + } + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } static void can_host_socketcan_read(void *opaque) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index f3cffee520..bfd0f5b8a7 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -2581,14 +2581,16 @@ static void gen_unknown_opcode(CPUX86State *env, DisasContext *s) if (qemu_loglevel_mask(LOG_UNIMP)) { FILE *logfile = qemu_log_trylock(); - target_ulong pc = s->pc_start, end = s->pc; + if (logfile) { + target_ulong pc = s->pc_start, end = s->pc; - qemu_log("ILLOPC: " TARGET_FMT_lx ":", pc); - for (; pc < end; ++pc) { - qemu_log(" %02x", cpu_ldub_code(env, pc)); + fprintf(logfile, "ILLOPC: " TARGET_FMT_lx ":", pc); + for (; pc < end; ++pc) { + fprintf(logfile, " %02x", cpu_ldub_code(env, pc)); + } + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_unlock(logfile); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index abe4ef7799..d0e47e55dc 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -757,31 +757,35 @@ void tcg_prologue_init(TCGContext *s) #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { FILE *logfile = qemu_log_trylock(); - qemu_log("PROLOGUE: [size=%zu]\n", prologue_size); - if (s->data_gen_ptr) { - size_t code_size = s->data_gen_ptr - s->code_gen_ptr; - size_t data_size = prologue_size - code_size; - size_t i; + if (logfile) { + fprintf(logfile, "PROLOGUE: [size=%zu]\n", prologue_size); + if (s->data_gen_ptr) { + size_t code_size = s->data_gen_ptr - s->code_gen_ptr; + size_t data_size = prologue_size - code_size; + size_t i; - log_disas(s->code_gen_ptr, code_size); + disas(logfile, s->code_gen_ptr, code_size); - for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { - if (sizeof(tcg_target_ulong) == 8) { - qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", - (uintptr_t)s->data_gen_ptr + i, - *(uint64_t *)(s->data_gen_ptr + i)); - } else { - qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", - (uintptr_t)s->data_gen_ptr + i, - *(uint32_t *)(s->data_gen_ptr + i)); + for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { + if (sizeof(tcg_target_ulong) == 8) { + fprintf(logfile, + "0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", + (uintptr_t)s->data_gen_ptr + i, + *(uint64_t *)(s->data_gen_ptr + i)); + } else { + fprintf(logfile, + "0x%08" PRIxPTR ": .long 0x%08x\n", + (uintptr_t)s->data_gen_ptr + i, + *(uint32_t *)(s->data_gen_ptr + i)); + } } + } else { + disas(logfile, s->code_gen_ptr, prologue_size); } - } else { - log_disas(s->code_gen_ptr, prologue_size); + fprintf(logfile, "\n"); + qemu_log_flush(); + qemu_log_unlock(logfile); } - qemu_log("\n"); - qemu_log_flush(); - qemu_log_unlock(logfile); } #endif @@ -4201,10 +4205,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP) && qemu_log_in_addr_range(tb->pc))) { FILE *logfile = qemu_log_trylock(); - qemu_log("OP:\n"); - tcg_dump_ops(s, false); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "OP:\n"); + tcg_dump_ops(s, false); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif @@ -4246,10 +4252,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_IND) && qemu_log_in_addr_range(tb->pc))) { FILE *logfile = qemu_log_trylock(); - qemu_log("OP before indirect lowering:\n"); - tcg_dump_ops(s, false); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "OP before indirect lowering:\n"); + tcg_dump_ops(s, false); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif /* Replace indirect temps with direct temps. */ @@ -4267,10 +4275,12 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP_OPT) && qemu_log_in_addr_range(tb->pc))) { FILE *logfile = qemu_log_trylock(); - qemu_log("OP after optimization and liveness analysis:\n"); - tcg_dump_ops(s, true); - qemu_log("\n"); - qemu_log_unlock(logfile); + if (logfile) { + fprintf(logfile, "OP after optimization and liveness analysis:\n"); + tcg_dump_ops(s, true); + fprintf(logfile, "\n"); + qemu_log_unlock(logfile); + } } #endif From patchwork Wed Apr 20 18:05:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563980 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4406910map; Wed, 20 Apr 2022 11:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysi2wPPqTjVT25UB0BAEnFONRys69fvtTI7B+x9w3erYJYhLoyIS6vb4BVulgtWtqoOjRi X-Received: by 2002:a25:6641:0:b0:641:54e4:6edd with SMTP id z1-20020a256641000000b0064154e46eddmr22020587ybm.36.1650478715189; Wed, 20 Apr 2022 11:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478715; cv=none; d=google.com; s=arc-20160816; b=NjMwrywl35UtfDL0mWJex7cR0ynf1P3O7k7HMn4WQh6vCl9a8u51PJfWkBUUwDpIFC NH6CGPERb5MksObjGcs1bOb/urdSwtUT1rawu7diLityJc8Ckh7gokt9s1ZN1K44ZLKf e4fLf6LKH9C5U7ik3CcIX+Xnzaf95+7cVeWpf8VOIRd0e5QxFM19/YLGtMN9Ctp3POuL IuymYIDgEFAhLE39jcVWRJDFSTq8gJVk4HF6W6SMkbRxN4rXoWC4m3vFUQwUAwZCd/Qv AHqdaxzc4agq8JahRQmgDLEsCLAwr8RA+nM+YQI3iutfEb61RjXpZTAK5ROowMWlq/41 M/kg== 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=DibATXdAjww5C4SYG+noyUZdVK5yQkHcWdp7MeNDn0A=; b=QMeK45CuYDP/I0yF+btanLrC1BJ4rIw4LMhaU34Kk4F2EgM6Af3Wu+Qp6/VnMEeGW+ SrmZDIc2ErLjcRzdSGH4yPMDfPgfPB5iSJp1vQEvKqqPZQRbBVrovUH3+vXO6XuMwyH9 3X8+zEpREgazPlOSXwhh2WoaviEUphGvvOGaRPxYAdCxIPfY8K1mlFguUinTG0iB5WlC LAzC00kc/uGgopviOARSeD65pU/Lh83F5MZLJDfOuViqpoquvOdPPxs7UY3UnhJx20E0 WLBfS7fCTLLo3gSjZodqIa2XjEKojAZGvMmPUbFvkVgrsG5aK2Kgkv9EMbIPOL4JxYup GRqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H9yPuw9U; 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 j19-20020a25d213000000b00645001bd595si572248ybg.467.2022.04.20.11.18.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:18:35 -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=H9yPuw9U; 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]:56564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEuQ-0003gd-Ka for patch@linaro.org; Wed, 20 Apr 2022 14:18:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEio-0005OV-7P for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:34 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:44610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEil-0001C7-No for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:33 -0400 Received: by mail-pj1-x1030.google.com with SMTP id u5-20020a17090a6a8500b001d0b95031ebso2758211pjj.3 for ; Wed, 20 Apr 2022 11:06:31 -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=DibATXdAjww5C4SYG+noyUZdVK5yQkHcWdp7MeNDn0A=; b=H9yPuw9UxTQMpll5riSAcmd8AixneLGQZQy7/8RHWWqdzwJ3pZQfDF6a/KcLia0DNr vCrQuqaGKL3yVjNJLmKGeFzXCBy1WEd83z9dxG5GeDUReHa63a5PpMRSjzY67zT4lm4+ kftUOBRDIKhhFhl+tfKSRMJvzuFZzFwQu+UNVcWL66uJe6xKAdYMRVeWvqomWIwAlea6 slxF70sjusVTMvC8T4iHDVkbKmQkqr7q68iUEaT9bxQxUkALSJOEZtZOslCdfb+oFIVs 64x0SavW5pmzaAuTeEh+3+K/5yXJ84wTMjKGyPVAE1kLub4bxyRupfOkhN8FU91AvfNd MhvQ== 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=DibATXdAjww5C4SYG+noyUZdVK5yQkHcWdp7MeNDn0A=; b=WzeFW68R36HKVn6XB5pcJOdjedr+hkSqDicINPJwexnsQ4EtUlPBkQNLgxF+GVthT6 mrszEZO7TLqapov2z+KRE3YxiLgrovRG5HoqgzatVUsRMvW7dGhpl9JJX4wZrL0f4wI3 NUp4FhOUMIOuUl5ZRAwPeBl3ES81CKu46CqU1wXf6U5ElsOtB2FIv7hbYWZ0WDklrXTc XhHN7G1Mkykg11WjCQ/Qq5ottyoNbOr+fFfsw7s8Y6U1vJaIpYqmCm5hs9gYRQP1ZXTg NJjpUKT9EIxkB5ZJVajWOCOIRL1Bkln3as4/Fn5mIKZdAOjZwT10CKIT1FAb9e1glitr O3YQ== X-Gm-Message-State: AOAM530K9TF/D6prtP4pqplv5ZxvVgIOU+aW/S2spEeC+fkcIMujAufw IYmA2RaJ31fNfwseWwE701Y76+d22pl2nQ== X-Received: by 2002:a17:903:1c8:b0:15a:2088:848f with SMTP id e8-20020a17090301c800b0015a2088848fmr6636126plh.30.1650477990433; Wed, 20 Apr 2022 11:06:30 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 10/39] util/log: Remove qemu_log_vprintf Date: Wed, 20 Apr 2022 11:05:49 -0700 Message-Id: <20220420180618.1183855-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This function is no longer used. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-11-richard.henderson@linaro.org> --- include/qemu/log.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index d090faf22a..2d9455dc85 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -72,21 +72,6 @@ void qemu_log_unlock(FILE *fd); /* Logging functions: */ -/* vfprintf-like logging function - */ -static inline void G_GNUC_PRINTF(1, 0) -qemu_log_vprintf(const char *fmt, va_list va) -{ - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - vfprintf(logfile->fd, fmt, va); - } - rcu_read_unlock(); -} - /* log only if a bit is set on the current loglevel mask: * @mask: bit to check in the mask * @fmt: printf-style format string From patchwork Wed Apr 20 18:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563974 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4402874map; Wed, 20 Apr 2022 11:13:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx18m4JzPC3WDqmG1HDbdZJv8OBiZdjWKD8+xFUOqf5mNc+L9bpdxnbj4A0GVrEpo0giHvY X-Received: by 2002:a81:2d82:0:b0:2f4:d2b6:1864 with SMTP id t124-20020a812d82000000b002f4d2b61864mr511064ywt.342.1650478401853; Wed, 20 Apr 2022 11:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478401; cv=none; d=google.com; s=arc-20160816; b=kyT//8ebx/jrc0En/cElO1CP5Zqme1FmIBBY16sb2m1q46WQyG535sr3+pqU5b8YKU iPCy1k7mFSYvfPk079pjC2e1YBiC/OQWDPiiDk7Nm9EJbC9WJLxgxpKQGEQkPmjdGNAQ Xsw2RfW16I6OuRRKPihmXtlwJXj1E1lPWVOqYT+X6vjyYKtXdhp+c5SQOist1Wznne95 YEJFNA/h3qtPeLK7d22kFC7LNdXRbezSgIUI6E1W6wnBJIVv77Cqv56stbum4zsnGNBI TNuoo6TRDfZ2hfPLfFGjATPE9EN3y1SuXNMcE3lFDhX3dcdh2YCZMMcSsYGJ+Z3CYzD5 sE3Q== 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=PEwpJcfavRkH3ZeiI3Zgbs8jUfxSKvoW5MoAmvkSjTE=; b=Lv6/7hVMVTfFERDlf4xIuf8BPV0DEcPupEYc5U/4DcV7ow1biXiiXGHh0AhMjvP6kQ p5YSkZEjNS2Wyi+MJRcqYnL6IOxHEd6yM8ryAR+o5vwr5cPkF+vU5IfA6dRz41MGj+KX G5wM/x7nMo+YUW5MC1xzUFQl+TtC0hPARiTY4BPjed+eIMCp2p5aLngE1egfS8pgYQya XXD8DpFMSptrw5D1ChVjlASpLuiUfHSIZzN2lgzM9qNg3sZaTzaJmaTf9r0i+PpQGcvf kB9it7MRW4lM9bRMX3tz7n8/K2HJGRiv2axUHM/jcBa1ag2IFY5VFjVDLYR2VbeHhpuT 3dsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3sSbd4z; 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 i28-20020a25b21c000000b0063fae8d0024si577842ybj.446.2022.04.20.11.13.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:13:21 -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=R3sSbd4z; 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]:42808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEpN-0001bx-9h for patch@linaro.org; Wed, 20 Apr 2022 14:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEip-0005P1-2z for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:35 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:44976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEim-0001CM-U6 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:34 -0400 Received: by mail-pl1-x62a.google.com with SMTP id j8so2495732pll.11 for ; Wed, 20 Apr 2022 11:06:32 -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=PEwpJcfavRkH3ZeiI3Zgbs8jUfxSKvoW5MoAmvkSjTE=; b=R3sSbd4z0KYX6ESpdC8j5RHWWFMUDk6D+kQX39ejRhG12ashoHkvPSIihKEu87w9hb jW+Ngkjzx1c+dAW+B7RD9bF0Q8dQ32+xiWD78MghFhYhwJpcvcKJl0SrGNF1EmnXJbug Lv7EOBuyRp7/uY5KXI2Vm15qYsB3AiKSNcDaPL+y+VUgCgJOtwNEYSixhFtnkgHoOow3 T6GV8mJa7U+NIuxYTThplsIRfQSrwaa2nP+lru2QcyrMy/kt8O2Zf5Y2vnwhILDkdjtK zBg/cfyn2U7QhF9jTtOkgdhB1k9x5/VdmnU1GMsFabh5ZLUwt76Dc0dYXdfcp2yGnZxD kntg== 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=PEwpJcfavRkH3ZeiI3Zgbs8jUfxSKvoW5MoAmvkSjTE=; b=SZzfwOJV2appedQ446IXfLT1DOwQkFYp/ttbyBFj8xSDYudcKvvaarEPwtP+eUARIa UVAosRXnUt/aD8DFfwGY7TgydzCtBVsE++UGSd5/nxQbCiMKKAzEPmGNjOnwveC9mVsE jZdKr2CRsUoyAV7NRNE6mPuJU8j3ipnZ2PKlvrpjL5m35Z1YMNkVpMBIjmT+x9fKVsTn GuP/HOBFKSnA4e8p1ZUjWx5ghCwHQuSGkDBVqeMoG1OKTQpH9GsmXJS4BN+6td3WmK0Y 8ftcI5afWDz4XhUIIaleMnSzjXvxrBR+LhU/5QVs/LW6fxNdWwsvGNFLwDSQh69uXFDx pqRw== X-Gm-Message-State: AOAM532ioJdTjARVGf3ZhdAtUHqRBKCnQ4xhx+t+mz6PiPc6UF3HJXT4 c9VhBb62RwDd3faNa0DUJ0oMkMyJnnUIqQ== X-Received: by 2002:a17:902:b10c:b0:154:a3b5:b33a with SMTP id q12-20020a170902b10c00b00154a3b5b33amr21172573plr.3.1650477991553; Wed, 20 Apr 2022 11:06:31 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/39] tcg: Pass the locked filepointer to tcg_dump_ops Date: Wed, 20 Apr 2022 11:05:50 -0700 Message-Id: <20220420180618.1183855-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have already looked up and locked the filepointer. Use fprintf instead of qemu_log directly for output in and around tcg_dump_ops. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-12-richard.henderson@linaro.org> --- tcg/tcg.c | 109 ++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index d0e47e55dc..79a5e2816f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1808,7 +1808,11 @@ static inline TCGReg tcg_regset_first(TCGRegSet d) } } -static void tcg_dump_ops(TCGContext *s, bool have_prefs) +/* Return only the number of characters output -- no error return. */ +#define ne_fprintf(...) \ + ({ int ret_ = fprintf(__VA_ARGS__); ret_ >= 0 ? ret_ : 0; }) + +static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) { char buf[128]; TCGOp *op; @@ -1824,7 +1828,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) if (c == INDEX_op_insn_start) { nb_oargs = 0; - col += qemu_log("\n ----"); + col += ne_fprintf(f, "\n ----"); for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { target_ulong a; @@ -1833,7 +1837,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) #else a = op->args[i]; #endif - col += qemu_log(" " TARGET_FMT_lx, a); + col += ne_fprintf(f, " " TARGET_FMT_lx, a); } } else if (c == INDEX_op_call) { const TCGHelperInfo *info = tcg_call_info(op); @@ -1844,7 +1848,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) nb_iargs = TCGOP_CALLI(op); nb_cargs = def->nb_cargs; - col += qemu_log(" %s ", def->name); + col += ne_fprintf(f, " %s ", def->name); /* * Print the function name from TCGHelperInfo, if available. @@ -1852,15 +1856,15 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) * but the actual function pointer comes from the plugin. */ if (func == info->func) { - col += qemu_log("%s", info->name); + col += ne_fprintf(f, "%s", info->name); } else { - col += qemu_log("plugin(%p)", func); + col += ne_fprintf(f, "plugin(%p)", func); } - col += qemu_log(",$0x%x,$%d", info->flags, nb_oargs); + col += ne_fprintf(f, ",$0x%x,$%d", info->flags, nb_oargs); for (i = 0; i < nb_oargs; i++) { - col += qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[i])); + col += ne_fprintf(f, ",%s", tcg_get_arg_str(s, buf, sizeof(buf), + op->args[i])); } for (i = 0; i < nb_iargs; i++) { TCGArg arg = op->args[nb_oargs + i]; @@ -1868,34 +1872,32 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) if (arg != TCG_CALL_DUMMY_ARG) { t = tcg_get_arg_str(s, buf, sizeof(buf), arg); } - col += qemu_log(",%s", t); + col += ne_fprintf(f, ",%s", t); } } else { - col += qemu_log(" %s ", def->name); + col += ne_fprintf(f, " %s ", def->name); nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; nb_cargs = def->nb_cargs; if (def->flags & TCG_OPF_VECTOR) { - col += qemu_log("v%d,e%d,", 64 << TCGOP_VECL(op), - 8 << TCGOP_VECE(op)); + col += ne_fprintf(f, "v%d,e%d,", 64 << TCGOP_VECL(op), + 8 << TCGOP_VECE(op)); } k = 0; for (i = 0; i < nb_oargs; i++) { - if (k != 0) { - col += qemu_log(","); - } - col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[k++])); + const char *sep = k ? "," : ""; + col += ne_fprintf(f, "%s%s", sep, + tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } for (i = 0; i < nb_iargs; i++) { - if (k != 0) { - col += qemu_log(","); - } - col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[k++])); + const char *sep = k ? "," : ""; + col += ne_fprintf(f, "%s%s", sep, + tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: @@ -1910,9 +1912,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) case INDEX_op_cmpsel_vec: if (op->args[k] < ARRAY_SIZE(cond_name) && cond_name[op->args[k]]) { - col += qemu_log(",%s", cond_name[op->args[k++]]); + col += ne_fprintf(f, ",%s", cond_name[op->args[k++]]); } else { - col += qemu_log(",$0x%" TCG_PRIlx, op->args[k++]); + col += ne_fprintf(f, ",$0x%" TCG_PRIlx, op->args[k++]); } i = 1; break; @@ -1927,12 +1929,12 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) unsigned ix = get_mmuidx(oi); if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) { - col += qemu_log(",$0x%x,%u", op, ix); + col += ne_fprintf(f, ",$0x%x,%u", op, ix); } else { const char *s_al, *s_op; s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT]; s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)]; - col += qemu_log(",%s%s,%u", s_al, s_op, ix); + col += ne_fprintf(f, ",%s%s,%u", s_al, s_op, ix); } i = 1; } @@ -1950,9 +1952,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) name = bswap_flag_name[flags]; } if (name) { - col += qemu_log(",%s", name); + col += ne_fprintf(f, ",%s", name); } else { - col += qemu_log(",$0x%" TCG_PRIlx, flags); + col += ne_fprintf(f, ",$0x%" TCG_PRIlx, flags); } i = k = 1; } @@ -1967,49 +1969,42 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: case INDEX_op_brcond2_i32: - col += qemu_log("%s$L%d", k ? "," : "", - arg_label(op->args[k])->id); + col += ne_fprintf(f, "%s$L%d", k ? "," : "", + arg_label(op->args[k])->id); i++, k++; break; default: break; } for (; i < nb_cargs; i++, k++) { - col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]); + col += ne_fprintf(f, "%s$0x%" TCG_PRIlx, k ? "," : "", + op->args[k]); } } if (have_prefs || op->life) { - - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - for (; col < 40; ++col) { - putc(' ', logfile->fd); - } + for (; col < 40; ++col) { + putc(' ', f); } - rcu_read_unlock(); } if (op->life) { unsigned life = op->life; if (life & (SYNC_ARG * 3)) { - qemu_log(" sync:"); + ne_fprintf(f, " sync:"); for (i = 0; i < 2; ++i) { if (life & (SYNC_ARG << i)) { - qemu_log(" %d", i); + ne_fprintf(f, " %d", i); } } } life /= DEAD_ARG; if (life) { - qemu_log(" dead:"); + ne_fprintf(f, " dead:"); for (i = 0; life; ++i, life >>= 1) { if (life & 1) { - qemu_log(" %d", i); + ne_fprintf(f, " %d", i); } } } @@ -2020,28 +2015,28 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) TCGRegSet set = op->output_pref[i]; if (i == 0) { - qemu_log(" pref="); + ne_fprintf(f, " pref="); } else { - qemu_log(","); + ne_fprintf(f, ","); } if (set == 0) { - qemu_log("none"); + ne_fprintf(f, "none"); } else if (set == MAKE_64BIT_MASK(0, TCG_TARGET_NB_REGS)) { - qemu_log("all"); + ne_fprintf(f, "all"); #ifdef CONFIG_DEBUG_TCG } else if (tcg_regset_single(set)) { TCGReg reg = tcg_regset_first(set); - qemu_log("%s", tcg_target_reg_names[reg]); + ne_fprintf(f, "%s", tcg_target_reg_names[reg]); #endif } else if (TCG_TARGET_NB_REGS <= 32) { - qemu_log("%#x", (uint32_t)set); + ne_fprintf(f, "0x%x", (uint32_t)set); } else { - qemu_log("%#" PRIx64, (uint64_t)set); + ne_fprintf(f, "0x%" PRIx64, (uint64_t)set); } } } - qemu_log("\n"); + putc('\n', f); } } @@ -4207,7 +4202,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "OP:\n"); - tcg_dump_ops(s, false); + tcg_dump_ops(s, logfile, false); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } @@ -4254,7 +4249,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "OP before indirect lowering:\n"); - tcg_dump_ops(s, false); + tcg_dump_ops(s, logfile, false); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } @@ -4277,7 +4272,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "OP after optimization and liveness analysis:\n"); - tcg_dump_ops(s, true); + tcg_dump_ops(s, logfile, true); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } From patchwork Wed Apr 20 18:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563982 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4407312map; Wed, 20 Apr 2022 11:19:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYauZljP5SamrisLi5XDAsJFxVvgTdYK0lC36B29+U9eRs4p9vh/4VpVe1+DN4zjRqja8e X-Received: by 2002:a25:cf4e:0:b0:645:3b24:180b with SMTP id f75-20020a25cf4e000000b006453b24180bmr9830937ybg.565.1650478759065; Wed, 20 Apr 2022 11:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478759; cv=none; d=google.com; s=arc-20160816; b=bZag2GLWIubITr2lMhXZ15fSGDr40IeXcUkLNrtEA83GsO6g02dKkasesc5+AH84xv mVx75TZcJ4XoKdzcWTsKXPkrPWP7Yi5JrufrkbFNMNOQbSe1yMwocHH1MZ/ul2hXPPKk PXW231ZSExb4qjxJWAzzL5XG8D4ld1pstGv0/lo9nyWpNtUW+1zdQuPTWKse7gdkW24H 4uH1da6uXhznzHKl8lkvxzvza1/tSoAxt2J1RRgRFpKmgNZPjboLXplpXpH/jcfM5653 1oLY8A/6PuElD3MYtKvL1cyu/b/AsgR2cuX2dwnAmhj+11F/GbDeSTqeiLhHym3AD0np eC9Q== 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=F+kbx1OnoYPKMJfePg4nYu/xL7oy9bRgilKq4VZPcr4=; b=Mowae/8TAAJ2ESLrnQzLlPrcYEY1tBZPjwcoEuszF3/wljtCTtOXZ5OkfAleTZ2DIF JAvM2P9Gvrdc09PI/2lKirkgFKbOMcmOZZ44c5/z0PS7TPGuoAtyVhVUWpQLi0quu+Uc SaWhd4om/HgCXcq+r+BdmSZtWJhy1DwFOVL88MZtcV+CjQPtiq4xxAsLx9+HUCKhq8a4 ROmpLON5DxqyNe06gRZ2JjGkqDlI6E5zqJJ/0BVqyMTq7/IHRS7CoVBvKeL7l9H9kKYv OXot1jQdA2gR5m4cGZR2v0lCGTKVPm+ZNtzrpiWmN5S//4eWhxreljM9/MGVMDxNYsr8 Wz9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kt60A0S2; 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 e141-20020a255093000000b0063e4a31f7fasi467633ybb.657.2022.04.20.11.19.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:19:19 -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=Kt60A0S2; 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]:60100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEv8-0006jS-FF for patch@linaro.org; Wed, 20 Apr 2022 14:19:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEiq-0005SO-Tc for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:36 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:46897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEio-0001Cc-8G for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:36 -0400 Received: by mail-pj1-x1029.google.com with SMTP id e62-20020a17090a6fc400b001d2cd8e9b0aso2750153pjk.5 for ; Wed, 20 Apr 2022 11:06:33 -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=F+kbx1OnoYPKMJfePg4nYu/xL7oy9bRgilKq4VZPcr4=; b=Kt60A0S2FVKdJJzWRRGi4UGfQzMtTsZPKic4rAyaCraxmsVpa3zR+4HgObqXRvilxW h26gghK88sdhClall5PY2TRSI1To7ZGYh0ZAZAXd5FvS0xQnAtWY/NWYzQiJr+2zwurz X6pAN5D1YBRGueRA2x54tN88MiTWMMpghR18iawjUPgjZlLPIbYKLGFW3barjSxVCAEZ Rh3ynypK61KaatH6y4B0ykggXYr8FjeL1nZWY8bZdTg/GjSaTZxS9PjcXCrGTCKAESrP nLLO3g1GVcytranXQle6WXc3mThInUD3/Ulti8HZu9gGpeivCnHKB/RNYJ9YD8aEyRzG Huvg== 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=F+kbx1OnoYPKMJfePg4nYu/xL7oy9bRgilKq4VZPcr4=; b=py1zguLH1+ou+6mOWaqrEZgaiox4JHkAHhwgYvwN8ObYyEmzjlOlv3GjVKgHpjNHz0 JKPVTGsdVOtZzSo2M+0Gd5UZROO6mRGXGy1cwC6JWJ869z06ePxl5DJIF1PttaMwWw8q 5FnybjVsY7fF6HIW8GTUwY9o2NE6wFCBGK0iedXvQjaiTNcKJ4+SFXCn7v+4WfNifwUH ZQX/bvL/qfftlf2vTPIDCzgueJvKZFQqRVH5Z7RWQgoO5CDo6pIHI1VgYZAcuXHuGS/u pZ+h4AzvJZIBTavncCMVwSUGL0rB4F63ASSwXBdyqLnmJGGm+AORrK74uJESx/9Mbi9Y 6Smw== X-Gm-Message-State: AOAM533vBINdXsBudrMmNZGFDQYHSsEF7vdWufYx8nhaBFQ9RXxNJfj5 IdAfa48OJ2Lm0tGyWR1t4aD859/XtLy+5g== X-Received: by 2002:a17:902:6acc:b0:149:8f60:a526 with SMTP id i12-20020a1709026acc00b001498f60a526mr21975330plt.25.1650477992701; Wed, 20 Apr 2022 11:06:32 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 12/39] exec/translator: Pass the locked filepointer to disas_log hook Date: Wed, 20 Apr 2022 11:05:51 -0700 Message-Id: <20220420180618.1183855-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have fetched and locked the logfile in translator_loop. Pass the filepointer down to the disas_log hook so that it need not be fetched and locked again. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-13-richard.henderson@linaro.org> --- include/exec/translator.h | 2 +- accel/tcg/translator.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 | 7 ++++--- target/hppa/translate.c | 15 ++++++++------- target/i386/tcg/translate.c | 6 +++--- target/m68k/translate.c | 7 ++++--- target/microblaze/translate.c | 7 ++++--- target/mips/tcg/translate.c | 7 ++++--- 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 ++++--- 23 files changed, 92 insertions(+), 72 deletions(-) diff --git a/include/exec/translator.h b/include/exec/translator.h index 9bc46eda59..31d3fa76ff 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -118,7 +118,7 @@ typedef struct TranslatorOps { void (*insn_start)(DisasContextBase *db, CPUState *cpu); void (*translate_insn)(DisasContextBase *db, CPUState *cpu); void (*tb_stop)(DisasContextBase *db, CPUState *cpu); - void (*disas_log)(const DisasContextBase *db, CPUState *cpu); + void (*disas_log)(const DisasContextBase *db, CPUState *cpu, FILE *f); } TranslatorOps; /** diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index af8798f98b..fe7af9b943 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -142,7 +142,7 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "----------------\n"); - ops->disas_log(db, cpu); + ops->disas_log(db, cpu, logfile); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 4e887311ab..9af1627079 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -3027,10 +3027,11 @@ static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void alpha_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void alpha_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps alpha_tr_ops = { diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 9333d7be41..19c09c3b53 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -14967,12 +14967,12 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } static void aarch64_tr_disas_log(const DisasContextBase *dcbase, - CPUState *cpu) + CPUState *cpu, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cpu, dc->base.pc_first, dc->base.tb->size); } const TranslatorOps aarch64_translator_ops = { diff --git a/target/arm/translate.c b/target/arm/translate.c index e8dfa71364..38e7a38f28 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9891,12 +9891,13 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void arm_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps arm_translator_ops = { diff --git a/target/avr/translate.c b/target/avr/translate.c index af8a3e0f9c..dc9c3d6bcc 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -3015,10 +3015,11 @@ static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void avr_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void avr_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps avr_tr_ops = { diff --git a/target/cris/translate.c b/target/cris/translate.c index 3656cd6db1..ac101344a3 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3268,11 +3268,12 @@ static void cris_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void cris_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void cris_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { if (!DISAS_CRIS) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } } diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index 98f1452cad..d4fc92f7e9 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -833,10 +833,11 @@ static void hexagon_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void hexagon_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void hexagon_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 0b83ee4d98..b8dbfee5e9 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -4305,29 +4305,30 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void hppa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void hppa_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { target_ulong pc = dcbase->pc_first; #ifdef CONFIG_USER_ONLY switch (pc) { case 0x00: - qemu_log("IN:\n0x00000000: (null)\n"); + fprintf(logfile, "IN:\n0x00000000: (null)\n"); return; case 0xb0: - qemu_log("IN:\n0x000000b0: light-weight-syscall\n"); + fprintf(logfile, "IN:\n0x000000b0: light-weight-syscall\n"); return; case 0xe0: - qemu_log("IN:\n0x000000e0: set-thread-pointer-syscall\n"); + fprintf(logfile, "IN:\n0x000000e0: set-thread-pointer-syscall\n"); return; case 0x100: - qemu_log("IN:\n0x00000100: syscall\n"); + fprintf(logfile, "IN:\n0x00000100: syscall\n"); return; } #endif - qemu_log("IN: %s\n", lookup_symbol(pc)); - log_target_disas(cs, pc, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(pc)); + target_disas(logfile, cs, pc, dcbase->tb->size); } static const TranslatorOps hppa_tr_ops = { diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index bfd0f5b8a7..b7972f0ff5 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -8690,12 +8690,12 @@ static void i386_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } static void i386_tr_disas_log(const DisasContextBase *dcbase, - CPUState *cpu) + CPUState *cpu, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cpu, dc->base.pc_first, dc->base.tb->size); } static const TranslatorOps i386_tr_ops = { diff --git a/target/m68k/translate.c b/target/m68k/translate.c index af43c8eab8..4026572ed8 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6257,10 +6257,11 @@ static void m68k_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void m68k_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void m68k_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps m68k_tr_ops = { diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 2561b904b9..bf01384d33 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1833,10 +1833,11 @@ static void mb_tr_tb_stop(DisasContextBase *dcb, CPUState *cs) } } -static void mb_tr_disas_log(const DisasContextBase *dcb, CPUState *cs) +static void mb_tr_disas_log(const DisasContextBase *dcb, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcb->pc_first)); - log_target_disas(cs, dcb->pc_first, dcb->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcb->pc_first)); + target_disas(logfile, cs, dcb->pc_first, dcb->tb->size); } static const TranslatorOps mb_tr_ops = { diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c index b82a7ec6ad..6de5b66650 100644 --- a/target/mips/tcg/translate.c +++ b/target/mips/tcg/translate.c @@ -16141,10 +16141,11 @@ static void mips_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void mips_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void mips_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps mips_tr_ops = { diff --git a/target/nios2/translate.c b/target/nios2/translate.c index f89271dbed..89b97ef520 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -833,10 +833,11 @@ static void nios2_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void nios2_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void nios2_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps nios2_tr_ops = { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index ca79e609da..7b8ad43d5f 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1687,12 +1687,13 @@ static void openrisc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void openrisc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void openrisc_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { DisasContext *s = container_of(dcbase, DisasContext, base); - qemu_log("IN: %s\n", lookup_symbol(s->base.pc_first)); - log_target_disas(cs, s->base.pc_first, s->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(s->base.pc_first)); + target_disas(logfile, cs, s->base.pc_first, s->base.tb->size); } static const TranslatorOps openrisc_tr_ops = { diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f14f8d7309..fa34f81c30 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7769,10 +7769,11 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void ppc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void ppc_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps ppc_tr_ops = { diff --git a/target/riscv/translate.c b/target/riscv/translate.c index fac998a6b5..6495726302 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1155,18 +1155,20 @@ static void riscv_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void riscv_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void riscv_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { #ifndef CONFIG_USER_ONLY RISCVCPU *rvcpu = RISCV_CPU(cpu); CPURISCVState *env = &rvcpu->env; #endif - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); #ifndef CONFIG_USER_ONLY - qemu_log("Priv: "TARGET_FMT_ld"; Virt: "TARGET_FMT_ld"\n", env->priv, env->virt); + fprintf(logfile, "Priv: "TARGET_FMT_ld"; Virt: "TARGET_FMT_ld"\n", + env->priv, env->virt); #endif - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps riscv_tr_ops = { diff --git a/target/rx/translate.c b/target/rx/translate.c index 5db8f79a82..c8a8991a63 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -2342,10 +2342,11 @@ static void rx_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void rx_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void rx_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN:\n"); /* , lookup_symbol(dcbase->pc_first)); */ - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps rx_tr_ops = { diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c index 80f1f0be9a..ae70368966 100644 --- a/target/s390x/tcg/translate.c +++ b/target/s390x/tcg/translate.c @@ -6660,16 +6660,17 @@ static void s390x_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void s390x_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void s390x_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { DisasContext *dc = container_of(dcbase, DisasContext, base); if (unlikely(dc->ex_value)) { - /* ??? Unfortunately log_target_disas can't use host memory. */ - qemu_log("IN: EXECUTE %016" PRIx64, dc->ex_value); + /* ??? Unfortunately target_disas can't use host memory. */ + fprintf(logfile, "IN: EXECUTE %016" PRIx64, dc->ex_value); } else { - qemu_log("IN: %s\n", lookup_symbol(dc->base.pc_first)); - log_target_disas(cs, dc->base.pc_first, dc->base.tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dc->base.pc_first)); + target_disas(logfile, cs, dc->base.pc_first, dc->base.tb->size); } } diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 43bc88b7b3..f1b190e7cf 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -2352,10 +2352,11 @@ static void sh4_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void sh4_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +static void sh4_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cs, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cs, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps sh4_tr_ops = { diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 4c7c7b5347..2e28222d31 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -5901,10 +5901,11 @@ static void sparc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) } } -static void sparc_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void sparc_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps sparc_tr_ops = { diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 417edbd3f0..d170500fa5 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -8861,10 +8861,11 @@ static void tricore_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void tricore_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void tricore_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps tricore_tr_ops = { diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index fc4e9d2c9a..1485df2f22 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1296,10 +1296,11 @@ static void xtensa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) } } -static void xtensa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) +static void xtensa_tr_disas_log(const DisasContextBase *dcbase, + CPUState *cpu, FILE *logfile) { - qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); - log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size); + fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first)); + target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size); } static const TranslatorOps xtensa_translator_ops = { From patchwork Wed Apr 20 18:05:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563984 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4408328map; Wed, 20 Apr 2022 11:20:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymdmvj73KUqtSb1tX8fWUDoI3zpzQRNfdbZAimpT4LPX/GD0vZ4eTtMr0AwCOUvLEJFdNw X-Received: by 2002:a0d:ea42:0:b0:2eb:eaf1:eb71 with SMTP id t63-20020a0dea42000000b002ebeaf1eb71mr22468567ywe.57.1650478845098; Wed, 20 Apr 2022 11:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478845; cv=none; d=google.com; s=arc-20160816; b=vNLBXWmII7ow/XMyarYSOEJvm1+66bAi4OoDOBM5PjsEn5bzdKU4rN2ogwii48oBak 8uu0QflzidvvnB5MdMCsV5N7oFI1yFxry10gNxi8ickwyNTxGVu9GdaVqY5axT7GE0ay ZAIKtYtbVLTA4HgWvQM7Tuf44mR+cvVzZXxpgoN0c8dc8jPn9I1XaUO259C8wR+156Gc 0BiHYAYnEd/nEgSltG2thuL40Ee0HOFjXmXomWBW1yRkRLndjFzII+bjL/99jBUKTXsq NIRlM2tcfT3SBQiHJAyvWjfgsnEaMQo8tw1lWDp3LMO60tD1rHgmZsUSPtzt7W+HedLa Wfmg== 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=YBEnYIn1GV5idkFObB274C97yF/rcyYAk+xYD7a+lYQ=; b=O2ZWMSjtCm/WFMyWqu63Dds/uq3KGeBCAKOVTP/NnaGIBK19hjUzGIXY+gwF1szjcP MWgt+lxsd61iXRg0tppguddONcbWufQWVRkH/TQTmF7GiXicxQGNuDRqJ/uTHsHQpFYM f15+HDydOZadS9uwh9ey/VL+7zfiRnIDGVj7Kf1wpKxziKygM5oFGIAV3UHcGl/bKw86 UNE7LIvu7JCr1hgJJy3JOBsmtnhf2N/HCgTAZlxLLh0hWeCJkryB9DgIRl8PNMtYfs8y OvOc81Xxw2DwdsbB7FJ7hsIdi1qV1vkKt5e2nrIE/Qxijyc4Hl7xxh/2M+j7AYwCnT7Z tZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q5PprUS2; 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 z188-20020a254cc5000000b0063e8ee7a95asi524978yba.119.2022.04.20.11.20.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:20:45 -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=q5PprUS2; 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]:36700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEwW-0001lQ-GV for patch@linaro.org; Wed, 20 Apr 2022 14:20:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEiq-0005S2-SK for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:36 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:40956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEip-0001Cq-Av for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:36 -0400 Received: by mail-pj1-x102b.google.com with SMTP id md20-20020a17090b23d400b001cb70ef790dso5617876pjb.5 for ; Wed, 20 Apr 2022 11:06:34 -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=YBEnYIn1GV5idkFObB274C97yF/rcyYAk+xYD7a+lYQ=; b=q5PprUS2S1xxjv8u1Nt0QMCtBnGwfuq3HSP62uIZnxwFLcZW8kLCgxdWCWqJjiEh0t WvA1BwRAnzLeQ/vNg4q8JDF0pAWTgt2G1OCge1DQoPm3sElXQvm3m0+X5AR0DEnysOSe 1EVOIrPIG2cQZOOZpGHXYWsZuU4VfEBHpoRZSP+aYl0HSxGZbX14pgma1qtTv3x0UEEv Ao19qXofWYvCSPta4+P6Im1Qjhhwnazz7HJFHm/POk9TGGv3EfHs06HlXGHxyRcxtemO sRhdfI+7b6LXM7RdVH0k5jhrYewpO7kLOeNNx/aJwceLzUEavthNvuz/6rAYfGmqFhwD tWQw== 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=YBEnYIn1GV5idkFObB274C97yF/rcyYAk+xYD7a+lYQ=; b=a0Mf84MpXtMEM7ymz45grw9RvmmgOjXK6zFPdttXr+j/3Sm1acM0B07wqAH7FAQwdP x3SQgwxcIS/o2dMjnChWCAgq2kLkgMEwmWts4LTuS6MriG/iBphMY9m3T6r2ushH4qru tfZKFGQxbwGnovb+IswHIG2KiKMRj6SK/SjqWHPgaX2F6sXpEIaieMuls+vKwcrGYxHd 2icaJukTsRyFzjgBp6tuCsfIYAgEQIp7m2d/9zOSywipq5NcuzBzaLPvR0uQiPMvXNSd NNevULJAJdgaLya41XZYxcB5y3hpcypxIDfMi2yHiyDWQWEa4HpAUgJWrGLXwMZ6rY7U s71Q== X-Gm-Message-State: AOAM530FmW5ncmlGLqGPqFgL/36WHxycq/dtQVedVddm6AehE0oF0rFZ kN8UEXTwrh2OKYGWsgYp9AwA+hTqF1zxKg== X-Received: by 2002:a17:902:cacb:b0:158:694f:240e with SMTP id y11-20020a170902cacb00b00158694f240emr22177797pld.153.1650477993847; Wed, 20 Apr 2022 11:06:33 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 13/39] exec/log: Remove log_disas and log_target_disas Date: Wed, 20 Apr 2022 11:05:52 -0700 Message-Id: <20220420180618.1183855-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These functions are no longer used. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-14-richard.henderson@linaro.org> --- include/exec/log.h | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 648f4d2263..06ab9841ee 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -43,30 +43,6 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) } #ifdef NEED_CPU_H -/* disas() and target_disas() to qemu_logfile: */ -static inline void log_target_disas(CPUState *cpu, target_ulong start, - target_ulong len) -{ - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - target_disas(logfile->fd, cpu, start, len); - } - rcu_read_unlock(); -} - -static inline void log_disas(const void *code, unsigned long size) -{ - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - disas(logfile->fd, code, size); - } - rcu_read_unlock(); -} - #if defined(CONFIG_USER_ONLY) /* page_dump() output to the log file: */ static inline void log_page_dump(const char *operation) From patchwork Wed Apr 20 18:05:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563988 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4410736map; Wed, 20 Apr 2022 11:24:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJSAbfzfwO2fNPBJ0dZo9g4GHY+Ze9lXUChdBq7HItjvC974OPGq7tnJnGmQXIA4NHhhAR X-Received: by 2002:a25:b9d2:0:b0:628:a85f:953c with SMTP id y18-20020a25b9d2000000b00628a85f953cmr20919027ybj.312.1650479061925; Wed, 20 Apr 2022 11:24:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479061; cv=none; d=google.com; s=arc-20160816; b=FP7k9yvuc/hRo/25kUW3OCz0gG03OpZvVtNdE/+gDbNadtfcv3SC8/+VHxuuEG2m5W znECEiaiBy7hBaXE1wSpfCt21b9dY7gUIPEUYr46k6TxqsW0DkLDzEKE0Yzar+1IqmNe DF16v7D90oAAyCKWZoNkuslBZ7yqzSmB5y5DhBllzGoeQOy1Z26Vr3iHxSI+oTANmSVZ ZB68F1EjGqPmIucdYDyacC7ctrNhZi+gxec2TTgI0dX3WkWLHBfeuWDVItIn0lIfVeuI HSvo/QPDFKyYczX8o7Q+OXq9TAW3ZN2z3UQUN+pbOvsqrJ59mBu7vnO/SAkAs23jSSM0 GiEw== 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=Jh8l0ggXdEtDEXJ/qJx0UWqwH+qQZo23UKh5hwekfRk=; b=bYPSnd7ZTuFbQrqDZABdR08FkC5TcQQdG2a1+1YP3ibjNIF18CKgrnlzFSSG1vG7GJ mFcaVjtfht3Vjlf3NU/kLDV481JTjl2s1kJnmhdsxfhnHTTVBgzpEf8zuyH3dOmJXAVM feZb81jAGH5u4zsq2T83MGrQMbnUR1Wjb8oUaGI5fjh7fC305glETW5gTVe30IDa7L1t vAcviAjdCJTADpHPV9rJQE8Hldtqf9zdDeFse3pRga8/evRLeE3C5Bq8i4gTcA2+GwoC UupJ4/ADQeMLgAd+H5WRLq4jVhiKuJjYYTqlFfOEI8gmHCkELsBGw/lYr1J6zZgaisAj l/Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RrtAGNk3; 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 k4-20020a819304000000b002e5bb9dca6dsi632466ywg.246.2022.04.20.11.24.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:24:21 -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=RrtAGNk3; 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]:45380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF01-0000KX-Dr for patch@linaro.org; Wed, 20 Apr 2022 14:24:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEir-0005WU-Sm for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:37 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:33579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiq-0001D2-Cf for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:37 -0400 Received: by mail-pl1-x631.google.com with SMTP id c23so2554846plo.0 for ; Wed, 20 Apr 2022 11:06:36 -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=Jh8l0ggXdEtDEXJ/qJx0UWqwH+qQZo23UKh5hwekfRk=; b=RrtAGNk33qUEAXRwaMh7poGWOQpPtpvOqT2WFj+k9atO4TWhtr++Kt1Q4uhjALoIkK vqM8UMA6NLFZ9NoEeggT8KPgAYndEK0sVhSVXa2aPDh0+yElj4RjQfMX70nlhJj8PNpJ dm4U3ZoRJzkDQxS7t46oArMqK2vUaZCGMxCgKxdVkMYWLHoIJIsXR2lMiZmJpeP1ueH9 mOym8ZVfHH1EWM+A0w92fjQGxW05lLvgcCvG1JHd21xtTSf+t0U6RCFJdrUWiH/++1U4 H+7EapBMSUCJOeJMwQcRxnihSSGiJkUwP1y+LLQ6Pn6c1B/mFdfIWt4LGIfVT5zGp0wg xoUw== 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=Jh8l0ggXdEtDEXJ/qJx0UWqwH+qQZo23UKh5hwekfRk=; b=bmDEulBww5RqDhShMZ287xpDxAS7zzjRPdfFZWal2601cvBa4Embzy6RCulj2kpTs5 JSYbnl2Rmxun4dC0vORGjGi9SoIULLEH9OFabQ7IW1uTg4ITNGG/w5rweUZzC7HsO3FD IHRQev9qKzobbxmg96o+pUUmEoEfeH9w5RqIivEiR1rquIZXqAajn85u3GwWY9+MpeVs GGjL04clS2YAAL5MVIKaMJXp9ql7IWs0tTgclps16KeM1UavtrE1jTrlK7vHon3f2p4P KTW/J9b/tKA41L+HRsj6OES/z2yb/Q0WZD2HVC8QVML2GGdr1Pb28HQyNqedKHXt3X9y eurw== X-Gm-Message-State: AOAM532yqcK22EEakJ3fk+eh9OA5rRZUs3irVBjG/oOp5aNwCMPB4iAO zvzE3itl3lnYrV3nxXKUrTIIMU/+kMZbiA== X-Received: by 2002:a17:902:7442:b0:158:a253:b4d5 with SMTP id e2-20020a170902744200b00158a253b4d5mr21731277plt.94.1650477995160; Wed, 20 Apr 2022 11:06:35 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 14/39] accel/tcg: Use cpu_dump_state between qemu_log_trylock/unlock Date: Wed, 20 Apr 2022 11:05:53 -0700 Message-Id: <20220420180618.1183855-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Inside log_cpu_state, we perform qemu_log_trylock/unlock, which need not be done if we have already performed the lock beforehand. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-15-richard.henderson@linaro.org> --- accel/tcg/cpu-exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 8b7f9a3065..635aeecc0a 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -224,7 +224,7 @@ static inline void log_cpu_exec(target_ulong pc, CPUState *cpu, #if defined(TARGET_I386) flags |= CPU_DUMP_CCOP; #endif - log_cpu_state(cpu, flags); + cpu_dump_state(cpu, logfile, flags); qemu_log_unlock(logfile); } } From patchwork Wed Apr 20 18:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563978 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4405784map; Wed, 20 Apr 2022 11:17:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDODV+mWbUxDBKKEigATpcxx0QEvwkFtpFEA7YImrZstPG+GkSIBOrcq+o5OS3Cz5tPbrA X-Received: by 2002:a25:585:0:b0:645:729a:e38b with SMTP id 127-20020a250585000000b00645729ae38bmr284737ybf.373.1650478626419; Wed, 20 Apr 2022 11:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478626; cv=none; d=google.com; s=arc-20160816; b=x8V78DorLzS14/BQ7pku/oENy5UKJ06nkl5ghedoO2GEZjOMqMls8G3uoBoqW/VgIT TXDDZ2DNhakkAsSphP0ScRqkDzXD904ZNB2lPZAB4dC7wl0SiCQeQ3vHiQZI+K0H9Q4Y ExanqxXQszMcq2iuyud/EpO1iNYz2xj9EjaHaPVqTZWzf02Fzq8mXbSkPFq5Mi2ELO+Y S3oHQBTKDgPXe05udBG3d5n7B1Xe/CBbE5y1i8+k3Unowvqvs7Ft/AzHBcYDQn8Kv1Ur h80ERXteanFkkMYlMzxkiG8ws4KwJ2cE4bpy1n8kOXc0womH++ihgR38OvajgY6YQx4B bVAQ== 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=esKzBdANexAUJ4Ped1Zb42JAumSJtJDyJYcrCyyvHX4=; b=N1UUEI2p5hfloq4iy0AghoOvplLNR7mYyeSKxlYQV8nKsq4ImJ2c3Dw3h4joLbxtNf VlzyQD9CtK642k8Q9QJh7+2K5T/W/fC8q0ZOHD31VwWCEJMbN6+65fYMaru31R9uefdx jwQMpkarBB8AX6Mp+aduHri26VC4M5gFPdtVQ6NkSqU6AB7YnzH6MSmuX7xViKwFoCRS MGxwNLwbQQ39OVLptJ3UoLrab1HVqLoOyfzO1DD+yG4/uKqYxQ2FTsvGOq1FPJCIXuyp 7Giw1aew9OYs/B/NrRERYvQhCVhPpSpDd2OND6oqOTLFMbRV3Z9lUldRNCqF8EcrFAG2 qNEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZKomJVMj; 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 g194-20020a0dddcb000000b002eb49096516si655897ywe.13.2022.04.20.11.17.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:17:06 -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=ZKomJVMj; 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]:51404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEsx-0007Wa-KH for patch@linaro.org; Wed, 20 Apr 2022 14:17:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEit-0005Zn-0c for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:39 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:54908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEir-0001EH-HO for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:38 -0400 Received: by mail-pj1-x1032.google.com with SMTP id md4so2659298pjb.4 for ; Wed, 20 Apr 2022 11:06:37 -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=esKzBdANexAUJ4Ped1Zb42JAumSJtJDyJYcrCyyvHX4=; b=ZKomJVMj8BgYVpRyt1Rt9WsCKZz1IJCXLskaJ9AhN0rJ0uGnFnMPbfeFZ6MndKNjSp YdujrSaWVhPwFF8dxSFZ3mnNh4YVFH0BTizXIJVzKBEHC9JTAo0SdUX7/edKslnycaha 10fkUmetQzeCq+9gcBipxtKs48+7Mr/gzB3Aa9pJGoIM9Bfis8SDMur7YTAUwPlF+Q5+ A6joYilTFgH7eURlNGfyjPMX333fZ2HFpduwpRfzc7ZHzTuSIuhmPwzqp6XFhNrV3ZOD xrcKae91FF6C2vhHgSU0RX8j1G36ZgNUhY+GLKopUN3JZ38moVk3w1SHe+WM5zrcrs1o 5yXw== 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=esKzBdANexAUJ4Ped1Zb42JAumSJtJDyJYcrCyyvHX4=; b=TGjkx4bIkFlHhr8VQwH2XDbwQkJgdauv1MpQHXTP9B1FafgCkRycrAkfLSwIvuQZec pUgqs+vTbGfHqF3fF0XYGp+QbbY7th2ca4RQB7hPTaJziDfnleF9w3yYbHGQAox51IFg 8dak6dSUSURqk/JCEhDt4+DM6zpoBsh21I4WCfgETZ/mzGZSfKfhJ0ops1TpRHnUHtJp A9bPlwzHCiCORoXT4WKHTWLxsDmgIriJpa7KZFTIg1oQS/9d5ACtvWo6o6QJhU5j1Gd6 xAq7iZNuVg4gqAyBXrHkqQ8YlfFPvWrWevl4nNSd7AgxvbOoVc6PJSBM/C+GR182xe06 eh9g== X-Gm-Message-State: AOAM532DyPuGipPi9sZBdZEligt8HJUGpqKsOnaizUDHyDdUxa/N1L8M ijkIjg08iI0VjX3AtlFCY/QsIUQq/0rg+A== X-Received: by 2002:a17:90a:5902:b0:1cb:a0eb:8f8c with SMTP id k2-20020a17090a590200b001cba0eb8f8cmr5803770pji.17.1650477996297; Wed, 20 Apr 2022 11:06:36 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 15/39] target/nios2: Remove log_cpu_state from reset Date: Wed, 20 Apr 2022 11:05:54 -0700 Message-Id: <20220420180618.1183855-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is redundant with the logging done in cpu_common_reset. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-16-richard.henderson@linaro.org> --- target/nios2/cpu.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 6975ae4bdb..b0877cb39e 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -46,11 +46,6 @@ static void nios2_cpu_reset(DeviceState *dev) Nios2CPUClass *ncc = NIOS2_CPU_GET_CLASS(cpu); CPUNios2State *env = &cpu->env; - if (qemu_loglevel_mask(CPU_LOG_RESET)) { - qemu_log("CPU Reset (CPU %d)\n", cs->cpu_index); - log_cpu_state(cs, 0); - } - ncc->parent_reset(dev); memset(env->regs, 0, sizeof(uint32_t) * NUM_CORE_REGS); From patchwork Wed Apr 20 18:05:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563986 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4409529map; Wed, 20 Apr 2022 11:22:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzowiYZu2p8XsRY52b0JUslgeLBk2Rw42GGH/oB3opQCUqkxAl7o9+wyPJPSX2jYjVDmTS3 X-Received: by 2002:a0d:e601:0:b0:2f0:e346:b0fd with SMTP id p1-20020a0de601000000b002f0e346b0fdmr21814647ywe.418.1650478952671; Wed, 20 Apr 2022 11:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478952; cv=none; d=google.com; s=arc-20160816; b=T6HawyKZYelnjPmveR3quaRcKL8U000bnVm1UJ9wtUmr75xm7lDuhf2+v7u7X6Hjnr Uiv0nfvkZAfyHRpEMy+dhcY6JmNLnKSivaH1frVXuEFzc4ZO0MZXn+FeojZYiIDI1q/U xduA8yJrkfhWVVse/sM8ZSMvIqpc4NUzme2Pe/bCeReTkQkqUknqdOHn4hPhfa35gKeJ JHhi0ZxuZU9We8PLZmmpFw9sYgTeOm92bXfp2yzq2xf4TH20Swx1G9OAefUMCrdCkbmh SCqyzsiFpnHVID4fIH9vesFPyCnbjRRJJPbAztrGX9F0rkVYV2TcdIBezeCnmVnXFuhc TLZw== 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=QruqmmtFKc2ehxSS4AhSTbmV3nwhrgkbO6GJghhE20A=; b=BJkfQRRAvqGt3OZlvM2cB0fleqJIsUUEAeGOM0mlaa+aDqyOkI0+zlA5FK2iSVq8L2 XYrCGwXIVPmNi8MxP+1EN/Z8v0eqWK68a3t7vdGVuR/qSOualalLeTJ9yTFEDtSSzfUV 8B8qEO49MwYLlQG+i6M8Pq3Ra3nE6wn695uF+azN5gBPzZoQ9ESZYft1OhbvOkJwvi4v jphAY+XfDs9bhd+SDKmQnfjHIwoD6oAhDYYW79nsUfc0sUR1G9tQhGkViRuEpbIluBmc 5YeBzwYpn1A0+dmsIXDw5zyiLwBKcu8eBjLtyYIgyMogelBsdtWb8UfQUgNguDPiXxZJ zTWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I+neKLts; 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 u83-20020a256056000000b0064501fc0e20si485865ybb.650.2022.04.20.11.22.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:22:32 -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=I+neKLts; 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]:40572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEyG-0005UT-6M for patch@linaro.org; Wed, 20 Apr 2022 14:22:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEiu-0005d1-4g for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:40 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:46901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEis-0001Ea-KJ for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:39 -0400 Received: by mail-pj1-x102d.google.com with SMTP id e62-20020a17090a6fc400b001d2cd8e9b0aso2750301pjk.5 for ; Wed, 20 Apr 2022 11:06:38 -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=QruqmmtFKc2ehxSS4AhSTbmV3nwhrgkbO6GJghhE20A=; b=I+neKLtsUJg9Dy3ptCe2XHdvkpuUL0HMvvqPnps3YP+rfG5i1WvQHq2jDyOSRgXXcz C9wHp/UVwmkQ/jAnPCtzScTMUr//3jtOQ/nYIiWNLA6JmrlQ4h+UBIY+Mzz//GBOgwCM /A5h3IYfmenpXKPQoDR4rIXGOn4CfFUCfGLI0FbtOjLiLyad62rw+YEmtY3BrWgcxwid Fqu+heL7cfc83irvbn1qISJixp/+67C7dsW7vWootLI9pZJ8laIjFbnNJrh31/F3IyH4 8WB9V3KoAgvQX3Ycwa9SWQiG516GqMAekzw8YXE8sx2dTM37F7EF64v9wZ+rLjnn7+5K PdJA== 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=QruqmmtFKc2ehxSS4AhSTbmV3nwhrgkbO6GJghhE20A=; b=woXzdOBHSt4kD0LXxfjy4aQ9qpWxccg6Q2pYKwIZvvqBd0aiW2J5N9Zq/b7G9SuZsf IkrCuUboYzrlhz0QuZbKawGtJX5ZTkL83u0ZS1tEyeIzHxXzFDIBAm3A2e8GxFwprxPy 0z5vZ9EFoYdtGmI2tzrxJotVzTreFFwKpszh5+atD2wTUCdGdtyPp3M0axI8/VLnotgM rOlbfF/p6/R/Hg0nTCw1VRCoGfMBstmstwgkwXsdy/BlKCYh/LYzShsVLVcHTzSQonqX rJTJ2MdnB4gX6ddO/wKNC4PXAUD+suZ1HkjeMEvyL8cAhXnUAm4ROhTcAsNxjIQhjAPX NWdg== X-Gm-Message-State: AOAM533oxL7lqWF+6MU4hc2slTFk2hUtYxoEAKY55oJAsCQAl7S8cYYj VFwFhW1wyYCo6VFgbS/y1Q9G/5Jhluy8KA== X-Received: by 2002:a17:90b:1b01:b0:1d2:ef4a:98e1 with SMTP id nu1-20020a17090b1b0100b001d2ef4a98e1mr5811694pjb.163.1650477997351; Wed, 20 Apr 2022 11:06:37 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 16/39] util/log: Use qemu_log_trylock/unlock in qemu_log Date: Wed, 20 Apr 2022 11:05:55 -0700 Message-Id: <20220420180618.1183855-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Avoid using QemuLogFile and RCU directly. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-17-richard.henderson@linaro.org> --- util/log.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/util/log.c b/util/log.c index 6b7b358573..090bc3bc39 100644 --- a/util/log.c +++ b/util/log.c @@ -62,23 +62,22 @@ void qemu_log_unlock(FILE *fd) /* Return the number of characters emitted. */ int qemu_log(const char *fmt, ...) { + FILE *f = qemu_log_trylock(); int ret = 0; - QemuLogFile *logfile; - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { + if (f) { va_list ap; + va_start(ap, fmt); - ret = vfprintf(logfile->fd, fmt, ap); + ret = vfprintf(f, fmt, ap); va_end(ap); + qemu_log_unlock(f); /* Don't pass back error results. */ if (ret < 0) { ret = 0; } } - rcu_read_unlock(); return ret; } From patchwork Wed Apr 20 18:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563975 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4403521map; Wed, 20 Apr 2022 11:14:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxZtGvGLJZ1No8LGlDOE9MlacFGkOcR9W6KydhbnXq7CDmg+1rXgM0rRs8AXJG5uiDQ7s6 X-Received: by 2002:a05:6902:1004:b0:642:456b:2f93 with SMTP id w4-20020a056902100400b00642456b2f93mr21069682ybt.475.1650478456827; Wed, 20 Apr 2022 11:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478456; cv=none; d=google.com; s=arc-20160816; b=qlD/+HaRwD4B5SkkFY+eW6YKW8wm7AZdzJ6b8RWiJlPNriIGRrgx0CJVhlAL5tSncf nt2100vrr+MU5GP1do8kBnLCJuXMpMxi+qnk6h+KY3N9x/+pPgkJTU//2+St6SyeC75z 5xLVmu1h4beJtPpViyUy+9TktgVyMTWXT0h7ul2+zH5GQDQmPTJF7RsaHce9WIScrNUl ZogX+JNcpVB6NcqOunIohirBx7ZvUylnRpoDutxaaQzyNuzPg8AlkHSkXf3T0R9YzOZc xxTn1aVLx6J2g1IyQgwAWlhRlYqShPk2RHw54KS8vEIKzmrBtpMr/rELmO7Zx1vJneKp mUfA== 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=9kNrYJBefDhwrAwQum1YSp9+GWqiN1kEakCqoDTb2v0=; b=WoTryw8I+GxttVt37kDv/9224oJZgzFHzduHCQr7OhpKq2QoBkio2Ae6IVZUcasyZT CnDJEGKoTQDGe6Q5zooHazvnlBTQirjZE4RPvceZ8BTspphiX5Ej4zGYJ1pRDBn5wp6Y iXDKwqzgGqbfBziO5LWYAkYiwbpCeIUuoaCoBNPDYzTCtB4NlVGpP+haCtrSh1QJKGqF BPc3ZTg+9UWNzOsYiCWsJwLY8H7NQkDqclgD3QXkDia+DVO8B75K/UKFD5XsKjYgcVCL iktpJI/g5uMldqgLmiIdaVYEABm2nKycb3LjlGcT9lo5FlJX5RcUgEEq3PnGN86al1Pr MQQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JTDAHtHV; 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 9-20020a250509000000b00641341e5b5fsi534455ybf.673.2022.04.20.11.14.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:14:16 -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=JTDAHtHV; 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]:45908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEqG-0003gK-8q for patch@linaro.org; Wed, 20 Apr 2022 14:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEiv-0005f5-5Y for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:41 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:38404) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEit-0001Es-Dk for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:40 -0400 Received: by mail-pl1-x62c.google.com with SMTP id n18so2516162plg.5 for ; Wed, 20 Apr 2022 11:06: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=9kNrYJBefDhwrAwQum1YSp9+GWqiN1kEakCqoDTb2v0=; b=JTDAHtHVs3LxKpd04ZztjV8WW/iYOnPZSszGwFgVX9xjjdMWWExqyqqYOQjaKhCNoE leEBbFjF7VTmhaJFe4TC1RPJl0YoJ/LUOsrSzlWEqeDbjhuyklAP57FeCMxVZKATjO6l mO8gumgleMSED3SzDSMeWjqQDHVvcrhCv1VmlF9VpN4gNgqu/NF/b6PDQH9IKy9JPA6I 4ODnDvO04X+Cv+a9lbPe9kBShImzT2vAYzmmhsRbWMMm852+Zv4viqpAe+6gMRHxMdXN OMG849O5iGIyyQujlJmy9yP2A28ZAtfXsNQJd2ebpdmxir/OJQoIaXTIsnomy171aW/M l4VA== 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=9kNrYJBefDhwrAwQum1YSp9+GWqiN1kEakCqoDTb2v0=; b=DISnA4a+Fv79tZKckRawYRBalRHESybe7hyEIO25QBKDdhM4aCCmmq2/tTWp0xw19/ tKCnuWbEfxJOOhM3ie6ISgVmxftoOz5Ye6lra+JFv6/G8VcQUZ4RP621D3jLGfWTfYuc OQ/FdjHH0gzwtlz2tV9LwCNuPx0njxczMk24hlefVunBPEzdJUNGS27BdulJBGPtS1rU YpmaVieguDwr+GpvLj7Ar/gHeryvHgxvbgPuw9/bOBj1Mjc+6Fpukde30WKKyEZdyWct EfM64WZZgbgNUq40mq+Esx/tVAj6DTIiEzpQhyBy1DU9QZ8DICqesBE/xXJaLuooHAJW uzmw== X-Gm-Message-State: AOAM532Izr8Evh+a/KknHi+2GAr3YYChAWMOzeKtRIt/DJ0L3cNtn/Jx 0ba+qfuwo1hGOgHw+zTySssi0uPlN8jYhQ== X-Received: by 2002:a17:902:c941:b0:158:f9ca:7769 with SMTP id i1-20020a170902c94100b00158f9ca7769mr16257031pla.161.1650477998172; Wed, 20 Apr 2022 11:06:38 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 17/39] util/log: Drop return value from qemu_log Date: Wed, 20 Apr 2022 11:05:56 -0700 Message-Id: <20220420180618.1183855-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The only user of this feature, tcg_dump_ops, has been converted to use fprintf directly. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-18-richard.henderson@linaro.org> --- include/qemu/log-for-trace.h | 2 +- util/log.c | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/include/qemu/log-for-trace.h b/include/qemu/log-for-trace.h index 5e41517227..d47c9cd446 100644 --- a/include/qemu/log-for-trace.h +++ b/include/qemu/log-for-trace.h @@ -30,6 +30,6 @@ static inline bool qemu_loglevel_mask(int mask) } /* main logging function */ -int G_GNUC_PRINTF(1, 2) qemu_log(const char *fmt, ...); +void G_GNUC_PRINTF(1, 2) qemu_log(const char *fmt, ...); #endif diff --git a/util/log.c b/util/log.c index 090bc3bc39..2bd4dfba1b 100644 --- a/util/log.c +++ b/util/log.c @@ -59,26 +59,17 @@ void qemu_log_unlock(FILE *fd) } } -/* Return the number of characters emitted. */ -int qemu_log(const char *fmt, ...) +void qemu_log(const char *fmt, ...) { FILE *f = qemu_log_trylock(); - int ret = 0; - if (f) { va_list ap; va_start(ap, fmt); - ret = vfprintf(f, fmt, ap); + vfprintf(f, fmt, ap); va_end(ap); qemu_log_unlock(f); - - /* Don't pass back error results. */ - if (ret < 0) { - ret = 0; - } } - return ret; } static void __attribute__((__constructor__)) qemu_logfile_init(void) From patchwork Wed Apr 20 18:05:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563992 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4412001map; Wed, 20 Apr 2022 11:26:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsFmGDnsolwC2169MeG1QCqCCo7ku7UD0A73ccoFTqflFh1uq2hahdAHnk84El1A5MIm8t X-Received: by 2002:a81:8507:0:b0:2eb:9715:78d3 with SMTP id v7-20020a818507000000b002eb971578d3mr22577417ywf.304.1650479179524; Wed, 20 Apr 2022 11:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479179; cv=none; d=google.com; s=arc-20160816; b=anw2dnzO5mlclK6xNzXZC/IXF9Z6Wp6oAWFsy3D9MazL1VUh+JTgiobwU1s3aNAOli JFUYcP+hbHq/xoMN8ZIbQnlLE+nQIlfDqcYiXnO/AX36ZscXWBbIP6Gg043GX/F7Ob+l TJHeqWnnqbM4ue/FrCp6pafK8Bhr07yfxVmg2N+tXFkQkJE9PcUrzsVTvhzCGxvjwc5/ k7uyYnrq8jfXfOHz1Bcq8ne2BsgBdLaDozx23OU2qzXN5k9jsj67wXYxRm830hBTLkqC M1f98Eo3YRTN66xu7ycZTDoEeqOPjh4hjZ41WBsYEkClmOoiUDOCkGf4569TMD86pB1o GfMw== 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=nV9NUHGE3OwdaVnxN1+80eLd/X0Cf+bcd/I1jEloa/Y=; b=WXc4Ux8kw6tNHtgInQA5jnDfin46Q6B7cpHIVM8QltbySlwiM3SpECy4qtl77guOwQ 7iwy7MoHqBrxfavIEuRsbaWpk/tIzLax9ohu6Do0NoySAKAWlxnZSpmKx4FiL//KDttd sIHsQwuuBqDtXZzk4ljsScA5qsoYlRuvUbASN+sDxgTZc5DV0Re2VHPR1rcD5Y1hhFdP Evc/ScagirEQQetub/0BFjtPkHeN8KTznV2GCyIBGr4pMml1axyc+ZQ2n/tM10b6GGli RYr9fvObQQV+1ohSAzX2KJy9/WgLi8iqApJYkFwg7+/G71wLHplzAs0b/yH1b1dMejTO HGcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r+VbEOcr; 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 x1-20020a5b0281000000b00641c83eaa8dsi632293ybl.132.2022.04.20.11.26.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:26:19 -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=r+VbEOcr; 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]:53822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF1v-0006CF-2T for patch@linaro.org; Wed, 20 Apr 2022 14:26:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEiv-0005he-Tz for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:41 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:53045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiu-0001FT-Gt for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:41 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 2so2682921pjw.2 for ; Wed, 20 Apr 2022 11:06:40 -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=nV9NUHGE3OwdaVnxN1+80eLd/X0Cf+bcd/I1jEloa/Y=; b=r+VbEOcrHJi7H0lgJHSg9Jc4AOakhitDcSF9LzkeaLqazxQMiYi7fPO+q+HDnQA1cS RjExJJ7iroUlKj3/Dct3KyWYuaXZCkpN3Vz8szBMJVD+YLpB8RT6fqpGGywXl075OF/M fVtlUVAgFSU/mj5lK/XbwvxfHPYR7+7vUr3EPO4rJhWO/DKX8wiK/fkIBSSO/ZH48okO R/rPhuGzx/C75pL9Zf3d0AuzmD0qAizRrI+FmGoexOKL5jZszFTESyZiJotZHcBLCrdN j68Htmh/cJ0bYSkWXi6R55ytLdx/UX8cbFawk6UIkZdesvhfpKj7bkgexik6OopdL7kG r+vQ== 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=nV9NUHGE3OwdaVnxN1+80eLd/X0Cf+bcd/I1jEloa/Y=; b=QIXMSwcIjq0GEJTPXoLADfwD0nLoFifxXYCvG/Q0Lp8NC7Apd2LypaUDmYBD2AsLhV CJ5IaYFrzxDgrdB1d9iZvgryi3P7ZdcB2AAsTYjiupAXykaamxHRUxG8vIPvpqIBQUtr ZedCFXTpbQqYjXyAjAaJKR+oZMVNtRFuq8TmQnA6jJ+Rz50YSP+mFjuHG9xxRCvR7NAT R4agn/898/HYWkklN+jgcvA+21NN8Lv6UTH/LjKvzAIFr+uMCaV9PSSFPBbghhjxYZpS bZLEpJ9xwbLd9mCeDtDTjfi3olw1V6O84a+A+x+XBlL04NZ1bHMkvGt4RUfSqs+ycODU 9sgg== X-Gm-Message-State: AOAM532Z1qoMtOZH4x3abB1yYbBSt40Z4sq2sgN/Odcq274t+3fkx+ZY 0e+eW+7umDRqhyxEF72AgzpNp+o75EqyEQ== X-Received: by 2002:a17:903:4052:b0:155:fc0b:48fb with SMTP id n18-20020a170903405200b00155fc0b48fbmr21706776pla.27.1650477999202; Wed, 20 Apr 2022 11:06:39 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 18/39] util/log: Mark qemu_log_trylock as G_GNUC_WARN_UNUSED_RESULT Date: Wed, 20 Apr 2022 11:05:57 -0700 Message-Id: <20220420180618.1183855-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that all uses have been updated, consider a missing test of the result of qemu_log_trylock a bug and Werror. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-19-richard.henderson@linaro.org> --- include/qemu/log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 2d9455dc85..3a1f3a6020 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -67,7 +67,7 @@ static inline bool qemu_log_separate(void) /* Lock/unlock output. */ -FILE *qemu_log_trylock(void); +FILE *qemu_log_trylock(void) G_GNUC_WARN_UNUSED_RESULT; void qemu_log_unlock(FILE *fd); /* Logging functions: */ From patchwork Wed Apr 20 18:05:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563990 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4411205map; Wed, 20 Apr 2022 11:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziTEDpUk82ks5/dBP2mAPxF7g7a5+X/uwLjechcDvNzT8nn01/cvJr4u14wNTmsrzoWnoR X-Received: by 2002:a25:2408:0:b0:641:d07e:6ca with SMTP id k8-20020a252408000000b00641d07e06camr21063392ybk.341.1650479103436; Wed, 20 Apr 2022 11:25:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479103; cv=none; d=google.com; s=arc-20160816; b=LD7CNGkecUuyeBcvGIMyBmoWfzNJ/ZRVfkmtCqPK184kFWu1hO++iTpbk1hvW79PpB jZ8mI5TsM8cSaVe6zWx15/59j1GiS8fKGqLcP8+n1J/h7F7oBzZQPzLpw69THBmalTBk I3QsBmAi04FWZ7Ikjydy9pgTfRdqBczan1fgAsJ13SzRdpaml2hQpoG7SjeKRy4jt9lx 8SNYGUY/q3pKTomd9qLHGFFjRTJijo/lyNav71IsZf0PuZrPIqFn+4UeHPr8hSKRGMWT 1h0PyijwSfZOBIPWkWRev5XVTg5v6c/R5PDi1bCkbL90wta9MpNGTM6qN0x53GcwkoJM zqGg== 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=/Jc8czLJ+xJoqfVC4MJuDy4q9ofndXIDoJR07sdyF2M=; b=A2/9AfP3dHKiWmruyBih0uOI/nQHROpMlENKhaM4F/37rSOz4KI/V5rFuU5ogn06QF iANpO5EMiNbxt8hJjaZIut2nMIpBNop2JXk+OMFypxgb0IH/n6j26osgqVxc9lY3bpoE +Wpaf7AVROfhfF+VWxAbQFgGaboJnu2A07SEJnXHNZMUhJz9wE73wnmZjaLI8sJe9XsW 296PxC6yvF0rZBSHChdFIUOWtIb/MCbvQf6Wnb2GDT9ObJAs/kbtD9ccFqWJddaT+SJb vr2O4K/Ljhklu67TRhTIwBs5TxNBkJZ8oR7GnmvoktVefYeEsf5sbRZpZSYhyVh9HOVD mSNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fihwW7z2; 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 c6-20020a25f306000000b006371ee363e0si530831ybs.517.2022.04.20.11.25.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:25:03 -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=fihwW7z2; 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]:48984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF0g-0002mM-Ro for patch@linaro.org; Wed, 20 Apr 2022 14:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEix-0005m7-8C for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:43 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:45681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiv-0001Fi-GC for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:42 -0400 Received: by mail-pj1-x1030.google.com with SMTP id n33-20020a17090a5aa400b001d28f5ee3f9so2756124pji.4 for ; Wed, 20 Apr 2022 11:06:41 -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=/Jc8czLJ+xJoqfVC4MJuDy4q9ofndXIDoJR07sdyF2M=; b=fihwW7z2nSDMPRKgTOvf5dwWFexlZUNzBbUgNu8TcBcb0+gLhgfgsd3OPlmwfcjzYA GhO9x+5At2FqIniwwqpPkE8J269/e0CckcVDEVE7glPT/c+/BCd2pykbwFkkqpsRNFnJ hix4qoItW3mzY5aR3Fo1C1VIYRLSQMEgEvu/I5XM0yOXm2Bng/FyVL7jKe8oJ/kznF7W scaP/LC7spPEvj3jNn54FQIuPxAAMkDHs60fH3rtxFZ7rBGO6wWOY1mdXDKJlOUzi7pg 9F2kZzio+fyK2+p/MznAiE6OiKdBPIwGRn3f/azYKyGqGHn8/9MamrxwCofCr9DA+Mr8 YXwg== 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=/Jc8czLJ+xJoqfVC4MJuDy4q9ofndXIDoJR07sdyF2M=; b=RPhIWXLpEw8xFu/F2wZGGkVTfRA5z6cO9yYysZ0zE4GW47DOBOWdINtGzs7Gwa7x5o MzTm6Wpikfl34m8k49OcADVzfndTGly3dbPWIFW1vY1j05bKTlGWoDDkfC2N+fvhfSAY 0qMFkkjbJ4bD2I9/C6nZnu+UT31uhK2izGJT0wnVBVF4kykLa4WdwJw7vLbQig38ae1E fRoEdd6+DEBIeC7yq4b/aQxswdp4r1a5RzMcAiErb5LYG3ZXv+E/8dDon+yjU/PYr/2W tLqv9XhuxTbBTqFKUyjgdIv9DF6cBIgKHQZoXGn/+9wp465oDI/3alP0xkaqMlmBqzQi mFDA== X-Gm-Message-State: AOAM530pb6yq7vmiMQxxxl+scFZZmPwAtek/QHf5WKVL464sdwjIryqM bH0b7eTXfkW3If4ND5mFKsslUFkYD3+dxA== X-Received: by 2002:a17:902:b488:b0:156:509c:5c42 with SMTP id y8-20020a170902b48800b00156509c5c42mr21883393plr.2.1650478000233; Wed, 20 Apr 2022 11:06:40 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 19/39] util/log: Remove qemu_log_flush Date: Wed, 20 Apr 2022 11:05:58 -0700 Message-Id: <20220420180618.1183855-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All uses flush output immediately before or after qemu_log_unlock. Instead of a separate call, move the flush into qemu_log_unlock. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-20-richard.henderson@linaro.org> --- include/qemu/log.h | 2 -- accel/tcg/translate-all.c | 1 - cpu.c | 1 - hw/net/can/can_sja1000.c | 1 - hw/xen/xen_pvdev.c | 1 - net/can/can_socketcan.c | 1 - tcg/tcg.c | 1 - util/log.c | 14 +------------- 8 files changed, 1 insertion(+), 21 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 3a1f3a6020..75973111bb 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -121,8 +121,6 @@ int qemu_str_to_log_mask(const char *str); */ void qemu_print_log_usage(FILE *f); -/* fflush() the log file */ -void qemu_log_flush(void); /* Close the log file */ void qemu_log_close(void); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 6230f3c022..291034cb09 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1594,7 +1594,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/cpu.c b/cpu.c index ded4173d40..7076ec123a 100644 --- a/cpu.c +++ b/cpu.c @@ -405,7 +405,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) vfprintf(logfile, fmt, ap2); fprintf(logfile, "\n"); cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); - qemu_log_flush(); qemu_log_unlock(logfile); } qemu_log_close(); diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 23d634af6f..e0f76d3eb3 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -261,7 +261,6 @@ static void can_display_msg(const char *prefix, const qemu_can_frame *msg) fprintf(logfile, " %02X", msg->data[i]); } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/hw/xen/xen_pvdev.c b/hw/xen/xen_pvdev.c index 0423c61158..037152f063 100644 --- a/hw/xen/xen_pvdev.c +++ b/hw/xen/xen_pvdev.c @@ -230,7 +230,6 @@ void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level, xen_pv_output_msg(xendev, stderr, fmt, args); va_end(args); } - qemu_log_flush(); } void xen_pv_evtchn_event(void *opaque) diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c index a6388563c3..c1a1ad0563 100644 --- a/net/can/can_socketcan.c +++ b/net/can/can_socketcan.c @@ -89,7 +89,6 @@ static void can_host_socketcan_display_msg(struct qemu_can_frame *msg) fprintf(logfile, " %02X", msg->data[i]); } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 79a5e2816f..13c16c2bd0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -783,7 +783,6 @@ void tcg_prologue_init(TCGContext *s) disas(logfile, s->code_gen_ptr, prologue_size); } fprintf(logfile, "\n"); - qemu_log_flush(); qemu_log_unlock(logfile); } } diff --git a/util/log.c b/util/log.c index 2bd4dfba1b..cab0642a7f 100644 --- a/util/log.c +++ b/util/log.c @@ -54,6 +54,7 @@ FILE *qemu_log_trylock(void) void qemu_log_unlock(FILE *fd) { if (fd) { + fflush(fd); qemu_funlockfile(fd); rcu_read_unlock(); } @@ -269,19 +270,6 @@ out: g_strfreev(ranges); } -/* fflush() the log file */ -void qemu_log_flush(void) -{ - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - fflush(logfile->fd); - } - rcu_read_unlock(); -} - /* Close the log file */ void qemu_log_close(void) { From patchwork Wed Apr 20 18:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563979 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4406470map; Wed, 20 Apr 2022 11:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwogqz1Y+FgO+Ld8LKpZqFsUI91LOXNwOyOuTLQBYAzd5esOuQJ9xVqPQbLnnr2JkJ7A1ex X-Received: by 2002:a0d:c685:0:b0:2ef:6aaf:5358 with SMTP id i127-20020a0dc685000000b002ef6aaf5358mr21565079ywd.453.1650478680688; Wed, 20 Apr 2022 11:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478680; cv=none; d=google.com; s=arc-20160816; b=sJluwIspjy9YzKDHtvZFcaMR6qnoAyPLpVhu+dNZb9HrRcOvVKsgreR/2A2dqzm9Kd Z8764Km3jqQmfKRzAUeil7jP6+4ZUPYvKaEjy+H9pjJu2Pi0VlL+G/PzHvVk1KVxYQWO Oo8DRjENFoPJ5xKINHUF96O6iOuuv0TrPuF0DSh+6cS9zn26inoVlj2MKO+sYNRaVZsQ J7JZ9/4bNgcKK1Hcw/3XeBKtBljcFKGz23YSKsdv9t8yI44E9ozU0TiP+rf6DC6u9wJy raDrX5GuO4Mes2bqrlxeUggEKktiDIyQ12KNljAvXGaPR5KU6Gpcev0tmq5iqRVfi/7v OqYQ== 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=OUIcQ5zLACIhYX2zcEvzffhtx00mXb1YP/5lTmvaplA=; b=dTgL+keU5aKSKCvI9ohr0Ni0JVWw81s6IoQ2409YZRFWLXXQC63tO90tMJQLsnXL9w XPAT8F7aO+Y3gd9GanEmookl/dTKEBjZ0dx/xMBnUGT5tCMSCloHWqCXjZ8FaC3/P5dz u958hjxZ9CqcujeRKjNbb0UWMc3K0GUAwh/7yxs2B/a0oabakPtLSOBYUs8N4UsXs+4b baoPS8TcWY6mwq5uofKoupCYS4E/UbAf3n4ulog+It+BnCxoXfZ/em15ZSfI7cWnbdYa uuXXexvbBF27UaKlXt2HAgYdg3y5cKrkmG8L0hfXfSTfn3D10sv/wAF5OTep22WrNG69 DIBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aK+ss044; 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 206-20020a8104d7000000b002eb6e3309fbsi560500ywe.375.2022.04.20.11.18.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:18:00 -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=aK+ss044; 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]:54678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEts-0001uJ-4z for patch@linaro.org; Wed, 20 Apr 2022 14:18:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53374) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEix-0005ol-UT for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:43 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:51789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiw-0001Gh-AO for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:43 -0400 Received: by mail-pj1-x1034.google.com with SMTP id bg24so2682119pjb.1 for ; Wed, 20 Apr 2022 11:06:41 -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=OUIcQ5zLACIhYX2zcEvzffhtx00mXb1YP/5lTmvaplA=; b=aK+ss044hIrbHPFycrlaZHSQllxWTmwHu+PL/6aLVb+nxPtBrqMOUOMEpIcHLwUSif 51Cu7OcLdWR3teX6O8Aute/Acqh2hrI777tRWW/flQvSaaZA1QAD5MvaLlPEx737us9V g6PwldBWVtwaivQdzzqrsmUMFqnZJPQ2rKbMhZat49UIFx75gyy4zsKYPOX8oLwofPZ/ RB4fJEbB24ZT6+clOFE4Cd4tNjRfJS4je331H3/s0GRCDgYFOxoyU2gNIe8XHWQDez/1 p1CBesRcuvB3OFvQPc3gXkk8BMIunNeROIaLRJ3l1yLdAZJ44DZ/Z/Z6UcoKONTedQnp QkgQ== 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=OUIcQ5zLACIhYX2zcEvzffhtx00mXb1YP/5lTmvaplA=; b=WNr5TXx0zrqNpFLwjKTPjgw+nWp2b+MijeZ2wyPW2dl6BItPhL1+O5CnX+QJxHwU8i cmxb/42meFR8pHqC9aFZ9VJ2trO5J8eI37WSMEPWy9ER+1W93/h43bGdQQFwAGABQuGp ozBP5CD2OyfgFFolZ6yooDsFAVa9Oh3Go0vsfkKZn4znxssMiavdH+WfwUBP6+zkHUBo LWTaBYBNisrjsDy0J88kNfvHtUITUAbR3oJjIeM0c0394M5dFwMpZeqvwqclPFBhrFpR eBiV9ALGKqqCqslsS0uUDq/Rz3aNQ5sOlIGREFq/DQHrTD9mNnnQF9/019pWKp6ZKji9 7h2g== X-Gm-Message-State: AOAM531PpLqy31GeUR07Mx39c7C4Tz5P4DQwzBr53qDzO0qmIclo/IDb iudbuXlv2Q6gX+No+f6gEf5C994RcRkkGg== X-Received: by 2002:a17:903:2487:b0:159:bce:4e1a with SMTP id p7-20020a170903248700b001590bce4e1amr12183733plw.4.1650478001099; Wed, 20 Apr 2022 11:06:41 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/39] util/log: Drop call to setvbuf Date: Wed, 20 Apr 2022 11:05:59 -0700 Message-Id: <20220420180618.1183855-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: -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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Now that the log buffer is flushed after every qemu_log_unlock, which includes every call to qemu_log, we do not need to force line buffering (or unbuffering for windows). Block buffer the entire loggable unit. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-21-richard.henderson@linaro.org> --- util/log.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/util/log.c b/util/log.c index cab0642a7f..caa38e707b 100644 --- a/util/log.c +++ b/util/log.c @@ -136,12 +136,6 @@ bool qemu_set_log(int log_flags, Error **errp) logfile->fd = stderr; } -#if defined(_WIN32) - /* Win32 doesn't support line-buffering, so use unbuffered output. */ - setvbuf(logfile->fd, NULL, _IONBF, 0); -#else - setvbuf(logfile->fd, NULL, _IOLBF, 0); -#endif log_append = 1; qatomic_rcu_set(&qemu_logfile, logfile); } From patchwork Wed Apr 20 18:06: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: 563993 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4413439map; Wed, 20 Apr 2022 11:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTfFMoxDWpwVBuvcSUDIbkQ9W6SabmCoEHGxzhVs78w0t3PNPVpNeAa3ElMOKkutlaQmMZ X-Received: by 2002:a05:6902:154a:b0:644:b61b:a95e with SMTP id r10-20020a056902154a00b00644b61ba95emr22754893ybu.264.1650479299000; Wed, 20 Apr 2022 11:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479298; cv=none; d=google.com; s=arc-20160816; b=JMcimdTiDxc/wX7FeEClmQ5n0PfQxUYQ8JV+DBkSpDUUaHvB7XyQjxbn8zzmHre1oG lIsgH9fmtKTa99umVLAdBP3tU0V+8ndr5iZChOIYEQ4oA5EPQcZdGdX6ksHrvHSyV+Qm guzY8pt+jx9cabwLlIeI2ZxOIWtfaJTwrigfVOoq6J/rcibmx1X9zkN1QM04W8/CLfsl zEtLRmfoAxppvkEBR9yRO5rfjIsqNAcFd7G0+XcJmArVULe9DVp6jwUS61bnGUtgmFX4 lhYnsZx78U0MTfNCyjilayz+RUNe4PWK3pX9iAmK7Qax4ObY+a+wJcrvbpYS29/a98Nl xOtg== 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=qwwWjzueBoGHmyIr/QS+H9jb1bNImx0NNgZVRYsrQuo=; b=X3c5JoQoSIQZd1bFd33bXQFcgeTGjl2CiApVGhvsRDgtThZWw8I2MyT7BBwHQEcwBI giObnVn/mVY0mArIq5PjOMmGxu5i+aG5/3bJ+35UXDagVa7dT0/Jxb4S7gJLzB/MECrX YodKU/ec9SqwdHe25SWTXjkgs9Eo2RiOfVg7Psoosz9Vo3/F7aGQnPP5XOZJjkaW8Rl+ L9m+BNRlK9sBsD1EBVfGM72WqxEXdMGwtAMjIgxb1UZQ4ZJjRkJQjN3/lq3I3sq9Wqn+ opQ7Z9lMFgCmCbqkTTHe+hkN/u6ZYz9h8SvPNy/h3zPQyuyMRHqyWYpigS8YoF7dhNlA H+6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bPbWDTCl; 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 i2-20020a25f202000000b0064154ee43c4si580016ybe.464.2022.04.20.11.28.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:28:18 -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=bPbWDTCl; 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]:57506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF3q-0000G9-GH for patch@linaro.org; Wed, 20 Apr 2022 14:28:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEiz-0005rX-8U for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:45 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:38884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEix-0001H7-I0 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:44 -0400 Received: by mail-pf1-x434.google.com with SMTP id b15so2687170pfm.5 for ; Wed, 20 Apr 2022 11:06:43 -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=qwwWjzueBoGHmyIr/QS+H9jb1bNImx0NNgZVRYsrQuo=; b=bPbWDTClDOMSARBVgZg4abfVZ7hPv+gub2zCRRWaNCdeWg7jEsfsrgP1P3IsnGVM91 aIPxgQx/c7GyZsuRI3lp44E3qg4KpqHYpWLk2lmxQE7EZdlHrdkx9qqmuQbDIsYmck13 EFS+TKkFDV3NkXt+rGvdjRSZb42Ci997Xuw3xMCceVJLp2E2QwilIfV1n6axWDPS+Ncs a3D5/g8S53TpIJEJB+zCauu1G2+lIJs1DdEVO4O3gmqESpXXSg5sNHeIDMH+goGVz8WN TYg6QOBH06UQs53iNEKhcjn25XrzEbUYy9Qb+CRNfImfuilz3tqaabc6cys+3TSnpjQm Mv7g== 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=qwwWjzueBoGHmyIr/QS+H9jb1bNImx0NNgZVRYsrQuo=; b=iMPgtQy4r9Mlk/o96KmbVrCnIUrUw9WpmvyqXkWLEx2fuejT+Q6RvLTGmwHDLgJzBD ZwosyQXGTZpoUGSfa2XUNXKYX+IU/oWmgLnBUYP6WQv1BBRCS7J0JAC/S4f9G8Mtqui7 PaS2WfCO+rTeetv8v9BpIxO7dyXT5aH5UvwzLVxhoEaJG3NOCFAVsviRk64jCdibcyE1 V2d+C9eY1FBlOZ0L6aq9nguTyEXKgcCxOnyYjMZYEP0vOFTGGNa2kDnFxJL+dvNxz2qG usL9md2IYbJc51GIjvJRW3CVHHHQjDjES2ygj5RKns5u6/R0h8CWNcnFwXXgK034wvAA /jsA== X-Gm-Message-State: AOAM530bxX5+AhguLGkCmVmlwX6fX6fWsCwOR9oWetvptjDVhTq5MjO8 EqCkSrY7xyhmKm7Bh2W8BMEerY88QDNWjQ== X-Received: by 2002:a05:6a00:138e:b0:50a:9503:44a7 with SMTP id t14-20020a056a00138e00b0050a950344a7mr9912354pfg.75.1650478002199; Wed, 20 Apr 2022 11:06:42 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 21/39] bsd-user: Expand log_page_dump inline Date: Wed, 20 Apr 2022 11:06:00 -0700 Message-Id: <20220420180618.1183855-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have extra stuff to log at the same time. Hoist the qemu_log_trylock/unlock to the caller and use fprintf. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-22-richard.henderson@linaro.org> --- bsd-user/main.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0c8aa1ae90..ed26fc5acb 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -503,20 +503,29 @@ int main(int argc, char **argv) g_free(target_environ); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - qemu_log("guest_base %p\n", (void *)guest_base); - log_page_dump("binary load"); + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "guest_base %p\n", (void *)guest_base); + fprintf(f, "page layout changed following binary load\n"); + page_dump(f); - qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); - qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); - qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n", - info->start_code); - qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n", - info->start_data); - qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); - qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n", - info->start_stack); - qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); - qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); + fprintf(f, "start_brk 0x" TARGET_ABI_FMT_lx "\n", + info->start_brk); + fprintf(f, "end_code 0x" TARGET_ABI_FMT_lx "\n", + info->end_code); + fprintf(f, "start_code 0x" TARGET_ABI_FMT_lx "\n", + info->start_code); + fprintf(f, "start_data 0x" TARGET_ABI_FMT_lx "\n", + info->start_data); + fprintf(f, "end_data 0x" TARGET_ABI_FMT_lx "\n", + info->end_data); + fprintf(f, "start_stack 0x" TARGET_ABI_FMT_lx "\n", + info->start_stack); + fprintf(f, "brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); + fprintf(f, "entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); + + qemu_log_unlock(f); + } } /* build Task State */ From patchwork Wed Apr 20 18:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563996 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4414447map; Wed, 20 Apr 2022 11:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztLyIxOFBh6n2bVoe0XtIPA/dyW1y/ejNu+ufAaB7ikne3sQzz5Hv9Fv6I37qdf9e9Id5L X-Received: by 2002:a81:18d7:0:b0:2eb:553e:f3ee with SMTP id 206-20020a8118d7000000b002eb553ef3eemr21809077ywy.393.1650479388933; Wed, 20 Apr 2022 11:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479388; cv=none; d=google.com; s=arc-20160816; b=TlRsaJUJhVh//CD8bI9y7lQNP2nht8UaVgwYBxy3047n0fLmox3jZ3YTpUeLu10nmX GfAwmDc35cJD/yrZqGpawO5lMCJBCmd6Ww0jZn7uE713JnzzLBqazJDP83aLy3vw37T6 bgrzltfnMhDDqD0nL1KkKAlqX0QLT+m+q1KM09L//F5+rmBaR6+FCdloBsVN+38KUt53 WcdjUYa4y5VCZCO0kOnpzuI65ERKQVA/BgZiQ5E8hsP4UvF4uFC2Ve0xlkPMOC8/hWpO ZvqHrJJ9swuUtxmB2CK1jhcC/xTUU142Hz2JnmFPI8mfRPPMDLLqsi/srcgM3ZT8EORd vE7A== 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=qOm2StT5IGEkhcpPNeIDDUNyOCcShPcyMnYny7wZFf0=; b=dteajH4g30epxPqg4wjIFjR1jgBH7AOQIbyMmg7XFT/38vw0URRVAhkuYxs6r81jbq 4zRbmnJkQ9EQ7AbO4OWhG3J+bX7wbG/r/wItYwfkk7G3NzB3g2worsb0l4U3drpkdyme CIWlwVPWRpa7IftmUdxiHN+ts1vzBNRbCRreQqZBTTp50nR6yyj4VipXcCNbjwsUNKc0 UuVmKzlT1E5HxfLLaEYogTgQy20YEsKCV4ZDAIWGqgWoaPxcNCn1ejfw+vbHmr5jfrh9 gF9CJdsAIdOKDvqpknhp0GbCY4zXPZ3jszOeO3SuI0z0G2H1KUbukjXBXE5zt88L4XV8 DOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x9gSS7O4; 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 e204-20020a2537d5000000b0064563891097si625483yba.167.2022.04.20.11.29.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:29:48 -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=x9gSS7O4; 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]:33786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF5I-0003SJ-Dk for patch@linaro.org; Wed, 20 Apr 2022 14:29:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj0-0005wt-KL for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:46 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:36617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiy-0001Iz-Sx for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:46 -0400 Received: by mail-pf1-x42e.google.com with SMTP id z16so2690468pfh.3 for ; Wed, 20 Apr 2022 11:06:44 -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=qOm2StT5IGEkhcpPNeIDDUNyOCcShPcyMnYny7wZFf0=; b=x9gSS7O4VE4vVADiGzqkJKGvkeioIyU3lXeGY1cEOWB6X5CnkbwJ5Rl6DYAi39zusd S3EQumGHKh/GT0j9OLl3nhUl2BKFtMzXpAvxu5OzZ3/k2JUWY5gbPTqx9Oj5hb0L6Lix z9gs4ZRpItGdAyGhnoK2UItGDzuqxrYjZpCHKjqGXMz9J6x6t4P9xih5EEix1dR/7dcF P+DufUcrG9LjTMp6jSKB2c1OY65ZqKnBokuf9Bhw8HQSrULjhelz1m/XpKc5M2knz49+ 5NoNHKe5FjwXI2j1B3RNyxE15p/pDprZua8sUA5HX8yPM9eLT96bsl6BP1A7IY5JxrgM G6Gw== 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=qOm2StT5IGEkhcpPNeIDDUNyOCcShPcyMnYny7wZFf0=; b=eyUJ7w5cBMspm170GDrnVDCnA/LLll1PlM34XhaY0gK3i7q5PYGIQ1+7BEq+7jv2Bn cGfjeRSmUnZcQfI1na7NaD7VN1wMBJkmQVo7RoRRI+8jxk/9POHF0ANFpM2HVdJzhj8e RbF3ymzErStzFbl7agH57hULs83CBEJigNkoMR3vYs0Pnnm+L3H6hY7tFkAyWiKwmFYY bkrh9hEG7nvpRmyWag1A0RYLp+ye1qDnUs1ERlLWJzLkogUTTZ3Mi4Nrc8OIzvOASRfu F0oLeTYJ7o9NRrVABa6TCtOwEDD3UW9ATkJwZFITsjSUCfNplYV0DgIaaCHKI71u/Nbb 4hIg== X-Gm-Message-State: AOAM531PIHW9fcIITVNoRBsA2o4dIJsdTiT76zR4DDWM79QXzZ9Uao5o /Oz4nKYIx+mD5dcpnJHkq+DvHJVaL9eFwQ== X-Received: by 2002:a05:6a00:170d:b0:50a:858e:2b6e with SMTP id h13-20020a056a00170d00b0050a858e2b6emr14105339pfc.48.1650478003579; Wed, 20 Apr 2022 11:06:43 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/39] linux-user: Expand log_page_dump inline Date: Wed, 20 Apr 2022 11:06:01 -0700 Message-Id: <20220420180618.1183855-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have extra stuff to log at the same time. Hoist the qemu_log_lock/unlock to the caller and use fprintf. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-23-richard.henderson@linaro.org> --- include/exec/log.h | 15 --------------- linux-user/main.c | 43 +++++++++++++++++++++++++++++-------------- linux-user/mmap.c | 7 ++++++- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 06ab9841ee..ad0a40cfeb 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -42,19 +42,4 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) } } -#ifdef NEED_CPU_H -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(const char *operation) -{ - FILE *logfile = qemu_log_trylock(); - if (logfile) { - fprintf(logfile, "page layout changed following %s\n", operation); - page_dump(logfile); - } - qemu_log_unlock(logfile); -} -#endif -#endif - #endif diff --git a/linux-user/main.c b/linux-user/main.c index 6aed4929ab..d263b2a669 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -857,21 +857,36 @@ int main(int argc, char **argv, char **envp) g_free(target_environ); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - qemu_log("guest_base %p\n", (void *)guest_base); - log_page_dump("binary load"); + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "guest_base %p\n", (void *)guest_base); + fprintf(f, "page layout changed following binary load\n"); + page_dump(f); - qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); - qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); - qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n", info->start_code); - qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n", info->start_data); - qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); - qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n", info->start_stack); - qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); - qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); - qemu_log("argv_start 0x" TARGET_ABI_FMT_lx "\n", info->arg_start); - qemu_log("env_start 0x" TARGET_ABI_FMT_lx "\n", - info->arg_end + (abi_ulong)sizeof(abi_ulong)); - qemu_log("auxv_start 0x" TARGET_ABI_FMT_lx "\n", info->saved_auxv); + fprintf(f, "start_brk 0x" TARGET_ABI_FMT_lx "\n", + info->start_brk); + fprintf(f, "end_code 0x" TARGET_ABI_FMT_lx "\n", + info->end_code); + fprintf(f, "start_code 0x" TARGET_ABI_FMT_lx "\n", + info->start_code); + fprintf(f, "start_data 0x" TARGET_ABI_FMT_lx "\n", + info->start_data); + fprintf(f, "end_data 0x" TARGET_ABI_FMT_lx "\n", + info->end_data); + fprintf(f, "start_stack 0x" TARGET_ABI_FMT_lx "\n", + info->start_stack); + fprintf(f, "brk 0x" TARGET_ABI_FMT_lx "\n", + info->brk); + fprintf(f, "entry 0x" TARGET_ABI_FMT_lx "\n", + info->entry); + fprintf(f, "argv_start 0x" TARGET_ABI_FMT_lx "\n", + info->arg_start); + fprintf(f, "env_start 0x" TARGET_ABI_FMT_lx "\n", + info->arg_end + (abi_ulong)sizeof(abi_ulong)); + fprintf(f, "auxv_start 0x" TARGET_ABI_FMT_lx "\n", + info->saved_auxv); + qemu_log_unlock(f); + } } target_set_brk(info->brk); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index a861f1e1d1..48e1373796 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -630,7 +630,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - log_page_dump(__func__); + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } } tb_invalidate_phys_range(start, start + len); mmap_unlock(); From patchwork Wed Apr 20 18:06:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563981 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4407297map; Wed, 20 Apr 2022 11:19:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXpXP6ihATxiiPnRq889TJ9EChwSdXijv2LzkzgBzArzsYQ6Bg+UTpJZ4SpHmT66u0kPKM X-Received: by 2002:a25:35c5:0:b0:641:dab1:5ef9 with SMTP id c188-20020a2535c5000000b00641dab15ef9mr21497216yba.396.1650478757630; Wed, 20 Apr 2022 11:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478757; cv=none; d=google.com; s=arc-20160816; b=e7VegwAQukcEjuOS2Nb3DKNz6dSwLQmbaCmPP8g+ckPd1jWZLH21ouwyGfwO4NAkjM BaF/ZdJESLuDnjFQa0u5sdSMXfHqDxRY5d5UrpKyFeN9krQk2J678qk0wDHkHU3PgVj0 ap4vmsZmt/I/VoGttO1ebS0UzRIjalPy+T6x/N8gIX/SKFnfAc7LcCQmUQkCr+72RAGQ dokmyxR8+vl0rm9nm6rsjzCK6l61Eh0jA7aflBNGazqLpXLCzeo1F9Wve5kWOaDZFGVN kaOUqKRAYTv3AEnTDWf0U5t/4VnqAlPpFcO6xpW9EUoyZl/PChXts/JIULleTZT3ScXy tJwA== 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=GOrnudVIf/VxKnimUR+ZGBs6Siav2WOrF7wND8cSk34=; b=KzJxFU5SO+3eokkDFP1BCYe1MOPyJmYomstnm8nTNdq2nxoc1jWPZJY/WN7BLwsyGw mUyUT5S52/rj/UG3I0LszU148dDNV3u1myvEtdo1t766AYefBTdF8f4o/J6BUU3xke5F D4Yr5bvS5xwCBy81Y/uC4+gqZ+4CKtR4Fx6VmwshAbn89GSRj8w7VcCUwGKGjP3qh3aR SmRFiefQo8NfeaOBCOvoBlOwirpHnYnxF6eEs8mOZQWMorl8vDB765cNrwYypj2NdHKg rlYCwToeVD7IhAINHHzmkJzaLrOg/erRShL40KHzP53W86envo9WHxycD3h7F8h5F3Va VlEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ggx42s3a; 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 e130-20020a251e88000000b0064540692272si564629ybe.262.2022.04.20.11.19.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:19:17 -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=ggx42s3a; 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]:60164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEv7-0006lN-4b for patch@linaro.org; Wed, 20 Apr 2022 14:19:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj1-0005zk-8l for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:48 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:35433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiz-0001Js-Nw for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:46 -0400 Received: by mail-pl1-x62c.google.com with SMTP id b7so2526154plh.2 for ; Wed, 20 Apr 2022 11:06:45 -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=GOrnudVIf/VxKnimUR+ZGBs6Siav2WOrF7wND8cSk34=; b=ggx42s3afKDy0Esj7MdNSiaEsrqqryaxX1GiKCM1OvoO6IVOH0RTNktTs+JtFRKEKG wv4ov7ndzSrzCz9fLGH/fXO4LI2w5OFHaNmKAWQKaWAtAh5pgtK36R+iNNnbBRWMAzGE +8FALRQBHdjyDAnTt722CjMIE2luDAL3eXoeJJdl5JDdrD2zRer1VJ6eikhJyEd1Xb+W d4pUjhH+nb8IdyHeYs1MvfRncQ4fC8t40omEd2W2pPhx/isz4cGvF4RnsMNJn96Gqwmv xtxx82R8xWpxaXEU3rTEme0jV7LFfR3SwQ9OmsnGc9Z6ZYlrIsmtPT2cDpkV791FU/Ro G1XA== 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=GOrnudVIf/VxKnimUR+ZGBs6Siav2WOrF7wND8cSk34=; b=yha8/BeWC0s0bFXsZDxoSjld5Pq+6T/V3ojf69qiomhg/BmkE2+idHZfW5F1AdlZvH khx/f3MpnqRl5WERs9+AsAOsdNCL744MY01A/CNh70xUZxm7IuLFBb2jZ63pxp43KN6T JOkLpkyLG21vEz/HuWsw5vFptLnSd0diBMPa0tgO+8hOSGlGdh+YEn8BIwOPNCILA5iB H1JyTkZXPtt92aeEoACPpCsyjEMsFpOetmXQ9vGEghvoRMqmkHE1kJw+LF3gDDs8rLIX 7hhGXUdm/98KOe0y+xIEGrpoS3EG9V/HSbnaZ6xDcbCb9QuUxFA8qHnI2eLsDQHuA/CD 7yYQ== X-Gm-Message-State: AOAM530eYy9qAWJxJLHfHWsroNg/rIBR6WKCrYWKvY42B6gSTiQ1r4Wy 4ETCAL5Bs7jN4DDvvIt9UdtSfC9fwrOyOQ== X-Received: by 2002:a17:902:ba98:b0:15a:44ee:9e91 with SMTP id k24-20020a170902ba9800b0015a44ee9e91mr264163pls.3.1650478004428; Wed, 20 Apr 2022 11:06:44 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 23/39] tests/unit: Do not reference QemuLogFile directly Date: Wed, 20 Apr 2022 11:06:02 -0700 Message-Id: <20220420180618.1183855-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use qemu_log_lock/unlock instead of the raw rcu_read. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-24-richard.henderson@linaro.org> --- tests/unit/test-logging.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 4c595356ae..87db7fe04a 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -109,12 +109,10 @@ static void test_parse_path(gconstpointer data) static void test_logfile_write(gconstpointer data) { - QemuLogFile *logfile; - QemuLogFile *logfile2; + FILE *logfile0, *logfile1; gchar const *dir = data; - g_autofree gchar *file_path = NULL; + g_autofree gchar *file_path0 = NULL; g_autofree gchar *file_path1 = NULL; - FILE *orig_fd; /* * Before starting test, set log flags, to ensure the file gets @@ -123,29 +121,28 @@ static void test_logfile_write(gconstpointer data) * this is needed. */ qemu_set_log(CPU_LOG_TB_OUT_ASM, &error_abort); - file_path = g_build_filename(dir, "qemu_test_log_write0.log", NULL); + file_path0 = g_build_filename(dir, "qemu_test_log_write0.log", NULL); file_path1 = g_build_filename(dir, "qemu_test_log_write1.log", NULL); /* * Test that even if an open file handle is changed, * our handle remains valid due to RCU. */ - qemu_set_log_filename(file_path, &error_abort); - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - orig_fd = logfile->fd; - g_assert(logfile && logfile->fd); - fprintf(logfile->fd, "%s 1st write to file\n", __func__); - fflush(logfile->fd); + qemu_set_log_filename(file_path0, &error_abort); + logfile0 = qemu_log_trylock(); + g_assert(logfile0); + fprintf(logfile0, "%s 1st write to file\n", __func__); + fflush(logfile0); /* Change the logfile and ensure that the handle is still valid. */ qemu_set_log_filename(file_path1, &error_abort); - logfile2 = qatomic_rcu_read(&qemu_logfile); - g_assert(logfile->fd == orig_fd); - g_assert(logfile2->fd != logfile->fd); - fprintf(logfile->fd, "%s 2nd write to file\n", __func__); - fflush(logfile->fd); - rcu_read_unlock(); + logfile1 = qemu_log_trylock(); + g_assert(logfile1); + g_assert(logfile0 != logfile1); + fprintf(logfile0, "%s 2nd write to file\n", __func__); + fflush(logfile0); + qemu_log_unlock(logfile0); + qemu_log_unlock(logfile1); } static void test_logfile_lock(gconstpointer data) From patchwork Wed Apr 20 18:06:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564000 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4416936map; Wed, 20 Apr 2022 11:33:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgwod5/jqyfS88SZlLV3Z2NawnCZ4uNWFlj6ZANvMh4ChUSOQNeN5t9p1HQnr6Uf2uDFxl X-Received: by 2002:a5b:982:0:b0:63e:7d7e:e2f2 with SMTP id c2-20020a5b0982000000b0063e7d7ee2f2mr19974669ybq.549.1650479605113; Wed, 20 Apr 2022 11:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479605; cv=none; d=google.com; s=arc-20160816; b=zG4lEL+M3v88P/ta6Hav0v+8OEablvl8fxWliyWa9H8dEsXNeXPkZF+c5SiSpQ8XlL k9nMZmSU1O1epfc9fi9Jo1j8jFW3sj+TaqmLQ3BFI/krvLGoytT6iWGPGgq3Vd87CIW4 2VvRMXuIePUVIpiRI3j2x/J3gvncZKB9FUscfMwf6SmPyy+D77emvAftNLoj1JRTVivB 77eThJuxW+kI0xWnFAdrh379S37ruZs9e7/PmN4ilsQM8tUxbWnvV/bZScOTYP0NcKhl dXxyLeDZaorJ4jmxQxaMen3Fi68I3rGj5TClu0xBpIubXyag4N4h9Yij+uEbCv5JuqbR vVpg== 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=ZUqBSat00byLemeTfD7/Iumu+QHfeVxNUfYZbny+2jE=; b=cxV/mb/9tc0A5O9Etp2jr7O/67E4yUi/bCw7DWZnlHQxhD+1anzbKwKHyoWX4spGcX oo5gk6Ri52AmBusazhjcNLmjmSwVq4Tx01AtTkAunBH1MwMNfbNt0+vrNRlV6JLv+biI ca09nwJB8+cbAgvn7b1beXBKGArVWdXgcW3apTMLFVHC4/jJ37i1AOXByoaxnUZk38OZ lJHqyRUVsK/HeKDKNf67C3KYVq5nsYkEfK1GPq4YaBbv0Nfr7AdfNnTvAWiuvGEMJm1T SjGVFZBMEdoBgtuqcidkBHLpNnQ0X3uoDMxYkdo6bf8qpdmx7z0TGjxQldCe+9t9nY87 +BUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=prQmANPm; 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 e18-20020a25d312000000b0063da5bb690asi649086ybf.486.2022.04.20.11.33.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:33:25 -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=prQmANPm; 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]:42048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF8m-0000r8-Im for patch@linaro.org; Wed, 20 Apr 2022 14:33:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj2-000619-AJ for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:48 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:35570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj0-0001KP-Lh for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:48 -0400 Received: by mail-pg1-x535.google.com with SMTP id r83so2341579pgr.2 for ; Wed, 20 Apr 2022 11:06:46 -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=ZUqBSat00byLemeTfD7/Iumu+QHfeVxNUfYZbny+2jE=; b=prQmANPm6S7etniKW2gdS+qVcyfqxy5syT0HPryuxuPo2TWrYmgADWAWFaUjQoaglu XcJwpQRG2td4uLmIsEJX/f51V3y0kN+FihM8sOw3AuAFi8f2dNQQpyB21jt0/yHJW1rs PPRqijV4YbtGDb5OdtBseHhBHXwTNtS4q6ts6a4I5RzO583k4NU4SJDxu5LaykLxCgml bEdfmDARgBnfjqSan/AiTWCw1XFJw0H1sMhDnZj0Kj6phmZp1484J3GyiYnlFFufNPB9 JOhm8SCx/pSka8kkKXQNOE6U5CAdvw6oijiXEbYv3512WTVbymZOwwsHdDak1TiwQ9YM LOJw== 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=ZUqBSat00byLemeTfD7/Iumu+QHfeVxNUfYZbny+2jE=; b=vsV0hZaJiOU23mMPkIrzuEOaJ+OldzNap3yrOpwOf3UCzeftIjT8XoMjmfktUeVm/D bk0VezMELQ2y03gJxTwWMScHFblwTMBX+VpUXW26LSfqdBGb/RANaYbFDzEJVglRfYif hQW6vv2XUl1cHQXUd7o/Z3oAm5YgAsRO9mX3sHSzaxAC2zGDxH2zuW5FCMwM75ZKqkfj biltatjprg9EpoAHFw3ol7z29E2hMqrVlnzuPHZzJ+w6JFek0/Z9u0WJqTG+AHCmnEkD Rgh3NTGAWXbQCkzMy3W5hhRu7+KDsNu+4o2zdMVzbQWf+GGvReXfCr+nE4+guBMw3XnQ J7rg== X-Gm-Message-State: AOAM531bOdDcs1t6kNVtnkQ64ShYARmHKuEbMgQ7EbUWHlkPpb0WdHwp ErrXxrzaQhqCmLr7rcvG60POIPV1+TtVqw== X-Received: by 2002:a05:6a00:2444:b0:4fd:db81:cbdd with SMTP id d4-20020a056a00244400b004fddb81cbddmr24580821pfj.32.1650478005282; Wed, 20 Apr 2022 11:06:45 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/39] include/exec/log: Do not reference QemuLogFile directly Date: Wed, 20 Apr 2022 11:06:03 -0700 Message-Id: <20220420180618.1183855-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x535.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use qemu_log_trylock/unlock instead of the raw rcu_read. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Message-Id: <20220417183019.755276-25-richard.henderson@linaro.org> --- include/exec/log.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index ad0a40cfeb..4a7375a45f 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -15,15 +15,10 @@ */ static inline void log_cpu_state(CPUState *cpu, int flags) { - QemuLogFile *logfile; - - if (qemu_log_enabled()) { - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - cpu_dump_state(cpu, logfile->fd, flags); - } - rcu_read_unlock(); + FILE *f = qemu_log_trylock(); + if (f) { + cpu_dump_state(cpu, f, flags); + qemu_log_unlock(f); } } From patchwork Wed Apr 20 18:06:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563997 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4415738map; Wed, 20 Apr 2022 11:31:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIF+9Ps8/4Qo65AnGAZ7YjaueRKedz/ZcMIKjoqJP3g04ip8o/JGQ0ZT1NyRxKDtFRdfB+ X-Received: by 2002:a25:8e90:0:b0:637:3d1f:cc39 with SMTP id q16-20020a258e90000000b006373d1fcc39mr21570149ybl.321.1650479503422; Wed, 20 Apr 2022 11:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479503; cv=none; d=google.com; s=arc-20160816; b=AeN+tmOtL7McClPi5u3TJPyk7K33bS6tXHnA/JO+nMPqvu7tU4WTCJ3GAduPHFoIa1 LfDL1qV+VFtLGhvWwrV04nm4zR8FvpZH8vvHKjlbU3YHyp55tvQros+7Fq0th8q2TA8/ g3OrH/+QHbUZqBugq+qUOdvpZDGdLOZ8Gjnhv/K+rPCBG9UhmPfcwJaURpHVM3eA+zOk gbbk8U94SL2cpec1gjKVkQZ+3HaPji549QKtCeR4u7aaSSEO8N5TGAgjSL1bZz+Pmu0F 6Uy0uL8EMITO5i7OhsiD8Cjm6bDaG8mVS3vPKFET/WkEYS7QeebnXgwm3NPznPPfp/L2 /IzA== 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=xNgxgSaf8cG296x/VWOV0Bb0OftTv/JlrbrLRCW/aGg=; b=UsEiVZXJ62Yp0YS6cpjrJ16WPaVnw8X4wSiLwkZkrLuNbOyw/gbtsUrshLOwsnf3hP ozMUUNPHv7mTTKa2NnNcWJHwiUYqT+C7hHv2u6Pao6AWZWXAjD6ny9JxY4RQeQRvnSXt UHCWumZAj5PySISrKZB5GXlH5GbjEwMMEyIIj1Ka9MxrB+ExJ5cCLVUJBBt7oR79wfq0 WeKwrVbFHNX3yIkYa9h6Rxqeu6xdxUOiPCJmtYc+k+vcqoj4e4DBqX1OBKH8nuPkQJtd F3PLf7mvCTPEKq2BjMDHQL9Z/s9Veu4Mohzln6hFiI0+DYEw7lHGXInxbDVgxCQufbrz H/zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nTAfeNHu; 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 62-20020a250841000000b0063d4dd5c0b4si588087ybi.373.2022.04.20.11.31.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:31:43 -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=nTAfeNHu; 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]:37474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF78-0005xP-Ta for patch@linaro.org; Wed, 20 Apr 2022 14:31:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj3-00063P-2S for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:49 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:39763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj1-0001LO-Bo for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:48 -0400 Received: by mail-pj1-x1034.google.com with SMTP id mp16-20020a17090b191000b001cb5efbcab6so5618690pjb.4 for ; Wed, 20 Apr 2022 11:06:46 -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=xNgxgSaf8cG296x/VWOV0Bb0OftTv/JlrbrLRCW/aGg=; b=nTAfeNHuNz4i4FKgFQ1zornoofMjWP6meJNXoMhkztlMGr2molp84K1KFWeTl+kaXz JpUl4inAP6caaRV5FqJW6zUVxaDmwfjMWXNYMF12m8bJ9oS/9f/Q3GW0pGk1rosmt2UH g8Byi0+jq0Jlh6omAmawic1xfXulx35wIx/SR3DYQf8ytP3x7UCXS/QE/KBfgrRqBYJe 6LAPBByME7GzihzSAvEcJAEa2qBlAbpOsSQC47BeT/4n9CtopPHPIiz+HClQJ9YuHtPa DOfJxfFkAFyL/9lxDH1FXdXizvHUK2j/0RIkcVzg+4nu4MpNrTFH5wZWNqr4OoLOrD82 Ssew== 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=xNgxgSaf8cG296x/VWOV0Bb0OftTv/JlrbrLRCW/aGg=; b=aF2m3XDowglChDu+JisvJ8KN7w5fPmsQDL5HzNb0qlWFy7JRwwo2OoQ1X0/zmnqJQ/ KVN7xcFh6fXqp8P4jpLMfspDnm3xcoNpy2vNG+/W0SgfaetmZeK2J6t7+zCZQRV79wYN z/Suw+vs5XpB/7i8pmjsPA/bNMpi5To727YES0zF23gPWp6YR9HH4BoU05ms96RI85ii UR826t6teHXHm+vcBT2VbmD439Ad/JUDbAAmHaU5uGSG3x+0nTtq5P1NuM8pW55WSsL7 Q1PdShD9cMh/C4ePQ+rHlXuRxpDMLKJCcQIp6urWT2jiCVCmUeEkBhfN/RSBkxBY9MUD KXmQ== X-Gm-Message-State: AOAM532bIJiWUcO6l5bx7KAnAR0cT7kqw3DrxZEO8ElD+zZ76aQal66a VQDO02bKNucztjtUHsn94EmK3dTB1MjfCw== X-Received: by 2002:a17:902:cacb:b0:158:694f:240e with SMTP id y11-20020a170902cacb00b00158694f240emr22178630pld.153.1650478006091; Wed, 20 Apr 2022 11:06:46 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 25/39] include/qemu/log: Move entire implementation out-of-line Date: Wed, 20 Apr 2022 11:06:04 -0700 Message-Id: <20220420180618.1183855-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: -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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Move QemuLogFile, qemu_logfile, and all inline functions into qemu/log.c. No need to expose these implementation details in the api. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-26-richard.henderson@linaro.org> --- include/qemu/log.h | 38 ++++---------------------------------- tests/unit/test-logging.c | 1 + util/log.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 75973111bb..42d545f77a 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -3,46 +3,16 @@ /* A small part of this API is split into its own header */ #include "qemu/log-for-trace.h" -#include "qemu/rcu.h" - -typedef struct QemuLogFile { - struct rcu_head rcu; - FILE *fd; -} QemuLogFile; - -/* Private global variable, don't use */ -extern QemuLogFile *qemu_logfile; - /* * The new API: - * */ -/* Log settings checking macros: */ +/* Returns true if qemu_log() will really write somewhere. */ +bool qemu_log_enabled(void); -/* Returns true if qemu_log() will really write somewhere - */ -static inline bool qemu_log_enabled(void) -{ - return qemu_logfile != NULL; -} - -/* Returns true if qemu_log() will write somewhere else than stderr - */ -static inline bool qemu_log_separate(void) -{ - QemuLogFile *logfile; - bool res = false; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile && logfile->fd != stderr) { - res = true; - } - rcu_read_unlock(); - return res; -} +/* Returns true if qemu_log() will write somewhere other than stderr. */ +bool qemu_log_separate(void); #define CPU_LOG_TB_OUT_ASM (1 << 0) #define CPU_LOG_TB_IN_ASM (1 << 1) diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 87db7fe04a..7327de7b5f 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -29,6 +29,7 @@ #include "qapi/error.h" #include "qemu/log.h" +#include "qemu/rcu.h" static void test_parse_range(void) { diff --git a/util/log.c b/util/log.c index caa38e707b..8b8b6a5d83 100644 --- a/util/log.c +++ b/util/log.c @@ -26,14 +26,42 @@ #include "trace/control.h" #include "qemu/thread.h" #include "qemu/lockable.h" +#include "qemu/rcu.h" + + +typedef struct QemuLogFile { + struct rcu_head rcu; + FILE *fd; +} QemuLogFile; static char *logfilename; static QemuMutex qemu_logfile_mutex; -QemuLogFile *qemu_logfile; +static QemuLogFile *qemu_logfile; int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; +/* Returns true if qemu_log() will really write somewhere. */ +bool qemu_log_enabled(void) +{ + return qemu_logfile != NULL; +} + +/* Returns true if qemu_log() will write somewhere other than stderr. */ +bool qemu_log_separate(void) +{ + QemuLogFile *logfile; + bool res = false; + + rcu_read_lock(); + logfile = qatomic_rcu_read(&qemu_logfile); + if (logfile && logfile->fd != stderr) { + res = true; + } + rcu_read_unlock(); + return res; +} + /* Lock/unlock output. */ FILE *qemu_log_trylock(void) From patchwork Wed Apr 20 18:06:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563985 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4409498map; Wed, 20 Apr 2022 11:22:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCI8UBnk2uFZBiLNsIZDkEzKsDjNpj1TDpxwFLZtRgB0UbiH+Tow2PR9bva7E2EoJoh7J2 X-Received: by 2002:a25:b92:0:b0:641:d7cc:8ee1 with SMTP id 140-20020a250b92000000b00641d7cc8ee1mr21928063ybl.243.1650478949989; Wed, 20 Apr 2022 11:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478949; cv=none; d=google.com; s=arc-20160816; b=ue1/B8E56nzBJQJOiRsxp8FXb+1jSozzqWsiyhRqJ0AfLXmS1YSpe8zQa28Imsg5eG 4xJfVxPlQqHNqjdOn4E/3gqe2vXIwQyyCXxijDdZRvjrUYBvONuw83zJXRFWMsKK5mZC ome2DTlbZ8WtKKqJJwT+6+2Rh4nIgvSD9ryV1RPy8XBOn7KiM4DKDji5cUcv/sA/ypgz ckNeJmzAhacAMbZpUzu12qUGfMieNQWk7BAji+vyEo+cp61o52+y8IhF/Nouiycz4cye tTTKP4DGnG0Pl8As7wp34PBhZJVHaBDpMjOQ0D8t9tl4z0+6nefmBG3sr6D/Jpr3P12l AXgg== 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=U9WvSSPQfsR19RuOaY3NyKfhfBva7JRzInAY9nQW5DY=; b=uf8182prbDv6Rp9qxjkxnxCKDj5EUmcfD/sJ2sw2OxJeXCSNULpiW8LhzdfcWuSpcX hJQxpDqLb0tb1VtNG0XrdSId1oBoImnimZllNoFtjJI12FOPjAczwF0K3+UiJhm3CfWO a7CZRxP2Qah9Dgnu9Ey74z7gqqAmzFE7zh03D9p/LonvVaToFOpV7upfeVzvok67JZPT LTXb8evrKFHbegxG1qUInRSNEu1E/sG5W8QWvEs7sLItgmTZsrTjLHpM5D5fNZCCZ4U0 mlDXQxBlKm7UiM6mI2GPAdvSs6ve+ypGL9PChp521bFOdWTWmElkSGTRPRDqL8jqJD0J grSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hAFXpV1t; 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 4-20020a250a04000000b00641199e4635si478933ybk.668.2022.04.20.11.22.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:22:29 -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=hAFXpV1t; 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]:40384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEyD-0005MO-Ev for patch@linaro.org; Wed, 20 Apr 2022 14:22:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj4-000675-7O for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:50 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:46003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj2-0001Li-JY for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:49 -0400 Received: by mail-pf1-x42b.google.com with SMTP id h1so2659593pfv.12 for ; Wed, 20 Apr 2022 11:06:48 -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=U9WvSSPQfsR19RuOaY3NyKfhfBva7JRzInAY9nQW5DY=; b=hAFXpV1t8Uno/zs89Clh7l9W6Ia24SYh7+sjTyrIXlA1IrCok6ZXF7QzD9OMMgwLSs xADe0miOaI7Y/FaOoDnHx/3e0k4n9nBlXj7pkyDKB3GD71elasMHwjVQhaqF7x3XtHYm Y7oRI+7C55n28Muc/A4cSwS1XVRHF4Vr/jtr13tHypZEk2c/y8CkB6Tvm4xlzRti5VnS XKRoAYllehsorSqwYWTPva1eu4+M4HMmonIW9js7H4Zvx+KPV4HxxFvyKFurYluN+ITc e+mUyB8xgnbBku4ZneUh26XPScwN0L0KnLWxroT/lueOiMeuoipS+hDxolM5h+XY8Hk+ X6sQ== 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=U9WvSSPQfsR19RuOaY3NyKfhfBva7JRzInAY9nQW5DY=; b=ycNYXesIkamYJ6qQhUBbC4pdjdWAvNC/+F1w3rlMfb6sna3sT31j6HVMEYfDcE/ieK 0dW1wxCk07ptD6g5UOL5TwUMftCWDtBudmAptn6yD0/DajWKoetB5+kCjzifyJ4AZvxG 5o9PBVvVu2EXNugCGMgf7hOV7YR03yVa6jU0wqKooI7cCS+CpncfYs+/nUPmwJNN5x8S 23jNFnaSJLtEg5hO5j7BGNC7C4BQuxq8c0RnD/Hhopy2r54lYyJbEykPyAiygl7SKEc5 okrnqKZj+L4fkTPU1YmgkbX9FKsgneb4YWt40ZNWzKQwQhgfLBhjJIvFxzSAVgRakpYT sCdA== X-Gm-Message-State: AOAM532dF71XDyyRKN6wdEftoZw/AOdCrDrXpqeLgBIvJ44NZeMl+58X JTbliuzK/WOQJRsVCrmhkQ4pVKzK/nM4Ng== X-Received: by 2002:a63:5917:0:b0:39c:c450:3143 with SMTP id n23-20020a635917000000b0039cc4503143mr20409939pgb.531.1650478007104; Wed, 20 Apr 2022 11:06:47 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 26/39] sysemu/os-win32: Test for and use _lock_file/_unlock_file Date: Wed, 20 Apr 2022 11:06:05 -0700 Message-Id: <20220420180618.1183855-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42b.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The bug referenced in os-win32.h was fixed in mingw-w64 v6. According to repology, version 5 used by ubuntu 18, which is not yet out of support, so provide a meson link test for it. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-27-richard.henderson@linaro.org> --- meson.build | 12 ++++++++++++ include/sysemu/os-win32.h | 16 +++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 6ba60950c8..d083c6b7bf 100644 --- a/meson.build +++ b/meson.build @@ -2030,6 +2030,18 @@ foreach k, v: config_host endif endforeach +# Older versions of MinGW do not import _lock_file and _unlock_file properly. +# This was fixed for v6.0.0 with commit b48e3ac8969d. +if targetos == 'windows' + config_host_data.set('HAVE__LOCK_FILE', cc.links(''' + #include + int main(void) { + _lock_file(NULL); + _unlock_file(NULL); + return 0; + }''', name: '_lock_file and _unlock_file')) +endif + ######################## # Target configuration # ######################## diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index 3c74a78e33..edc3b38a57 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -109,20 +109,22 @@ static inline char *realpath(const char *path, char *resolved_path) return resolved_path; } -/* ??? Mingw appears to export _lock_file and _unlock_file as the functions - * with which to lock a stdio handle. But something is wrong in the markup, - * either in the header or the library, such that we get undefined references - * to "_imp___lock_file" etc when linking. Since we seem to have no other - * alternative, and the usage within the logging functions isn't critical, - * ignore FILE locking. +/* + * Older versions of MinGW do not import _lock_file and _unlock_file properly. + * This was fixed for v6.0.0 with commit b48e3ac8969d. */ - static inline void qemu_flockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _lock_file(f); +#endif } static inline void qemu_funlockfile(FILE *f) { +#ifdef HAVE__LOCK_FILE + _unlock_file(f); +#endif } /* We wrap all the sockets functions so that we can From patchwork Wed Apr 20 18:06:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563989 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4411191map; Wed, 20 Apr 2022 11:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9ewQvawLpw46eKATzJLrLOaZPLTT9gID22BeV+BBD/Nue1mBVUm1mIjYc4lWb3rdpPROj X-Received: by 2002:a25:86c4:0:b0:645:4957:126b with SMTP id y4-20020a2586c4000000b006454957126bmr7189410ybm.158.1650479102493; Wed, 20 Apr 2022 11:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479102; cv=none; d=google.com; s=arc-20160816; b=D2EeUbKqpxd2zndsKH419SLlu71fYh048wiXASfI8nPk21Yv+0E+3F7BD8l/btFWwO 3XJYseAPZdxY++YBKmerAiDbYy9mAAu+1a672fJC0nTrVGWS/v/vtgKqwQZsTVw4DKdq 9Bs68tmyOg3TF15xdG1GG4WT1ccL9BIbvDs8rzo9A5pVG0VikgRJTjy4xF1ujgDK/5TF qyzUlJC01pdCiE9qJuxCxiPMpd7ozQZ4GI330d8wRbCgNEPQ2882EuqTR4s3GmS/kyAI Pl3jOSZHZ0voamGgStR2BKWQxH2vWs5eoo1yqnagrTDiWPROyvAUIWRoaemcWNaqjP3z cURg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=+1xS1L7CgjRHGs3eIcyj4ttpSwhlL5McPO5MyWVkzsM=; b=uLkgRbLdsl7kDG3rkjDYhmkoL+J0TlFL85+WIDgPzhxEgflMm1iVkljSYH2Pnrkknl qFE2ro1sbJIb/GVDsS6mXUAabnUIGTDfVyFURfNRUxMiq7Inx2D279PbRZLnkl9gxSzw 7L1gAnli1NGWZe9xrCNsTCsDms7FXaEksgKZCxR0aYYXkhNe1qxiqdavNfLvv5cYof66 rgaEAcoJLPzNH18gxuY/9zBm5gahUaW8/ft1AkdcL0cDiBU2pHzsdVcj7SFIsUjijS8m pWg98tCFlB/Y3lBw/OrybzyoCE7nSu86DkLyKuJbHoGV+OuUsXAAAiiQBUJ9SEUhCRmy zJVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xmzWp8Ei; 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 193-20020a2504ca000000b0063d95041efesi534672ybe.661.2022.04.20.11.25.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:25: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=xmzWp8Ei; 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]:48864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF0f-0002hs-TO for patch@linaro.org; Wed, 20 Apr 2022 14:25:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj5-00069V-0a for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:51 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:35562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj3-0001M2-7t for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:50 -0400 Received: by mail-pg1-x52c.google.com with SMTP id r83so2341702pgr.2 for ; Wed, 20 Apr 2022 11:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=+1xS1L7CgjRHGs3eIcyj4ttpSwhlL5McPO5MyWVkzsM=; b=xmzWp8EiIMNLcgLr5xBIysZksCCR6adwU7kFi0I9ZD5BwlS8q3Gk0/pumywShgSCW/ IYVLFpKxrLC4SOpVMlqNQWd6+g27fW5cjDz/qUIArMlr3ZWJEhsTKWWTN4M6kVCMRw9F y0UX7te0BMrJ6+mzTOpXoj8mUNun3O5OQbPRnh0DRkpNPUn1/jFeuK1n/yD0471hd1EJ o/HkrxXxJwcFXmHk47dgpwRWqiqxCLORHDcir+majMJ5xfngss0uZENUx9mYWjt5erW9 7R6jPuKZce1KwQV/Fv+lUTCA5vPQSSdALoV37b22X0pGezvN0BO0hdK3dBIKm7P7P64K SL2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+1xS1L7CgjRHGs3eIcyj4ttpSwhlL5McPO5MyWVkzsM=; b=ur7fvnSrnecor8sGbluZMbl88/jZuRifPJLtMz7AUvDrEM3JpO01aZqLirsARdSrFh wFJ+5iB4BnTr+MA6LEhLFola7EX+J46G2U7dKvugo1zCBPghIwpksuoAlnXKM4RlIuGe 2VlqHH3mQ3WOogb2jjphlcdGwYocdrf0WSNoegf2y2ACT7Qf15ribXrdjEjDi0Jz6uxe CVG9sOc5OJ+u98yPjw+mDd+iGQeylb2rT9/4jHmHUUg+iGcEfNhqq7If1dbmrl8qC1vC cuj2KTgdsjnLwFEetK1MybFI2KF4Za01EJDmpDBs8QdhIdYIgmvIDJvkpga72sDvbOFm kgRw== X-Gm-Message-State: AOAM532xmp0MnmRMu/yzqeHEZI1WLpc4dOYy45hFUFDITMYPCyJ+n8c6 wAy5ubts4mmb7ji/YFGvYN+0ii5ZnLLNNg== X-Received: by 2002:a63:4642:0:b0:398:b6b9:5f45 with SMTP id v2-20020a634642000000b00398b6b95f45mr20826265pgk.518.1650478007929; Wed, 20 Apr 2022 11:06:47 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 27/39] util/log: Introduce qemu_set_log_filename_flags Date: Wed, 20 Apr 2022 11:06:06 -0700 Message-Id: <20220420180618.1183855-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Provide a function to set both filename and flags at the same time. This is the common case at startup. Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-28-richard.henderson@linaro.org> --- include/qemu/log.h | 1 + util/log.c | 122 ++++++++++++++++++++++++++++----------------- 2 files changed, 77 insertions(+), 46 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index 42d545f77a..b6c73376b5 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -82,6 +82,7 @@ extern const QEMULogItem qemu_log_items[]; bool qemu_set_log(int log_flags, Error **errp); bool qemu_set_log_filename(const char *filename, Error **errp); +bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); diff --git a/util/log.c b/util/log.c index 8b8b6a5d83..2152d5591e 100644 --- a/util/log.c +++ b/util/log.c @@ -117,15 +117,58 @@ static void qemu_logfile_free(QemuLogFile *logfile) } /* enable or disable low levels log */ -bool qemu_set_log(int log_flags, Error **errp) +static bool qemu_set_log_internal(const char *filename, bool changed_name, + int log_flags, Error **errp) { - bool need_to_open_file = false; + bool need_to_open_file; QemuLogFile *logfile; - qemu_loglevel = log_flags; + QEMU_LOCK_GUARD(&qemu_logfile_mutex); + logfile = qemu_logfile; + + if (changed_name) { + char *newname = NULL; + + /* + * Allow the user to include %d in their logfile which will be + * substituted with the current PID. This is useful for debugging many + * nested linux-user tasks but will result in lots of logs. + * + * filename may be NULL. In that case, log output is sent to stderr + */ + if (filename) { + char *pidstr = strstr(filename, "%"); + + if (pidstr) { + /* We only accept one %d, no other format strings */ + if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { + error_setg(errp, "Bad logfile format: %s", filename); + return false; + } + newname = g_strdup_printf(filename, getpid()); + } else { + newname = g_strdup(filename); + } + } + + g_free(logfilename); + logfilename = newname; + filename = newname; + + if (logfile) { + qatomic_rcu_set(&qemu_logfile, NULL); + call_rcu(logfile, qemu_logfile_free, rcu); + logfile = NULL; + } + } else { + filename = logfilename; + } + #ifdef CONFIG_TRACE_LOG - qemu_loglevel |= LOG_TRACE; + log_flags |= LOG_TRACE; #endif + qemu_loglevel = log_flags; + /* * In all cases we only log if qemu_loglevel is set. * Also: @@ -134,71 +177,58 @@ bool qemu_set_log(int log_flags, Error **errp) * If we are daemonized, * we will only log if there is a logfilename. */ - if (qemu_loglevel && (!is_daemonized() || logfilename)) { - need_to_open_file = true; - } - QEMU_LOCK_GUARD(&qemu_logfile_mutex); - if (qemu_logfile && !need_to_open_file) { - logfile = qemu_logfile; + need_to_open_file = log_flags && (!is_daemonized() || filename); + + if (logfile && !need_to_open_file) { qatomic_rcu_set(&qemu_logfile, NULL); call_rcu(logfile, qemu_logfile_free, rcu); - } else if (!qemu_logfile && need_to_open_file) { - logfile = g_new0(QemuLogFile, 1); - if (logfilename) { - logfile->fd = fopen(logfilename, log_append ? "a" : "w"); - if (!logfile->fd) { + return true; + } + if (!logfile && need_to_open_file) { + FILE *fd; + + if (filename) { + fd = fopen(filename, log_append ? "a" : "w"); + if (!fd) { error_setg_errno(errp, errno, "Error opening logfile %s", - logfilename); + filename); return false; } /* In case we are a daemon redirect stderr to logfile */ if (is_daemonized()) { - dup2(fileno(logfile->fd), STDERR_FILENO); - fclose(logfile->fd); + dup2(fileno(fd), STDERR_FILENO); + fclose(fd); /* This will skip closing logfile in qemu_log_close() */ - logfile->fd = stderr; + fd = stderr; } } else { /* Default to stderr if no log file specified */ assert(!is_daemonized()); - logfile->fd = stderr; + fd = stderr; } log_append = 1; + + logfile = g_new0(QemuLogFile, 1); + logfile->fd = fd; qatomic_rcu_set(&qemu_logfile, logfile); } return true; } -/* - * Allow the user to include %d in their logfile which will be - * substituted with the current PID. This is useful for debugging many - * nested linux-user tasks but will result in lots of logs. - * - * filename may be NULL. In that case, log output is sent to stderr - */ +bool qemu_set_log(int log_flags, Error **errp) +{ + return qemu_set_log_internal(NULL, false, log_flags, errp); +} + bool qemu_set_log_filename(const char *filename, Error **errp) { - g_free(logfilename); - logfilename = NULL; + return qemu_set_log_internal(filename, true, qemu_loglevel, errp); +} - if (filename) { - char *pidstr = strstr(filename, "%"); - if (pidstr) { - /* We only accept one %d, no other format strings */ - if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { - error_setg(errp, "Bad logfile format: %s", filename); - return false; - } else { - logfilename = g_strdup_printf(filename, getpid()); - } - } else { - logfilename = g_strdup(filename); - } - } - - qemu_log_close(); - return qemu_set_log(qemu_loglevel, errp); +bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp) +{ + return qemu_set_log_internal(name, true, flags, errp); } /* Returns true if addr is in our debug filter or no filter defined From patchwork Wed Apr 20 18:06:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563983 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4407684map; Wed, 20 Apr 2022 11:19:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4qWzYHEF8eccv+BGoiDFTG1+TUg+sz0ksmRq6ZOZui8HV9PANhLNd8UlkfSGX/Y4FEknO X-Received: by 2002:a81:a82:0:b0:2eb:ebe3:3924 with SMTP id 124-20020a810a82000000b002ebebe33924mr23077316ywk.360.1650478793911; Wed, 20 Apr 2022 11:19:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478793; cv=none; d=google.com; s=arc-20160816; b=K526qSdZKI0aDUOj+qD+qxMnPeN1BrJ1ZuaOtmqqt3E5iDf1CxDoVBRMHDIBPvBx6G 2jGwNGHbFcaSEeBw5ygd0GvCp63nSGBuRlESokz5+z5avncUets5o/pP1adNDeE7MF+9 /Aandpmo5CLbH4D45/6GQXr7axE6X/0AuvO4RYVY4TzjDOSX037qVtLULJsJ0RdJdJty QSl0b4ZNQc0LgbU+tsbnZ5FOnFhjqEXOEqx/6qj0YQ8Cy7ETNl+u6Sj2nCH71SwND7O2 WZOMXEJgqh+AQqzrm1h/Hpp/5HPsAmkO5cjRAsfG9u9hQAGZBO//Z7BfTLbSAt+yusUv Bb6Q== 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=7eEUo/lkzPtBSQrQRpI3Km3z9H0IRO1hS7ph/cOmoCs=; b=i3oWmTELIgor91rVgenSKhWiqLNhCLX/ibEsoHu4JmyeVc0Hs2IzcVJMq4vuLBD5zg QxAcl26zi/mTAAUx0DjjwZMHl/GSQqGu91P7FMFtYY1hFJDnr4k0A9p20gXFErA9/nNg pU2nbBWjXEMZyVsj6b0FSpFoMY/y02JN7mkM/GSglL44VMIW43V33L09qu4x8rKECF2S QjNrfh7NSNchgrGYzYiKmw636WoWgfg+4aMIWjJSBtDIaJ06E+6+sbyU0TYAWhJAqb5M P0lJqcuZiKQNTb2HFMQhqaNmECtu4dYExT6nGFGEZouPFwL4NpEOS6Sfo6Aa7gWxtx9D TwBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vycUFljy; 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 w8-20020a25b888000000b00644f191d805si582581ybj.509.2022.04.20.11.19.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:19:53 -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=vycUFljy; 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]:34962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEvh-0000SS-F0 for patch@linaro.org; Wed, 20 Apr 2022 14:19:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj5-0006BG-Je for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:51 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:35563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj4-0001MD-0E for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:51 -0400 Received: by mail-pg1-x52d.google.com with SMTP id r83so2341744pgr.2 for ; Wed, 20 Apr 2022 11:06:49 -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=7eEUo/lkzPtBSQrQRpI3Km3z9H0IRO1hS7ph/cOmoCs=; b=vycUFljyLFxkvYBOt1P+W6jDxDjm7ltxqewprzMoR0SlPsgGfYOt44dfrvcngxS5DT f0uKTdvDWy1DnnaNK8SDujKazln3gCzRhq1TOMQZ98WVkBWJmG6ifRz4yQo/iNATnYrE rQ+oZK2MbWAa1OSYIi3Svu8bw91AXgMJHAJgjZajQUD4Ii/TdSYPWyrOWF26sxoJO0ch HkYkG4GqfGs6wjuLoUoy8uOMDN8xzPW7H0EH63hNAHHYHG9fNFVbRFTKo+Fcnu6BJ2M5 l2sobtOEB1HuhwIZzdNQgHY3HH/ZZFpM6ctZoloRT/fzp31hZJ33ZtjXjmJbXKB0VF1H 12sQ== 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=7eEUo/lkzPtBSQrQRpI3Km3z9H0IRO1hS7ph/cOmoCs=; b=it7OQyG6OX6Qm/Hkx1k1LQra4A4pAFA9jjS3tNBIvvr6ecw1nOCK36oE0QiIRtic41 5nNessWKEh98EAjtAC9SqctUpJ+lqrYZgjJ/rex8OPqfZtxHd5oYGfnjmf27DQTJVND+ cbwYm6/UZopUgMiFouCbUM23/4AYtGW7HEP8gQOJ7M1C9BoD6FQDc4ARg6faJSzcNvNy 5vvok4kCNYnOLcxhIscsMNLbxkhmLsCY95ixzwZQnakWh13CoLG6pIjx5P+MV3TV0gZt HE/AzwgVQWtM22WbrsUzYYU51LwGMzWV26saHfs3ApsZHRuSrM/SWkBY3bmxyXobHxYj OVWg== X-Gm-Message-State: AOAM5308MvdJZ71JHOHh1bpOc+S3KcrQbc0rg1mIQaMkd/ygxj0yrJiP JsTjiF9b7DjMZvDfWYN8nmcF/sX0FeFBbg== X-Received: by 2002:a63:d64d:0:b0:374:6edc:989c with SMTP id d13-20020a63d64d000000b003746edc989cmr20454636pgj.434.1650478008781; Wed, 20 Apr 2022 11:06:48 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 28/39] bsd-user: Use qemu_set_log_filename_flags Date: Wed, 20 Apr 2022 11:06:07 -0700 Message-Id: <20220420180618.1183855-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Perform all logfile setup in one step. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-29-richard.henderson@linaro.org> --- bsd-user/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index ed26fc5acb..aa13eae7f3 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -405,16 +405,16 @@ int main(int argc, char **argv) } /* init debug */ - qemu_set_log_filename(log_file, &error_fatal); - if (log_mask) { - int mask; - - mask = qemu_str_to_log_mask(log_mask); - if (!mask) { - qemu_print_log_usage(stdout); - exit(1); + { + int mask = 0; + if (log_mask) { + mask = qemu_str_to_log_mask(log_mask); + if (!mask) { + qemu_print_log_usage(stdout); + exit(1); + } } - qemu_set_log(mask, &error_fatal); + qemu_set_log_filename_flags(log_file, mask, &error_fatal); } if (optind >= argc) { From patchwork Wed Apr 20 18:06:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564001 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4417806map; Wed, 20 Apr 2022 11:34:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy96uKA6jFvO2xARlrFi3/bhJOTrKhfOKFAqL3hW+1c0qzB1nd1jRu6W8BxwUNkwhyPhivU X-Received: by 2002:a05:6902:1206:b0:644:dec2:6c22 with SMTP id s6-20020a056902120600b00644dec26c22mr18209551ybu.578.1650479681631; Wed, 20 Apr 2022 11:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479681; cv=none; d=google.com; s=arc-20160816; b=NytDB8CQIOrncJi2hmzcenAc9YSZP2H9xuQMLfia5OUIcMS+U5brRK1MToe2OGvXsd gj4xCoeEqdHnJw3eqTYPhC6lEuFQ1seQk9UaWmWrI6AdomiOgT0HT/K6jEsCClA1cwwq HEBYg95e4OWsREf5kyOPVFwB143p6YXje2jhkIGJCsJZjz8E6Eirb54wqyM5iooqf2qZ Vl/nGLyaqW2zOjchf8vMDfeiRKfUlLCGQHuLFRBr+v++MHyCfnl7MjF/RjP68la7TVzo RNVbjB9V5M6qPH0g0Bku5T6rLqgRRImHTqxxH6qZPQ+JXqLFvnSBOv7TlSOCp5Ml0pSF qL+w== 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=Aaj9Eqxm00442I9UsHwK98R5AWzqyFTC/zPZ/aayFrs=; b=qIOKOkqgts33kQCu/aKmQyi5doND5692L+1ZGjJpMN9rXRLWYBmgNV457+tB4F9zvb PXrhiOedXh4vqC3+Cj61tXds+IZkOJtzw8fGrcQpGgIxbyhLU9c79mDmNQnjQasCNnrG /bL+DJpPq6yFSPp1pkasKhuM/CEMqhwDWolA/9GQb3lnXJTHaSr/tv8My8SnRARwM91G cCr1FY/aGnHOTLQ1xDHuzCBU/bhGKr/kKZgBo8l5Dbb/TrfvYI46Gi1yh5oAdL90ivNE q2E284t08jAALKx2sZed3JGrMh1b7mF0T/E0m6arYXmoh/Q8cjEHLVM8Y9AB/TLpsep/ 3DSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AqxPSu/z"; 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 w10-20020a5b08ca000000b00644b8a68518si609008ybq.520.2022.04.20.11.34.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:34:41 -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="AqxPSu/z"; 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]:45664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFA1-0003M1-4r for patch@linaro.org; Wed, 20 Apr 2022 14:34:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj7-0006Ib-0t for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:53 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:42572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj5-0001MT-DG for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:52 -0400 Received: by mail-pg1-x529.google.com with SMTP id bg9so2317317pgb.9 for ; Wed, 20 Apr 2022 11:06:50 -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=Aaj9Eqxm00442I9UsHwK98R5AWzqyFTC/zPZ/aayFrs=; b=AqxPSu/z/KFTQVMtWc7lNsKooPFvWYwAMlBI53gE47l4bsC7aKuWodfRDTIlIla9ke k1ti7UFWIqoUlqvH4ZdCGZwI6N7EZIlRjFCNF9AZAfFDj+UxPG9DWhwuCwN3dsPx5sxh r5EgNNcGPfb90txEQ0esbTwL6owYpGGMmWBLiaahD/BVX2pznID8wMMZ5azxn/KacIdo YPbsG1dE3a6KTnVxtXKS+jh9MWGlZkVi49yxJDhA4C5ZKCCizj/UFUo7qFvcJcnEGV8m Cx3E1s8JPw2tztV3CF4dDy3nY1uS8Ycq/mkh4HN3YJynGdKDXNnddM0LRjIboAorWM0n 6Y5Q== 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=Aaj9Eqxm00442I9UsHwK98R5AWzqyFTC/zPZ/aayFrs=; b=jXpD4A7uvqzXREMClFibF84+hM6h0uDwEyzMCufcirM7NpSt7s2tmqrP+ZaO+dctSd A+RuHaKpLMtNmV3z0Yy86WsihlzVAsS5OIkVjCcyiGs/RVAulKpPiylxUKHHqjO0/3KC t6QAUic2PNkcN3pjGd5j7XESSKbyP6IXDvIcqJjErMGr80JrVs7hFy5z3IhzuPbd5wqH mmDK5DiFbsUlIbW2zuy44aMUbbALebQp89TINebXz6Ezm+KYpKnNi7DxBbvzGjZ9g+K8 G7b/CQt95Uk/ffN25nxDBNQNunYPzsReDaISDPQQl1cfSXMqzNL07MyA1oj1+su50tZe +zEA== X-Gm-Message-State: AOAM531vsXE0kpVBVpBMmWlWgsFCgQLLYm68WjmsHSePeDzNbLBwkaDK XC7JMLbhr0y6q7v3R2K5Nc0PmK8Sj2d/rg== X-Received: by 2002:a63:ce45:0:b0:399:1124:fbfe with SMTP id r5-20020a63ce45000000b003991124fbfemr20800950pgi.542.1650478010011; Wed, 20 Apr 2022 11:06:50 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/39] linux-user: Use qemu_set_log_filename_flags Date: Wed, 20 Apr 2022 11:06:08 -0700 Message-Id: <20220420180618.1183855-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Perform all logfile setup in one step. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-30-richard.henderson@linaro.org> --- linux-user/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index d263b2a669..0297ae8321 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -85,6 +85,7 @@ static bool enable_strace; * Used to support command line arguments overriding environment variables. */ static int last_log_mask; +static const char *last_log_filename; /* * When running 32-on-64 we should make sure we can fit all of the possible @@ -257,7 +258,7 @@ static void handle_arg_dfilter(const char *arg) static void handle_arg_log_filename(const char *arg) { - qemu_set_log_filename(arg, &error_fatal); + last_log_filename = arg; } static void handle_arg_set_env(const char *arg) @@ -643,7 +644,6 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; - int log_mask; unsigned long max_reserved_va; bool preserve_argv0; @@ -677,10 +677,9 @@ int main(int argc, char **argv, char **envp) optind = parse_args(argc, argv); - log_mask = last_log_mask | (enable_strace ? LOG_STRACE : 0); - if (log_mask) { - qemu_set_log(log_mask, &error_fatal); - } + qemu_set_log_filename_flags(last_log_filename, + last_log_mask | (enable_strace * LOG_STRACE), + &error_fatal); if (!trace_init_backends()) { exit(1); From patchwork Wed Apr 20 18:06:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564005 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4419743map; Wed, 20 Apr 2022 11:37:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuDibCbipHCFEBYgiaoMNIyoZbYYg6OCkjZpqorG462N6UlY/h+STg3kbdMt3mgfuwG/eE X-Received: by 2002:a25:404c:0:b0:641:d636:1610 with SMTP id n73-20020a25404c000000b00641d6361610mr21401820yba.209.1650479854981; Wed, 20 Apr 2022 11:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479854; cv=none; d=google.com; s=arc-20160816; b=JA0VxVcbJnbFakdPNDqE6WY51zNB8rBdrncnseWUbVzlwIPg9nNh2V1HAeIc3yR/2h MRWXeQRL+xgL17VuRoQD3hMNHfCXwKq9PgLJsevnf5FNTDQ46Oqwpw6gOYW2yb3veUNm erYoizTf5pM4tajASAvq8+hw0yTryYva+wEcLYuFhipkoL6qcLlYWJ/rrgCrPiItJgt1 pW714et/2dNZ4IODViVPq0fU18bO693I0QHlC/yBAvH5L1a/Gvi24ZPIs3D6z1XFdsUQ sMpy60Qp21QpOIKRN5dHyjU8DiMEwSB55LP5eMvn/iJ22f2IAl0c4oALeky2ZZatK124 SKyg== 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=/s0wl9WGt9PyoXN9DcmhdMDO6XLUI9CxJxFlhTlZYAE=; b=sH7Awadkd1CP+W9dQJMszt+lpTj3Ka1kteqb7RfHtZqzj9BFcALMZh/5wwuMy+4CkB zkHocncWynDx58IDqnv4wLL4I+I6eOeHZSkvsV19yiK4QLeKAwGs+GDD+QQALSwltlGe Shp2IRSEnoIAMy49qqMJCvkw0FMP47g7Ywl4rCS9++6/JOnIqFMw1aVple0bCq9PcBwj 4Xxmm3nsNecm4e02Qfi3sMNSjGzw7PxWvSRlJG5Jdq9sEBQRCr3567NZUFlwny3qbTOa q4hUlXSQZa4u175jdt476GuKGoeinzSBukFxXpChbyP+nPblF3pwM1Fbigxa9SkdXhfR aw0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sOZrUBeq; 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 67-20020a810346000000b002ec27f6d9d8si595369ywd.238.2022.04.20.11.37.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:37:34 -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=sOZrUBeq; 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]:53992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFCo-0000fT-Ge for patch@linaro.org; Wed, 20 Apr 2022 14:37:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj8-0006Ko-1K for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:54 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:34771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj6-0001Mr-FX for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:53 -0400 Received: by mail-pg1-x52f.google.com with SMTP id t4so2342787pgc.1 for ; Wed, 20 Apr 2022 11:06:52 -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=/s0wl9WGt9PyoXN9DcmhdMDO6XLUI9CxJxFlhTlZYAE=; b=sOZrUBeqcmKoLsRnM3X8fvRQP7TiplfcXZ5+qZ+V/7QX3LAu6pQtDRepwsoOG3Zjuz iiefIFsUD2vtOY2Z4hVJsUQEpE6kjN86pPJFlGQabWs6F7hVmhinZbmLZ4mav3Qqda+D roBl5aVQgmWNMWxh0ZOMXBjghRVV/K5ihSY0l1lEpNHKpBDXPHv/7Q2wWXfyA3+ET1nc IT7BeRPcA3Omb/rWl501tfq3JZKAfcbbxIrcX9nYc8jQ/w2S4wsitF1JlrT0tI05o0JM 3s3KHzlhfWiPxysvf9CNjSPw8XKueNWS9KAXnwcxBjuhSu3ReYg+6O0US+kJANT+hdU7 8+Ww== 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=/s0wl9WGt9PyoXN9DcmhdMDO6XLUI9CxJxFlhTlZYAE=; b=c1ng0Pe2zVCuPHx+mowDolMsYbT5OTCxBMa5BUokyrHcVwoH5y13Hs3EMtRMcT8092 HjUkJVELGvbeCBy7pEWG43jDLEcjqnTSD1GNdx8ao3iI2iuuyGO6Vs2CmOPfmxnMh7HJ jJRQ8PRO9k6uxfvcohaC+knqexV893pzXantCxinP52tjriq+4UMLZPSljauJBfRo3np UXzkaVZwDMXzCbQqSNK96txk3FStjJUtaA4N6hQdziDbGYadtVcZxzG+Ld9CVMR5h3EX hHvTfPugZBM3UcxJGDOqqWnkSGVr9k39U5f12LxtFdcQ+SIq8XdG/VXNvtRhQwAEIyyv XlYQ== X-Gm-Message-State: AOAM531mzau4U8nYlQ56AdfP54tvwKyd+plkN6Zmg0a2WUi9qXLf60tb NlLiwR46HGehRnt/b2ylbsM3V3K7VGMvkg== X-Received: by 2002:a63:6fc4:0:b0:393:9567:16dc with SMTP id k187-20020a636fc4000000b00393956716dcmr20043211pgc.593.1650478010992; Wed, 20 Apr 2022 11:06:50 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 30/39] softmmu: Use qemu_set_log_filename_flags Date: Wed, 20 Apr 2022 11:06:09 -0700 Message-Id: <20220420180618.1183855-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Perform all logfile setup at startup in one step. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-31-richard.henderson@linaro.org> --- softmmu/vl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index fe9de2f896..f679d48d74 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2560,19 +2560,16 @@ static void qemu_process_early_options(void) #endif /* Open the logfile at this point and set the log mask if necessary. */ - if (log_file) { - qemu_set_log_filename(log_file, &error_fatal); - } - if (log_mask) { - int mask; - mask = qemu_str_to_log_mask(log_mask); - if (!mask) { - qemu_print_log_usage(stdout); - exit(1); + { + int mask = 0; + if (log_mask) { + mask = qemu_str_to_log_mask(log_mask); + if (!mask) { + qemu_print_log_usage(stdout); + exit(1); + } } - qemu_set_log(mask, &error_fatal); - } else { - qemu_set_log(0, &error_fatal); + qemu_set_log_filename_flags(log_file, mask, &error_fatal); } qemu_add_default_firmwarepath(); From patchwork Wed Apr 20 18:06:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564004 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4418909map; Wed, 20 Apr 2022 11:36:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWPJDTy5LIrNqiLvxN43qre3+SpuXB7/7ZPC4QBkPwzq8bljazcUaTxmyGNpOxj94kKHvB X-Received: by 2002:a81:50c:0:b0:2ef:4c3d:af5a with SMTP id 12-20020a81050c000000b002ef4c3daf5amr22449236ywf.85.1650479793109; Wed, 20 Apr 2022 11:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479793; cv=none; d=google.com; s=arc-20160816; b=EX+1xohyKYaoBMnpU8OnaGEbod5eA1CmUg4n4jnbQyYUHIf3hZOvqa6gML3GWU2UBc 5QZYVwbWZDX5o8AZy87p4qeZKe+DObpebzigkmK3sopGPUJhQPxc10D6CnVzMiuhXn49 w+kT3+dkdXzFg5qAyQ1IxXeVSHqgSgADoJ6aeBKhCt6kI2kB1qkBS1VOwhyFn7J3ORv4 E9+J9goUFKBi/B8QY3JInMxe5h4kIvAVuaaBGL45H1qkKak9hdSjTWX5RBC4kIdi6nSD 14I7EtCsN7vCxZa61zh6aNTbSj/eCzIvHyQTu3hPDa7MTcWqyFOkbbU6EsFLtx9q/hmW jCyw== 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=p9DdDXF/cfTV0TrHX0YMQwF1dlIRO0Y9R9S6R8WRAHE=; b=nyxaAYREfmL4qhDuVab5RkljWIw5yOCTAZprZLP7Dkq6fGJo/N2sSc3rBj2GIhJvHa U5H0xWYVxAAAucw/f+cKfSD/Ovbk7DrOpoeloBfeWunmIK7GS8HhA02t/F9fo884iAQW 0kiZ76pef59gi7UBQcuzY3S5l5kCp/TrDNe7gefmhPzl4ePGrYgGQgXNRG2EBljRBgTT c1JdbRX2rHNGtzKwdgc5DRVZ7HjSvanjOwjiI20EzXHn/jfdYBfF6ytNBHruau7VCRc6 /gd3kMwYbEH3SWIqBjLpQJiMea42LBDvj7HUFZc09eoc69CG9N2ucrwNGMIaPKMfPtb8 ZPRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RUi+7HfC; 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 b184-20020a2567c1000000b00641d681f4e9si696605ybc.19.2022.04.20.11.36.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:36:33 -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=RUi+7HfC; 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]:50336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFBo-0006by-Kp for patch@linaro.org; Wed, 20 Apr 2022 14:36:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj9-0006O7-0k for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:55 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:36640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj7-0001Mx-AS for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:54 -0400 Received: by mail-pl1-x62e.google.com with SMTP id q3so2524699plg.3 for ; Wed, 20 Apr 2022 11:06:52 -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=p9DdDXF/cfTV0TrHX0YMQwF1dlIRO0Y9R9S6R8WRAHE=; b=RUi+7HfCt4XKs3r+YAojdrzhMB85gY6MjEAXaJVsViHv271/ib+Lc483m7U44HFg7Z V8HA3QnUMz8dq7zF5F04brOcHnRLRfSSOq9ljz3Ee/PfHxGYIKZQyuT5DQ4CC5bwt0Qx EKOZUFMm1xLeLhsEO/j29EUq8pOz5k1Yn6dPOt+IQXDY9c1Eg5MgOMBxmZvW3BdYqg9K T6PZ60xUShwmSUo9UndJeIxxllhlJqTZRovECLhfI37YipKEFdc252g4kF3+C70ny9jq 1DUhFIqnIjbHC5IvY5/EdtPKt05+e+fBUPBo2KBjuGU7MCdpqiTHyW8jgHU23/sBR7gi lX+A== 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=p9DdDXF/cfTV0TrHX0YMQwF1dlIRO0Y9R9S6R8WRAHE=; b=Gr0zpN0KOs6NmCbTlU2YmdQR86iBkYeI3nCB6XR0QOwknwduGJ225Mi8Vd38TiGCH7 ApXsqkuHN7H29OiQZbEmsFPDfD8FUdC6FlFEs/y1tPdi8fLsj/G0xIv1IIU9sWysKf+K E3aoM+WLEe5wX3GG6WRC06h9zrlyqjV9FEendjFzqUlpOYavSvXltkFhAKllzaKAf8No nK+GHAZ0LcDt673yXGdOiRsQkwi+zWfaSa0IiPP+RX4MUMxZhPEXUbwoqyBLljGPGlmZ hhyB0pd3EQfKBGXd4t2/ryqNXcLA2tti5o2nrJ0HmCpoJrOg+8qAFYBs357MaWs77pee v7zg== X-Gm-Message-State: AOAM532TabYQpZmvdcBni4rFtPDbgyQMBq0gWdaJo3xcjKHEVCHSaHrD 1Zg9R/i6qo52UVCr+Mia7hE+1KbXUIqyIg== X-Received: by 2002:a17:90b:4a48:b0:1d2:ba31:9853 with SMTP id lb8-20020a17090b4a4800b001d2ba319853mr5772017pjb.243.1650478012023; Wed, 20 Apr 2022 11:06:52 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 31/39] util/log: Remove qemu_log_close Date: Wed, 20 Apr 2022 11:06:10 -0700 Message-Id: <20220420180618.1183855-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The only real use is in cpu_abort, where we have just flushed the file via qemu_log_unlock, and are just about to force-crash the application via abort. We do not really need to close the FILE before the abort. The two uses in test-logging.c can be handled with qemu_set_log_filename_flags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-32-richard.henderson@linaro.org> --- include/qemu/log.h | 3 --- cpu.c | 1 - tests/unit/test-logging.c | 4 ++-- util/log.c | 17 +---------------- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index b6c73376b5..a325bca661 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -92,7 +92,4 @@ int qemu_str_to_log_mask(const char *str); */ void qemu_print_log_usage(FILE *f); -/* Close the log file */ -void qemu_log_close(void); - #endif diff --git a/cpu.c b/cpu.c index 7076ec123a..584ac78baf 100644 --- a/cpu.c +++ b/cpu.c @@ -407,7 +407,6 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) cpu_dump_state(cpu, logfile, CPU_DUMP_FPU | CPU_DUMP_CCOP); qemu_log_unlock(logfile); } - qemu_log_close(); } va_end(ap2); va_end(ap); diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c index 7327de7b5f..66dbc82a56 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -169,7 +169,7 @@ static void test_logfile_lock(gconstpointer data) * Initiate a close file and make sure our handle remains * valid since we still have the logfile lock. */ - qemu_log_close(); + qemu_set_log_filename_flags(NULL, 0, &error_abort); fprintf(logfile, "%s 2nd write to file\n", __func__); fflush(logfile); qemu_log_unlock(logfile); @@ -207,7 +207,7 @@ int main(int argc, char **argv) tmp_path, test_logfile_lock); rc = g_test_run(); - qemu_log_close(); + qemu_set_log_filename_flags(NULL, 0, &error_abort); drain_call_rcu(); rmdir_full(tmp_path); diff --git a/util/log.c b/util/log.c index 2152d5591e..491a8f97f9 100644 --- a/util/log.c +++ b/util/log.c @@ -198,7 +198,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, if (is_daemonized()) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); - /* This will skip closing logfile in qemu_log_close() */ + /* This will skip closing logfile in qemu_logfile_free. */ fd = stderr; } } else { @@ -322,21 +322,6 @@ out: g_strfreev(ranges); } -/* Close the log file */ -void qemu_log_close(void) -{ - QemuLogFile *logfile; - - qemu_mutex_lock(&qemu_logfile_mutex); - logfile = qemu_logfile; - - if (logfile) { - qatomic_rcu_set(&qemu_logfile, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); - } - qemu_mutex_unlock(&qemu_logfile_mutex); -} - const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_OUT_ASM, "out_asm", "show generated host assembly code for each compiled TB" }, From patchwork Wed Apr 20 18:06:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563994 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4414130map; Wed, 20 Apr 2022 11:29:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzewJRhjetwn0i7NQJT6wESvNeZckr/raf8QtvjKlf/WY8CGCAcrWF3lSB/ssA/80KGwGKF X-Received: by 2002:a81:8902:0:b0:2eb:e2fd:8a1d with SMTP id z2-20020a818902000000b002ebe2fd8a1dmr21996659ywf.516.1650479359728; Wed, 20 Apr 2022 11:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479359; cv=none; d=google.com; s=arc-20160816; b=dxxfNXXa7a0f8xpaCTXkGjsfOeTFqyGzEb8V84y21C1ongHktTkALCi+qxqKpizbB3 XjRNfDn/j/D4Ebkr3lCmaz7x1wiY9EAZwmp6YBwEDxBK9u82ej/J0ybg3y+WlaV8M6Us z27tdB8c43/vU916zr8nGqOhe5ikiAw0ZrAxEolL7Cp4gdJhHvbpkoMMEuYmcjiSK8C+ c3WveKS/X7ZVaG9Tv2mxPqYoTQD6rfW4+AcmP2SL1pAvE72GeWiYMlXI/PhV2rCMZ3m6 t1x92lWsfNWXOupNfG4+xTQwSCYQzmTHkFPFqRDZWDJSJm3Knq0TE5lGzsLzWUBQ0VcG Oh5Q== 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=ggCkE4H0GpylDO/t2+Oit+yU2z/D8eefxrTSlD31bcs=; b=r9Q56RXsWa2Dd6Gkbsc1W2/7vfhgBRtkadVEuEp7ur8zjFl6Yooy9CS1fnss2ssj4J eAy3ZjbLQsgJNgEHb2lYR/2Zm8ieCVeGUeZZ0O6qhLj81BE2Dyjks+TyFhwR0RxVTK6J a0I2bdEfVlf56z3SbNvjvRhkR0/yA8QzHd+O59pK8X47UBrulobYdDg1sKWzNsspO6ZS oHWYVBblUQIFnaRLu3x+yBVb3vwE9W2o630Vp3urvcf8vLqrN0BxAJUdLn3McMUrCfXk kgR9RBoF9mtjuDaTX4A7QpfaLn3g77ha/2+V60wuvdi9APIPUtnn7k0vs3vRfTCW/WKR YLyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Tg6rA8NJ; 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 a133-20020a254d8b000000b00641bfa3b798si627531ybb.51.2022.04.20.11.29.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:29:19 -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=Tg6rA8NJ; 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]:60298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF4p-0002HX-7z for patch@linaro.org; Wed, 20 Apr 2022 14:29:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj9-0006RG-Ul for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:55 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:41887) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj8-0001N8-CW for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:55 -0400 Received: by mail-pl1-x62c.google.com with SMTP id s14so2505758plk.8 for ; Wed, 20 Apr 2022 11:06:53 -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=ggCkE4H0GpylDO/t2+Oit+yU2z/D8eefxrTSlD31bcs=; b=Tg6rA8NJvLT2odlNnWZkXSs2ISzYkKnQ8qRrrgnvHXveiG8IuFT4+Ksmmg8lYmfGZ0 mG3h4wrK30x7GuGlw5jCChySypeVQZJ8vrfswfh2LWRSTMfD9J9N2JH1fPfxqdYGSt8g SdQyQ1VENYjWhYAXY41pafSri8GpQBD/9VmhlXaUprIWuw5l0pGQrzuWHS+bA3Qb1O8r ji4h+scdQfXofj4g/39xs42UyKTc7UBE0gdgpzi+Md5gibaxZaRogk33y2lKbOmu7PrV MH01zZ/OsulNAnrVgIfgDVDa7nn2tcBWM1kHsIibNm1RepHBIsJzsH8nuG5/3VNUDuGH r0Gw== 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=ggCkE4H0GpylDO/t2+Oit+yU2z/D8eefxrTSlD31bcs=; b=biRCwmcsCBRu9YACN+uH0AOgAn0P+v0fPT9vqpgLhbI6IURM/Z7HMNxhLzlZgh9wzg HAe5u0E0fMwNNBozIqTxD4FVJ8hXo7e1RP7JDhiaezWBQ7wNrT/qD30qZnkBh71Z0pQR 9HaLTxPBqkDc0XNtNKoFZp+gk18V3kYA/clFSFkePdKk9b0Jnr6vHKKrnXmY5aTli662 OJd4zr2N3TmKmnVSfWjM0RUp5hlt45Whr4mfdGZnUU8NmZ3nESe3KAIcWyxxy86x1yRx RNoqhzxySkiLdrNjvqVKU9L2+BIO9rDvfF17ymXUZMDeI3BW44xauqgPeHpxOjUPdz+7 dLTg== X-Gm-Message-State: AOAM53063PAYE1Bazt6xXDE5Vy/sgQ2RLFTey4TLDsVBqFIE3o/nL+Y5 6Lt6dT5PBfkvr2WlgCnF0RvRPvUEsFBupg== X-Received: by 2002:a17:902:f70b:b0:14d:643d:9c99 with SMTP id h11-20020a170902f70b00b0014d643d9c99mr22154719plo.18.1650478013067; Wed, 20 Apr 2022 11:06:53 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 32/39] util/log: Rename logfilename to global_filename Date: Wed, 20 Apr 2022 11:06:11 -0700 Message-Id: <20220420180618.1183855-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename to emphasize this is the file-scope global variable. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-33-richard.henderson@linaro.org> --- util/log.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/util/log.c b/util/log.c index 491a8f97f9..b3f79deb6c 100644 --- a/util/log.c +++ b/util/log.c @@ -34,7 +34,7 @@ typedef struct QemuLogFile { FILE *fd; } QemuLogFile; -static char *logfilename; +static char *global_filename; static QemuMutex qemu_logfile_mutex; static QemuLogFile *qemu_logfile; int qemu_loglevel; @@ -151,8 +151,8 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, } } - g_free(logfilename); - logfilename = newname; + g_free(global_filename); + global_filename = newname; filename = newname; if (logfile) { @@ -161,7 +161,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, logfile = NULL; } } else { - filename = logfilename; + filename = global_filename; } #ifdef CONFIG_TRACE_LOG @@ -173,9 +173,8 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, * In all cases we only log if qemu_loglevel is set. * Also: * If not daemonized we will always log either to stderr - * or to a file (if there is a logfilename). - * If we are daemonized, - * we will only log if there is a logfilename. + * or to a file (if there is a filename). + * If we are daemonized, we will only log if there is a filename. */ need_to_open_file = log_flags && (!is_daemonized() || filename); From patchwork Wed Apr 20 18:06:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564009 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4421912map; Wed, 20 Apr 2022 11:41:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVI71FjAsp2IU6VqXuWOYjKOq8VC3CHXvYA9WGPxV7/h07fTPHWKyZbrKpoe6eAaZCXMyE X-Received: by 2002:a81:8382:0:b0:2f1:57ee:7b85 with SMTP id t124-20020a818382000000b002f157ee7b85mr21631639ywf.194.1650480066205; Wed, 20 Apr 2022 11:41:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650480066; cv=none; d=google.com; s=arc-20160816; b=eN+FmkHWd+FKiKbP37t3fJIk5kN3YtyYd2Bzdi6uYkx5qxUdRG3uWjydEZ1TvKc/yr wpeFuv5iQ3WUNyQxq73MNxFh0rSPlkY/lXCiFUrjESVEXwy1hxhal+avjqTksmi6sJnj RaKDZy9DDa/3ZhHApKdoTt4B2lTJjps/6qkRJ4D9PjGfCbH7H74yv9RV33vAH3CVQquJ qGr/XzZ4NvoCIOgTgU2HDkDaVAmXuaP2SN3Cnm3gMsL2ZlLmZbd+47PORA191vFo+Wta vwH5Tjz7J8k/CqwY29eSWZ+jz76DKHhltSp3AALMA7fsjpOXyHUBNoUUkN5vXwJWFqvV CLWA== 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=wXQZPorOYiPb8USNYQC2Il4MeLE5umHkixP2P9sGTQU=; b=evJhVjMeDsXzXeEiVeP3VJ9Id1pPQRlRjsoHDGLcBfI/h7lAOMW9aWl7troR+9bOoF /xVrP5thROEQWjmsvH5+u0YGGl8yEr12oGgQxnUkaRU32zdHvcVkwxcxvOo71kAhKAJj oeDldYf+wr0I4VOFdCPRiZrBPzzjRn/jpLBhgn36VDMb1h4c40CUtG43PuF1xSD+l1nM m6MDcHuF80Xp842Pc6qqlzwh2ABdkh4ElBBP2v8QC4tRd4pjTBaRbJEb3jCAXwAXGccF /qy3df5B1HGfAVz1E9Zd5E8iZo52V749Y2LQF5l5iZ7tlXCPpxbRjfJJXmR+yAX4muNC D1gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZKttw674; 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 v131-20020a254889000000b006453aa0793csi597923yba.123.2022.04.20.11.41.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:41:06 -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=ZKttw674; 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]:34250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFGD-0006Vd-KT for patch@linaro.org; Wed, 20 Apr 2022 14:41:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjA-0006UJ-Pa for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:56 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:36624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEj9-0001NI-66 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:56 -0400 Received: by mail-pf1-x434.google.com with SMTP id z16so2690854pfh.3 for ; Wed, 20 Apr 2022 11:06:54 -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=wXQZPorOYiPb8USNYQC2Il4MeLE5umHkixP2P9sGTQU=; b=ZKttw674b1WA6JSU/S96TnKiSGV1KZbXKOdB26pr/v8PMB/cMd3zDhzXjge2QApLKj Ad6NAWLCK8i2mphc68gia8VrrpiWr+We2DLcNYDQNmViDmdM4wLoujd6oLe1kbXjxetL N8JAjXFo6ipHLh+USnyrfsLC+c+oPNnAF+7oH75cgdCS2yiHjY5PcmrCCO0nj/77c9m+ chtaTr5et9HPYT3K4E3WoAjHEO4SrwY5QqIVGSudhRjqAjtpx5eoP5LivuNnnNLasMtq I2I+bv0vE0uPKgGndeKU5GZ2EMJQawW0EVQStaxJzObFC7jM4LzF82uKK4LEm3rBIYSv FAog== 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=wXQZPorOYiPb8USNYQC2Il4MeLE5umHkixP2P9sGTQU=; b=fr72lBtecZpePwXSmZ1I6Zjv6448T3DKAes7JWpzNePVe6eRhdyfNDVjdC3qJ/cxTm mOVtgpvqcrXmOhRLAm7ALyFBvTVYO3kUMAUAy2da6XTWvIqPslUjotC0JTm9k3dJ/sXS quRyfK6efv0UCKvNgLWUUfgachjAmgwaSECTLqMv7wV7AUzdk/sfPUgbQc0qs769E1o4 /s+NOBAYJ3FArvsNehlLh525IRweBrYW99QpJBf6t5jpi+kF6t52JhM8wvKQAOnkHcXx SAWFW9whcinMWOBshLp3IFrLpVHV9gaUWSzrB21OJK2F8EUc04aVUSBj0qD9xAi6bBxD YqHw== X-Gm-Message-State: AOAM533o0N6mxGFwlwWDfSp3Zx7s74uPWx1bhahCydLOPm9sTFGQJyPr LYYRCbxTNVpSMStlW+t4oOarG1Nigy5PRw== X-Received: by 2002:a63:fd43:0:b0:39c:d17a:62af with SMTP id m3-20020a63fd43000000b0039cd17a62afmr20380443pgj.450.1650478013920; Wed, 20 Apr 2022 11:06:53 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 33/39] util/log: Rename qemu_logfile to global_file Date: Wed, 20 Apr 2022 11:06:12 -0700 Message-Id: <20220420180618.1183855-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename to emphasize this is the file-scope global variable. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-34-richard.henderson@linaro.org> --- util/log.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index b3f79deb6c..425f0064b0 100644 --- a/util/log.c +++ b/util/log.c @@ -36,7 +36,7 @@ typedef struct QemuLogFile { static char *global_filename; static QemuMutex qemu_logfile_mutex; -static QemuLogFile *qemu_logfile; +static QemuLogFile *global_file; int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; @@ -44,7 +44,7 @@ static GArray *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) { - return qemu_logfile != NULL; + return global_file != NULL; } /* Returns true if qemu_log() will write somewhere other than stderr. */ @@ -54,7 +54,7 @@ bool qemu_log_separate(void) bool res = false; rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); + logfile = qatomic_rcu_read(&global_file); if (logfile && logfile->fd != stderr) { res = true; } @@ -69,7 +69,7 @@ FILE *qemu_log_trylock(void) QemuLogFile *logfile; rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); + logfile = qatomic_rcu_read(&global_file); if (logfile) { qemu_flockfile(logfile->fd); return logfile->fd; @@ -124,7 +124,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, QemuLogFile *logfile; QEMU_LOCK_GUARD(&qemu_logfile_mutex); - logfile = qemu_logfile; + logfile = global_file; if (changed_name) { char *newname = NULL; @@ -156,7 +156,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, filename = newname; if (logfile) { - qatomic_rcu_set(&qemu_logfile, NULL); + qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); logfile = NULL; } @@ -179,7 +179,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, need_to_open_file = log_flags && (!is_daemonized() || filename); if (logfile && !need_to_open_file) { - qatomic_rcu_set(&qemu_logfile, NULL); + qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); return true; } @@ -210,7 +210,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, logfile = g_new0(QemuLogFile, 1); logfile->fd = fd; - qatomic_rcu_set(&qemu_logfile, logfile); + qatomic_rcu_set(&global_file, logfile); } return true; } From patchwork Wed Apr 20 18:06:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564007 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4421136map; Wed, 20 Apr 2022 11:39:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+W9xuRMbd2W5jBVkNCr/wjMJr8dQA/5zXWHzJTKw1NqVTWMvPhaNRihrxK4bId9SpOa1P X-Received: by 2002:a05:6902:1547:b0:641:fb0b:4830 with SMTP id r7-20020a056902154700b00641fb0b4830mr22229611ybu.175.1650479993349; Wed, 20 Apr 2022 11:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479993; cv=none; d=google.com; s=arc-20160816; b=ieg1U+lLzCEWoVt32cbSCU6WC+c7sVZkSIttPe9DKVfZCyMI5KATKOIBiV0dc+LbHI +VM8I+5GvtoHWvjrF5Ze+HQaKfqooBmgPxgwfTG9zPX4H6dMRgdduT2nAW/LOfy2sxad nh5sXBm+qU4ztl0tyxtp3+lKv1xcJjgbAv3X1DhiAatk0o8QYdvF+U+DFRqKo0Xco694 w5jZFO8T3OsGlfqTkAcDteLVD1NFHZgGgrWEngCDH8iR9oL2GEdRXZMDUqUWlcdNKfzB 78RT0ESTvGmIVW/ngUsWsrRW/L7n1o51RKQO8qqySuCdlaYAB3PgeljDBqKdRteAe+iZ eSjw== 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=wMWj7YM0nzYagMh7eETc1VXY8wfINhxGbhd+jW17juQ=; b=sH5WuXNIxCX5x3LrgI9xgff+AgAdDnUKVL2YV2FscupkT1p3FOMrE5sYZTY0GFyaqj WDf5PiyLk0c80zPXnNnK3rQGW3wLR9KtJhRZbFY63Qy0hmncTLycrjiGZu1aYaHeA1EL CZ7JMlnay4Ax4isfkHv5nf5EYomdkAsYmIwx9L7h6mVyY1IhnsGQdeKydNZKl2FvfCjA C/OC1gqek+ROHGQJVJnGicatafuyVbmQ3l7VAuasIwk9xRyWSBkqfvrt0cM7XU+gweM6 A0uLsyzmeFdKL7s0phaBtMFKXFu/4bE5QGzbBbyH5FaAVBn+E5oaS+v2O58pHpA00XhJ ngJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=puHKylPI; 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 x132-20020a81638a000000b002f1d125a64fsi732661ywb.276.2022.04.20.11.39.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:39:53 -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=puHKylPI; 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]:58820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFF2-0003yS-Sp for patch@linaro.org; Wed, 20 Apr 2022 14:39:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjB-0006X8-P0 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:58 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:51789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjA-0001NS-6n for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:57 -0400 Received: by mail-pj1-x1033.google.com with SMTP id bg24so2682596pjb.1 for ; Wed, 20 Apr 2022 11:06:55 -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=wMWj7YM0nzYagMh7eETc1VXY8wfINhxGbhd+jW17juQ=; b=puHKylPILerUTc4djNeXItly9Glyr06soqRqdfpgM0+SgYlytr0c7F7gsJUhyrWVSj JhnjvzewVYDJ8Oa8ODOKKeRtYtQdHqMa/5MDymdhgVVHdUVcbzVIX5xxrlwjV5EmFLbe IOnK7IGnVkBPrK3eTRI9eOQLLikOo5cfhAUAvnzsfVpXqEU5szMUtXsoIdBBCp2kJkYv k4ZpWfzwHasev7zIfRIRhxwvC3zNunk+ABTMLIuVIb1eFr5FwqG7okjl+00zIUI1zfTO N5Pc6WSsYjVDSy7+H/y+lvZhuaFzJWWK6Y+2rUaMvjjvh/GVxVCCwDOPqrnAIjQWbLjM SKHg== 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=wMWj7YM0nzYagMh7eETc1VXY8wfINhxGbhd+jW17juQ=; b=mgcDuS3WQLE6SqzrzeeU3x/dGaiQBvU4e/rp735xwvUlNLLahe/CXmPLqe9sMM4TKE mTJaeWK7qZSfo6wj2An90bdQu71ZNpeVx6DaOC9t7QQs0PxKuuco84KXh0eQyADONvrH 5ZaZJKVPBeID5Fr8kREXx0bGm+gACJxa/RVlzmPaEiTqYnbSFclEHuWWvjRTLrLdKqAE 4r1eKvrxySMEBY2ZqbjFoUMbTAJqOOoYTQgR9juzh3pAsR7H4CK/UBvLXqAzj08We47O BE+zeS6YlxDgNdlQCMJwYbb2iLCckvFCMH17nifhXQ9nfsaTIdXl6Dsaxl8tJL4dLGzm mndQ== X-Gm-Message-State: AOAM533FwPnXvIv+jWGfwgrSoCib3pfP4bBqZZczTbS3K/PmjOp0ZTne 162no6RNhPatVghmKXjfojecPmVBykVxpw== X-Received: by 2002:a17:903:20f:b0:158:d86a:f473 with SMTP id r15-20020a170903020f00b00158d86af473mr21699968plh.92.1650478014908; Wed, 20 Apr 2022 11:06:54 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 34/39] util/log: Rename qemu_logfile_mutex to global_mutex Date: Wed, 20 Apr 2022 11:06:13 -0700 Message-Id: <20220420180618.1183855-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rename to emphasize this covers the file-scope global variables. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-35-richard.henderson@linaro.org> --- util/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/util/log.c b/util/log.c index 425f0064b0..bb201664ac 100644 --- a/util/log.c +++ b/util/log.c @@ -34,9 +34,11 @@ typedef struct QemuLogFile { FILE *fd; } QemuLogFile; +/* Mutex covering the other global_* variables. */ +static QemuMutex global_mutex; static char *global_filename; -static QemuMutex qemu_logfile_mutex; static QemuLogFile *global_file; + int qemu_loglevel; static int log_append = 0; static GArray *debug_regions; @@ -101,9 +103,9 @@ void qemu_log(const char *fmt, ...) } } -static void __attribute__((__constructor__)) qemu_logfile_init(void) +static void __attribute__((__constructor__)) startup(void) { - qemu_mutex_init(&qemu_logfile_mutex); + qemu_mutex_init(&global_mutex); } static void qemu_logfile_free(QemuLogFile *logfile) @@ -123,7 +125,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, bool need_to_open_file; QemuLogFile *logfile; - QEMU_LOCK_GUARD(&qemu_logfile_mutex); + QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; if (changed_name) { From patchwork Wed Apr 20 18:06:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564010 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4423585map; Wed, 20 Apr 2022 11:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX2I94DVFqzgx/FONhyD9cwLnpBdX+LAVdCibWTpLO0+m3A7rjukqm4cksE0BNDECKVwY8 X-Received: by 2002:a05:6902:103:b0:628:3eb4:a6cc with SMTP id o3-20020a056902010300b006283eb4a6ccmr21158444ybh.4.1650480210878; Wed, 20 Apr 2022 11:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650480210; cv=none; d=google.com; s=arc-20160816; b=RPE3me3Eff5AcLUzUq6WzQ6NS7w+CEX6hu/sHufdb9Ivfp8cQDjkwOCkXKWvQiHMfl aFsefFjaZfNzY9Rbrpj3YK3U9fkIFut9h9uPVsDsSRhkMrXVXEK40LI7DQH1w0HjVNlR wAVlmu0ArjOc54ri9klhFoljHeOF2j4A4gnQzBSctrxRgPjU7STll6Abuf9C6mwJx5MX 8NesiS7PPAvZ3DHhKjKf0oLs+nPMti1oWh0wZSsrQ5tliSk8Fe2LeFOO54oU4XpgR8hE 529Dy5Ta5WcyOgayEJ6DkRYD72vKGWzgD7+ot0XO4dMg5ffhM+CkyuxkvT/bffJRwpl+ 785Q== 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=2MVQ6oRvGvxSZhPXXz6BFKR1T+po8XlGuK7eE+lEBHY=; b=IuR+3Hp/JiAcAJPWCX0dGflZaizedG8OtkjEw9EUJ7ClYb9x6OIGAposGR5lMNEVe/ MEBrpfe625oTOBjxfeA83Sn5n8MAOKM6S1kFpFEEy8dLEOS4CltdQpXU13REQX1pDSdQ O6FHoempEyVfaYSPDqAWXe5dVgP9pns5s7Gh5Oy8GLqTTgrQNdj30LS6uexjZZS/IMlS A40fktkEfs/SAO4NRLjg6a/xHv+q/rw3Uq4k1dCsJJFOJzc31UEhrxCtUnoN0im+f7Y+ P4nrr1pcCmVbYtCTXzitpjWZXUu0S8wgGy1INF2K6Qb4YeOQujtZcu4eneaHc0zeXT4a OrZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eLiEo58Y; 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 131-20020a250389000000b0064546fb1d85si788179ybd.611.2022.04.20.11.43.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:43:30 -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=eLiEo58Y; 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]:39094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFIY-0001I6-Dq for patch@linaro.org; Wed, 20 Apr 2022 14:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjC-0006Y9-Ey for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:58 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:36648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjB-0001Nb-0W for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:58 -0400 Received: by mail-pl1-x636.google.com with SMTP id q3so2524860plg.3 for ; Wed, 20 Apr 2022 11:06:56 -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=2MVQ6oRvGvxSZhPXXz6BFKR1T+po8XlGuK7eE+lEBHY=; b=eLiEo58YBAd+F7BfF6M1murFbSsCh2Ga7+QSuFrvO9joYjro79ToBkPJfpZ1QfeV9K AR4vKz+UyFKBnSyctHzRUf8pJZMhlOLETTp4yvopCEXd9CWCuUzzsHX55F6dza6o6rT8 WkzuM46Wq1YYWJD7LZ92Uxhy0KNkk07BMsUnX7BsoSiR+tO4ihEgOOzqreuXtBNWZUP4 qBdZLenY3A50QMg0PvX8ieUF6WKQe0p5sPiCSRjHpsAUmkiS5aC+UY4AkMAk8eoM8ZDY 6p9B9jH7pYzSiAH49ZUjI0glGTR44h5bhnsSalafJVNbV5KClhuZIFBr1TEgT8PcGerb HkaQ== 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=2MVQ6oRvGvxSZhPXXz6BFKR1T+po8XlGuK7eE+lEBHY=; b=o4Wl0MWe/8ZtYznAN+HDRVZg3T4FF0Wxs8eyREkhghO7qmPDnNRjcw2iTj0yJ3lJZf ahe4iUw5p3GqBWiK8WrDbeb8gVVqeRfYRHxf2g3gaAuKSifXGN77B8/O+8VvZcjc0vXC vr16HV79RsD9vI/WTjwOBggdA40f5vm41/fDAGRcghxHJ5JCf9VLNigiN8sqf+hy60dL FTVuG1Id6vXPMcYqmJkpaQ/0fC1YU47fXY8XvIDtNoyq8U+8zqV9TpHvidn7FfdKS9nT NEFjDlEkNvsl6yNJy/vDKnAwoL78QIb9cnB+RDq7MElTHmSfwperAejwQ/Gg8UBwPASo o3uQ== X-Gm-Message-State: AOAM532IM++dPp2yWeduglOxjNEZ+3JpnM656O/JJ2ujISyhlPBK7dLU QK/+R2K5xrWK+FrPc2rM+xjuGX7cn6EMcg== X-Received: by 2002:a17:90b:4f92:b0:1cd:3a73:3a46 with SMTP id qe18-20020a17090b4f9200b001cd3a733a46mr6001884pjb.66.1650478015737; Wed, 20 Apr 2022 11:06:55 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 35/39] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal Date: Wed, 20 Apr 2022 11:06:14 -0700 Message-Id: <20220420180618.1183855-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Only call is_daemonized once. We require the result on all paths after this point. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-36-richard.henderson@linaro.org> --- util/log.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/log.c b/util/log.c index bb201664ac..631856e231 100644 --- a/util/log.c +++ b/util/log.c @@ -123,6 +123,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, int log_flags, Error **errp) { bool need_to_open_file; + bool daemonized; QemuLogFile *logfile; QEMU_LOCK_GUARD(&global_mutex); @@ -178,7 +179,8 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, * or to a file (if there is a filename). * If we are daemonized, we will only log if there is a filename. */ - need_to_open_file = log_flags && (!is_daemonized() || filename); + daemonized = is_daemonized(); + need_to_open_file = log_flags && (!daemonized || filename); if (logfile && !need_to_open_file) { qatomic_rcu_set(&global_file, NULL); @@ -196,7 +198,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, return false; } /* In case we are a daemon redirect stderr to logfile */ - if (is_daemonized()) { + if (daemonized) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); /* This will skip closing logfile in qemu_logfile_free. */ @@ -204,7 +206,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, } } else { /* Default to stderr if no log file specified */ - assert(!is_daemonized()); + assert(!daemonized); fd = stderr; } From patchwork Wed Apr 20 18:06:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564013 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4426669map; Wed, 20 Apr 2022 11:48:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpOENPkZWZj8EH2stYxWdIG49zTnps15BV9NbC/8rajX4UaTdaam8LNs0k3ihXDXWutqkp X-Received: by 2002:a05:6902:1c5:b0:644:d1dc:c325 with SMTP id u5-20020a05690201c500b00644d1dcc325mr19019122ybh.385.1650480480491; Wed, 20 Apr 2022 11:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650480480; cv=none; d=google.com; s=arc-20160816; b=mLeDR7JgOUvB/jAks6v3Wx5Wkzl47FWMxwIkkxluLNsGEisdaSJRM9ygELlelemgqj mI74SCQUrEMLHMQPHbUyGy35n5+excKQ5qsyKePOlxmeJOzmkEXhk5Ynv1GTqifxqKoA uspau3qLSPz6zMmNz/Rs7PMhic+1pFzKBNmfMQPGhggUXYs1lGes5sdmm+nOACCYQZqF L33WiAnken0uwoH/6nORYdoSv7n5JVUMMaTfK30QLfXmiqbVaMKKzucRRbykRJ2qv2xD NwKhCMFRobCWEVZeEmhJRBZgHl6WECsRcN2aiWm4nl390NH0+DGU88Q9PKtoQ2vBMtol F1CQ== 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=tZ+1vNgSHfNmZ/UL/tApzON6GzdUJtNXO8p7nkeNuLQ=; b=u5EVNZ1bFVlHGXvLMPCxon1Zpy1jILDXUd9W4/cl/+yvzd13/86Pe6s5oEHOujVntf hgTCeTmbj/spJHjVdn47Ibh0+YxEN+oCoGMyqRKtD3wawmqqf8IIuE+NGRM9T7Saf1bD b7dPzViCSaNQFI0DccHlUOpwcwfBP3Vz6rMxqNLNOVToNIef/E2vxJT4X56W5vdfHD8/ Bema09Wdh5SIFqmCKnxvjjazF/+M9Vz7MtoRwS5nYTbOGkF+pfDTEqEnvcK9B/FZ9/to JEBOmhNNYdNo2F3lmbcCE3BO4Mo07TR7fRVCt5u26zke/j6ZlCZbz7sRZOF5iIOZYdFK NhFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jGCsMRja; 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 g126-20020a255284000000b00641cbcd6229si736900ybb.69.2022.04.20.11.48.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:48:00 -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=jGCsMRja; 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]:47778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFMu-0007Tt-0z for patch@linaro.org; Wed, 20 Apr 2022 14:48:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjD-0006Zu-K6 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:00 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:42737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjC-0001Nn-1l for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:59 -0400 Received: by mail-pl1-x62a.google.com with SMTP id s17so2504089plg.9 for ; Wed, 20 Apr 2022 11:06:57 -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=tZ+1vNgSHfNmZ/UL/tApzON6GzdUJtNXO8p7nkeNuLQ=; b=jGCsMRja5Gwp//whq4PO3YeQQLG5uByk77rEj5xA90IexEj9/4//4lh3/yUVBR2j/E +tYCSb2wmgV4kjWy5rL6uvqHXiTfeMSKktc8ajmuULJW0BCbsvgZufNC7ZeV0kFoHxc9 cv9JYMef4Iup6kd1Bc2m7xz2g7IZ9gvyvp7e+62YQM9juWRTFUT+ilvplUdRhlzCPFOw D/2PEe+P7ArSsgoTCwVj0zAnuP3H3I5BbXiYgvX6dqL3SLAR/UUNAC7JnXumNq5j+TiR hI9Gbcrptw4asYFoumpjd3TWDdjR59R5vIHuid3D7trc6T5Ana617WRHPLdeNDg1rUMf UF6Q== 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=tZ+1vNgSHfNmZ/UL/tApzON6GzdUJtNXO8p7nkeNuLQ=; b=JltSBxCfwSbibpiGTaFKuwz5AdB70+Rgx45bdlYo7xA6FRA/p2h0s4jCJZN0jwJvyZ vONfyxbUNTFtS627kDqSdjf+P2D9Yigm/n9pqmLtxsy/j++WaKS5tOhhPAEBBF1ebmQS o01Getxn06G4PS9wAPol0W7BA7ThjyfEXHQKDdBY+Xf4QnhlFez3U7Jje7GVWuhrU3rg i/PdDHLWHElgo7C/npRRIktJl1xdrAH964Tl0iO9FVpVE72HisLqAmeAKUxy8FMqwPXc HpjO+Cgy9In3kCkFFyoSGixPNBbHT9Q1nxXsYDLtQu2jXY0ng5PiZgk1uX/1tm6MnTxe umYw== X-Gm-Message-State: AOAM531BHPJPetioig85BRhjgUKfOZ86g7CsgabxxeShOTI2T9WgRY7D mng+J7D6m1qYqs5pMzxZ2njduR4FeDzqWA== X-Received: by 2002:a17:90b:3b4b:b0:1d2:e3fe:e1a1 with SMTP id ot11-20020a17090b3b4b00b001d2e3fee1a1mr5867777pjb.239.1650478016808; Wed, 20 Apr 2022 11:06:56 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 36/39] util/log: Combine two logfile closes Date: Wed, 20 Apr 2022 11:06:15 -0700 Message-Id: <20220420180618.1183855-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Merge the close from the changed_name block with the close from the !need_to_open_file block. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-37-richard.henderson@linaro.org> --- util/log.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/util/log.c b/util/log.c index 631856e231..21da961d8d 100644 --- a/util/log.c +++ b/util/log.c @@ -157,12 +157,6 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, g_free(global_filename); global_filename = newname; filename = newname; - - if (logfile) { - qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); - logfile = NULL; - } } else { filename = global_filename; } @@ -182,11 +176,12 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, daemonized = is_daemonized(); need_to_open_file = log_flags && (!daemonized || filename); - if (logfile && !need_to_open_file) { + if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); call_rcu(logfile, qemu_logfile_free, rcu); - return true; + logfile = NULL; } + if (!logfile && need_to_open_file) { FILE *fd; From patchwork Wed Apr 20 18:06:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563987 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4409927map; Wed, 20 Apr 2022 11:23:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxulbqTJL80zM4FnvO1wF89KS54aE3mEu2FSOIvo5Mm3F1Ay9nSR0T2RekEoGOUIwU9/SIA X-Received: by 2002:a81:ecd:0:b0:2eb:f1d0:9513 with SMTP id 196-20020a810ecd000000b002ebf1d09513mr22366655ywo.452.1650478983607; Wed, 20 Apr 2022 11:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478983; cv=none; d=google.com; s=arc-20160816; b=qiWBXEw9ibeDQrlkdnIWpOpXOgqjmOGC9HKBDFdFQ52IXnj1GCiR/LiTiZn06OjPui OZ6JW218x1AnYk09I7/KaBQO1ELx6ndqYySH89gIUfLte5zAi8kYQbBf/7wAq4T79TsC sFzN9JY/eNc//ied5K/s2rD7BBpKG2B9oHzvSPp6I/AP6tJsJoDIy91xvMVe4kK1lMtL JAilnzKSIRmrYc0nHLWOA1Mqb+SX2/8nWNbY0m7Xn7ZHITVCLa74j331N7Mn0VurWoI/ jMZNRQ6kwCroC8BeCcf8qldFzHbmTLlrIEQEhb+Dt7vDU6T6N/yPi1T/pSqkor1t/8zq TJ9g== 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=24qJPC1oFAO3Id/yaILSHNoaXDm+P/+xDRz86KIt45U=; b=JEGHmjVRCKRXub2to5oNI3w5BkM3NCpevE7r9Rzk1Txvn6RoyEX5NbrXoFutFbY4rC mH1Dyq4UW5vx1NJhDCXX4uNiL1wZKSQXfQuh7A9+LvSaWbfIj3si8zx+LX5L8gps064r gJ+woSb+jaqx7Ty6XDhvKBP0bFnTwmGboNOTZR6OqzKk2ykk4Qr9V29uxisrwsSNet0p mhj3YvdaZ62rZb1MJUVRviYTrGB5wNcoK4y73pTXIh32qzbfHfEvyokQZuXMOqgZdT3N Tu6SOmKwoThe6PnsOeBV0eXkH56OoKfXAxc+X62FP+SFCSN6ue29CzxQneRxNUJ3F4jY nAWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x0qrO7uL; 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 r14-20020a0de80e000000b002e5be453663si628398ywe.176.2022.04.20.11.23.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:23:03 -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=x0qrO7uL; 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]:43430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEyl-0007R7-4S for patch@linaro.org; Wed, 20 Apr 2022 14:23:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjE-0006bL-UT for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:01 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:43604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjD-0001Ny-AM for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:00 -0400 Received: by mail-pj1-x102b.google.com with SMTP id j8-20020a17090a060800b001cd4fb60dccso2772219pjj.2 for ; Wed, 20 Apr 2022 11:06:58 -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=24qJPC1oFAO3Id/yaILSHNoaXDm+P/+xDRz86KIt45U=; b=x0qrO7uLDZDDUgkkVsiXjRfZagK4HkX3hTzqX5/SINlT4vbvXnvIzpBMWNr+Wtjx+z C3KAWmZntYNvZNEiUdUJ0uzedCDorCIesynOFjL+/2CV2CfxXitXOT/z4nJFkSIYdtz4 /IgpNhna80UHj+QJyW9LNHx7PmBxCXxUiytrXNTh+KynHZCLElPScS0XR5dEbN+m0QOj eVcKEzIYy1D6J7OmSwLgVKEhOPsfasw7SkIStMCA9clWxF6FcB27tbTcUlwKeH14zwn8 qz1VKg0C8bfc/PvIWz+zJ/jroAteRhe1NAf5GCcG+fJaJmDNg9zopmZVRSt+EA0hGHuK dX5w== 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=24qJPC1oFAO3Id/yaILSHNoaXDm+P/+xDRz86KIt45U=; b=uDOMnfk0QWvxuzUN3E4T8JJ3XTMonpIf0VmI2GvPhJs+RDSA4kw75qFZC53WKDPw2f QFUhboiuXALbf+iihPtBgdfljSJPrNmpTeImn15pyfi9aV7yy5JPXf96SGUH682txJde ySHKZX4cxytnIATPzBJnEszfmoIbaDXWw9Udehw8FdaaJDUla5hL+fhCeueQfHpNp7OS xlG6IupVHvaN4jWT82Rv5BO4J6bqX2YT1nPSgpt/5eM1JFS35ASezZtd6Oo7g/0Wqv3N EqyInxWoKpE5Ss+Ho/pNmW0g/CUtNGYs2wtTELKFTbQHXOtmO5rOZuY44aUdNTV4+gq3 pb+A== X-Gm-Message-State: AOAM530eoiV4EtwdPoCya6gOWYMSB5Df2hqc8AeuMoJt5ItgqpD+4P/D /C+lWvN4TzQE/KgVsWXdHlAjPGCrpGyA6w== X-Received: by 2002:a17:902:c941:b0:158:f9ca:7769 with SMTP id i1-20020a170902c94100b00158f9ca7769mr16258391pla.161.1650478017803; Wed, 20 Apr 2022 11:06:57 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 37/39] util/log: Rename QemuLogFile to RCUCloseFILE Date: Wed, 20 Apr 2022 11:06:16 -0700 Message-Id: <20220420180618.1183855-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" s/QemuLogFile/RCUCloseFILE/ s/qemu_logfile_free/rcu_close_file/ Emphasize that this is only a carrier for passing a pointer to call_rcu for closing, and not the real logfile. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-38-richard.henderson@linaro.org> --- util/log.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/util/log.c b/util/log.c index 21da961d8d..eb6e85b2f0 100644 --- a/util/log.c +++ b/util/log.c @@ -29,15 +29,15 @@ #include "qemu/rcu.h" -typedef struct QemuLogFile { +typedef struct RCUCloseFILE { struct rcu_head rcu; FILE *fd; -} QemuLogFile; +} RCUCloseFILE; /* Mutex covering the other global_* variables. */ static QemuMutex global_mutex; static char *global_filename; -static QemuLogFile *global_file; +static RCUCloseFILE *global_file; int qemu_loglevel; static int log_append = 0; @@ -52,7 +52,7 @@ bool qemu_log_enabled(void) /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void) { - QemuLogFile *logfile; + RCUCloseFILE *logfile; bool res = false; rcu_read_lock(); @@ -68,7 +68,7 @@ bool qemu_log_separate(void) FILE *qemu_log_trylock(void) { - QemuLogFile *logfile; + RCUCloseFILE *logfile; rcu_read_lock(); logfile = qatomic_rcu_read(&global_file); @@ -108,14 +108,12 @@ static void __attribute__((__constructor__)) startup(void) qemu_mutex_init(&global_mutex); } -static void qemu_logfile_free(QemuLogFile *logfile) +static void rcu_close_file(RCUCloseFILE *r) { - g_assert(logfile); - - if (logfile->fd != stderr) { - fclose(logfile->fd); + if (r->fd != stderr) { + fclose(r->fd); } - g_free(logfile); + g_free(r); } /* enable or disable low levels log */ @@ -124,7 +122,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, { bool need_to_open_file; bool daemonized; - QemuLogFile *logfile; + RCUCloseFILE *logfile; QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; @@ -178,7 +176,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, qemu_logfile_free, rcu); + call_rcu(logfile, rcu_close_file, rcu); logfile = NULL; } @@ -196,7 +194,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, if (daemonized) { dup2(fileno(fd), STDERR_FILENO); fclose(fd); - /* This will skip closing logfile in qemu_logfile_free. */ + /* This will skip closing logfile in rcu_close_file. */ fd = stderr; } } else { @@ -207,7 +205,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, log_append = 1; - logfile = g_new0(QemuLogFile, 1); + logfile = g_new0(RCUCloseFILE, 1); logfile->fd = fd; qatomic_rcu_set(&global_file, logfile); } From patchwork Wed Apr 20 18:06:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563991 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4411737map; Wed, 20 Apr 2022 11:25:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0ECDpCLCklagzxZGId7wS+5LFfHscsNMogGnaw+7vsF7YoLAdns/AiCMyV5AkaJcMXaXX X-Received: by 2002:a25:2394:0:b0:641:bf9b:c5f3 with SMTP id j142-20020a252394000000b00641bf9bc5f3mr21726398ybj.395.1650479155020; Wed, 20 Apr 2022 11:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479155; cv=none; d=google.com; s=arc-20160816; b=X9atZuigD6t+GD8MkTK6dsZ1NToPKLlTKnxpIl3JSC300f3DlGCqOVteYBghSRkXsD VfLRSJ+bmgHj80AqElYCFpOmRtCfWDEuoZmgIV4MEcEr5P5mMg5EbuJwKOP7SToof2vQ iKHR9jA9fzcVDw0KxueMZMPEna7n2X4nc1f0Lq4BgZLReWkydxZf233LzjSpxIKZX7qw E/Q7IZRqa5YWmA0YhMiP78S8m1/aA4NtpP/zFwhMGIxqljtZhp+NBUVses/RS/h1rUT2 ss/aXxTRuuuoL158xcqfYvYSp5EhbSMLHxjRjX1TFalfICbJgf7ohbqLIaf6Ekyxxh25 N+Hg== 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=fQR19rVt1keBu2rrRIYBg7sKmNRFnuKf5yFDcZrxQ60=; b=nQIigJCvA6EgkUj0ysV+4Ub6W+QEVYn/3ZpchW7NVBsrpIYbhBgxHnOuwdoujsyoHz 5ATtSBuSMex02vH06qIO/NCbV9mvLQdycGyu1046QGOW5hjBnea/bd6mh+aiFuOPNc3k EApL0ELiDEYFczssDTd6gCXq6FSSwxN854CmOylFMapt1foOzUlyGrJYHQdnIswmK/7O CVJ87qF1/OHbR98M7LNbFM55+WW0/NE5CdFh2eAjKbpvm10qDchJqB9yWlFqVdgFlQRU aqyXv7P/7SP3Bi5EnxLtSfQrd0WmWkXd7MDf2+l/BmUk5xsYS7RrBTZUEUbkH+evXZ7l 8zdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FTMm8sw9; 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 f66-20020a251f45000000b00641d1e26d8bsi595009ybf.3.2022.04.20.11.25.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:25:55 -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=FTMm8sw9; 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]:51882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF1W-0004h0-H4 for patch@linaro.org; Wed, 20 Apr 2022 14:25:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjF-0006cS-UH for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:01 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:37826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjE-0001OH-77 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:01 -0400 Received: by mail-pl1-x62e.google.com with SMTP id v12so2518069plv.4 for ; Wed, 20 Apr 2022 11:06:59 -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=fQR19rVt1keBu2rrRIYBg7sKmNRFnuKf5yFDcZrxQ60=; b=FTMm8sw9osd5gRoDlSlEZGeMkHrej+ZiMxr2D9wxXS+Vj1awd6MGCtAKKvFGC7zaZQ gzPt8Nu7eCLxx2qujQ9IosE6u1uaHSXPoaNNJ+EFpl9HknZLKmO+Aj3g2xYXozZ+6y6g QipsFllkBTAH7UpqQd11XeFlKnAAA8NPQgW9dvGfvMwGFPso2HPvf6hZlyHuTb0v2Q6F 4M3tNDeFvhcCnqnC2a3ImAajNGqNKyuxIVnp5FOvNAJLOALlzGp6XF93QrVyb1qkKK0P PDHUopLxyqW5WLYY36L/Jm10+OypsVI40CgZUvUY5i6KUD2AIyPNcZDuShWnBWGf3+Ai vdzw== 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=fQR19rVt1keBu2rrRIYBg7sKmNRFnuKf5yFDcZrxQ60=; b=nPUTMxCJ2iJDZM3OBrR7kN6ltOq9fMtEtCKXmbfAnpx1fRnKzN/KJbaXyWuBJH25CL XGQCDzCz4TTzje+60ksIVsDPKBtHquVhHXWQf/IF+ISGhw6RmJ6KoGG6Nmsrqq9h1lMk 3ZKhrCLFIIGpQeJMYm3bupFeUTJCg4uXSXVdHpIZJcTMSIIW/9qj2/ND5hPdZo/SNmTk a9XTq5uSFpC8FKHejKgzM1OiTe1pozjhTL841jfNWgK/Jil4RIWcYyPnQOy/+Gm++fq1 VzF6R+LRbxWxg+qiWMohWWrcqcxAmiOuiD3Sb6EDhXwjkmoLafjR4Mlt0YSOYb79W51h zWaQ== X-Gm-Message-State: AOAM530R6v/HNTMgsVG7MVwp+vzzz6MrLiAW8Ym7zq7YZKG3BOaXFTTZ UdZcOVVHd3o3DjJdJcJY832M+aYpNLEC7g== X-Received: by 2002:a17:902:850b:b0:158:27a2:66eb with SMTP id bj11-20020a170902850b00b0015827a266ebmr22483475plb.5.1650478018985; Wed, 20 Apr 2022 11:06:58 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 38/39] util/log: Limit RCUCloseFILE to file closing Date: Wed, 20 Apr 2022 11:06:17 -0700 Message-Id: <20220420180618.1183855-39-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use FILE* for global_file. We can perform an rcu_read on that just as easily as RCUCloseFILE*. This simplifies a couple of places, where previously we required taking the rcu_read_lock simply to avoid racing to dereference RCUCloseFile->fd. Only allocate the RCUCloseFile prior to call_rcu. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-39-richard.henderson@linaro.org> --- util/log.c | 68 +++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/util/log.c b/util/log.c index eb6e85b2f0..df0710720f 100644 --- a/util/log.c +++ b/util/log.c @@ -37,7 +37,7 @@ typedef struct RCUCloseFILE { /* Mutex covering the other global_* variables. */ static QemuMutex global_mutex; static char *global_filename; -static RCUCloseFILE *global_file; +static FILE *global_file; int qemu_loglevel; static int log_append = 0; @@ -46,46 +46,44 @@ static GArray *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) { - return global_file != NULL; + return qatomic_read(&global_file) != NULL; } /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void) { - RCUCloseFILE *logfile; - bool res = false; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&global_file); - if (logfile && logfile->fd != stderr) { - res = true; - } - rcu_read_unlock(); - return res; + FILE *logfile = qatomic_read(&global_file); + return logfile && logfile != stderr; } /* Lock/unlock output. */ FILE *qemu_log_trylock(void) { - RCUCloseFILE *logfile; + FILE *logfile; rcu_read_lock(); - logfile = qatomic_rcu_read(&global_file); + /* + * FIXME: typeof_strip_qual, as used by qatomic_rcu_read, + * does not work with pointers to undefined structures, + * such as we have with struct _IO_FILE and musl libc. + * Since all we want is a read of a pointer, cast to void**, + * which does work with typeof_strip_qual. + */ + logfile = qatomic_rcu_read((void **)&global_file); if (logfile) { - qemu_flockfile(logfile->fd); - return logfile->fd; + qemu_flockfile(logfile); } else { rcu_read_unlock(); - return NULL; } + return logfile; } -void qemu_log_unlock(FILE *fd) +void qemu_log_unlock(FILE *logfile) { - if (fd) { - fflush(fd); - qemu_funlockfile(fd); + if (logfile) { + fflush(logfile); + qemu_funlockfile(logfile); rcu_read_unlock(); } } @@ -110,9 +108,7 @@ static void __attribute__((__constructor__)) startup(void) static void rcu_close_file(RCUCloseFILE *r) { - if (r->fd != stderr) { - fclose(r->fd); - } + fclose(r->fd); g_free(r); } @@ -122,7 +118,7 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, { bool need_to_open_file; bool daemonized; - RCUCloseFILE *logfile; + FILE *logfile; QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; @@ -176,37 +172,37 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); - call_rcu(logfile, rcu_close_file, rcu); + if (logfile != stderr) { + RCUCloseFILE *r = g_new0(RCUCloseFILE, 1); + r->fd = logfile; + call_rcu(r, rcu_close_file, rcu); + } logfile = NULL; } if (!logfile && need_to_open_file) { - FILE *fd; - if (filename) { - fd = fopen(filename, log_append ? "a" : "w"); - if (!fd) { + logfile = fopen(filename, log_append ? "a" : "w"); + if (!logfile) { error_setg_errno(errp, errno, "Error opening logfile %s", filename); return false; } /* In case we are a daemon redirect stderr to logfile */ if (daemonized) { - dup2(fileno(fd), STDERR_FILENO); - fclose(fd); + dup2(fileno(logfile), STDERR_FILENO); + fclose(logfile); /* This will skip closing logfile in rcu_close_file. */ - fd = stderr; + logfile = stderr; } } else { /* Default to stderr if no log file specified */ assert(!daemonized); - fd = stderr; + logfile = stderr; } log_append = 1; - logfile = g_new0(RCUCloseFILE, 1); - logfile->fd = fd; qatomic_rcu_set(&global_file, logfile); } return true; From patchwork Wed Apr 20 18:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 564016 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4429056map; Wed, 20 Apr 2022 11:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxuymebrgUmyI8N9u3I9zvUetxqmWKkh7mtOX1Eawq1tEPQEzPGN8EVBMQOhv1rQ85z0Cd X-Received: by 2002:a81:d847:0:b0:2d8:1c55:942a with SMTP id n7-20020a81d847000000b002d81c55942amr22472397ywl.260.1650480722951; Wed, 20 Apr 2022 11:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650480722; cv=none; d=google.com; s=arc-20160816; b=I9T5Py5mkQRaRRaXhbnhVzrEJf4Jx87F1K8ARIvg0sTVQL6vpfwZJHE5Q+8fZpwuIp DJQw5g/pOIBclqUCbHTWLnnyN3xTSh/d7gHpjsoFIPeL/N0fOOsfyQRYfoCg2mPLD/1a Ec/L4XRroOQTInRd0VfC4NgT92axjO3/xRIoBm1VFGKYZZHutFYqRblZGFwxvY0HUkja hiAAxxHRW+gOfUjvOltQ0vydin6KFpLELwoUPg3FZvlmrXvO+s8oXvlvjhwz2g9OLN1d cJHxOwQUYehKDXKYUPPuAIz7g+ARItIkzgA2aCQx4uS4gUFawrIgKCAVvkjKK+WsEgrw uE2w== 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=mQhWQ76a/TrHDYsD63ke8s7ervjjWME9wTXb7YGDbfo=; b=jQVW5xa9lSd8z2RaR1apX4JtXPoUDbdWq0NR3no9lxoOPB1gi9zEIgz7+gMsWsJMBH +E+mtTGOiWZJTaIuqYgrDoLpacOwwFjz/IXVOnclwH6NPts//mbz30zp68z7ONRzKMe5 iDlI3XK5yKN/ri3ldcfVsB0VSlPV6MaIhXh4JGwHL7iqUi7cLJAXoTMilqviDHhqvC3y vxIfKATcW0/0mb/nFqjDpb9W37F5FXQognTikONu8opyPjzZ0mojq05rnR5gYWZhRepf FdTZ2vxr0unwoSrY2h6GjNUOj+9wHRPHW/geTQBEezKrAn9R+GYbGLStDuvcZhZkwH1m I+BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bxiu52lk; 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 h7-20020a252107000000b0063db9bb06f7si694998ybh.258.2022.04.20.11.52.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:52: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=bxiu52lk; 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]:56266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhFQo-0004s9-Ed for patch@linaro.org; Wed, 20 Apr 2022 14:52:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEjH-0006h2-S1 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:03 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:55846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEjF-0001OT-Qe for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:07:03 -0400 Received: by mail-pj1-x1036.google.com with SMTP id ll10so2656211pjb.5 for ; Wed, 20 Apr 2022 11:07:01 -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=mQhWQ76a/TrHDYsD63ke8s7ervjjWME9wTXb7YGDbfo=; b=bxiu52lk7inKHZmg4hGYeiPfJmW54c4me4qWuW/hxU7VOuDD6/b8eoo4hUlkKsliiH w6apNV9oO2cGOIDm1r+eDuNN0sq0zcE4stv1bC6aWRkrwjouOZgquwYsx7dBPxppaeQ7 Xdayxm46Xu1CVUgxaHKT1ODjxkzweYqohHn0ppfxxBxbkxh/QiSPfo85O/5O/rr2r/Fg uyE8AsJD3U/hmdKe6o56huqzPTXpEaDI8nDfatx6dG5RRaQ9IL/fbo0bAUw2ca7flmyz aqOE749B2xwuO20ZlgfgDTI1vRJ8BpN52BIvxBoDqlIwNoRyNsspcx44ycjgF/CMku4g S/Tg== 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=mQhWQ76a/TrHDYsD63ke8s7ervjjWME9wTXb7YGDbfo=; b=sPKPrikOTE6P1hdj/LI3hSaageG018kuWtiujfrCm7MBHZ7EzygurKmCU5Koyc2/qE 4SUg9w1QQpRCR4p+IMAstUx8sViPqrm5GVsX+89/xfBbOobKjUnWiq1p9SzVBG91exu1 hNBOCq4AEQXQ17OFI/Ggzqsz9XDovWWJRovHp+EjImN8NWvNgC9VPbuP8UCdyoF4BOCU q55XB/fG/NKzjuTfoi/nSnXnmmt8Nk/h0nYrCVwMPkXoRGBvuEzpwC5ViO+8xPqkyEFt nnn/aMRzi2KBRZC0LxZltakpigwkm63BtiU7jrt2razIl94bO/5QkCx+BoqP7xaKJJoD Wllg== X-Gm-Message-State: AOAM533dPeefRn2U55W1uDFedRa+L4EPYXi0VcXR6i4UagApqNm1gjmZ hnaDYUpGb1I/Uxj+uYk29oHNpK5O/LvJvA== X-Received: by 2002:a17:902:d64a:b0:158:9521:2d1a with SMTP id y10-20020a170902d64a00b0015895212d1amr21727515plh.80.1650478020299; Wed, 20 Apr 2022 11:07:00 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 39/39] util/log: Support per-thread log files Date: Wed, 20 Apr 2022 11:06:18 -0700 Message-Id: <20220420180618.1183855-40-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Add a new log flag, tid, to turn this feature on. Require the log filename to be set, and to contain %d. Do not allow tid to be turned off once it is on, nor let the filename be change thereafter. This avoids the need for signalling each thread to re-open on a name change. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-40-richard.henderson@linaro.org> --- include/qemu/log.h | 1 + util/log.c | 163 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 128 insertions(+), 36 deletions(-) diff --git a/include/qemu/log.h b/include/qemu/log.h index a325bca661..c5643d8dd5 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -34,6 +34,7 @@ bool qemu_log_separate(void); #define CPU_LOG_PLUGIN (1 << 18) /* LOG_STRACE is used for user-mode strace logging. */ #define LOG_STRACE (1 << 19) +#define LOG_PER_THREAD (1 << 20) /* Lock/unlock output. */ diff --git a/util/log.c b/util/log.c index df0710720f..d6eb0378c3 100644 --- a/util/log.c +++ b/util/log.c @@ -27,6 +27,9 @@ #include "qemu/thread.h" #include "qemu/lockable.h" #include "qemu/rcu.h" +#ifdef CONFIG_LINUX +#include +#endif typedef struct RCUCloseFILE { @@ -38,22 +41,40 @@ typedef struct RCUCloseFILE { static QemuMutex global_mutex; static char *global_filename; static FILE *global_file; +static __thread FILE *thread_file; int qemu_loglevel; -static int log_append = 0; +static bool log_append; +static bool log_per_thread; static GArray *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) { - return qatomic_read(&global_file) != NULL; + return log_per_thread || qatomic_read(&global_file) != NULL; } /* Returns true if qemu_log() will write somewhere other than stderr. */ bool qemu_log_separate(void) { - FILE *logfile = qatomic_read(&global_file); - return logfile && logfile != stderr; + if (log_per_thread) { + return true; + } else { + FILE *logfile = qatomic_read(&global_file); + return logfile && logfile != stderr; + } +} + +static int log_thread_id(void) +{ +#ifdef CONFIG_GETTID + return gettid(); +#elif defined(SYS_gettid) + return syscall(SYS_gettid); +#else + static int counter; + return qatomic_fetch_inc(&counter); +#endif } /* Lock/unlock output. */ @@ -62,20 +83,34 @@ FILE *qemu_log_trylock(void) { FILE *logfile; - rcu_read_lock(); - /* - * FIXME: typeof_strip_qual, as used by qatomic_rcu_read, - * does not work with pointers to undefined structures, - * such as we have with struct _IO_FILE and musl libc. - * Since all we want is a read of a pointer, cast to void**, - * which does work with typeof_strip_qual. - */ - logfile = qatomic_rcu_read((void **)&global_file); - if (logfile) { - qemu_flockfile(logfile); - } else { - rcu_read_unlock(); + logfile = thread_file; + if (!logfile) { + if (log_per_thread) { + g_autofree char *filename + = g_strdup_printf(global_filename, log_thread_id()); + logfile = fopen(filename, "w"); + if (!logfile) { + return NULL; + } + thread_file = logfile; + } else { + rcu_read_lock(); + /* + * FIXME: typeof_strip_qual, as used by qatomic_rcu_read, + * does not work with pointers to undefined structures, + * such as we have with struct _IO_FILE and musl libc. + * Since all we want is a read of a pointer, cast to void**, + * which does work with typeof_strip_qual. + */ + logfile = qatomic_rcu_read((void **)&global_file); + if (!logfile) { + rcu_read_unlock(); + return NULL; + } + } } + + qemu_flockfile(logfile); return logfile; } @@ -84,7 +119,9 @@ void qemu_log_unlock(FILE *logfile) if (logfile) { fflush(logfile); qemu_funlockfile(logfile); - rcu_read_unlock(); + if (!log_per_thread) { + rcu_read_unlock(); + } } } @@ -112,40 +149,81 @@ static void rcu_close_file(RCUCloseFILE *r) g_free(r); } +/** + * valid_filename_template: + * + * Validate the filename template. Require %d if per_thread, allow it + * otherwise; require no other % within the template. + */ + +typedef enum { + vft_error, + vft_stderr, + vft_strdup, + vft_pid_printf, +} ValidFilenameTemplateResult; + +static ValidFilenameTemplateResult +valid_filename_template(const char *filename, bool per_thread, Error **errp) +{ + if (filename) { + char *pidstr = strstr(filename, "%"); + + if (pidstr) { + /* We only accept one %d, no other format strings */ + if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { + error_setg(errp, "Bad logfile template: %s", filename); + return 0; + } + return per_thread ? vft_strdup : vft_pid_printf; + } + } + if (per_thread) { + error_setg(errp, "Filename template with '%%d' required for 'tid'"); + return vft_error; + } + return filename ? vft_strdup : vft_stderr; +} + /* enable or disable low levels log */ static bool qemu_set_log_internal(const char *filename, bool changed_name, int log_flags, Error **errp) { bool need_to_open_file; bool daemonized; + bool per_thread; FILE *logfile; QEMU_LOCK_GUARD(&global_mutex); logfile = global_file; + per_thread = log_flags & LOG_PER_THREAD; + if (changed_name) { char *newname = NULL; /* - * Allow the user to include %d in their logfile which will be - * substituted with the current PID. This is useful for debugging many - * nested linux-user tasks but will result in lots of logs. - * - * filename may be NULL. In that case, log output is sent to stderr + * Once threads start opening their own log files, we have no + * easy mechanism to tell them all to close and re-open. + * There seems little cause to do so either -- this option + * will most often be used at user-only startup. */ - if (filename) { - char *pidstr = strstr(filename, "%"); + if (log_per_thread) { + error_setg(errp, "Cannot change log filename after setting 'tid'"); + return false; + } - if (pidstr) { - /* We only accept one %d, no other format strings */ - if (pidstr[1] != 'd' || strchr(pidstr + 2, '%')) { - error_setg(errp, "Bad logfile format: %s", filename); - return false; - } - newname = g_strdup_printf(filename, getpid()); - } else { - newname = g_strdup(filename); - } + switch (valid_filename_template(filename, per_thread, errp)) { + case vft_error: + return false; + case vft_stderr: + break; + case vft_strdup: + newname = g_strdup(filename); + break; + case vft_pid_printf: + newname = g_strdup_printf(filename, getpid()); + break; } g_free(global_filename); @@ -153,8 +231,18 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, filename = newname; } else { filename = global_filename; + if (per_thread && + valid_filename_template(filename, true, errp) == vft_error) { + return false; + } } + /* Once the per-thread flag is set, it cannot be unset. */ + if (per_thread) { + log_per_thread = true; + } + /* The flag itself is not relevant for need_to_open_file. */ + log_flags &= ~LOG_PER_THREAD; #ifdef CONFIG_TRACE_LOG log_flags |= LOG_TRACE; #endif @@ -163,12 +251,13 @@ static bool qemu_set_log_internal(const char *filename, bool changed_name, /* * In all cases we only log if qemu_loglevel is set. * Also: + * If per-thread, open the file for each thread in qemu_log_lock. * If not daemonized we will always log either to stderr * or to a file (if there is a filename). * If we are daemonized, we will only log if there is a filename. */ daemonized = is_daemonized(); - need_to_open_file = log_flags && (!daemonized || filename); + need_to_open_file = log_flags && !per_thread && (!daemonized || filename); if (logfile && (!need_to_open_file || changed_name)) { qatomic_rcu_set(&global_file, NULL); @@ -354,6 +443,8 @@ const QEMULogItem qemu_log_items[] = { #endif { LOG_STRACE, "strace", "log every user-mode syscall, its input, and its result" }, + { LOG_PER_THREAD, "tid", + "open a separate log file per thread; filename must contain '%d'" }, { 0, NULL, NULL }, };