From patchwork Tue Jun 27 07:24:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1800456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=idjFbBvX; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqx8Q30FFz20bH for ; Tue, 27 Jun 2023 17:25:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qE34A-00080u-PL; Tue, 27 Jun 2023 03:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qE348-0007z7-Ek for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:44 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qE346-0005uI-Iw for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:44 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-666e3b15370so2540236b3a.0 for ; Tue, 27 Jun 2023 00:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687850680; x=1690442680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=31NL63ixAGpk3LIat/cuu4mWxOeI4E9qGV2see5Ihc0=; b=idjFbBvXwKV7P6RPlI168so8sDZLzjGiIJQVCwDCMs7HZdB3zGeQa3OI8//8A6aAvj teqnhcbmoNiUafp28Ju26qIOYpcefUPoyin2SD7oVfWUs8DAWayZa4Y8jmMfDZSs0ECm yXCkdwNX+AP5nYzTyl+QODZmvb6yORbin2cqyug7N2wBfDdbD2CLDIGxdUXBiZi2VL4/ O6RIq4tqQS1DY10HtVMxlUKK1Qel4vCFTPZIUE+CQbet8168d7PZTEGU2oS4Y4IvroS8 PQ+ThzvBLKdT83hwbD9HAh/2oiuP+acHHA69WBe/9pddvhCTWKYCuEW3USAmE3jGfSM0 XVhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687850680; x=1690442680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=31NL63ixAGpk3LIat/cuu4mWxOeI4E9qGV2see5Ihc0=; b=FpGSHOArQ/lVrtypZaSUCg8IiNyNWkM0eTA8bVK0sSmXk23/HYuc6pt9epmWY+i0Z9 BOHdnh8keBHSh0hVJwXH99H6VRjuFrsbLb6OX2fdvnG9SX9zn/yJdPiSVnY2Ec9A9qZW vIZSBaPRNyq8pF5zvYoJz0NjxBaYcTVaxxmMmjH3BcvJOwMuCjnbyhdsz8pH4hiRFqWb +r3XJ1CYDAskDnIFdcvCHqJu+Uu2Wh+EzJrpnT+1CgGpmUpEvtnl2N1yEkhcv5Dzhh88 c5kwVdK5Eer6Mcyx/mpeC8FArjRIkPBs6ppbb0TRscYEv3NO2P8GSn61I0dbE98Pzmz5 l80g== X-Gm-Message-State: AC+VfDwCXlM788wvDszVFcdo9HIFVcojM3eN8x/kTygaytVo6dVApHFA 8WDpJSSehEF3yN1qZ4LiR10Zmg== X-Google-Smtp-Source: ACHHUZ73oV2d4QF9GQvVihiONVEGWuZJGAQbCcbiw0ot78pW1+uN7aAkL+PyTj9rcZhrwh2z/qXNSA== X-Received: by 2002:a05:6a00:1946:b0:658:cbf1:d05a with SMTP id s6-20020a056a00194600b00658cbf1d05amr29579960pfk.3.1687850679770; Tue, 27 Jun 2023 00:24:39 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id u22-20020aa78496000000b00640f1e4a811sm3210915pfn.22.2023.06.27.00.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 00:24:39 -0700 (PDT) From: zhenwei pi To: berto@igalia.com Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, berrange@redhat.com, zhenwei pi Subject: [PATCH v2 1/5] throttle: introduce enum ThrottleType Date: Tue, 27 Jun 2023 15:24:27 +0800 Message-Id: <20230627072431.449171-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627072431.449171-1-pizhenwei@bytedance.com> References: <20230627072431.449171-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x42f.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use enum ThrottleType instead of number index. Signed-off-by: zhenwei pi Reviewed-by: Alberto Garcia --- include/qemu/throttle.h | 11 ++++++++--- util/throttle.c | 16 +++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 05f6346137..ba6293eeef 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -99,13 +99,18 @@ typedef struct ThrottleState { int64_t previous_leak; /* timestamp of the last leak done */ } ThrottleState; +typedef enum { + THROTTLE_READ = 0, + THROTTLE_WRITE, + THROTTLE_MAX +} ThrottleType; + typedef struct ThrottleTimers { - QEMUTimer *timers[2]; /* timers used to do the throttling */ + QEMUTimer *timers[THROTTLE_MAX]; /* timers used to do the throttling */ QEMUClockType clock_type; /* the clock used */ /* Callbacks */ - QEMUTimerCB *read_timer_cb; - QEMUTimerCB *write_timer_cb; + QEMUTimerCB *timer_cb[THROTTLE_MAX]; void *timer_opaque; } ThrottleTimers; diff --git a/util/throttle.c b/util/throttle.c index 81f247a8d1..5642e61763 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -199,10 +199,12 @@ static bool throttle_compute_timer(ThrottleState *ts, void throttle_timers_attach_aio_context(ThrottleTimers *tt, AioContext *new_context) { - tt->timers[0] = aio_timer_new(new_context, tt->clock_type, SCALE_NS, - tt->read_timer_cb, tt->timer_opaque); - tt->timers[1] = aio_timer_new(new_context, tt->clock_type, SCALE_NS, - tt->write_timer_cb, tt->timer_opaque); + tt->timers[THROTTLE_READ] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_READ], tt->timer_opaque); + tt->timers[THROTTLE_WRITE] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_WRITE], tt->timer_opaque); } /* @@ -236,8 +238,8 @@ void throttle_timers_init(ThrottleTimers *tt, memset(tt, 0, sizeof(ThrottleTimers)); tt->clock_type = clock_type; - tt->read_timer_cb = read_timer_cb; - tt->write_timer_cb = write_timer_cb; + tt->timer_cb[THROTTLE_READ] = read_timer_cb; + tt->timer_cb[THROTTLE_WRITE] = write_timer_cb; tt->timer_opaque = timer_opaque; throttle_timers_attach_aio_context(tt, aio_context); } @@ -256,7 +258,7 @@ void throttle_timers_detach_aio_context(ThrottleTimers *tt) { int i; - for (i = 0; i < 2; i++) { + for (i = 0; i < THROTTLE_MAX; i++) { throttle_timer_destroy(&tt->timers[i]); } } From patchwork Tue Jun 27 07:24:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1800454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=D/rKe/GJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqx8L2ksPz242H for ; Tue, 27 Jun 2023 17:25:54 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qE34B-00081N-8k; Tue, 27 Jun 2023 03:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qE349-000805-Bs for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:45 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qE347-0005v0-Mp for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:45 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-666e5f0d60bso2074980b3a.3 for ; Tue, 27 Jun 2023 00:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687850682; x=1690442682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9T2skCqD7gbOa8K9gXY5lRhjHEdGesDQeEu2J1OpYu8=; b=D/rKe/GJvjD1fhjD1M3q6RwqhYWH/X0LzkmXWJBmjMPMiUvmUzJm75j0FJAvNozd9i tpLk1wqbS5eHBAI9BVqAeioSlkFLXw2URqOD3jlXAKcfR0JChYM7R3TVG6aq8yhO5RFf VamZZmcEPl6NS6SdqHd2FAoECvnvNXpL4igbur73EnZF5aE4y6D7iCvgdzARC7IBhnoi sp2MkvxlaCBYC2jJR43H/hHdbM/lrVeNHx6+TcpSjFDebvIKW8+rDUgK2xFMhS0/ejWz 6kqJY1P9rwcnklR9ih7E5Tr3kuvIXcOO6xEX8DdPbS2RpVvDCyUuIlWGy08F4yXbyW/2 8LyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687850682; x=1690442682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9T2skCqD7gbOa8K9gXY5lRhjHEdGesDQeEu2J1OpYu8=; b=fmC5FrizSqrzLWDH7ScFWWKZ3sCNN8zEcRme6ydYZEIHqiz57fAkoJB8RNpWc83opg 3C4VSPMAelH6u3mf+mUXBrA91IvBvd9f3zg8MP6erYLCvtliGfybXcTc1T4f5UJdjHOa hcLZSA93/TKukbGxY1To2aJd5fT0qLwpBDivqQ5ni+1xfscl0d+XGOPu2Tw/9tpnclWb WqYTX5LVYJ2RSxz72VvBYrQzNFXXumXcKpwRGGSyfhAglaYncVxQB9sr7wGR/5Rk7h9M X3kIA7Kkf/i0CYj8IRfu7xbGPLtvFlHgbOOaw+44rudxWNC5q9+pKfmpx1NlTjpl4/mb f1VQ== X-Gm-Message-State: AC+VfDzBppUIQjebNi83Nv1MUO1ZlYr1dGK4REfRjP+8JdM7CQ0bAfm9 WJAtkKbwQfJjJZXYZGQZRNdsFw== X-Google-Smtp-Source: ACHHUZ5PPVWPjTUAIe70mNKSlJGJmj4QDC9ZtlF9NKHgsANELZOTBjOBLMZipdjhi7E5vMrtpv/XcQ== X-Received: by 2002:a05:6a00:1482:b0:65e:ec60:b019 with SMTP id v2-20020a056a00148200b0065eec60b019mr26281035pfu.25.1687850682538; Tue, 27 Jun 2023 00:24:42 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id u22-20020aa78496000000b00640f1e4a811sm3210915pfn.22.2023.06.27.00.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 00:24:42 -0700 (PDT) From: zhenwei pi To: berto@igalia.com Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, berrange@redhat.com, zhenwei pi Subject: [PATCH v2 2/5] test-throttle: use enum ThrottleType Date: Tue, 27 Jun 2023 15:24:28 +0800 Message-Id: <20230627072431.449171-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627072431.449171-1-pizhenwei@bytedance.com> References: <20230627072431.449171-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x42f.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use enum ThrottleType instead in the throttle test codes. Signed-off-by: zhenwei pi Reviewed-by: Alberto Garcia --- tests/unit/test-throttle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c index 7adb5e6652..a60b5fe22e 100644 --- a/tests/unit/test-throttle.c +++ b/tests/unit/test-throttle.c @@ -169,8 +169,8 @@ static void test_init(void) /* check initialized fields */ g_assert(tt->clock_type == QEMU_CLOCK_VIRTUAL); - g_assert(tt->timers[0]); - g_assert(tt->timers[1]); + g_assert(tt->timers[THROTTLE_READ]); + g_assert(tt->timers[THROTTLE_WRITE]); /* check other fields where cleared */ g_assert(!ts.previous_leak); @@ -191,7 +191,7 @@ static void test_destroy(void) throttle_timers_init(tt, ctx, QEMU_CLOCK_VIRTUAL, read_timer_cb, write_timer_cb, &ts); throttle_timers_destroy(tt); - for (i = 0; i < 2; i++) { + for (i = 0; i < THROTTLE_MAX; i++) { g_assert(!tt->timers[i]); } } From patchwork Tue Jun 27 07:24:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1800453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=dMZ5Sczm; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqx8L2R92z20bH for ; Tue, 27 Jun 2023 17:25:53 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qE34E-00082S-CG; Tue, 27 Jun 2023 03:24:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qE34C-00081s-F9 for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:48 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qE34A-0005wN-RE for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:48 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-666e6541c98so4125264b3a.2 for ; Tue, 27 Jun 2023 00:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687850685; x=1690442685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kBqk0P8ZAq/bseWj2v63OA5vbf0dCu8gI6RyFAhm6VE=; b=dMZ5SczmifPG3Z/AE4OsdO3FfB+xzMeJl9psEySF6VSreSWYfIxKQZ6j9xbWx7ft5a gouiO+tPRu/RYI5PzrRdXrEdCFwPa+neN6uc2MNkUUsCGFFmGITo5mFgvF78HcfKtIuk bQx1rOnCqxBrfpcLypcUrPUkCtec0X2xUP8u88lXxnVe/mQnurcWJ27O12c6PDLN+FWC 9TTeEdGzEcgAAcbecsV05AS5h7vMRRLI7VQCY8FCD+oP9LRc5qQpxfMuOvwouJbINYQN O8c46i2Ht2RVNPW/QvrG7Mcn6A55SVwrB+qTwhWlyZZ6Swx42fJHzaEYeerfwOcsiu1N iuGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687850685; x=1690442685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kBqk0P8ZAq/bseWj2v63OA5vbf0dCu8gI6RyFAhm6VE=; b=a9FvdJ32bkz6NP411L70tAFxFSR4yhf53hDB1XvwlBG5YBJtaBVMxm5b96f+Lcc1ae nUdGGOj9C4RtS9MKZT1eWnsFtRWESpWne+TFBFtQb0s4FEvD8GiiTUKP2hJXV0E1IbHi Geqz6mwPwyEVi2wkxoQWSf2eFXfdGQ1FQqhe8/ChTnDtqe+duwGFFL6Jd+GpPfqm0MK7 eq06yqMY9V/GAP5sja4ms1tR/cFsmUNXFE1MP842RiD8aptOiQ2JqryLT4Q+1T/6OzQZ JzZxxG9L9EMACB+ojb88aDIXnmrcndyPEJRyATGlbi5c8r8Lmr2zA1aUIt2dbsI/lDOF DqTw== X-Gm-Message-State: AC+VfDwVd1qihHlwUVR+aI5U/QOtVXWxz2gsp9d/LNYLWVyNc5Up8tBc lZCZF3YkBU83RWDLpU4As3lwbA== X-Google-Smtp-Source: ACHHUZ4N2Vj4H1uP9sXnc6Sg3hh6r+xim33RXrLEi2g9ASnuAdy6y6/XHMGf934+y5U1BoItzDLcYA== X-Received: by 2002:a05:6a00:b8c:b0:673:aca1:a0b0 with SMTP id g12-20020a056a000b8c00b00673aca1a0b0mr9137935pfj.3.1687850685437; Tue, 27 Jun 2023 00:24:45 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id u22-20020aa78496000000b00640f1e4a811sm3210915pfn.22.2023.06.27.00.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 00:24:44 -0700 (PDT) From: zhenwei pi To: berto@igalia.com Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, berrange@redhat.com, zhenwei pi Subject: [PATCH v2 3/5] throttle: support read-only and write-only Date: Tue, 27 Jun 2023 15:24:29 +0800 Message-Id: <20230627072431.449171-4-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627072431.449171-1-pizhenwei@bytedance.com> References: <20230627072431.449171-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x430.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Only one direction is necessary in several scenarios: - a read-only disk - operations on a device are considered as *write* only. For example, encrypt/decrypt/sign/verify operations on a cryptodev use a single *write* timer(read timer callback is defined, but never invoked). Allow a single direction in throttle, this reduces memory, and uplayer does not need a dummy callback any more. Signed-off-by: zhenwei pi Reviewed-by: Alberto Garcia --- util/throttle.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/util/throttle.c b/util/throttle.c index 5642e61763..c0bd0c26c3 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -199,12 +199,17 @@ static bool throttle_compute_timer(ThrottleState *ts, void throttle_timers_attach_aio_context(ThrottleTimers *tt, AioContext *new_context) { - tt->timers[THROTTLE_READ] = - aio_timer_new(new_context, tt->clock_type, SCALE_NS, - tt->timer_cb[THROTTLE_READ], tt->timer_opaque); - tt->timers[THROTTLE_WRITE] = - aio_timer_new(new_context, tt->clock_type, SCALE_NS, - tt->timer_cb[THROTTLE_WRITE], tt->timer_opaque); + if (tt->timer_cb[THROTTLE_READ]) { + tt->timers[THROTTLE_READ] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_READ], tt->timer_opaque); + } + + if (tt->timer_cb[THROTTLE_WRITE]) { + tt->timers[THROTTLE_WRITE] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_WRITE], tt->timer_opaque); + } } /* @@ -235,6 +240,7 @@ void throttle_timers_init(ThrottleTimers *tt, QEMUTimerCB *write_timer_cb, void *timer_opaque) { + assert(read_timer_cb || write_timer_cb); memset(tt, 0, sizeof(ThrottleTimers)); tt->clock_type = clock_type; @@ -247,7 +253,9 @@ void throttle_timers_init(ThrottleTimers *tt, /* destroy a timer */ static void throttle_timer_destroy(QEMUTimer **timer) { - assert(*timer != NULL); + if (*timer == NULL) { + return; + } timer_free(*timer); *timer = NULL; @@ -272,7 +280,7 @@ void throttle_timers_destroy(ThrottleTimers *tt) /* is any throttling timer configured */ bool throttle_timers_are_initialized(ThrottleTimers *tt) { - if (tt->timers[0]) { + if (tt->timers[THROTTLE_READ] || tt->timers[THROTTLE_WRITE]) { return true; } @@ -424,8 +432,12 @@ bool throttle_schedule_timer(ThrottleState *ts, { int64_t now = qemu_clock_get_ns(tt->clock_type); int64_t next_timestamp; + QEMUTimer *timer; bool must_wait; + timer = is_write ? tt->timers[THROTTLE_WRITE] : tt->timers[THROTTLE_READ]; + assert(timer); + must_wait = throttle_compute_timer(ts, is_write, now, @@ -437,12 +449,12 @@ bool throttle_schedule_timer(ThrottleState *ts, } /* request throttled and timer pending -> do nothing */ - if (timer_pending(tt->timers[is_write])) { + if (timer_pending(timer)) { return true; } /* request throttled and timer not pending -> arm timer */ - timer_mod(tt->timers[is_write], next_timestamp); + timer_mod(timer, next_timestamp); return true; } From patchwork Tue Jun 27 07:24:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1800457 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=jNtNH0fl; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqx8d3Mptz20bH for ; Tue, 27 Jun 2023 17:26:09 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qE34I-00083g-4p; Tue, 27 Jun 2023 03:24:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qE34G-00083T-O0 for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:52 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qE34D-0005xC-VT for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:52 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3a04cb10465so2997332b6e.3 for ; Tue, 27 Jun 2023 00:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687850689; x=1690442689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FRXWrqQ1kl9gX0iLfTTY+0v6ie/ntSqjODl1zUDXtao=; b=jNtNH0flxsy543WKsFhVyFawVZEfII2sBhh6HL5/mH0dtIuDxxhBGh58xxNaczBp4J Kg2bOMa8E4+nQEF0rFUzGIMP6s+PaoBT0J/aSrRCIwSYPlI91jUUbw3sZ3vPQkcSf6yn B4Feap7/mQD9z7Cp6SQx2ipcWWXM74GFThUNjlkF3L+SV1DiqTX6E64sgBcTIfiinPjm dB/lbEEt+SRoyDeNkXcxJv0bd8WchIQwbiEQQYm6O8mxACIqZNUiZ8ZT5yesFEfa2gYK yo0BmbUIAEa8eK5hg9Tm3qRO83Cl2Tn1P3FbXekZu30NbyEVRRpdDcEXUrKytn+f1RuN pZbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687850689; x=1690442689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FRXWrqQ1kl9gX0iLfTTY+0v6ie/ntSqjODl1zUDXtao=; b=c9oeu3Z4zR+fWCal87qrXZv/71qXQThuGGGUXzz3FqBKxjg081sg4yEDYvCi0Ry+Ws nxIfAKp5ZLXpoqqN70Rgff6ILeBKLz2cQerouLhdsRqdIrAJ8RsLkmN4jTnpWSygVREn BwW1VCuCnnEgwYQ0m1iFL33PW/KF3SmP+W6AAtZHXZpzTPLIavvdqL8w7q4JPQ1okWf2 zDXbdHlhhtGAXh1GumjLPPNdq0Nrisagda9AiId/GirmubeDzTW/r5fUFQY8mZQrEG2v HbkUv5QMlIXLA5FGbAc1c7sNpzfDBU3IhzIxHonQQEPGAYwxbFq/H2qvDxY+H+Jhfc8S w4Zg== X-Gm-Message-State: AC+VfDxXzcwUgHu88HObKvZwnB+QEKv012pxGdLVS86kyS9m/+SLaZqN uR1THpRGI5O7sn6Wgpa7K3MPVQ== X-Google-Smtp-Source: ACHHUZ5D0JWPQQNt87kZFEyFgWMYYCw2rLZcE43HmIP4J5kxQbslfNTNpjvfzIYOdkVOvHM1zHztEw== X-Received: by 2002:a05:6808:1496:b0:3a0:3929:c6e7 with SMTP id e22-20020a056808149600b003a03929c6e7mr27129342oiw.21.1687850688530; Tue, 27 Jun 2023 00:24:48 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id u22-20020aa78496000000b00640f1e4a811sm3210915pfn.22.2023.06.27.00.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 00:24:47 -0700 (PDT) From: zhenwei pi To: berto@igalia.com Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, berrange@redhat.com, zhenwei pi Subject: [PATCH v2 4/5] test-throttle: test read only and write only Date: Tue, 27 Jun 2023 15:24:30 +0800 Message-Id: <20230627072431.449171-5-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627072431.449171-1-pizhenwei@bytedance.com> References: <20230627072431.449171-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=pizhenwei@bytedance.com; helo=mail-oi1-x22b.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=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: zhenwei pi Reviewed-by: Alberto Garcia --- tests/unit/test-throttle.c | 66 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c index a60b5fe22e..5547837a58 100644 --- a/tests/unit/test-throttle.c +++ b/tests/unit/test-throttle.c @@ -184,6 +184,70 @@ static void test_init(void) throttle_timers_destroy(tt); } +static void test_init_readonly(void) +{ + int i; + + tt = &tgm.throttle_timers; + + /* fill the structures with crap */ + memset(&ts, 1, sizeof(ts)); + memset(tt, 1, sizeof(*tt)); + + /* init structures */ + throttle_init(&ts); + throttle_timers_init(tt, ctx, QEMU_CLOCK_VIRTUAL, + read_timer_cb, NULL, &ts); + + /* check initialized fields */ + g_assert(tt->clock_type == QEMU_CLOCK_VIRTUAL); + g_assert(tt->timers[THROTTLE_READ]); + g_assert(!tt->timers[THROTTLE_WRITE]); + + /* check other fields where cleared */ + g_assert(!ts.previous_leak); + g_assert(!ts.cfg.op_size); + for (i = 0; i < BUCKETS_COUNT; i++) { + g_assert(!ts.cfg.buckets[i].avg); + g_assert(!ts.cfg.buckets[i].max); + g_assert(!ts.cfg.buckets[i].level); + } + + throttle_timers_destroy(tt); +} + +static void test_init_writeonly(void) +{ + int i; + + tt = &tgm.throttle_timers; + + /* fill the structures with crap */ + memset(&ts, 1, sizeof(ts)); + memset(tt, 1, sizeof(*tt)); + + /* init structures */ + throttle_init(&ts); + throttle_timers_init(tt, ctx, QEMU_CLOCK_VIRTUAL, + NULL, write_timer_cb, &ts); + + /* check initialized fields */ + g_assert(tt->clock_type == QEMU_CLOCK_VIRTUAL); + g_assert(!tt->timers[THROTTLE_READ]); + g_assert(tt->timers[THROTTLE_WRITE]); + + /* check other fields where cleared */ + g_assert(!ts.previous_leak); + g_assert(!ts.cfg.op_size); + for (i = 0; i < BUCKETS_COUNT; i++) { + g_assert(!ts.cfg.buckets[i].avg); + g_assert(!ts.cfg.buckets[i].max); + g_assert(!ts.cfg.buckets[i].level); + } + + throttle_timers_destroy(tt); +} + static void test_destroy(void) { int i; @@ -752,6 +816,8 @@ int main(int argc, char **argv) g_test_add_func("/throttle/leak_bucket", test_leak_bucket); g_test_add_func("/throttle/compute_wait", test_compute_wait); g_test_add_func("/throttle/init", test_init); + g_test_add_func("/throttle/init_readonly", test_init_readonly); + g_test_add_func("/throttle/init_writeonly", test_init_writeonly); g_test_add_func("/throttle/destroy", test_destroy); g_test_add_func("/throttle/have_timer", test_have_timer); g_test_add_func("/throttle/detach_attach", test_detach_attach); From patchwork Tue Jun 27 07:24:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhenwei pi X-Patchwork-Id: 1800458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=T3AopUNI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqx8r5fQjz20bH for ; Tue, 27 Jun 2023 17:26:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qE34I-00083x-Mf; Tue, 27 Jun 2023 03:24:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qE34I-00083h-3w for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:54 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qE34G-0005y8-Lh for qemu-devel@nongnu.org; Tue, 27 Jun 2023 03:24:53 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-666edfc50deso2742989b3a.0 for ; Tue, 27 Jun 2023 00:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687850691; x=1690442691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7FeC1jjF+q04RZdBsWPb+IClQRx3l8j/sIEwU9Sqjtc=; b=T3AopUNIbwwfuEcLs2R34+dGeVkTA3+OYnLVFo8AssEbdEowl9724QOXyMityRd4Un Ya61/nwfEcgiZ13BsL8cq/kgW9NjScvXeXkQwk0nep0dPPIcSoUVvrWKSRns1x2WOOk3 +qj3glU4inZtyutCx04siXeOqLy1Hx1Q/kid7qMzuMtfoWUm+RWjdIMlz3ACUtyZUWgP LsN/8wFCPMIPR2e0SbLatQZH9POZp0Rq8Rc4GSpDb2b4IVEnyUkYHBE6Zdx3bL7DnfMz LVryELmuNaXGsx1p0Yx0bglnYmu+H5+ACLeZ1Wal7QuSBWmPMpMraJ41yqGju7lfhPwL Hwig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687850691; x=1690442691; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7FeC1jjF+q04RZdBsWPb+IClQRx3l8j/sIEwU9Sqjtc=; b=C4iu9hnyjxqr16SYUCMPOoYSiKfKTH7jtReQKnDuyD2YIbhvIWHi0KOCOBD/p/HRyD x4bDRNnMrUAElUt2UjYquoqU5Gx6W36KCyWSqwOGGm/rtG9/mMNRlqeBmmRg3/Iu2i9D GbS4p1X8rjJ38iC67He9ISEYTmoLJIzRI/1/Pf5RMXm4WZP4MgoS6GklXbHX+B35l2Kn SqnzsG3iYGWRQbLFoGGu9kCKZMjhyjPuFpOY0jt43wFrzy6AMNJIrwg47EdODgdS/Tyv XsKfU5jBw7eEp8wLXZOztmpMesSudvVRrwkY7kmo3Mclky0pg7joOL+5ljAOseuHuo0h t8Aw== X-Gm-Message-State: AC+VfDy2tQr7zPC4m7Ouh91A93RaKFa0PakX2yWicGrKJHzd//E4W0cw nwuhmvifoywL1RMPtLrnNm880w== X-Google-Smtp-Source: ACHHUZ6Occy9V5lI2I5EPzsQaPBfEGgBPBDWpThbFMgh1DB6M9OdECYnHNZAvNdWLQJaNYjSAOtOhg== X-Received: by 2002:a05:6a00:300e:b0:67a:8ed:cec with SMTP id ay14-20020a056a00300e00b0067a08ed0cecmr4832331pfb.2.1687850691362; Tue, 27 Jun 2023 00:24:51 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id u22-20020aa78496000000b00640f1e4a811sm3210915pfn.22.2023.06.27.00.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 00:24:50 -0700 (PDT) From: zhenwei pi To: berto@igalia.com Cc: arei.gonglei@huawei.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, berrange@redhat.com, zhenwei pi Subject: [PATCH v2 5/5] cryptodev: use NULL throttle timer cb for read direction Date: Tue, 27 Jun 2023 15:24:31 +0800 Message-Id: <20230627072431.449171-6-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230627072431.449171-1-pizhenwei@bytedance.com> References: <20230627072431.449171-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=pizhenwei@bytedance.com; helo=mail-pf1-x435.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Operations on a crytpodev are considered as *write* only, the callback of read direction is never invoked. Use NULL instead of an unreachable path(cryptodev_backend_throttle_timer_cb on read direction). Signed-off-by: zhenwei pi Reviewed-by: Alberto Garcia --- backends/cryptodev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 7d29517843..5cfa25c61c 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -331,8 +331,7 @@ static void cryptodev_backend_set_throttle(CryptoDevBackend *backend, int field, if (!enabled) { throttle_init(&backend->ts); throttle_timers_init(&backend->tt, qemu_get_aio_context(), - QEMU_CLOCK_REALTIME, - cryptodev_backend_throttle_timer_cb, /* FIXME */ + QEMU_CLOCK_REALTIME, NULL, cryptodev_backend_throttle_timer_cb, backend); }