From patchwork Fri Jun 10 14:26:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9169939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6BD266048C for ; Fri, 10 Jun 2016 14:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A0372832C for ; Fri, 10 Jun 2016 14:32:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EFF928366; Fri, 10 Jun 2016 14:32:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C253B2832C for ; Fri, 10 Jun 2016 14:32:35 +0000 (UTC) Received: from localhost ([::1]:41426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNUA-0007wy-TO for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Jun 2016 10:32:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNOp-0003ea-JB for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBNOj-0005fe-45 for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:27:02 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:34741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBNOi-0005fY-TE for qemu-devel@nongnu.org; Fri, 10 Jun 2016 10:26:57 -0400 Received: by mail-pf0-x242.google.com with SMTP id 66so3410936pfy.1 for ; Fri, 10 Jun 2016 07:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HWmerHK53FqTNQbH123DKe5BSRb0bKEdX/W9DQjuL/E=; b=Ps3BElpi+3mN3CRDckpjtTyOO/UB4YNTYMTbBHtkOAdPkh0UrONXv0j7EL9hZKPXne SM1toJ8WXW2M1yYjIQNpS5v6lGxya1CF/cJDD6/Q2RjJJscug2eJKc8WeHzeDw5fUswt mbSeKN+om51Fvs++m9I8OZPmLOCGAnpGaXgQQAD0QlT1WaFmKiSicbG7aZ8Oi6DYxPm/ 8Sb5AGox9PHmkFgvivkBsr8zgTrXJqpPL5MJ2wtp19nJ6Qo2KzRPhxcGWuhT+HJXjbte 48x5YSHpN/EiBS/KwKAIt3JKj5d/IYSzEXUwDTI9h+y7SBpbQLTwlgB1Beg5RfEHmsqu Yixw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=HWmerHK53FqTNQbH123DKe5BSRb0bKEdX/W9DQjuL/E=; b=VNBcK6YEq4IHhcch/fihDjpN6hNZIWLwIlbimrZt+Rvwij5pePa8PBS+/WzzQM+Ywh b3N3lox24XKQ+0T3W6yAjdIu11ulWRvu7bFvdWGv1jezIxa/o2H6EH8OjV1XHMB5SO+t 9ywhAa07qfgEJv5EnOBPdUnjRPgQH4BPWzmTSRhBQ44ILz8AMoMRjtN+s5+BotbUzt3B pEhEl9B5W8AcCYmmJ1ELEKhhkffKcgIZQHSaGVzXGCGO1dqoE/xi/HPZ8ZMRahTkSoi9 TYYO58xlCJwQpJ0VEDkA2/9FYJL1L1RBb49Us8bhOF8ZmtwwcivyT7IRbVGMIwz8vill EM4A== X-Gm-Message-State: ALyK8tJX/g7kljONhSktwhc1IW4EVYBYJoocrI6PGsFKiPOdbAUR0FwhlV6QRUB8ePWj7A== X-Received: by 10.98.24.70 with SMTP id 67mr2714725pfy.52.1465568816263; Fri, 10 Jun 2016 07:26:56 -0700 (PDT) Received: from anchor.twiddle.net (71-37-54-227.tukw.qwest.net. [71.37.54.227]) by smtp.gmail.com with ESMTPSA id vy8sm18227219pab.22.2016.06.10.07.26.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 07:26:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 Jun 2016 07:26:40 -0700 Message-Id: <1465568813-19771-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465568813-19771-1-git-send-email-rth@twiddle.net> References: <1465568813-19771-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 02/15] seqlock: remove optional mutex X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Emilio G. Cota" This option is unused; besides, it bloats the struct when not needed. Let's just let writers define their own locks elsewhere. Reviewed-by: Sergey Fedorov Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Message-Id: <1465412133-3029-3-git-send-email-cota@braap.org> Signed-off-by: Richard Henderson --- cpus.c | 2 +- include/qemu/seqlock.h | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/cpus.c b/cpus.c index 326742f..1c92362 100644 --- a/cpus.c +++ b/cpus.c @@ -621,7 +621,7 @@ int cpu_throttle_get_percentage(void) void cpu_ticks_init(void) { - seqlock_init(&timers_state.vm_clock_seqlock, NULL); + seqlock_init(&timers_state.vm_clock_seqlock); vmstate_register(NULL, 0, &vmstate_timers, &timers_state); throttle_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL_RT, cpu_throttle_timer_tick, NULL); diff --git a/include/qemu/seqlock.h b/include/qemu/seqlock.h index 70b01fd..e673482 100644 --- a/include/qemu/seqlock.h +++ b/include/qemu/seqlock.h @@ -19,22 +19,17 @@ typedef struct QemuSeqLock QemuSeqLock; struct QemuSeqLock { - QemuMutex *mutex; unsigned sequence; }; -static inline void seqlock_init(QemuSeqLock *sl, QemuMutex *mutex) +static inline void seqlock_init(QemuSeqLock *sl) { - sl->mutex = mutex; sl->sequence = 0; } /* Lock out other writers and update the count. */ static inline void seqlock_write_lock(QemuSeqLock *sl) { - if (sl->mutex) { - qemu_mutex_lock(sl->mutex); - } ++sl->sequence; /* Write sequence before updating other fields. */ @@ -47,9 +42,6 @@ static inline void seqlock_write_unlock(QemuSeqLock *sl) smp_wmb(); ++sl->sequence; - if (sl->mutex) { - qemu_mutex_unlock(sl->mutex); - } } static inline unsigned seqlock_read_begin(QemuSeqLock *sl)