From patchwork Sun May 9 15:16:10 2021 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: 432868 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2107444jao; Sun, 9 May 2021 08:18:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyO0biwVuZkycqeClt1nFbyGAxOjhWWLk7/oJIFXxh0b5CHw/Wl/aTJkKX8DUKmu/UgyBUD X-Received: by 2002:a05:6e02:1212:: with SMTP id a18mr18392043ilq.2.1620573502176; Sun, 09 May 2021 08:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620573502; cv=none; d=google.com; s=arc-20160816; b=VLdBY028JMhvDXblZWLePFuzhwcY/qhIjtS0vwtu5rVDm/sYfTJRTkQqzaqi8gRJmu 2/yb6Bnp9DzUbgxvhoe8VbFUCthOncrEOILpcjqyVVT6jWEMoTI56Ck9bB3G09irtDGg YIoHNOOgnh8t+fqfmUR5ARvbYuaYGjkaCVWL5bJ/YyA6QmtCdmQblCt9Anplzgk7PKHY zurBNB2caqxsnVjHSSqu3ItTgDPO9vUhEgBsDnytio+Sk9xxNuuPSMZjMAB+x861SJ+I LPQOkgPtcBCJOJBFwZjY2D+By2khulzyWHLEyDgdNfZxVBjM1RMsu8R55EKAfJPBRpty mqEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=g/4SxtqNPm0E/CIeRZgN6CpYgDUnydXgvlLbsp+hewQ=; b=WmNBKwbG+TwEJ6LuyZ55cyIbhpicd/5OV1BSKQc/+UkSIpt+DOltnwgoeXkFudiZTJ bH7YbsGYX3T+ZER2JPc/v9ZSc+onb+ONwiFPBNGByAVbvgv+MEpxWjTlgoO094/qTeBp 8Pl+OfC1LQqetnk8ZkYNqeIQD4bEyw9ta2Nvo+iO13iktxKF6dBIrL9KSvpY2q3eDJkL Wn9wuKsxnZhnTo8+9LHo4eM2F2Idwah75yT7+BVZ0Kg6+u+HXrFzEk0XsFDm3AtRB/RB yismuYkJY7EgB1zvmvy266zrsI2yr81cmvDAqtV9+PsTz48Ks+BIiOL3zyjnVMUHhP2/ h7pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=g1qDQPuY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u5si7065014jat.11.2021.05.09.08.18.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 May 2021 08:18:22 -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=fail header.i=@gmail.com header.s=20161025 header.b=g1qDQPuY; 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=fail (p=NONE sp=NONE dis=NONE) header.from=amsat.org Received: from localhost ([::1]:51584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lflCH-00069Y-KJ for patch@linaro.org; Sun, 09 May 2021 11:18:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lflAT-0004uv-St for qemu-devel@nongnu.org; Sun, 09 May 2021 11:16:29 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:37885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lflAR-0005Hl-QN for qemu-devel@nongnu.org; Sun, 09 May 2021 11:16:29 -0400 Received: by mail-wm1-x335.google.com with SMTP id b11-20020a7bc24b0000b0290148da0694ffso9741702wmj.2 for ; Sun, 09 May 2021 08:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g/4SxtqNPm0E/CIeRZgN6CpYgDUnydXgvlLbsp+hewQ=; b=g1qDQPuY8atoSzlEkszcdJ+eEHA/16oyeHN3JAuilwQMmKCRQ1a49G4J/wKGEXx6ei XbrxU2p3MaOPsDCim6QTXX0OkqQZD5eok2dIKtpGdtMWWhYoBqM0yXr2H5lV3Cdcf3hj IgeK/tcwXhqRBEzFOqXIYJXxMhSe6j+U+aoWwpUd/cO4y1Ils9JaZP2usf5oUAKSzpgj sxe9gaiN+b5WEV7sNw+6ERPJDhZ1titXnGb++Za7CKzVnKO5w39coDgoB9XEJnqN3e4Q xryr661yP3zQFHigcB6KtP5ICU2rlzFKb8ePtpxxO04sZm+vyNU2O+IG+PcIDgzIvxZM 4sPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=g/4SxtqNPm0E/CIeRZgN6CpYgDUnydXgvlLbsp+hewQ=; b=csH7jXQ8t4Z/8G0dsDq9+M08qnklL3rfS7dpqStfbkoPb3fKCKiG1yHClXndRCqxJU xT9scYSnigCBvxutsD8pciotlniRl6LnmaT4PkOrNXaMOftsrb9NtZtxWaoyOO4YUMc/ VTKjtysMDYEayysRiy/efQhbGkjhE84AmB63EwK1M8jrD35kzoa00e3qqikpANRK35z0 /fiDTXsD9jbgQ2u5wiBe92N+9g1vubcVercAFhGwIuEKuTBGOd7wZYUzhEL0MHPveOcK tL9Mgb077ImCu+qisx5WYfdKSSHfMPDjMe5GITa66j32b7hO6s3oMg3Lo4/7lzITEptd wWHQ== X-Gm-Message-State: AOAM5317tmCcxtxwCF1McHicuizXHEllo1mG6diHOpCnHs5nTU+wd2Tx ZAYIO3EYqxrIFOZFKf/cPQsN+Vj/f4GHiNTO X-Received: by 2002:a05:600c:3388:: with SMTP id o8mr32529782wmp.101.1620573385750; Sun, 09 May 2021 08:16:25 -0700 (PDT) Received: from localhost.localdomain (39.red-81-40-121.staticip.rima-tde.net. [81.40.121.39]) by smtp.gmail.com with ESMTPSA id f6sm19891650wru.72.2021.05.09.08.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 May 2021 08:16:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/9] accel/tcg: Replace g_new() + memcpy() by g_memdup() Date: Sun, 9 May 2021 17:16:10 +0200 Message-Id: <20210509151618.2331764-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210509151618.2331764-1-f4bug@amsat.org> References: <20210509151618.2331764-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20210508201640.1045808-1-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daudé --- accel/tcg/cputlb.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) -- 2.26.3 diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 84e7d91a5ca..f616b58a898 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -837,11 +837,8 @@ void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr, } else if (encode_pbm_to_runon(&runon, d)) { async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon); } else { - TLBFlushPageBitsByMMUIdxData *p - = g_new(TLBFlushPageBitsByMMUIdxData, 1); - /* Otherwise allocate a structure, freed by the worker. */ - *p = d; + TLBFlushPageBitsByMMUIdxData *p = g_memdup(&d, sizeof(d)); async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_2, RUN_ON_CPU_HOST_PTR(p)); } @@ -875,13 +872,11 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *src_cpu, flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon); } else { CPUState *dst_cpu; - TLBFlushPageBitsByMMUIdxData *p; /* Allocate a separate data block for each destination cpu. */ CPU_FOREACH(dst_cpu) { if (dst_cpu != src_cpu) { - p = g_new(TLBFlushPageBitsByMMUIdxData, 1); - *p = d; + TLBFlushPageBitsByMMUIdxData *p = g_memdup(&d, sizeof(d)); async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_async_2, RUN_ON_CPU_HOST_PTR(p)); @@ -927,15 +922,13 @@ void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu, /* Allocate a separate data block for each destination cpu. */ CPU_FOREACH(dst_cpu) { if (dst_cpu != src_cpu) { - p = g_new(TLBFlushPageBitsByMMUIdxData, 1); - *p = d; + p = g_memdup(&d, sizeof(d)); async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_async_2, RUN_ON_CPU_HOST_PTR(p)); } } - p = g_new(TLBFlushPageBitsByMMUIdxData, 1); - *p = d; + p = g_memdup(&d, sizeof(d)); async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_2, RUN_ON_CPU_HOST_PTR(p)); }