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; }