From patchwork Mon Jul 13 20:04:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=yw5nL6g3; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F446zcyz9sRR for ; Tue, 14 Jul 2020 06:04:52 +1000 (AEST) Received: from localhost ([::1]:37380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4h0-00080z-J8 for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4ga-0007wO-JI for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:24 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54760) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gY-0006GW-Pk for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:24 -0400 Received: by mail-wm1-x343.google.com with SMTP id o8so1127115wmh.4 for ; Mon, 13 Jul 2020 13:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0GDUfAsY7oBRDehZI0s+LxQK3zPfLdSNXvvRvB9ltNY=; b=yw5nL6g3+qlDT1vGZe3O7nVEHuN/ORByMYZCWmIxWlV5hRsbZdkpgasJF+EHpfT/U3 eFZ7fOM3c+cQMGQly6hlnOL41wG9Zh3u5LH/e5PqJma5RxhBuq5UClbPl8Rpxuu9akMO miavOMoDFULXNlHf+y35Msxy7oQQt2WtMDyArCW6l1e8bm8dUSvw26pXFOc6B53slPZd dcr5c4jytxONTFdDd4y+TVWWpJi66HcBXgwIddm7K5yqEBxv4I+xuH8I1kIMOrJb49ud 75+cQJ+vr6iXyeqiwU64stFveQ8q5rKK5hiM6caYy2gos9lhmblwS3EXJyZvh8U2U0av UcFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0GDUfAsY7oBRDehZI0s+LxQK3zPfLdSNXvvRvB9ltNY=; b=RFP8FwTG2AE1cKdt67caE8lgOFYD1Ko5qu/AUuNNhrRJ2oVP860sFVGDWvwvinzXGn dZzGO5+oYU6ZqWhHqAy6iHwg9SdFf5ixGv18mNqLQNJ2d8udYLqnAkWHb/oBrmWmN8aH NfyJzUHBI5ZHLlHN306cgCcEVy2fZODIBmFHx0bgEIAtgO8YUFtxN88KCgWj91EHQDQe XypsqoL9t5JkAODCL/y2C10DhexVgadXopAme1qAiVZkCQ+kiWcB3P32rxSgaBUPr7zk nGF9Ocp1qWYFZhduFi/9TXTRW1hOHktnlPYd4cmJXgi8/yxpHOQu0fdhghaJnmCD23aO pq1Q== X-Gm-Message-State: AOAM533SEIOeXlUzjvQCiULA+YoLCe3Hm01RuvXUp1d+rb5GayHFQ6j0 KDiy1vc8SFHwlkFwxuzcqctsUQ== X-Google-Smtp-Source: ABdhPJzegv7amUwaE2S81w1cqoMgy56Dy96GV2sB/SBsvOScBidYjJBtHQvM82m4DdvneZtzuadIAg== X-Received: by 2002:a1c:e18a:: with SMTP id y132mr1017817wmg.27.1594670661440; Mon, 13 Jul 2020 13:04:21 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 133sm1010756wme.5.2020.07.13.13.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AD1E61FF87; Mon, 13 Jul 2020 21:04:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 01/11] configure: remove all dependencies on a (re)configure Date: Mon, 13 Jul 2020 21:04:05 +0100 Message-Id: <20200713200415.26214-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The previous code was brittle and missed cases such as the mipn32 variants which for some reason has the 64 bit syscalls. This leads to a number of binary targets having deps lines like: all.clang-sanitizer/mipsn32el-linux-user/linux-user/signal.d 140: /home/alex/lsrc/qemu.git/linux-user/mips64/syscall_nr.h \ 455:/home/alex/lsrc/qemu.git/linux-user/mips64/syscall_nr.h: all.clang-sanitizer/mipsn32el-linux-user/linux-user/syscall.d 146: /home/alex/lsrc/qemu.git/linux-user/mips64/syscall_nr.h \ 485:/home/alex/lsrc/qemu.git/linux-user/mips64/syscall_nr.h: which in turn would trigger the re-generation of syscall_nr.h in the source tree (thanks to generic %/syscall_nr.h rules). The previous code attempts to clean it out but misses edge cases but fails. After spending a day trying to understand how this was happening I'm unconvinced that there are not other such breakages possible with this "caching". As we add more auto-generated code to the build it is likely to trip up again. Apply a hammer to the problem. Fixes: 91e5998f18 (which fixes 5f29856b852d and 4d6a835dea47) Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- configure | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/configure b/configure index bc3b9ad931..e1de2f5b24 100755 --- a/configure +++ b/configure @@ -1955,23 +1955,20 @@ EOF exit 0 fi -# Remove old dependency files to make sure that they get properly regenerated -rm -f */config-devices.mak.d - # Remove syscall_nr.h to be sure they will be regenerated in the build # directory, not in the source directory for arch in alpha hppa m68k xtensa sh4 microblaze arm ppc s390x sparc sparc64 \ i386 x86_64 mips mips64 ; do # remove the file if it has been generated in the source directory rm -f "${source_path}/linux-user/${arch}/syscall_nr.h" - # remove the dependency files - for target in ${arch}*-linux-user ; do - test -d "${target}" && find "${target}" -type f -name "*.d" \ - -exec grep -q "${source_path}/linux-user/${arch}/syscall_nr.h" {} \; \ - -print | while read file ; do rm "${file}" "${file%.d}.o" ; done - done done +# Clean out all old dependency files. As more files are generated we +# run the risk of old dependencies triggering generation in the wrong +# places. Previous brittle attempts to be surgical tend to miss edge +# cases leading to wasted time and much confusion. +find -type f -name "*.d" -exec rm -f {} \; + if test -z "$python" then error_exit "Python not found. Use --python=/path/to/python" From patchwork Mon Jul 13 20:04:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Fk7BignJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F5q68ZPz9s1x for ; Tue, 14 Jul 2020 06:06:23 +1000 (AEST) Received: from localhost ([::1]:45268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4iT-0002qT-Hr for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:06:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gZ-0007v8-OZ for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:23 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:52614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gX-0006GI-Vl for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:23 -0400 Received: by mail-wm1-x32e.google.com with SMTP id q15so1134726wmj.2 for ; Mon, 13 Jul 2020 13:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IfI68+hGedk3QHICFsR2P3eF65wa15xU34V8+iox5Mc=; b=Fk7BignJC4e2MO5V34Np7ijOb2FvQ4tc3ItjokhW1S+X1rbUwRrf3sijfTT0Ta4IDH JJRGXrI90GE46IdXyWc+AiCfd/efrULGeAaRqk8Tkqxkcznq2t4u/ng/CRFMd5tpZmf/ sQk3YeEKaDmYzX7bOd+BO2dB7mVGWQg49nQVoQhKKwyiH7bHyyrEaxODfD2JWWg+6mFT 2zz3jgI2mForK6vK33+b8T/hgWwm+dN3I74Jduqlf168FOwGzQqBxtU4WUBRDcPITkow YnKDI/C1d3TxAvqSKqvTCTOHKiJ+Y90CO03Tof9pgP0hLtWrrkqaCU+oqyKEiKu2ApqY fZBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IfI68+hGedk3QHICFsR2P3eF65wa15xU34V8+iox5Mc=; b=O6YOxmtfoRcU43POlstb3MoWS8HHSbJPUvRJE3+B+6ufQbJHq8lfyjZYrea6lb0Ead rroSfQrno0jClFp1nmJwsq8MTIr9XfpsZHgfRlFiZgcWTm3fRdXmK8Ull5Z/x0N9Vzd/ LWENxNCcHBD5q766jmg6tQ8s/casie06GZRvR4fuQEWmJZYCjndWblxrB5UyisgPXVnj Hrm1UW1aOqdG2kgMsJwRyZS9I+6fKR0C1eaekdLP6UYMcztI6LmqEdAdtA44xpBEL9Y5 UZAB5lLqCPyXXJ3Lfe7+ZEi352NkQsdk/qGjirnTITEh8FBfTVkIXx+Xbo99HT390fpL rHtA== X-Gm-Message-State: AOAM533b1oQnvMMgmB9Yuzh29sXmpOnY4mXYH9PPEpdZ1UqdcPdreZqN 4MzI2AyILOrmPYyppFCRb7YqHQ== X-Google-Smtp-Source: ABdhPJybkxT1AZnUTwMuQDEsYfqC5lNOeZcExMC4AWUVm2jwrzJx/KMvk6CFD9jKmM73grcrP/U5PA== X-Received: by 2002:a1c:1bc6:: with SMTP id b189mr1005398wmb.166.1594670660274; Mon, 13 Jul 2020 13:04:20 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id n125sm887378wme.30.2020.07.13.13.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C2B7D1FF8C; Mon, 13 Jul 2020 21:04:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 02/11] tests/docker: Remove the libssh workaround from the ubuntu 20.04 image Date: Mon, 13 Jul 2020 21:04:06 +0100 Message-Id: <20200713200415.26214-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, URIBL_BLOCKED=0.001 autolearn=ham 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: fam@euphon.net, Thomas Huth , berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth The libssh problem only exists in Ubuntu 18.04 - we can enable it in 20.04 again. Signed-off-by: Thomas Huth Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200713185237.9419-1-thuth@redhat.com> --- tests/docker/dockerfiles/ubuntu2004.docker | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/docker/dockerfiles/ubuntu2004.docker b/tests/docker/dockerfiles/ubuntu2004.docker index f7aac840bf..8d10934a2a 100644 --- a/tests/docker/dockerfiles/ubuntu2004.docker +++ b/tests/docker/dockerfiles/ubuntu2004.docker @@ -65,9 +65,6 @@ RUN apt-get update && \ RUN dpkg -l $PACKAGES | sort > /packages.txt ENV FEATURES clang tsan pyyaml sdl2 -# https://bugs.launchpad.net/qemu/+bug/1838763 -ENV QEMU_CONFIGURE_OPTS --disable-libssh - # Apply patch https://reviews.llvm.org/D75820 # This is required for TSan in clang-10 to compile with QEMU. RUN sed -i 's/^const/static const/g' /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h From patchwork Mon Jul 13 20:04:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iRoIvctJ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F7D0ssyz9s1x for ; Tue, 14 Jul 2020 06:07:36 +1000 (AEST) Received: from localhost ([::1]:51836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4jd-0005RB-RW for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:07:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gb-0007zx-Qe for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:25 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:50452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4ga-0006Gg-6W for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:25 -0400 Received: by mail-wm1-x344.google.com with SMTP id l17so1153429wmj.0 for ; Mon, 13 Jul 2020 13:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zYmy6YbAdYCCn5X7N7JnznTD44q8kk8nDaLydetiUF4=; b=iRoIvctJRweIWyuMWsjAtE8+JehMQIOHYYgkXVVIUgeOajqBilO/1mv4VT3kLduKqH Rdg5OhIxUXu7LbK67T5qfGAPbc2BUbtDrNnS0g5Axfio4PVe3bsdDRes7jHLLZzXXm/z iIwMbORvDonXZlZqGuI3boDjSOFy/TfKyTFhpeEjqXOBFm3V4aoU4EvfHqGD2/4uCnNu i53jSVpmZRtkTVQEqACbZGjXNMoO0NUCDuV2sfHuMjOcGd6UK+WfBAudmxK6PM1CzSE5 RMC3OgP6rcORKhr3QL0sia9O8g+pg9ih25NnHtU4zlCEir5cR3mcs2+k+6c+OgHOqhE+ sDHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zYmy6YbAdYCCn5X7N7JnznTD44q8kk8nDaLydetiUF4=; b=HNqmLK5dHVdgpgJtIVE1zXsqWdj3j/UAtVUqro/3EibFBXt8iH1Gjv1i41JCGd0/cc 0JQvlTLt2W6FnXvpzW+2gPcC7FeRqL9W4cgTUo6bndBOzUo4xQr2DyK2FrM+Oaa6bs0i KAzgN+npg6dzn6DCU+A2i0HfblM4ZpZdpspGjkMRyM6xVRhDYgsUn+r3sDY7InccoOzH heCOPWA5aOKi7JYrCvPTlXt9/swTj9sL4O3a9SXzlHuM7miC3vVuOeFGs1rrzRE9WtII gFnV+0Ro8eOrwR562iczceVelI5foC3mcZqItTFTqz/rDIoSXFqvjxIrczNluOULO4rs akTA== X-Gm-Message-State: AOAM5334BpKciG5PG37g1NI5H919uEpnFBDadrtn0j3xmfijB8IWH+PM oBD8ZcOX21rQf0Q8b+/44/ZBQw== X-Google-Smtp-Source: ABdhPJzSrbKIXuJ8ILQ/QnaQ/CNa5R0OBK58LYhieUHmOMwKHju6XbS+JqIXxVUYBU5CWTYEzuZVKg== X-Received: by 2002:a1c:a557:: with SMTP id o84mr1071156wme.42.1594670662723; Mon, 13 Jul 2020 13:04:22 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id w16sm30261370wrg.95.2020.07.13.13.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D86141FF8F; Mon, 13 Jul 2020 21:04:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 03/11] docker.py: fix fetching of FROM layers Date: Mon, 13 Jul 2020 21:04:07 +0100 Message-Id: <20200713200415.26214-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, URIBL_BLOCKED=0.001 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This worked on a system that was already bootstrapped because the stage 2 images already existed even if they wouldn't be used. What we should have pulled down was the FROM line containers first because building on gitlab doesn't have the advantage of using our build system to build the pre-requisite bits. We still pull the image we want to build just in case we can use the cached data. Signed-off-by: Alex Bennée Reviewed-by: Daniel P. Berrangé Tested-by: Philippe Mathieu-Daudé --- tests/docker/docker.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 2d67bbd15a..c9f20d8d09 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -306,14 +306,18 @@ class Docker(object): checksum = _text_checksum(_dockerfile_preprocess(dockerfile)) if registry is not None: - # see if we can fetch a cache copy, may fail... - pull_args = ["pull", "%s/%s" % (registry, tag)] - if self._do(pull_args, quiet=quiet) == 0: + sources = re.findall("FROM qemu\/(.*)", dockerfile) + # Fetch any cache layers we can, may fail + for s in sources: + pull_args = ["pull", "%s/qemu/%s" % (registry, s)] + if self._do(pull_args, quiet=quiet) != 0: + registry = None + break + # Make substitutions + if registry is not None: dockerfile = dockerfile.replace("FROM qemu/", "FROM %s/qemu/" % (registry)) - else: - registry = None tmp_df = tempfile.NamedTemporaryFile(mode="w+t", encoding='utf-8', @@ -339,6 +343,8 @@ class Docker(object): build_args += ["--build-arg", "BUILDKIT_INLINE_CACHE=1"] if registry is not None: + pull_args = ["pull", "%s/%s" % (registry, tag)] + self._do(pull_args, quiet=quiet) cache = "%s/%s" % (registry, tag) build_args += ["--cache-from", cache] build_args += argv From patchwork Mon Jul 13 20:04:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328425 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=egGZei3p; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F4441X9z9sQt for ; Tue, 14 Jul 2020 06:04:51 +1000 (AEST) Received: from localhost ([::1]:37234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4gy-0007vL-Vl for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gY-0007uP-Cw for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:22 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:40987) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gW-0006G5-MA for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:22 -0400 Received: by mail-wr1-x444.google.com with SMTP id z15so18130872wrl.8 for ; Mon, 13 Jul 2020 13:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iJReQOIYVR+hDlxB+L3VcS6ZiNXB7LvJkcVb9PUtdRA=; b=egGZei3pgMwO3u2LoCla+Sc+Qr4psViwJ6QQ5M+pGiBhZjK5OmcgmK4l+Gdzxikwm1 r5hdDPXotD9BVIXVtclv/ukGs4K/78CISsJBh6FU93L+T0MMoECrmHqAuzwb/3lCBwyv 14Hy0xk1GfAD6PVjK3OYr8FpsBvVxwRUTeUCmsrLR38rgaCZCI9iR1VcJFM6d7F/O5Uh r4HS06oTJHTnbVaZq6RsMrpNzxz7ZSA8d7KPCCodTGqqaJaSy75qTnSGILeKHcRhf895 tTGPUGymuEC1kP7ZTfx2VIHN7HT/ceBzccSau531exREEN/ktk0mnQh07Fbn8JbCkj6F CCSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iJReQOIYVR+hDlxB+L3VcS6ZiNXB7LvJkcVb9PUtdRA=; b=KzcK4OE2JC9g4RpbiMWGtB21930eiM/qmBULXnhBL5RgRPKi+03ElRMUTwevo2L4ZB e0u/mtbsPI0BnUtNltpUZXl1e7HYK4HjeVy/Akb+7PBHvBjVo2MCZyFdN2Fomj+m+IF7 Oz6Ge++pvMk/8MZitai4fb7O4TdkZwfXrXzc0Xelwd+x1/5+dBC7MhvRKSyeyH0JoV3i 0fKF3cHTIfKW0ucW7d8fIT4fQXz9slUMeZ2GXSsDNcDWLJltZo/AToxugH0Vdpkzctmy tlm2I4t6b6JJXXaY7RnKhXlQJvBzcXVA8B2vB8DWutV9ve2UCAbzTOC/AY0feNYvGekH izwQ== X-Gm-Message-State: AOAM531aY5E7eHOnNcuJuIF/Q/lCRcgscuSxCxKbQrp7fKOPtKMydI31 D593YpUD6kOswzOB7u+3yb02gg== X-Google-Smtp-Source: ABdhPJyDYVPuV1GhmLeVfHDE8UkJmFkRvjFxBtEC77YNrA4tb+dtN8fi74cfYvRCcCJ1neddlXGR4w== X-Received: by 2002:a05:6000:11cc:: with SMTP id i12mr1193551wrx.224.1594670659382; Mon, 13 Jul 2020 13:04:19 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g13sm26056579wro.84.2020.07.13.13.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:16 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id EEDC81FF90; Mon, 13 Jul 2020 21:04:15 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/11] fpu/softfloat: fix up float16 nan recognition Date: Mon, 13 Jul 2020 21:04:08 +0100 Message-Id: <20200713200415.26214-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, Peter Maydell , berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, LIU Zhiwei , aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: LIU Zhiwei Signed-off-by: LIU Zhiwei Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200712234521.3972-2-zhiwei_liu@c-sky.com> --- fpu/softfloat-specialize.inc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpu/softfloat-specialize.inc.c b/fpu/softfloat-specialize.inc.c index 44f5b661f8..034d18199c 100644 --- a/fpu/softfloat-specialize.inc.c +++ b/fpu/softfloat-specialize.inc.c @@ -254,7 +254,7 @@ bool float16_is_quiet_nan(float16 a_, float_status *status) if (snan_bit_is_one(status)) { return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF); } else { - return ((a & ~0x8000) >= 0x7C80); + return ((a >> 9) & 0x3F) == 0x3F; } #endif } @@ -271,7 +271,7 @@ bool float16_is_signaling_nan(float16 a_, float_status *status) #else uint16_t a = float16_val(a_); if (snan_bit_is_one(status)) { - return ((a & ~0x8000) >= 0x7C80); + return ((a >> 9) & 0x3F) == 0x3F; } else { return (((a >> 9) & 0x3F) == 0x3E) && (a & 0x1FF); } From patchwork Mon Jul 13 20:04:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=cKldk/6O; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F7H0fmvz9s1x for ; Tue, 14 Jul 2020 06:07:39 +1000 (AEST) Received: from localhost ([::1]:52114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4jg-0005Xf-QI for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:07:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4ge-000879-Va for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:29 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:37542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gd-0006IX-8A for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:28 -0400 Received: by mail-wm1-x32a.google.com with SMTP id o2so1076464wmh.2 for ; Mon, 13 Jul 2020 13:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qFhIz7yTIzhv4ZECtrkYR3FRhbXI50/mJD1JravnOmY=; b=cKldk/6OJ9BpdVjh3uNLWqHfBSd6Niir92rdbxswNP6nDmR9QnWrzBg9GDexEHeGbp cuwBOZN4l9ZDGb3IVGDYL/DQ/1iLT2/4JF71A4Dlno12IOXOO5E2XiNZWLCSw8f5ba68 lN1EtjT25fdp1Sahr+Sdwl/Igx+0hYbZ8bxxj7OQhB+zPNdzyjzRMA2nLBVgiJsqfq+b SQS2Rfc1kEOyHFQsGhHyhIOWH872mQD8sZnaVhraomgGYlh1AJ6MdHmf960SeLhQVIVF 399lbJ41szLAMILnEI+scbxvptUXbp//E35HmT+7TFXymW4vb9uMOD+7Slno7gf5RGhE xZFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qFhIz7yTIzhv4ZECtrkYR3FRhbXI50/mJD1JravnOmY=; b=RKeOyAmNoTgUvPfTvPcjlsoOlVbZhpmHa8eeY9kGo0WcIK1fMaq8ZSbBx/SAKAVT2p 3NdInwXfFA5fFsNsKri4en9yAMtZSH0sxyI2hpc4XceJDd8kSehv+lQcLLBu7JHFgUzt Lj1TdKChc/xVOybfXDt6T35sN/v0+CxMCHft1ixlJ8OCXQ+x+QX/jCqKIy0tRTsTuyy9 uDjj4KEmnc1EQF/cAtCwx3hWeNoGrzp+fbur38he8DCzn62cGV9OcLq9R8dbD7+pgus9 xfr/nVoIG7sjit/y5QihaC0TCys8LDio9Ldr8/xN59F2IQzVNR1LcLo/YQatcHLUm4BR mC0w== X-Gm-Message-State: AOAM532s9IcQx5weRzBrqhu3KsTcXudXHmoCcbYJnadHrBREocIcKkw0 xe4ePEGIxSh6YiqgGChbLWe68w== X-Google-Smtp-Source: ABdhPJwxlSKhMU/Vz84Uop3ctb505hTVWJy+k+9QzaLpygNwy/Dh+IOOVEeGCGURh7QmoHOjdYcnIQ== X-Received: by 2002:a05:600c:2f88:: with SMTP id t8mr1030337wmn.186.1594670665891; Mon, 13 Jul 2020 13:04:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f17sm1010645wme.14.2020.07.13.13.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1254D1FF91; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/11] tests/plugins: don't unconditionally add -Wpsabi Date: Mon, 13 Jul 2020 21:04:09 +0100 Message-Id: <20200713200415.26214-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Not all compilers support the -Wpsabi (clang-9 in my case). To handle this gracefully we pare back the shared build machinery so the Makefile is relatively "standalone". We still take advantage of config-host.mak as configure has done a bunch of probing for us but that is it. Fixes: bac8d222a Signed-off-by: Alex Bennée Reviewed-by: Thomas Huth --- v2 - separate from main build system and check probe --- configure | 3 +++ tests/plugin/Makefile | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/configure b/configure index e1de2f5b24..08eaa99d19 100755 --- a/configure +++ b/configure @@ -7112,6 +7112,9 @@ echo "GIT_UPDATE=$git_update" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak +echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak +echo "GLIB_LDFLAGS=$glib_ldflags" >> $config_host_mak + if test "$default_devices" = "yes" ; then echo "CONFIG_MINIKCONF_MODE=--defconfig" >> $config_host_mak else diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile index 3a50451428..e9348fde4a 100644 --- a/tests/plugin/Makefile +++ b/tests/plugin/Makefile @@ -1,9 +1,16 @@ +# -*- Mode: makefile -*- +# +# This Makefile example is fairly independent from the main makefile +# so users can take and adapt it for their build. We only really +# include config-host.mak so we don't have to repeat probing for +# cflags that the main configure has already done for us. +# + BUILD_DIR := $(CURDIR)/../.. include $(BUILD_DIR)/config-host.mak -include $(SRC_PATH)/rules.mak -$(call set-vpath, $(SRC_PATH)/tests/plugin) +VPATH += $(SRC_PATH)/tests/plugin NAMES := NAMES += bb @@ -17,11 +24,18 @@ NAMES += lockstep SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) -QEMU_CFLAGS += -fPIC -Wpsabi -QEMU_CFLAGS += -I$(SRC_PATH)/include/qemu +# The main QEMU uses Glib extensively so it's perfectly fine to use it +# in plugins (which many example do). +CFLAGS = $(GLIB_CFLAGS) +CFLAGS += -fPIC +CFLAGS += $(if $(findstring no-psabi,$(QEMU_CFLAGS)),-Wpsabi) +CFLAGS += -I$(SRC_PATH)/include/qemu all: $(SONAMES) +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + lib%.so: %.o $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDLIBS) From patchwork Mon Jul 13 20:04:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=R7KFLfXv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F5w02HQz9s1x for ; Tue, 14 Jul 2020 06:06:27 +1000 (AEST) Received: from localhost ([::1]:45624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4iX-0002yl-Jz for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:06:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4ge-000856-2L for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:28 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:44885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gc-0006IH-3A for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:27 -0400 Received: by mail-wr1-x444.google.com with SMTP id b6so18142398wrs.11 for ; Mon, 13 Jul 2020 13:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kb87PAc0ILcvwPMRDtx1z2EyoH/JKtctRlrd2cWmYmY=; b=R7KFLfXvss6QA1s0lF4F3JbssBLto2qMYIIrmbreQJg1sgVQjo8itdImO5QxDT8A4k nnARnsGWE5+oopWZMkD0YIUkdckB9oFrA2G3o9DDVQe1Q5+kcRN82vYTaFLkQz9UCmDz vXA2eukaqhUEsffy5XUmju1jdRKnSVM1U5r+Db56u75Ws+IFIGdxWDJzf9XYxWGsbN7t PiHWwUpGmI/39h01NM7SaGZwjcLPyRhwOIabQmgfzW3AaqegWEqaWWqVUTGSCChw0qxV k68wV2Qluqy1OhnlEPfUvAKTTlBpquyLcNoriRz5HsbWrPCAiaDmDLua/vqh9KMRUPH+ 6g5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kb87PAc0ILcvwPMRDtx1z2EyoH/JKtctRlrd2cWmYmY=; b=A+b9V702TiLZUZUh7HEm7FVA9/MccOA58uY1TBPno88ByfmpwvFuYFLzqA1XQ1RHoz ZnIVqPJI3NRg+8qdnE9GsbR9Kmgf4Lp9VThEqpOYNL5cxQ0dI6I8KR6fQgxjb3tTmBx/ NSU4BvRaPu/TlZ6AceT3uFSylZ2UDBJcpaO/BLVSUMxitObDPv+EbbW7PI4kOepbDYW5 8ftT+GzjAStoGH5puubIsMNOtLed1XKKMjviFeut+yGRR05pCusa7gjClH53IZQF914y CbH0w2uul8imac+ey+T2wqEbiqYhrpaUJ3zlKipA5Pm0qCzdoCSHf0CBtQ9K3qQYk5KP VT9w== X-Gm-Message-State: AOAM5319JFOfoP6Vgs3m917mseimHaScoQrWpzmlRy6lw+VYMWeGFzF/ TQODAzB9u747yTlwrjQotAkcSA== X-Google-Smtp-Source: ABdhPJwUyLxRrB1B22Q9XU6df9A42VKwqlpGTi3eVSOW0naoJZTIgfVAJDLs8boUFGlZ6P6ycW+ATg== X-Received: by 2002:adf:ff90:: with SMTP id j16mr1183783wrr.364.1594670664723; Mon, 13 Jul 2020 13:04:24 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id k131sm874059wmb.36.2020.07.13.13.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2C8A01FF92; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/11] cputlb: ensure we save the IOTLB data in case of reset Date: Mon, 13 Jul 2020 21:04:10 +0100 Message-Id: <20200713200415.26214-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, Eduardo Habkost , aurelien@aurel32.net, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Any write to a device might cause a re-arrangement of memory triggering a TLB flush and potential re-size of the TLB invalidating previous entries. This would cause users of qemu_plugin_get_hwaddr() to see the warning: invalid use of qemu_plugin_get_hwaddr because of the failed tlb_lookup which should always succeed. To prevent this we save the IOTLB data in case it is later needed by a plugin doing a lookup. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Emilio G. Cota --- v2 - save the entry instead of re-running the tlb_fill. v3 - don't abuse TLS, use CPUState to store data - just use g_free_rcu() to avoid ugliness - verify addr matches before returning data - ws fix v4 - don't both with RCU, just store it in CPUState - clean-up #ifdef'ery - checkpatch --- include/hw/core/cpu.h | 16 ++++++++++++++++ include/qemu/typedefs.h | 1 + accel/tcg/cputlb.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 5542577d2b..8f145733ce 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -259,6 +259,18 @@ struct CPUWatchpoint { QTAILQ_ENTRY(CPUWatchpoint) entry; }; +#ifdef CONFIG_PLUGIN +/* + * For plugins we sometime need to save the resolved iotlb data before + * the memory regions get moved around by io_writex. + */ +typedef struct SavedIOTLB { + hwaddr addr; + MemoryRegionSection *section; + hwaddr mr_offset; +} SavedIOTLB; +#endif + struct KVMState; struct kvm_run; @@ -417,7 +429,11 @@ struct CPUState { DECLARE_BITMAP(plugin_mask, QEMU_PLUGIN_EV_MAX); +#ifdef CONFIG_PLUGIN GArray *plugin_mem_cbs; + /* saved iotlb data from io_writex */ + SavedIOTLB saved_iotlb; +#endif /* TODO Move common fields from CPUArchState here. */ int cpu_index; diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 15f5047bf1..427027a970 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -116,6 +116,7 @@ typedef struct QObject QObject; typedef struct QString QString; typedef struct RAMBlock RAMBlock; typedef struct Range Range; +typedef struct SavedIOTLB SavedIOTLB; typedef struct SHPCDevice SHPCDevice; typedef struct SSIBus SSIBus; typedef struct VirtIODevice VirtIODevice; diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 1e815357c7..d370aedb47 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1073,6 +1073,24 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, return val; } +/* + * Save a potentially trashed IOTLB entry for later lookup by plugin. + * + * We also need to track the thread storage address because the RCU + * cleanup that runs when we leave the critical region (the current + * execution) is actually in a different thread. + */ +static void save_iotlb_data(CPUState *cs, hwaddr addr, + MemoryRegionSection *section, hwaddr mr_offset) +{ +#ifdef CONFIG_PLUGIN + SavedIOTLB *saved = &cs->saved_iotlb; + saved->addr = addr; + saved->section = section; + saved->mr_offset = mr_offset; +#endif +} + static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, int mmu_idx, uint64_t val, target_ulong addr, uintptr_t retaddr, MemOp op) @@ -1092,6 +1110,12 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, } cpu->mem_io_pc = retaddr; + /* + * The memory_region_dispatch may trigger a flush/resize + * so for plugins we save the iotlb_data just in case. + */ + save_iotlb_data(cpu, iotlbentry->addr, section, mr_offset); + if (mr->global_locking && !qemu_mutex_iothread_locked()) { qemu_mutex_lock_iothread(); locked = true; @@ -1381,8 +1405,11 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, * in the softmmu lookup code (or helper). We don't handle re-fills or * checking the victim table. This is purely informational. * - * This should never fail as the memory access being instrumented - * should have just filled the TLB. + * This almost never fails as the memory access being instrumented + * should have just filled the TLB. The one corner case is io_writex + * which can cause TLB flushes and potential resizing of the TLBs + * loosing the information we need. In those cases we need to recover + * data from a copy of the io_tlb entry. */ bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx, @@ -1406,8 +1433,13 @@ bool tlb_plugin_lookup(CPUState *cpu, target_ulong addr, int mmu_idx, data->v.ram.hostaddr = addr + tlbe->addend; } return true; + } else { + SavedIOTLB *saved = &cpu->saved_iotlb; + data->is_io = true; + data->v.io.section = saved->section; + data->v.io.offset = saved->mr_offset; + return true; } - return false; } #endif From patchwork Mon Jul 13 20:04:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328439 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=zOKKinMl; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F8y6zX6z9sQt for ; Tue, 14 Jul 2020 06:09:06 +1000 (AEST) Received: from localhost ([::1]:58690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4l6-00089p-Hr for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:09:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gj-0008Gz-De for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:33 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gh-0006JN-GR for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:33 -0400 Received: by mail-wr1-x442.google.com with SMTP id b6so18142756wrs.11 for ; Mon, 13 Jul 2020 13:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RFloOI9RdqsuY1jzWY/LdnGW0qTS1vaDIDIUNvMdMkw=; b=zOKKinMl8Lc4tl+khcrq25otS5ClYMFza+X8Eb8n8PJ7hQDMp7qLKWT7XBzuLwUnTi VjmNAJQVQ8lV8KViFJt6Ozwz01fq/4O5j/ugnJOlgWRuWS2rLAvFgb/A1HQBF55RbRcZ GQvBF03MeCYdYuHLlSkW1GWLRGzaW/2xHlEzOxRnbI10ygzyNKxJW+TeXWZ60yztPJnx PwSYc/3A956kxyXldFVqJWJqmrfib28ef2fVWm+uiDaIOkbqTL/AdGRXizdlqrJpddv4 8IBew9zVF+kF5eibGXk6wzK6t67zqOdaQAphN8pyy3GT1vKQ8SeZRAq3HKPkeAvi7x7Q 3fsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RFloOI9RdqsuY1jzWY/LdnGW0qTS1vaDIDIUNvMdMkw=; b=HG6Ikq8ZHO+Vs/UYJ+j5HrrgIrKtr5bcVaHYHL5opYNB0HC+Vl3/y687JOH4QL8qlJ aV8kCd713EdH8aey2O1ugM5ZUZcBXiGkTwdZEP+tL6fcpT5+ZRg1FBkmbrujJ0p9Gv2c ay/dgyfdFldNDke89p23gXvB5Q+bbOGPSRqHy8ChzMiUuEg3y2LGSpTNYyxAd61ilBL9 ji/X7rTz4W2m8QeviiRJDr7zx5czlIS4tPnmrH1FWgRLSaZduxcx0i5IvVIE0qbsXLyn S4IICrwi/W/uPCDnFYr2lvEbkLOIMIKUtznB1LRrCh9kHpnQc/7xLOCCLBSDElPFNsdx e0pg== X-Gm-Message-State: AOAM530B8xazTi8iIvKMPlNruyh3RmR5jbCY1gx3KpP794VWJj5b3gOc SR4wTHNED6L0wMV77Rkm+CAuwg== X-Google-Smtp-Source: ABdhPJz0U1RwaSiDkrjwHwQDpu95CLWAZdSD8f+3Y7G8PVkw0FQyxceowkoWTeeyIBCnsVHLzEK73A== X-Received: by 2002:a5d:6107:: with SMTP id v7mr1188315wrt.174.1594670670106; Mon, 13 Jul 2020 13:04:30 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 190sm939618wmb.15.2020.07.13.13.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 43CCF1FF93; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 07/11] plugins: expand the bb plugin to be thread safe and track per-cpu Date: Mon, 13 Jul 2020 21:04:11 +0100 Message-Id: <20200713200415.26214-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, Dave Bort , kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" While there isn't any easy way to make the inline counts thread safe we can ensure the callback based ones are. While we are at it we can reduce introduce a new option ("idle") to dump a report of the current bb and insn count each time a vCPU enters the idle state. Signed-off-by: Alex Bennée Reviewed-by: Robert Foley Cc: Dave Bort --- v2 - fixup for non-inline linux-user case - minor cleanup and re-factor v3 - checkpatch --- tests/plugin/bb.c | 97 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 84 insertions(+), 13 deletions(-) diff --git a/tests/plugin/bb.c b/tests/plugin/bb.c index df19fd359d..e4cc7fdd6e 100644 --- a/tests/plugin/bb.c +++ b/tests/plugin/bb.c @@ -16,24 +16,67 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; -static uint64_t bb_count; -static uint64_t insn_count; +typedef struct { + GMutex lock; + int index; + uint64_t bb_count; + uint64_t insn_count; +} CPUCount; + +/* Used by the inline & linux-user counts */ static bool do_inline; +static CPUCount inline_count; + +/* Dump running CPU total on idle? */ +static bool idle_report; +static GPtrArray *counts; +static int max_cpus; + +static void gen_one_cpu_report(CPUCount *count, GString *report) +{ + if (count->bb_count) { + g_string_append_printf(report, "CPU%d: " + "bb's: %" PRIu64", insns: %" PRIu64 "\n", + count->index, + count->bb_count, count->insn_count); + } +} static void plugin_exit(qemu_plugin_id_t id, void *p) { - g_autofree gchar *out = g_strdup_printf( - "bb's: %" PRIu64", insns: %" PRIu64 "\n", - bb_count, insn_count); - qemu_plugin_outs(out); + g_autoptr(GString) report = g_string_new(""); + + if (do_inline || !max_cpus) { + g_string_printf(report, "bb's: %" PRIu64", insns: %" PRIu64 "\n", + inline_count.bb_count, inline_count.insn_count); + } else { + g_ptr_array_foreach(counts, (GFunc) gen_one_cpu_report, report); + } + qemu_plugin_outs(report->str); +} + +static void vcpu_idle(qemu_plugin_id_t id, unsigned int cpu_index) +{ + CPUCount *count = g_ptr_array_index(counts, cpu_index); + g_autoptr(GString) report = g_string_new(""); + gen_one_cpu_report(count, report); + + if (report->len > 0) { + g_string_prepend(report, "Idling "); + qemu_plugin_outs(report->str); + } } static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { - unsigned long n_insns = (unsigned long)udata; + CPUCount *count = max_cpus ? + g_ptr_array_index(counts, cpu_index) : &inline_count; - insn_count += n_insns; - bb_count++; + unsigned long n_insns = (unsigned long)udata; + g_mutex_lock(&count->lock); + count->insn_count += n_insns; + count->bb_count++; + g_mutex_unlock(&count->lock); } static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) @@ -42,9 +85,10 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) if (do_inline) { qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &bb_count, 1); + &inline_count.bb_count, 1); qemu_plugin_register_vcpu_tb_exec_inline(tb, QEMU_PLUGIN_INLINE_ADD_U64, - &insn_count, n_insns); + &inline_count.insn_count, + n_insns); } else { qemu_plugin_register_vcpu_tb_exec_cb(tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, @@ -56,8 +100,35 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) { - if (argc && strcmp(argv[0], "inline") == 0) { - do_inline = true; + int i; + + for (i = 0; i < argc; i++) { + char *opt = argv[i]; + if (g_strcmp0(opt, "inline") == 0) { + do_inline = true; + } else if (g_strcmp0(opt, "idle") == 0) { + idle_report = true; + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + if (info->system_emulation && !do_inline) { + max_cpus = info->system.max_vcpus; + counts = g_ptr_array_new(); + for (i = 0; i < max_cpus; i++) { + CPUCount *count = g_new0(CPUCount, 1); + g_mutex_init(&count->lock); + count->index = i; + g_ptr_array_add(counts, count); + } + } else if (!do_inline) { + g_mutex_init(&inline_count.lock); + } + + if (idle_report) { + qemu_plugin_register_vcpu_idle_cb(id, vcpu_idle); } qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); From patchwork Mon Jul 13 20:04:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Dm/LzKWT; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F5w6bzBz9sQt for ; Tue, 14 Jul 2020 06:06:28 +1000 (AEST) Received: from localhost ([::1]:45768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4iY-00032C-Ni for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:06:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gf-00088E-Tf for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:29 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:44885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4ge-0006Io-AA for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:29 -0400 Received: by mail-wr1-x443.google.com with SMTP id b6so18142536wrs.11 for ; Mon, 13 Jul 2020 13:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q6cYMqIkyzOX02PZCCZFUIzSlg7qzIM3UYcqhB9l+V0=; b=Dm/LzKWTHcv4R9bX/1f7jVEdJXV6pp0jm5BwwyhZOws8gjhr5pfomQ0gaFV+No/ks5 nlJ1Q8vxM7P/HvAgRv1RMGZkD82bAAAJq6qc6kPVnE2paZ584WNIymAoiWSkHKCQwfNy +okgcVwZxMwB89UVZJ01m3inQ1TDHIog4pTOuuQFJRLx+QqfZ+JAgWfMS17V8J0216Hh z6gGF13YhgFw/uDVNknA3UWpT5Vgl+on4LED/1B7qugbmx2vgawTPzoE4HMzUe6cSjFt PPedllNzn3LcSFIyYMmAak6/YF93OwFM6TLW5JurFx80Snac9lxZ07IfIi2zt85UkMPB +maQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q6cYMqIkyzOX02PZCCZFUIzSlg7qzIM3UYcqhB9l+V0=; b=rSle5sisCTU7XKlvm0Qxzi3v2Bzl4CRKcEv6GKhhNBeaQzsajvDJhYhaKYbkJS3Oq3 VdNeX4o9FZwhwRNBlK2JUIIfjl/2FeiNa/xYoXa6CBK2VgrsuwUg7hW/SkLeWXTia9ks FQ5l8LxE26KC8XjoaG6CMrSBxgVic+zsc/8Dmst80W6lOEhpDHfNjjhyY0LDi9jEBtFd n6VLkU5s3RU5Afst64bxicXM6nlvgkw27HSvz48absftptKcs/cr9jJwLNw1qB7zMv/v w1GKk8S/cUCtZvU6rJzsIP97DUHbaTMEgRLNNqPkEvl0fNg5czKjzKlMJKXZU3JrN9ev p8lg== X-Gm-Message-State: AOAM530m6ztQx42qUrf1e6+25aYGHQGrcUM+GrZMtl0U+TH7qig2BNji 0NKP9FNRe6tK6BMRIBFPjbNXeg== X-Google-Smtp-Source: ABdhPJwNWY3SgMXfjVwiYGdGYbA0lFpxY7vc3rvcdRQJAaD6W9w5gd+jwh61WKVoGWKcs6MW/BhWHA== X-Received: by 2002:adf:cf0a:: with SMTP id o10mr1212492wrj.14.1594670666857; Mon, 13 Jul 2020 13:04:26 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id s8sm24970176wru.38.2020.07.13.13.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 59E921FF96; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 08/11] docs/devel: fix grammar in multi-thread-tcg Date: Mon, 13 Jul 2020 21:04:12 +0100 Message-Id: <20200713200415.26214-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Review comment came just too late ;-) Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé --- docs/devel/multi-thread-tcg.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/devel/multi-thread-tcg.rst b/docs/devel/multi-thread-tcg.rst index 42158b77c7..21483870db 100644 --- a/docs/devel/multi-thread-tcg.rst +++ b/docs/devel/multi-thread-tcg.rst @@ -107,7 +107,7 @@ including: - debugging operations (breakpoint insertion/removal) - some CPU helper functions - - linux-user spawning it's first thread + - linux-user spawning its first thread This is done with the async_safe_run_on_cpu() mechanism to ensure all vCPUs are quiescent when changes are being made to shared global From patchwork Mon Jul 13 20:04:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=v3kHQID1; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F7J6Z16z9sQt for ; Tue, 14 Jul 2020 06:07:40 +1000 (AEST) Received: from localhost ([::1]:52336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4ji-0005d2-LZ for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:07:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gi-0008DC-2T for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:32 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gg-0006JE-Bs for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:31 -0400 Received: by mail-wm1-x342.google.com with SMTP id f18so1072171wml.3 for ; Mon, 13 Jul 2020 13:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VUrwUV80rymMTitCKofJuTKzmFLE1QgsXWLHHkxkAO0=; b=v3kHQID186Zb0rR2a71SzKHJMUiOt3xJpXHR8c6ygLWqa6vdNG1rnOojXPNBO1O89f 7jKGC/4IoNP9ZWdLWLWFJkky9QiPlCzAgfvf5gM8nfaC+dbEfkCQJVWWgF+vi+fO2yj3 KReYQa+04R/an/VJyVz1TmGFkc5cCpRW63NcEsPjkv/4K37P9sRuMurf2jTshytTyo9k FrAZ3vnQXmNn868AlQafCGuKJvDt1uzOMrdaOjmSYgDz+J4lDAwnVo5V3ALJNIvc2+Zt zOTFb4wjxEYtuavM+uenFk1WkyeXHeiFo8s2fR0DOfXzbjaEFu6rSiU82dXzMYD70lQT sjbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VUrwUV80rymMTitCKofJuTKzmFLE1QgsXWLHHkxkAO0=; b=GNwDMzaVRx34zrwahzzKs1lMI2kX7sOtXDeh5CODP/lz8veyaOjDI1NjNrT01ZH5Qu P6pYVJP1gVAb2H9bwiObYeHPkf4Go0DR/3WvveukmI7Hg+AP4asPn3tLkfHnY1Bw8Nsn rlwKOKozVci6GhLD6fivquzBUEHeaX6vDvq5e+Y82FFU+3fBe5+IS9+qJPs5oUwzrLVu zCfIoBn73g3SfVbdEY1uzO7LnMWJA2sLJ4WTtYB4UBWnHFZ3C42Z2MUxQJ/wonUv1F7/ IYVtepxlcv2quIAw7MBF0vwwo1oedh/jmZeZ8jHblj0oF3OKRJ/mn2XZjPu1OxbulQ9d 1e3g== X-Gm-Message-State: AOAM531xu+FtzCW4gv72rBTRJ5SrLkG0ZRxicFLCxqTD1PP1mbWEUE1n VacJfnOr1E7E8SJDaCeaGTG+4w== X-Google-Smtp-Source: ABdhPJz6jPJJswR/XcQVzF+bTcXWjgYeqpw8dI1E3iDnGaZ7KQQ4o0vZuYBqIMVVMeb+LUz63+5YLg== X-Received: by 2002:a7b:c194:: with SMTP id y20mr1066343wmi.83.1594670669046; Mon, 13 Jul 2020 13:04:29 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h23sm872362wmb.3.2020.07.13.13.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 713781FF98; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/11] hw/virtio/pci: include vdev name in registered PCI sections Date: Mon, 13 Jul 2020 21:04:13 +0100 Message-Id: <20200713200415.26214-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::342; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x342.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, "Michael S . Tsirkin" , =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When viewing/debugging memory regions it is sometimes hard to figure out which PCI device something belongs to. Make the names unique by including the vdev name in the name string. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin --- v2 - swap ()'s for an extra - --- hw/virtio/virtio-pci.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 8554cf2a03..215e680c71 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1406,7 +1406,8 @@ static void virtio_pci_device_write(void *opaque, hwaddr addr, } } -static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) +static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy, + const char *vdev_name) { static const MemoryRegionOps common_ops = { .read = virtio_pci_common_read, @@ -1453,36 +1454,41 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) }, .endianness = DEVICE_LITTLE_ENDIAN, }; + g_autoptr(GString) name = g_string_new(NULL); - + g_string_printf(name, "virtio-pci-common-%s", vdev_name); memory_region_init_io(&proxy->common.mr, OBJECT(proxy), &common_ops, proxy, - "virtio-pci-common", + name->str, proxy->common.size); + g_string_printf(name, "virtio-pci-isr-%s", vdev_name); memory_region_init_io(&proxy->isr.mr, OBJECT(proxy), &isr_ops, proxy, - "virtio-pci-isr", + name->str, proxy->isr.size); + g_string_printf(name, "virtio-pci-device-%s", vdev_name); memory_region_init_io(&proxy->device.mr, OBJECT(proxy), &device_ops, virtio_bus_get_device(&proxy->bus), - "virtio-pci-device", + name->str, proxy->device.size); + g_string_printf(name, "virtio-pci-notify-%s", vdev_name); memory_region_init_io(&proxy->notify.mr, OBJECT(proxy), ¬ify_ops, virtio_bus_get_device(&proxy->bus), - "virtio-pci-notify", + name->str, proxy->notify.size); + g_string_printf(name, "virtio-pci-notify-pio-%s", vdev_name); memory_region_init_io(&proxy->notify_pio.mr, OBJECT(proxy), ¬ify_pio_ops, virtio_bus_get_device(&proxy->bus), - "virtio-pci-notify-pio", + name->str, proxy->notify_pio.size); } @@ -1623,7 +1629,7 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) struct virtio_pci_cfg_cap *cfg_mask; - virtio_pci_modern_regions_init(proxy); + virtio_pci_modern_regions_init(proxy, vdev->name); virtio_pci_modern_mem_region_map(proxy, &proxy->common, &cap); virtio_pci_modern_mem_region_map(proxy, &proxy->isr, &cap); From patchwork Mon Jul 13 20:04:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328428 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=brV9IPLq; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F4C2lJgz9sQt for ; Tue, 14 Jul 2020 06:04:59 +1000 (AEST) Received: from localhost ([::1]:37878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4h6-0008Dq-VS for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:04:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gh-0008Al-0Y for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:31 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:36789) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gf-0006J4-5z for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:30 -0400 Received: by mail-wr1-x432.google.com with SMTP id k6so18141908wrn.3 for ; Mon, 13 Jul 2020 13:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WVJRm9yMA7V6UraKTz4oUpniy0kUGIO9MjLG/c6LBA4=; b=brV9IPLqyHOY39GAGvoiqQuEIULY6Qz2VDd5AMTfpE6Y2UX8M1sFYtiL7vQueonLBn XOzcaMlCmpE1l3nmzYzmBQJI7fjS4LXhPkpX+grlJAdRAUYXEzVgnsx+SQ9gRnzI8Pja yL86EcL3+h/C4sYALSzZRJtKD4QGi4YIFp2rXYUeNoHK4LCOLt+csBlOjl619Q9Q8mo4 LRHQUFX+wUDtQQSSmyBp7iGkXvC55tu8IrHhWVtp3gBvsXP4nM6lrwYtpvRjlEgpe604 X1aiueqArJdVvuxQ/cw/0SlCJ1insY33GyGv6+wuAIseRjmG9vhidUFQSzdB5YMsTVuh iyPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WVJRm9yMA7V6UraKTz4oUpniy0kUGIO9MjLG/c6LBA4=; b=cjVcWHtRT1BdCgxJTQVpCHdKJzwBQS/3vjRyKRZNCLKOkaaCXRlUhx0Au+nhbkm3+m JADjC/X95EYK/SPsXDb6X6HySgxwFy5Ia7iKM2/Y+3INll58l1/gn59QrzEs314xEf0j CseCalwRC6z7Av94on5T+r7QJUGldYvWeChltitft65xFmsukBvHBQmEnAIpUlGOccBN HAXfB0rzLFKfOSorU8nCjVDBNTUE8FWu4hO8VaU9s7I0Jg3mdH7n6B8Ff6kFxWMzNLrf 0DfGpv03nsM2EB0+256P7XNwkqfuAswlhC+Hyteti20Vh73AgfztTEmXAArOtAgdvQIK SlBw== X-Gm-Message-State: AOAM533nRlJ8JmsJIFbRnTIR4wbLYrDX6rAfKrOT2d+Uy/c8Hd1Akrj9 xXbZSde/Av7PAxZFlgmGbjcwNw== X-Google-Smtp-Source: ABdhPJzY6nZfWP1FFWkxezxCH53BQD5c/5qRA8nyUGnouowv9rCA9JVV/YjbOgu9bDKLZf97JbfH7w== X-Received: by 2002:adf:e482:: with SMTP id i2mr1157195wrm.75.1594670667812; Mon, 13 Jul 2020 13:04:27 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q7sm25941773wrs.27.2020.07.13.13.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8869F1FF99; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 10/11] plugins: add API to return a name for a IO device Date: Mon, 13 Jul 2020 21:04:14 +0100 Message-Id: <20200713200415.26214-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x432.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, Clement Deschamps , aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This may well end up being anonymous but it should always be unique. Signed-off-by: Alex Bennée [r-b provisional given change to g_intern_string] Reviewed-by: Clement Deschamps Reviewed-by: Emilio G. Cota Reviewed-by: Richard Henderson --- v3 - return a non-freeable const g_intern_string() - checkpatch cleanups --- include/qemu/qemu-plugin.h | 6 ++++++ plugins/api.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index bab8b0d4b3..c98c18d6b0 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -335,6 +335,12 @@ struct qemu_plugin_hwaddr *qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info, bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr); uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr); +/* + * Returns a string representing the device. The string is valid for + * the lifetime of the plugin. + */ +const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h); + typedef void (*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index, qemu_plugin_meminfo_t info, uint64_t vaddr, diff --git a/plugins/api.c b/plugins/api.c index bbdc5a4eb4..4304e63f0c 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -303,6 +303,26 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr *haddr return 0; } +const char *qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *h) +{ +#ifdef CONFIG_SOFTMMU + if (h && h->is_io) { + MemoryRegionSection *mrs = h->v.io.section; + if (!mrs->mr->name) { + unsigned long maddr = 0xffffffff & (uintptr_t) mrs->mr; + g_autofree char *temp = g_strdup_printf("anon%08lx", maddr); + return g_intern_string(temp); + } else { + return g_intern_string(mrs->mr->name); + } + } else { + return g_intern_string("RAM"); + } +#else + return g_intern_string("Invalid"); +#endif +} + /* * Queries to the number and potential maximum number of vCPUs there * will be. This helps the plugin dimension per-vcpu arrays. From patchwork Mon Jul 13 20:04:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 1328438 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qMuu8NUF; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B5F8w2Nqsz9sQt for ; Tue, 14 Jul 2020 06:09:04 +1000 (AEST) Received: from localhost ([::1]:58436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jv4l4-00083c-3S for incoming@patchwork.ozlabs.org; Mon, 13 Jul 2020 16:09:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jv4gl-0008Lf-Gq for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:35 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:36918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jv4gj-0006Ji-3P for qemu-devel@nongnu.org; Mon, 13 Jul 2020 16:04:35 -0400 Received: by mail-wr1-x42e.google.com with SMTP id a6so18135546wrm.4 for ; Mon, 13 Jul 2020 13:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pdf6aU3FyC9r3Nn2r3fEZmyoTvKCMt4IaqLuhhG9jq4=; b=qMuu8NUF/b5XQzGj6rgCcShJ7YZW8kcH5Cws6JU6MI7d+6hvHv2O8wUnQxD18xN6Ib /GUBwiTEa4mi60XToVO4xC4Vv528IZZWbNckDvFA+EAeTtPf8lNWOU18vdJ9uR2ddDer 9MtAnIARhKWhMJSXUSOlWGNCfqok2+OPyzZ0xwUH0d3l6mjambBEH34WyN/HOBZxjtCS TBY8Vk9tCA3A0DsJ5p3hsMOYAdA3zhejqb+xWlM1Kz5nr/yaFyAJndYCrov4ZNZL84b3 4WVfMvz8Qbw9uBgPv08fMSe2/8/ZjihGHZJaVVw++tRYhUx5PKEzlAeWu4Z1535PuLXO zRrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pdf6aU3FyC9r3Nn2r3fEZmyoTvKCMt4IaqLuhhG9jq4=; b=MbVnJqJd6DP0ycZbtdSEiarivYN+Zfu6flCygS76VaNET7bd187quK0+EJpMGOQNW3 hYkOfKlY/XGmFcdV/JMgkxbXSzvhq65n95Ub2NSWphLYRDFLtEnJ23OLBdPu5tw8gTQA OE8ctp0kVxnwHmsKd9eXSKp6GM9wh6X51oU3/NJ8Qb8vYLlfycNVBxXnCN2HAo+YmFP8 jbwN+syBNKdRI76nklr12K+DJLndf0p23L0X0rH/CinmFxRBLi5pDGHpDwFAYJ2fI/9x nivcAp7BGFIM/HkHHtb1ss7JtWrqUz2thSybKrOdOfGvXRVN8coB1PQfOC4Pu+5tTvmp i4gw== X-Gm-Message-State: AOAM533ZZzLU/YVjMqp/ccpe9OxBVCyW5HMjGKTmHFqrK9Fs0CgzT1fZ kdwmpnnjHzE+KLnHtkWpLrYaGA== X-Google-Smtp-Source: ABdhPJwVxlhQ9mVVhwT4VIn7GVK6w/nxlGINZcKsC992JVrFpK6Zxjo0UMSxUODSRdT1QtVrc4vJ5A== X-Received: by 2002:adf:d0d0:: with SMTP id z16mr1230452wrh.95.1594670671470; Mon, 13 Jul 2020 13:04:31 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id d81sm1348870wmc.0.2020.07.13.13.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 13:04:23 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A391A1FF9A; Mon, 13 Jul 2020 21:04:16 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/11] plugins: new hwprofile plugin Date: Mon, 13 Jul 2020 21:04:15 +0100 Message-Id: <20200713200415.26214-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200713200415.26214-1-alex.bennee@linaro.org> References: <20200713200415.26214-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, URIBL_BLOCKED=0.001 autolearn=ham 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: fam@euphon.net, berrange@redhat.com, robert.foley@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, robhenry@microsoft.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , aaron@os.amperecomputing.com, cota@braap.org, kuhn.chenqun@huawei.com, peter.puhov@linaro.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is a plugin intended to help with profiling access to various bits of system hardware. It only really makes sense for system emulation. It takes advantage of the recently exposed helper API that allows us to see the device name (memory region name) associated with a device. You can specify arg=read or arg=write to limit the tracking to just reads or writes (by default it does both). The pattern option: -plugin ./tests/plugin/libhwprofile.so,arg=pattern will allow you to see the access pattern to devices, eg: gic_cpu @ 0xffffffc010040000 off:00000000, 8, 1, 8, 1 off:00000000, 4, 1, 4, 1 off:00000000, 2, 1, 2, 1 off:00000000, 1, 1, 1, 1 The source option: -plugin ./tests/plugin/libhwprofile.so,arg=source will track the virtual source address of the instruction making the access: pl011 @ 0xffffffc010031000 pc:ffffffc0104c785c, 1, 4, 0, 0 pc:ffffffc0104c7898, 1, 4, 0, 0 pc:ffffffc010512bcc, 2, 1867, 0, 0 You cannot mix source and pattern. Finally the match option allow you to limit the tracking to just the devices you care about. Signed-off-by: Alex Bennée Reviewed-by: Robert Foley Tested-by: Robert Foley --- v2 - use 64 bit cpu masks - warn if we will exceed cpu mask capability - don't run in linux-user mode - skip in check-tcg for linux-user test v3 - update device name API - re-factor and clean-up - add source tracking - use direct hash for source/pattern - add match function - expand the commit message - checkpatch cleanups --- tests/plugin/hwprofile.c | 305 ++++++++++++++++++++++++++++++++++++++ tests/plugin/Makefile | 1 + tests/tcg/Makefile.target | 12 +- 3 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 tests/plugin/hwprofile.c diff --git a/tests/plugin/hwprofile.c b/tests/plugin/hwprofile.c new file mode 100644 index 0000000000..6dac1d5f85 --- /dev/null +++ b/tests/plugin/hwprofile.c @@ -0,0 +1,305 @@ +/* + * Copyright (C) 2020, Alex Bennée + * + * HW Profile - breakdown access patterns for IO to devices + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +typedef struct { + uint64_t cpu_read; + uint64_t cpu_write; + uint64_t reads; + uint64_t writes; +} IOCounts; + +typedef struct { + uint64_t off_or_pc; + IOCounts counts; +} IOLocationCounts; + +typedef struct { + const char *name; + uint64_t base; + IOCounts totals; + GHashTable *detail; +} DeviceCounts; + +static GMutex lock; +static GHashTable *devices; + +/* track the access pattern to a piece of HW */ +static bool pattern; +/* track the source address of access to HW */ +static bool source; +/* track only matched regions of HW */ +static bool check_match; +static gchar **matches; + +static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; + +static inline bool track_reads(void) +{ + return rw == QEMU_PLUGIN_MEM_RW || rw == QEMU_PLUGIN_MEM_R; +} + +static inline bool track_writes(void) +{ + return rw == QEMU_PLUGIN_MEM_RW || rw == QEMU_PLUGIN_MEM_W; +} + +static void plugin_init(void) +{ + devices = g_hash_table_new(NULL, NULL); +} + +static gint sort_cmp(gconstpointer a, gconstpointer b) +{ + DeviceCounts *ea = (DeviceCounts *) a; + DeviceCounts *eb = (DeviceCounts *) b; + return ea->totals.reads + ea->totals.writes > + eb->totals.reads + eb->totals.writes ? -1 : 1; +} + +static gint sort_loc(gconstpointer a, gconstpointer b) +{ + IOLocationCounts *ea = (IOLocationCounts *) a; + IOLocationCounts *eb = (IOLocationCounts *) b; + return ea->off_or_pc > eb->off_or_pc; +} + +static void fmt_iocount_record(GString *s, IOCounts *rec) +{ + if (track_reads()) { + g_string_append_printf(s, ", %"PRIx64", %"PRId64, + rec->cpu_read, rec->reads); + } + if (track_writes()) { + g_string_append_printf(s, ", %"PRIx64", %"PRId64, + rec->cpu_write, rec->writes); + } +} + +static void fmt_dev_record(GString *s, DeviceCounts *rec) +{ + g_string_append_printf(s, "%s, 0x%"PRIx64, + rec->name, rec->base); + fmt_iocount_record(s, &rec->totals); + g_string_append_c(s, '\n'); +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) report = g_string_new(""); + GList *counts; + + if (!(pattern || source)) { + g_string_printf(report, "Device, Address"); + if (track_reads()) { + g_string_append_printf(report, ", RCPUs, Reads"); + } + if (track_writes()) { + g_string_append_printf(report, ", WCPUs, Writes"); + } + g_string_append_c(report, '\n'); + } + + counts = g_hash_table_get_values(devices); + if (counts && g_list_next(counts)) { + GList *it; + + it = g_list_sort(counts, sort_cmp); + + while (it) { + DeviceCounts *rec = (DeviceCounts *) it->data; + if (rec->detail) { + GList *accesses = g_hash_table_get_values(rec->detail); + GList *io_it = g_list_sort(accesses, sort_loc); + const char *prefix = pattern ? "off" : "pc"; + g_string_append_printf(report, "%s @ 0x%"PRIx64"\n", + rec->name, rec->base); + while (io_it) { + IOLocationCounts *loc = (IOLocationCounts *) io_it->data; + g_string_append_printf(report, " %s:%08"PRIx64, + prefix, loc->off_or_pc); + fmt_iocount_record(report, &loc->counts); + g_string_append_c(report, '\n'); + io_it = io_it->next; + } + } else { + fmt_dev_record(report, rec); + } + it = it->next; + }; + g_list_free(it); + } + + qemu_plugin_outs(report->str); +} + +static DeviceCounts *new_count(const char *name, uint64_t base) +{ + DeviceCounts *count = g_new0(DeviceCounts, 1); + count->name = name; + count->base = base; + if (pattern || source) { + count->detail = g_hash_table_new(NULL, NULL); + } + g_hash_table_insert(devices, (gpointer) name, count); + return count; +} + +static IOLocationCounts *new_location(GHashTable *table, uint64_t off_or_pc) +{ + IOLocationCounts *loc = g_new0(IOLocationCounts, 1); + loc->off_or_pc = off_or_pc; + g_hash_table_insert(table, (gpointer) off_or_pc, loc); + return loc; +} + +static void hwprofile_match_hit(DeviceCounts *rec, uint64_t off) +{ + g_autoptr(GString) report = g_string_new("hwprofile: match @ offset"); + g_string_append_printf(report, "%"PRIx64", previous hits\n", off); + fmt_dev_record(report, rec); + qemu_plugin_outs(report->str); +} + +static void inc_count(IOCounts *count, bool is_write, unsigned int cpu_index) +{ + if (is_write) { + count->writes++; + count->cpu_write |= (1 << cpu_index); + } else { + count->reads++; + count->cpu_read |= (1 << cpu_index); + } +} + +static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + struct qemu_plugin_hwaddr *hwaddr = qemu_plugin_get_hwaddr(meminfo, vaddr); + + if (!hwaddr || !qemu_plugin_hwaddr_is_io(hwaddr)) { + return; + } else { + const char *name = qemu_plugin_hwaddr_device_name(hwaddr); + uint64_t off = qemu_plugin_hwaddr_device_offset(hwaddr); + bool is_write = qemu_plugin_mem_is_store(meminfo); + DeviceCounts *counts; + + g_mutex_lock(&lock); + counts = (DeviceCounts *) g_hash_table_lookup(devices, name); + + if (!counts) { + uint64_t base = vaddr - off; + counts = new_count(name, base); + } + + if (check_match) { + if (g_strv_contains((const char * const *)matches, counts->name)) { + hwprofile_match_hit(counts, off); + inc_count(&counts->totals, is_write, cpu_index); + } + } else { + inc_count(&counts->totals, is_write, cpu_index); + } + + /* either track offsets or source of access */ + if (source) { + off = (uint64_t) udata; + } + + if (pattern || source) { + IOLocationCounts *io_count = g_hash_table_lookup(counts->detail, + (gpointer) off); + if (!io_count) { + io_count = new_location(counts->detail, off); + } + inc_count(&io_count->counts, is_write, cpu_index); + } + + g_mutex_unlock(&lock); + } +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n = qemu_plugin_tb_n_insns(tb); + size_t i; + + for (i = 0; i < n; i++) { + struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i); + gpointer udata = (gpointer) (source ? qemu_plugin_insn_vaddr(insn) : 0); + qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr, + QEMU_PLUGIN_CB_NO_REGS, + rw, udata); + } +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + int i; + + for (i = 0; i < argc; i++) { + char *opt = argv[i]; + if (g_strcmp0(opt, "read") == 0) { + rw = QEMU_PLUGIN_MEM_R; + } else if (g_strcmp0(opt, "write") == 0) { + rw = QEMU_PLUGIN_MEM_W; + } else if (g_strcmp0(opt, "pattern") == 0) { + pattern = true; + } else if (g_strcmp0(opt, "source") == 0) { + source = true; + } else if (g_str_has_prefix(opt, "match")) { + gchar **parts = g_strsplit(opt, "=", 2); + check_match = true; + matches = g_strsplit(parts[1], ",", -1); + g_strfreev(parts); + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + if (source && pattern) { + fprintf(stderr, "can only currently track either source or pattern.\n"); + return -1; + } + + if (!info->system_emulation) { + fprintf(stderr, "hwprofile: plugin only useful for system emulation\n"); + return -1; + } + + /* Just warn about overflow */ + if (info->system.smp_vcpus > 64 || + info->system.max_vcpus > 64) { + fprintf(stderr, "hwprofile: can only track up to 64 CPUs\n"); + } + + plugin_init(); + + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + return 0; +} diff --git a/tests/plugin/Makefile b/tests/plugin/Makefile index e9348fde4a..e9d1947751 100644 --- a/tests/plugin/Makefile +++ b/tests/plugin/Makefile @@ -21,6 +21,7 @@ NAMES += hotblocks NAMES += howvec NAMES += hotpages NAMES += lockstep +NAMES += hwprofile SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES))) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 4b2b696fce..bc595b0588 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -129,8 +129,16 @@ ifeq ($(CONFIG_PLUGIN),y) PLUGIN_SRC=$(SRC_PATH)/tests/plugin PLUGIN_LIB=../../plugin VPATH+=$(PLUGIN_LIB) -PLUGINS=$(filter-out liblockstep.so,\ - $(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))) + +# Some plugins aren't testable automatically +SKIP_PLUGINS=liblockstep.so +ifdef CONFIG_USER_ONLY +SKIP_PLUGINS+=libhwprofile.so +endif + +PLUGINS=$(filter-out $(SKIP_PLUGINS),\ + $(patsubst %.c, lib%.so, \ + $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))) # We need to ensure expand the run-plugin-TEST-with-PLUGIN # pre-requistes manually here as we can't use stems to handle it. We