From patchwork Wed May 3 07:20:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 678701 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp911604wrs; Wed, 3 May 2023 00:32:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VHF3gLqEB+Eg4IpviGYdFFGFL/oNBK7deTaMVmfjCPyXqYOnjjsnS5LwQM4CybTmTLr6w X-Received: by 2002:a05:6214:d84:b0:61b:6cf2:eaf1 with SMTP id e4-20020a0562140d8400b0061b6cf2eaf1mr4777794qve.22.1683099151815; Wed, 03 May 2023 00:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683099151; cv=none; d=google.com; s=arc-20160816; b=gQKlZOcZN4z7IhFNx5nM7ry/2R3jUX0WI79gvnbBsY5gzbMRklYVdwXG1Y6pPph0DF Xzjprzf+Ux9MpS5yFzRxwBHptPcTDuWYn08qAnxG589nXg8E3EmLN7JSfnakUh3Qg8Pe uXeUPweLCzcDhk1ythW5rTsDunvs/yyxcEVyfzmxoHEJ1pk/z1YsrUEtPk06wflh7xTb z6jDMGpw5i6AvU0TLCrg+vvMVJfIym04McU5ejMQS7kgUpIjyd7fOfjj0Ev8h6ai3qiz g+SESzpVNBywV/C/3FK/42ihHQfQfXMY6f9U5K/xYKDUSByklDa78w5hrL5ZS6AUVhHB 12HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=czFfn3mdhb3cc0K7eXA/dlkeA2fEfLq9sRo8IDRWWf8=; b=DqVrk2ykIB5YgBJXFVwylzI4SinsyAOVGvywJeMYcYFHc0mm9G6PWqCfy6LTMOQjhZ MPWwBe+V1MSHi5a4lJ0XR9zPOTJcUO5Nd3FyskW1ZImuK3OgfNtsXJZ5f9gv7e0pbuMX td4uaNGpeRIJW2QOJOnMrnBvuw5B8odZTfotHPIupY1rP7mggfqtThXKVpMtOyfXpmQ9 3DCRO99y4qQ3wHcyMpQXErs3x2FlDNdUWyeyIN+Xwykue5oui3Mg+ZQg1i0K8eVTWRlC mZ9LoGkbXqiNQPK8QK62Hv6q7xVkwkVyxATFz9W9etjX+49kw/thfYvgy1d/7onCK5S7 YoGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JtNtM5mU; 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 s15-20020ac85ccf000000b003f2309181eesi824774qta.389.2023.05.03.00.32.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 May 2023 00:32:31 -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=JtNtM5mU; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pu6pC-0007VS-0V; Wed, 03 May 2023 03:22: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 1pu6oq-0006nC-4R for qemu-devel@nongnu.org; Wed, 03 May 2023 03:22:40 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pu6oj-0007Gw-24 for qemu-devel@nongnu.org; Wed, 03 May 2023 03:22:27 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f19ab99540so46397395e9.2 for ; Wed, 03 May 2023 00:22:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683098543; x=1685690543; 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=czFfn3mdhb3cc0K7eXA/dlkeA2fEfLq9sRo8IDRWWf8=; b=JtNtM5mU/Sx4s4CCdz34ODajSonIkcNUGY8EhUAksM0OX+y9BTiFv32nCtcHPeCWYW qqeixvAUYJWK+7W9v0KQQk916okscfAshKBzqMIp8row5ExnXjzKO2S1pCbXGPOfFp7h P69xs6o8lgtcoWDmVa7naZx63u2/m5d9nUab9sN+OjhbB7nFvM79OGpufdU6bipy2Ecw isXD+pId+JzLEtXfBzQOUkKSG8/+MbNjmPKEPAM4hB9nH3sxz00NsnH8zaQe1PDl24pH vhinJAG0w7/VFSylfkngvB1qziY1PsGQcH6ZVxQA6XI+1f8RFljXwQL3Ytz7zd+XYoy5 RR2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683098543; x=1685690543; 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=czFfn3mdhb3cc0K7eXA/dlkeA2fEfLq9sRo8IDRWWf8=; b=VE6Um6XVeLsBQdKn8Z4/a9nLAlgPeQVCh16Srdj5RYqD0HhngcNq5PN9+maqFrF3i3 GZVNKV88ZKK4/HuShqQO46cQXbYNraPkASMiz+PtfNCQP17DXO0ig4iXqIjO+Sm8BWya m38tZGM7FJvwtQqmRPVxqYM21f3Co38utefK4P+8gEfDdMI9V1SSFI4IOHgicfqla0PD Kfby6jmIk4Wbo/8T8tTh3diN+mS2HNXRjauAZYlq4bvhEk524bnkKabIf9X9PDM8lrPa Ug7cQh/1B/+aSJ0k2qS4N/rzQQaA6ylGuYoX1bZFQW8gpdIGIZB2bVqXL+IxBEfBNUyb tG9w== X-Gm-Message-State: AC+VfDwJo9ZMVFh9B8Fb1H7bGBqEKAD3zEhqo/VPubSBDfrDqoQDidgO mDKnshrtN5HuOBKyDvQ13EDmx/8CMOtsStDW2XKPJQ== X-Received: by 2002:a05:600c:2183:b0:3f1:76d7:ae2b with SMTP id e3-20020a05600c218300b003f176d7ae2bmr14290163wme.13.1683098543097; Wed, 03 May 2023 00:22:23 -0700 (PDT) Received: from stoup.Home ([2a02:c7c:74db:8d00:c01d:9d74:b630:9087]) by smtp.gmail.com with ESMTPSA id t4-20020a7bc3c4000000b003f1745c7df3sm962789wmj.23.2023.05.03.00.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 00:22:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: ale@rev.ng, philmd@linaro.org, marcel.apfelbaum@gmail.com, wangyanan55@huawei.com, anjo@rev.ng, Thomas Huth , Juan Quintela Subject: [PULL v2 01/12] softmmu: Tidy dirtylimit_dirty_ring_full_time Date: Wed, 3 May 2023 08:20:46 +0100 Message-Id: <20230503072221.1746802-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230503072221.1746802-1-richard.henderson@linaro.org> References: <20230503072221.1746802-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Drop inline marker: let compiler decide. Change return type to uint64_t: this matches the computation in the return statement and the local variable assignment in the caller. Rename local to dirty_ring_size_MB to fix typo. Simplify conversion to MiB via qemu_target_page_bits and right shift. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Richard Henderson --- softmmu/dirtylimit.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/softmmu/dirtylimit.c b/softmmu/dirtylimit.c index 82986c1499..71bf6dc7a4 100644 --- a/softmmu/dirtylimit.c +++ b/softmmu/dirtylimit.c @@ -232,18 +232,23 @@ bool dirtylimit_vcpu_index_valid(int cpu_index) cpu_index >= ms->smp.max_cpus); } -static inline int64_t dirtylimit_dirty_ring_full_time(uint64_t dirtyrate) +static uint64_t dirtylimit_dirty_ring_full_time(uint64_t dirtyrate) { static uint64_t max_dirtyrate; - uint32_t dirty_ring_size = kvm_dirty_ring_size(); - uint64_t dirty_ring_size_meory_MB = - dirty_ring_size * qemu_target_page_size() >> 20; + unsigned target_page_bits = qemu_target_page_bits(); + uint64_t dirty_ring_size_MB; + + /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */ + assert(target_page_bits < 20); + + /* Convert ring size (pages) to MiB (2**20). */ + dirty_ring_size_MB = kvm_dirty_ring_size() >> (20 - target_page_bits); if (max_dirtyrate < dirtyrate) { max_dirtyrate = dirtyrate; } - return dirty_ring_size_meory_MB * 1000000 / max_dirtyrate; + return dirty_ring_size_MB * 1000000 / max_dirtyrate; } static inline bool dirtylimit_done(uint64_t quota,