From patchwork Tue Mar 12 20:14:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 779786 Delivered-To: patch@linaro.org Received: by 2002:a5d:604e:0:b0:33e:7753:30bd with SMTP id j14csp2204354wrt; Tue, 12 Mar 2024 13:16:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZB39DJh0OOcYtVNfZ/behSG1YRa3tIvASaYRaEEr5gKQYicALJKe/Y/gebZtVLRRPV9tCQ+e5Zd1kO9twRFaM X-Google-Smtp-Source: AGHT+IFRN6lWHAwaEQIR9Rx0fSOgnH4g1q6MthMu/VR9rfDeYWKz5ASA/wuwSQFBb227RhollD1Z X-Received: by 2002:a05:620a:25d6:b0:788:32cb:929e with SMTP id y22-20020a05620a25d600b0078832cb929emr1374365qko.52.1710274569153; Tue, 12 Mar 2024 13:16:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710274569; cv=none; d=google.com; s=arc-20160816; b=wmaHwOL14dIyFuHXOwBnjzkDJa4cEnARl6oTx+Z9wDffgo8fj3Ip9HnN9yKBDvecx6 lKu88yWtuo3oco+IJ5YkinxTmjfTEjouAxyTQNRL1+lXwS8BZj0xxa66dvwFWNmHDm+G m0YpLtf802NNKbxD6GVwnkLkYN7tNxHMrpwmdmDOex9bGpqu7H6RlsaIfjNdpe93AswV DIJtx2lhO5K+RCAAepLyOiFs2M2SxJi4mK7O5KPb84BQZRd+qlRtlgKVUbxVvVZKM3dT ywT7Abk6XFSbdDrVc5cyfbJDWx48JgrY/zlK7SOiVsmhq/tk+ynEA87TdG+hf5siNrKk bL2g== 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=5VoQ8jbg5bbRds0jLIlJJfwZ5fmmJeECGQ91KyYNz/g=; fh=7UWA2RRneThTkX+dTrZkoV4po8/WMFgf92effoPAD5Y=; b=Y6uuueUvfOca8Cy0RSYxo+b14lqXR2ix0VOkJ5TMWWOgspwWmpyTs1o0JLnvOTHAzv qfnloYDoAi4zgoCAaUupgyr1miSsRb7KLMfWiXBKl7/Y6uMIKa6CbHU3CF86iSjg+uDg 2vTznYHNXTKKQS5YzOWDFnKEDvpd3O2ni9+fqWvchtGM5edpXkU50GKqNCs458WXYSxY FsssOajnTZcYNqa/s+P9QjPhakjmph3TwhVEI8SQ7u1bEOVhMzqY/o41wVWjLemdagR5 +soLuGmCVW+OT1iwxQQE07tJY4fqGMuIYMbmdz1LEzYONQ7AmfW+DKd8vG4Bh1gh2QpO CqPQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rKETpona; 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 wi22-20020a05620a571600b0078842187dc3si8132718qkn.669.2024.03.12.13.16.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2024 13:16:09 -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=rKETpona; 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 1rk8XG-0001pj-Uc; Tue, 12 Mar 2024 16:15:42 -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 1rk8Wv-0001mI-Cg for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:23 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk8Wt-0001Mc-5O for qemu-devel@nongnu.org; Tue, 12 Mar 2024 16:15:21 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33e99915809so2055311f8f.3 for ; Tue, 12 Mar 2024 13:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710274517; x=1710879317; darn=nongnu.org; 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=5VoQ8jbg5bbRds0jLIlJJfwZ5fmmJeECGQ91KyYNz/g=; b=rKETponaFzRC8+kBF7YBsdIkyS5kKPzzum7bP5Y19LVOwn7nBARbw2MHzoicwA0jue iwjjTjr1Jtp7iwB3OVo4wsbqnovyx44OKihBTubA7V4BXyw1KG4vWTcNZj8Hl00SoGQB VaCY/kbSBkjQGsU3YdHIHhITZRz9gbEUsLt82P+c24Ajz6Be9fM0astTkbhxM9Yy0VX4 +bpaRUGxfAGZiSGNkDjOeffT4bBIDyZOsxGMlyaOzt/e7LOUOh0E4daogCgSNyq1dF2Y /LhPKWFjixWsPxb4aK44y/2jbUoRDZBC2ydP1LTStIEspOT6eZGVZMm9w7Cj1YKjHEP/ 0skg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710274517; x=1710879317; 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=5VoQ8jbg5bbRds0jLIlJJfwZ5fmmJeECGQ91KyYNz/g=; b=HqDVlWwjacHQuE0wZSqYrM1o5/WKsCQ9QBxl5uCkY7+XJhzXhS26tHX+RfOQJ0fX4b Bf6FF3e+1gX99B/1aQP8H/DR4s7Nvxf0qziZCNploXDhcQL+iHKQ9sHTLH3g49JB3Ucg uc0Z6sNSoZ+lcYJ7nJo/fMlMrvhY/X/v///K/ARRCEECMBHzfJjN8K0GgGb2qNa1FyN1 EBw9BW99fxnAWpckWkDIpUJKq1nzRTwiKfTiMiBLqu7MnWjvPy4wF3Ve0Pzv/9ugEpXd yWVH7+j0G1V/jOtKChEE1iuYmBbbWZu2Q3BLU/3viUIzeQkuCx1cT7GD7hgICcBrwSHt IFRw== X-Gm-Message-State: AOJu0YzCG+jVOpeYcpvXzptTr/kkMsf6grJV55T3p9sd4NNnzzJK8Mj1 rNW1Md2SrqrahUtC4CEbxUgEAsyLmE9YIgPKDL2ToXkjqvRVLVnOZ3EJtXnLPJCxUR6DGKcL+IX RZus= X-Received: by 2002:adf:f305:0:b0:33e:7f5c:7a9c with SMTP id i5-20020adff305000000b0033e7f5c7a9cmr381053wro.35.1710274517042; Tue, 12 Mar 2024 13:15:17 -0700 (PDT) Received: from m1x-phil.lan ([176.187.206.139]) by smtp.gmail.com with ESMTPSA id z4-20020adff744000000b0033e7910ae23sm9819864wrp.49.2024.03.12.13.15.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 12 Mar 2024 13:15:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: David Hildenbrand , Richard Henderson , Nicholas Piggin , Peter Xu , Paolo Bonzini , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v2 2/3] physmem: Factor cpu_physical_memory_dirty_bits_cleared() out Date: Tue, 12 Mar 2024 21:14:57 +0100 Message-ID: <20240312201458.79532-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240312201458.79532-1-philmd@linaro.org> References: <20240312201458.79532-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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 From: Nicholas Piggin Signed-off-by: Nicholas Piggin Tested-by: Thomas Huth Message-ID: <20240219061731.232570-1-npiggin@gmail.com> [PMD: Split patch in 2: part 1/2] Signed-off-by: Philippe Mathieu-Daudé --- include/exec/ram_addr.h | 9 +++++++++ system/physmem.c | 8 +++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 90676093f5..b060ea9176 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -25,6 +25,7 @@ #include "sysemu/tcg.h" #include "exec/ramlist.h" #include "exec/ramblock.h" +#include "exec/exec-all.h" extern uint64_t total_dirty_pages; @@ -443,6 +444,14 @@ uint64_t cpu_physical_memory_set_dirty_lebitmap(unsigned long *bitmap, } #endif /* not _WIN32 */ +static inline void cpu_physical_memory_dirty_bits_cleared(ram_addr_t start, + ram_addr_t length) +{ + if (tcg_enabled()) { + tlb_reset_dirty_range_all(start, length); + } + +} bool cpu_physical_memory_test_and_clear_dirty(ram_addr_t start, ram_addr_t length, unsigned client); diff --git a/system/physmem.c b/system/physmem.c index 5441480ff0..a4fe3d2bf8 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -881,8 +881,8 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_addr_t start, memory_region_clear_dirty_bitmap(ramblock->mr, mr_offset, mr_size); } - if (dirty && tcg_enabled()) { - tlb_reset_dirty_range_all(start, length); + if (dirty) { + cpu_physical_memory_dirty_bits_cleared(start, length); } return dirty; @@ -929,9 +929,7 @@ DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty } } - if (tcg_enabled()) { - tlb_reset_dirty_range_all(start, length); - } + cpu_physical_memory_dirty_bits_cleared(start, length); memory_region_clear_dirty_bitmap(mr, offset, length);