From patchwork Thu Dec 19 10:49:31 2019 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: 182100 Delivered-To: patch@linaro.org Received: by 2002:a92:d0a:0:0:0:0:0 with SMTP id 10csp331153iln; Thu, 19 Dec 2019 03:10:54 -0800 (PST) X-Google-Smtp-Source: APXvYqzCvs/CjHx+1MkT4L+KrMQfx9uYCM3XGaTmjtpjWIXM7csIl5EOpD5t2XRyTkK3N2CB9TP+ X-Received: by 2002:a05:620a:91c:: with SMTP id v28mr6436549qkv.248.1576753854354; Thu, 19 Dec 2019 03:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576753854; cv=none; d=google.com; s=arc-20160816; b=lIIOVzOp0IxwQj8Zux2MFZZpC87keTIMthDP3vAVgddyEbF1XnbBwBgNxBWUQkCKlm wf2/Q1mWbKVWbqU5QEanhF6L8obRAp08FU76Z0ut0AfVav6l4K/Lws1lvKf+KAVWSbEe q+WtxAslWwbRsZY9cQrJnhNkpLaqMwndqRXj5p/asyd6+Di67WdV+NrCpfZL3i1Ry55n su5vcQI4hY+ds+qRUuSGk4yzZMt6yFLkqopgjoLEFh5JbJzXkuzg5ZABQxub+6YY1jvw LE3rQjB7S4EsG4pK3v+05ZVJr+VnulK1EENGUINXGvCtzhLM0nNSvh9IYpMc6tQj81zO n46w== 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=rjDJrz6x/SGN471YkmM/0ztom5/w9/oR2o+AFj80PtQ=; b=ugYlimpEizi8e8rpQ+ih4q99BIs2iHZ+Ngj4uygygYmHgl4K7sab687Q6g7ERKRsyX QeFFrZBtseniUVwDHj5NJ6VC53iQPaz4RubAdsxggl0AREMuGzMYnqPyXY5/CZ/pgpSK 1wHRypVpBTnq6t6I2VGQXWYVD8KYej6O0CzKTwI4X++qpnXcC3G7ljLC+KXX4D1CrRtP 02N8gUfuu2WLdIfkI++0VAy9n9uqua5qjmmR1ghTeZduIu2XVKhmqpX+enrmwmH31vv8 zgfJF91J98+kNmE3xCO5fNrTQPe3seEmv5woRh3ZfISlczSP6dEQxKh1vlaWkPoI05mi 6n/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qsiq10gG; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v5si2960022qvw.157.2019.12.19.03.10.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Dec 2019 03:10:54 -0800 (PST) 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=@linaro.org header.s=google header.b=qsiq10gG; 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=linaro.org Received: from localhost ([::1]:39250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihthl-0002kH-P0 for patch@linaro.org; Thu, 19 Dec 2019 06:10:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57951) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihtWk-0003zZ-1V for qemu-devel@nongnu.org; Thu, 19 Dec 2019 05:59:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihtWi-0001Yy-KE for qemu-devel@nongnu.org; Thu, 19 Dec 2019 05:59:29 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:33658) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ihtWi-0001U0-BS for qemu-devel@nongnu.org; Thu, 19 Dec 2019 05:59:28 -0500 Received: by mail-wr1-x444.google.com with SMTP id b6so5547414wrq.0 for ; Thu, 19 Dec 2019 02:59:28 -0800 (PST) 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=rjDJrz6x/SGN471YkmM/0ztom5/w9/oR2o+AFj80PtQ=; b=qsiq10gGXkKpkjtndeMa0YzmhXow3734kohC5sUAoc+NbOyXSEzhywOPk86eu2yIil wx9RZ2A49xYkCZdNyf36zWGyOPWCv2rWCXOho0tS7ifS4H4VDPbsiP+f2cX/aKnQb/wS WPc74fdkKGk27dnJ5wBrXCSvc4gViMIM1daantBQPc4fSbL+Ba1uN51J9x5209zoBk7b LQv7zlVrhd0dmTqQHRaE2WEUzxfEJy8DJCsZqHP5ibLh6IF33srDAYaY5YuDEE2Dpd3t FnMcy47LQDrpto978sYIZCSgZGI28PQ11Hh0D80ibWuLciFwtPwzavLysfsMltJe/LmA 2QJQ== 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=rjDJrz6x/SGN471YkmM/0ztom5/w9/oR2o+AFj80PtQ=; b=XgxBVS6FHWulWHrpZvZQNHGitoXFhXgfjpgH7+uSNO0xC5KvXCfyvlgm2AYk2ouJnV 4wKTxm0kLf120HYGcmt4Nb48a2C0oq+DT8YiyuMZq4wGty2o8xp93d9UaJyX7gaSQXAC Yei7pSBW4ps5a5xIeN751PFRkkf8Q28Nb6m3/4eng9tjVYR4uQHliUzOWWfK5kft8DRw 5txmg42tiF+NUShaX1kqaVWWqVOt+qBO+abmVDLy7IBMwfdhtJxtCKF9Td4pzUvXypTD haNaLYS649Hgb6qnUMuQisvzluQRctL04iMsP4QilIKdNuE/+KoBtJERsdUrLlj6TQPy PUaw== X-Gm-Message-State: APjAAAVMfnOE5b9wLNba+BEOzP0nHBai9dMe4XN2gf2X4osnBTvRAtcA 5dfW0STPxAxgz4C4r5jyG2MTIQ== X-Received: by 2002:adf:ffc5:: with SMTP id x5mr8876623wrs.92.1576753167174; Thu, 19 Dec 2019 02:59:27 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a1sm5967336wrr.80.2019.12.19.02.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 02:59:20 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8D2E81FFAC; Thu, 19 Dec 2019 10:49:36 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 22/25] linux-user: log page table changes under -d page Date: Thu, 19 Dec 2019 10:49:31 +0000 Message-Id: <20191219104934.866-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191219104934.866-1-alex.bennee@linaro.org> References: <20191219104934.866-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 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: Richard Henderson , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The CPU_LOG_PAGE flag is woefully underused and could stand to do extra duty tracking page changes. If the user doesn't want to see the details as things change they still have the tracepoints available. We push the locking into log_page_dump and pass a reason for the banner text. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier Message-Id: <20191205122518.10010-5-alex.bennee@linaro.org> -- 2.20.1 diff --git a/include/exec/log.h b/include/exec/log.h index 9bd1e4aa20b..fcc7b9e00ba 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -69,15 +69,14 @@ static inline void log_disas(void *code, unsigned long size) #if defined(CONFIG_USER_ONLY) /* page_dump() output to the log file: */ -static inline void log_page_dump(void) +static inline void log_page_dump(const char *operation) { - QemuLogFile *logfile; - rcu_read_lock(); - logfile = atomic_rcu_read(&qemu_logfile); + FILE *logfile = qemu_log_lock(); if (logfile) { - page_dump(logfile->fd); + qemu_log("page layout changed following %s\n", operation); + page_dump(logfile); } - rcu_read_unlock(); + qemu_log_unlock(logfile); } #endif #endif diff --git a/bsd-user/main.c b/bsd-user/main.c index 470a8bf79ed..7f4e3cd6271 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -963,7 +963,7 @@ int main(int argc, char **argv) if (qemu_loglevel_mask(CPU_LOG_PAGE)) { qemu_log("guest_base 0x%lx\n", guest_base); - log_page_dump(); + log_page_dump("binary load"); qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); diff --git a/linux-user/main.c b/linux-user/main.c index 6ff7851e86f..8718d03ee21 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -826,7 +826,7 @@ int main(int argc, char **argv, char **envp) if (qemu_loglevel_mask(CPU_LOG_PAGE)) { qemu_log("guest_base 0x%lx\n", guest_base); - log_page_dump(); + log_page_dump("binary load"); qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 0b1b43ac3c0..3d90fa459ca 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "trace.h" +#include "exec/log.h" #include "qemu.h" //#define DEBUG_MMAP @@ -539,10 +540,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, page_set_flags(start, start + len, prot | PAGE_VALID); the_end: trace_target_mmap_complete(start); -#ifdef DEBUG_MMAP - page_dump(stdout); - printf("\n"); -#endif + if (qemu_loglevel_mask(CPU_LOG_PAGE)) { + log_page_dump(__func__); + } tb_invalidate_phys_range(start, start + len); mmap_unlock(); return start;