From patchwork Sun Jun 25 08:56: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: 1799488 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=GzHtAzC1; 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 4QplHn4nfvz20ZF for ; Sun, 25 Jun 2023 18:58:13 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDLY7-0003Jg-2n; Sun, 25 Jun 2023 04:56: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 1qDLY4-0003J6-RZ for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:44 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDLY0-0006nP-Or for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:42 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1b7f223994fso5916305ad.3 for ; Sun, 25 Jun 2023 01:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687683399; x=1690275399; 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=NHwZXAIUjz71eo/wFLaIVEbGhwCrrzSAD1wFSJ5bs3c=; b=GzHtAzC1d9EOjRv4s9DZy/8xrOST4W83P6TiBfX8c08/qP5vugJ5yqfBukon/fv85C tQdWHGTa0NfwuqqDrdAm9uvsT0Mr0n8XeFaz2zYAcRdmq/lS5SePgnQ5erC/85Pm2Vu+ dvP6p0g33Tgbk7reiHLbTtpKOaAy8gRL/eKEfj24vTk7nd2IgJML9rhOQVv4HJmgVekp ReThB6yhycg4RIZ47GFg9eA19M0hLM7R9gYrBj4L+6V5oWr7G6wFgTTASHrXU/Ah9uiA VammEmc9dLk/0a0oG4G44nNcrBjC6EzJqKlisk1XYjWYQ+6rIGP2/nvMmr+/iRtGXfew Zwhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687683399; x=1690275399; 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=NHwZXAIUjz71eo/wFLaIVEbGhwCrrzSAD1wFSJ5bs3c=; b=DaNzzGJaCD3SmlCN5w44e06Ka5DcrDXLOrbETGMigyptWvfCiRfMAMjGF8mzAz6sCa GQR++5xsr1dOfrk3b6n7GXcxpYu2YuiUrdc+xZfQWrezaa8g2DKNd6kW3Y2corXTbIfM fiITu5tAtjf8qqZYOsfb0TN7a25HXKUTC9WBZMdJ90PMNdPMuixWrEeBSLKhpM/YT5Ob T8oEI5YD7G1SoQCbN8CZ7o/3xeTR94mFjc6npUVGJ4fzW2k+J8WvHgqp2LvKyWYluTpQ ZMKEKJGeNyIYgM45P9dSGykBIwzXVzuG5on2bR1fI5bdCQJr3/zV4ORaIgMeSMT0tnyl jtDg== X-Gm-Message-State: AC+VfDwVsm5+TXNKaBcbnyIlc/Yuez+c1MD9KK/f8d8Z24vR8LMu6b/f 4+zJb6PPpYk4rrU3lbhiotb0VCU6LfQNOZTyN60= X-Google-Smtp-Source: ACHHUZ4sTnggcVuAEPZPjGQA1wim6TgOBbs9AJ4B6BiqmSEYcnKPE041w+WcMVr4ZYqKTk6ioAaSQg== X-Received: by 2002:a17:902:728d:b0:1b0:3a03:50d0 with SMTP id d13-20020a170902728d00b001b03a0350d0mr4177939pll.26.1687683399476; Sun, 25 Jun 2023 01:56:39 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id w9-20020a170902e88900b001b1f991a4d0sm2176308plg.108.2023.06.25.01.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 01:56: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 1/5] throttle: introduce enum ThrottleTimerType Date: Sun, 25 Jun 2023 16:56:27 +0800 Message-Id: <20230625085631.372238-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625085631.372238-1-pizhenwei@bytedance.com> References: <20230625085631.372238-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=pizhenwei@bytedance.com; helo=mail-pl1-x635.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 ThrottleTimerType instead of number index. Signed-off-by: zhenwei pi --- include/qemu/throttle.h | 12 +++++++++--- util/throttle.c | 16 +++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index 05f6346137..0956094115 100644 --- a/include/qemu/throttle.h +++ b/include/qemu/throttle.h @@ -99,13 +99,19 @@ typedef struct ThrottleState { int64_t previous_leak; /* timestamp of the last leak done */ } ThrottleState; +typedef enum { + THROTTLE_TIMER_READ = 0, + THROTTLE_TIMER_WRITE, + THROTTLE_TIMER_MAX +} ThrottleTimerType; + typedef struct ThrottleTimers { - QEMUTimer *timers[2]; /* timers used to do the throttling */ + /* timers used to do the throttling */ + QEMUTimer *timers[THROTTLE_TIMER_MAX]; QEMUClockType clock_type; /* the clock used */ /* Callbacks */ - QEMUTimerCB *read_timer_cb; - QEMUTimerCB *write_timer_cb; + QEMUTimerCB *timer_cb[THROTTLE_TIMER_MAX]; void *timer_opaque; } ThrottleTimers; diff --git a/util/throttle.c b/util/throttle.c index 81f247a8d1..c1cc24831c 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_TIMER_READ] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_TIMER_READ], tt->timer_opaque); + tt->timers[THROTTLE_TIMER_WRITE] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_TIMER_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_TIMER_READ] = read_timer_cb; + tt->timer_cb[THROTTLE_TIMER_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_TIMER_MAX; i++) { throttle_timer_destroy(&tt->timers[i]); } } From patchwork Sun Jun 25 08:56: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: 1799490 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=PbgHJbeL; 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 4QplHz2gVVz20ZF for ; Sun, 25 Jun 2023 18:58:23 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDLYA-0003L4-Bb; Sun, 25 Jun 2023 04:56: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 1qDLY6-0003JO-N0 for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:46 -0400 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDLY4-0006o2-Jl for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:45 -0400 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-39ed11d6a50so1710287b6e.2 for ; Sun, 25 Jun 2023 01:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687683402; x=1690275402; 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=F0NBhtkdkVQWn6VJ4Hn5xFxABZWT2yxynQQGpDKOHM4=; b=PbgHJbeLdrDXaf1WCr6idDjMyQxyXrHWXOIbolnAYQjeJvYoTi4EU4xBPus2QYArDC CMj0AEDmIb+wyb3lWUVTe2iPWM1JWrjy/1RsyLybodzoNxIsK7jpLgVqJaQAc+luZDnO Xa9B96X6HvwiXOGQRLd1S664Q7Ou0Et9MgtjlQEqO0jM7jC272aDQafdfaczQ/dr5DjX MN/Of65qxTHq46bq6Hu5P6nwaFBqA+6hlEcC/HnHiTSCZsBWeRnVnWhEAUhvqy2tiY2R +kiyS+YlgYwWLNZaC1znejeC4X0lGR5vj6lte3tPoMKAtEhcEF2SzZSrM1b+4QHA2iCp tWBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687683402; x=1690275402; 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=F0NBhtkdkVQWn6VJ4Hn5xFxABZWT2yxynQQGpDKOHM4=; b=Wog9jEokboqpGfdmDMoPATQ3vyUvEkh/WexcgXfm6oI8be2Ea0qwcL7m15KVnHqoW1 8QPK5MUBvBqZ/Lr0rmFvQvVe0vLBmhyb2ou56P+48U9G/yZ31+vq1MC6UQzWtmvXRjoV umHH0W5uoXRwGk6s4RzfSZDF4Dj5AU0URYrCGxDq+AjWDiqEaSjStBB4XKgWMbJQv2WO wTqafI5y+/rS/vsenuPCXQNCHxepFLOJqb/BIotD9iSx+Sh37VUQmCCSRSO4MagSPRI2 uQaHDrI6D+PYs5dDBh/k34AfSQ0ny/HWZrcN38nZa8Udo70FA798UUJ6Xn3Y3Ju7kBW9 1nMw== X-Gm-Message-State: AC+VfDwWdPYR5W4Js4x8ozq3g27DciV5oufP1L1NWhf8lUPZa1TIcctk 85mpab3NCdCM2blQgOA9meJg9w== X-Google-Smtp-Source: ACHHUZ6+1NWjoeEuMZIp1pwpaeOEx1vjzOWcYYyYKc1xANYGF0zeII+e1OffHp07qQIg0IHYsEjd0Q== X-Received: by 2002:aca:1309:0:b0:3a1:c979:e6b6 with SMTP id e9-20020aca1309000000b003a1c979e6b6mr2556831oii.34.1687683402096; Sun, 25 Jun 2023 01:56:42 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id w9-20020a170902e88900b001b1f991a4d0sm2176308plg.108.2023.06.25.01.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 01:56:41 -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 2/5] test-throttle: use enum ThrottleTimerType Date: Sun, 25 Jun 2023 16:56:28 +0800 Message-Id: <20230625085631.372238-3-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625085631.372238-1-pizhenwei@bytedance.com> References: <20230625085631.372238-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=pizhenwei@bytedance.com; helo=mail-oi1-x22e.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 Use enum ThrottleTimerType 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..5fc2de4d47 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_TIMER_READ]); + g_assert(tt->timers[THROTTLE_TIMER_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_TIMER_MAX; i++) { g_assert(!tt->timers[i]); } } From patchwork Sun Jun 25 08:56: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: 1799485 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=OWW2mjZ8; 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 4QplHL6xR9z20ZF for ; Sun, 25 Jun 2023 18:57:49 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDLYB-0003La-41; Sun, 25 Jun 2023 04:56:51 -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 1qDLY8-0003KT-I5 for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:48 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDLY6-0006ob-FV for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:47 -0400 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6b5ef64bca6so2293416a34.3 for ; Sun, 25 Jun 2023 01:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687683405; x=1690275405; 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=KO+x2/TwqQvfw3CG6HNni2tR6UujcphSYLJP5Y5HOWA=; b=OWW2mjZ8KYtt1P2gV/hssgcHBZOZuPbzWzpm3TpohlKSWUTMZqHM93a0ivp80A7rsc 4Z7lr1emRy+2HNELEIa+11+lFkOgomKh+xKeXNwpq2OR3XdJtJdIIK6sLTut7a70Qov8 jQStAzXEfN//Q1U3xOvd+cZKwr4L4H9kL2Xgr0ET6b6MqTeiSVCbvsp9Pv9JRTzAq10I MI+lIL1fX6GqNsdAKEWUo6VawkNJg9EdGA+Zn32zigpxL5fafcKnKcgM/dMxVpCOiPcg unj3UQfBJf+fDnLc46FoT43Ok3Vfw3It+ZeRHzOz/3DNGqDqYOlaeJSiuo6bhh+0a3Qi fFcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687683405; x=1690275405; 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=KO+x2/TwqQvfw3CG6HNni2tR6UujcphSYLJP5Y5HOWA=; b=BtUDy4UDaMO5knJAK5qB1EehBjQyckzuApafG687D5lLWSfRsX96Zc+fIHVo9xKjGK YxU7K5GGGjLanqUPiX/yimsAovsBhbHpAbwvTWJJ9Q5uR9zlWGl/JWa+KL7/qX4rch3g 7+MefhxJF6ueeCeqnLt34l7NwFF3v8bJIh7y30SI+NJIfJBpoffc2Ym9JoWcEeo0FKIU ZjlRnli8xRnSGM9w2IStu0xOvtY+26wE5kEBKPq8UtZYUmQXu5g/UWkFRjnx5EPclsnB H9qM65TzsUSqem7v5M0MUdO7mPj0riDR25JQnEw4qApeftDextKi/ukSkeuxjwpepi+G CpAA== X-Gm-Message-State: AC+VfDzFjMiiCIY3pCfXN0MDNiLqI08pAQLPjDnODM83MLh9urIOuRWK 1LqKP79qV+9Q8h76ANikA5WMLg== X-Google-Smtp-Source: ACHHUZ49Vhdbl/YL2hiP6TA4O0r2IfcqxjK1IM5Ir9g/JwarPoqrabXKlkL/m2itimrhCZW2H2VuxA== X-Received: by 2002:a9d:7f0f:0:b0:6b6:8212:190c with SMTP id j15-20020a9d7f0f000000b006b68212190cmr10073301otq.1.1687683404948; Sun, 25 Jun 2023 01:56:44 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id w9-20020a170902e88900b001b1f991a4d0sm2176308plg.108.2023.06.25.01.56.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 01:56: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 3/5] throttle: support read-only and write-only Date: Sun, 25 Jun 2023 16:56:29 +0800 Message-Id: <20230625085631.372238-4-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625085631.372238-1-pizhenwei@bytedance.com> References: <20230625085631.372238-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=pizhenwei@bytedance.com; helo=mail-ot1-x334.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 --- util/throttle.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/util/throttle.c b/util/throttle.c index c1cc24831c..01faee783c 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_TIMER_READ] = - aio_timer_new(new_context, tt->clock_type, SCALE_NS, - tt->timer_cb[THROTTLE_TIMER_READ], tt->timer_opaque); - tt->timers[THROTTLE_TIMER_WRITE] = - aio_timer_new(new_context, tt->clock_type, SCALE_NS, - tt->timer_cb[THROTTLE_TIMER_WRITE], tt->timer_opaque); + if (tt->timer_cb[THROTTLE_TIMER_READ]) { + tt->timers[THROTTLE_TIMER_READ] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_TIMER_READ], tt->timer_opaque); + } + + if (tt->timer_cb[THROTTLE_TIMER_WRITE]) { + tt->timers[THROTTLE_TIMER_WRITE] = + aio_timer_new(new_context, tt->clock_type, SCALE_NS, + tt->timer_cb[THROTTLE_TIMER_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_TIMER_READ] || tt->timers[THROTTLE_TIMER_WRITE]) { return true; } From patchwork Sun Jun 25 08:56: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: 1799489 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=e6TJzVrG; 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 4QplHn6XxZz20bC for ; Sun, 25 Jun 2023 18:58:13 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDLYE-0003MO-CE; Sun, 25 Jun 2023 04:56: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 1qDLYC-0003Ld-CQ for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:52 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDLY9-0006pL-1Y for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:50 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1b5422163f4so18267035ad.2 for ; Sun, 25 Jun 2023 01:56:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687683407; x=1690275407; 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=/g/qKNXMsoUYUiLxUP/wb7Xh4Z40SdwPZE7/jq6+cKg=; b=e6TJzVrGGjTWbdAIS+z2uyizWcgniZc3q+jmeYnOkV/c59NBR4XCo6oIxavpoh0NgK jGxYAe/yiGFcFKDaiC5U3svZRyDnwrRL/+KAxyYu9SASExS3Ip8B35k1vIeURJ0VD1IX 8nTRJSfvF34RR7ydDxQnv0R9l1MNBermsQBK0ueYJ7s7gt5Iso9r9aGpvm9HhAc1LGEL gzz+o7EmfZ6eYAdU/U5m+IjonGgnz0SDS26ofolQ3FaJGvrzMNCWPqstX1llgopYZtJv LjZcbk6P/mELHhjsmh4d6zsWskDdMkAQN2JEdVWJ4OU9kVjCtd527GHm7FU5rDxKSx1W TsPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687683407; x=1690275407; 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=/g/qKNXMsoUYUiLxUP/wb7Xh4Z40SdwPZE7/jq6+cKg=; b=IABLMWzN6zn57J7ZSDfbNN078lG7fcX92ibSnXu7JCkySq2FyZg9SobOW3cjX0vIjs 3B8VyW99hcLk15FLueDFtKeF488TEan3BOyC/7uAExquHkq3wb3Ok3lfkP5s2g6uCfHw ny623shUaeTZhe7leGZ5/OsD3OxjSbpdn7/pJ899FHc0TCMBvaj3+JfS1kU8Zk/Kz+Kj 4KQQe9fmViHH50eay21+BR4PUiGT17D+mvJLs1vs0tR87+2SJ2QQf4n9YxEhQM35X19o D2sQu2Ug0oe5S3VvuGbaHfsxwIJy9swAznzReUGPV7qk+YnIqlJ1vU5dspCBScxeYdai bE1w== X-Gm-Message-State: AC+VfDzSJooeaU+UNFZf2LPcYPx6AQpF5fYfoy4k7SA9WqJgyks5bKD4 oRApU4ITv4qFKr3J4dZyvpwXJw== X-Google-Smtp-Source: ACHHUZ5h9EBdHvAb2sp7ZL+mLZl/PxZG1cSC0cdW+YH89UVhHC6qkt7Wlihny9EOF1pmQvMZH7CiYg== X-Received: by 2002:a17:902:7781:b0:1af:bbfd:1c07 with SMTP id o1-20020a170902778100b001afbbfd1c07mr4049303pll.57.1687683407718; Sun, 25 Jun 2023 01:56:47 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id w9-20020a170902e88900b001b1f991a4d0sm2176308plg.108.2023.06.25.01.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 01:56: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 4/5] test-throttle: test read only and write only Date: Sun, 25 Jun 2023 16:56:30 +0800 Message-Id: <20230625085631.372238-5-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625085631.372238-1-pizhenwei@bytedance.com> References: <20230625085631.372238-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=pizhenwei@bytedance.com; helo=mail-pl1-x634.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 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 5fc2de4d47..d7973980d1 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_TIMER_READ]); + g_assert(!tt->timers[THROTTLE_TIMER_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_TIMER_READ]); + g_assert(tt->timers[THROTTLE_TIMER_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 Sun Jun 25 08:56: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: 1799487 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=az3G1pdC; 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 4QplHc4WH6z20ZF for ; Sun, 25 Jun 2023 18:58:04 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDLYG-0003N1-Gf; Sun, 25 Jun 2023 04:56:56 -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 1qDLYE-0003MA-4l for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:54 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDLYC-0006q7-41 for qemu-devel@nongnu.org; Sun, 25 Jun 2023 04:56:53 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1b7f9d66812so2861925ad.0 for ; Sun, 25 Jun 2023 01:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1687683410; x=1690275410; 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=24YPfNosfleJuKPVRsv8yL1kyd9gmL1uJRfLV02ZmCM=; b=az3G1pdCNlYzaXB38/o4SQhNKBO1RpADI6rY60RwoMNYpP/4AOYyolO7zoAE/xzxeh KfdpLKnUi3aiQ9KFSqJSzuMINtXSYFEiHnXpLTCAicdoj1NCg+HRWuaNfvJf/UmG64i4 mBCgCTeIgSf9VIL/Md2bEX05f7oc4nYEkTSd7v9uMQubQ9Y9t3QSO8N1hdRD26IheeXM DsmeSazKBsph6ReHd8irp01ateraCVWMY+WTvGaT28PrnaIPIKa7S/toeBjZ+N/hCBxE fRPrWL9YsOFVXwo/tgdmaqWV/cN7xf0P75NmfcKto0BDOhYN2DYsawiXAcWisGs+bEey kVmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687683410; x=1690275410; 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=24YPfNosfleJuKPVRsv8yL1kyd9gmL1uJRfLV02ZmCM=; b=fapGWg1oHuvTaq/VOW1juWusivZjm2VRqEI4TNQZcYMgl3jPwYU79cDNvVU+TzLr8b 9AL5zXyBhTf4EUGCLvVQ5kLawS/Vwap/kezv5csR4YmdwDu9XK9p/Fvw0Go2g+3fgRJa wP2t4BZVRinHrZLtWy1dQz/RjSbHQFAwcGvbm/ApWRqqLVZ4aNz5AJ3B2liM/zStKTye ldTgJ7naBF29ybJuQaawZtU9/WxltwAA+oimvA7b2Mh+Ty7f4jf80upq2QJGLzRFGYW3 e+9+0rZ8OzIrpbbmrvxc/AifSK0z4Vnxy0NI3TBL7gqfU5BqFTixiZVPMxX53B4IPYaN kzjw== X-Gm-Message-State: AC+VfDxBKM6mYpO2Jkx/PaH3WxHbnV/qad/9sRvGqR+vDlzMm3udvlYT UNcQDmKafyzDVVgtJf/7BEOzCA== X-Google-Smtp-Source: ACHHUZ4c2n8JGRo9YUxVXN3Fxs5Hn1VwnQn+vUcv+fB7KtWB1AYo5Hwq21TTclSTh1HyXJGxsGvSRg== X-Received: by 2002:a17:902:b497:b0:1b7:f73d:524 with SMTP id y23-20020a170902b49700b001b7f73d0524mr1257026plr.43.1687683410389; Sun, 25 Jun 2023 01:56:50 -0700 (PDT) Received: from libai.bytedance.net ([61.213.176.11]) by smtp.gmail.com with ESMTPSA id w9-20020a170902e88900b001b1f991a4d0sm2176308plg.108.2023.06.25.01.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 01:56: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 5/5] cryptodev: use NULL throttle timer cb for read direction Date: Sun, 25 Jun 2023 16:56:31 +0800 Message-Id: <20230625085631.372238-6-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625085631.372238-1-pizhenwei@bytedance.com> References: <20230625085631.372238-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=pizhenwei@bytedance.com; 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: , 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 94ca393cee..19c24ccfad 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); }