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, ...) {