From patchwork Mon May 9 07:45:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ingo Molnar X-Patchwork-Id: 768572 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p497jhkH000575 for ; Mon, 9 May 2011 07:45:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752668Ab1EIHpk (ORCPT ); Mon, 9 May 2011 03:45:40 -0400 Received: from mx3.mail.elte.hu ([157.181.1.138]:33720 "EHLO mx3.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752651Ab1EIHpk (ORCPT ); Mon, 9 May 2011 03:45:40 -0400 Received: from elvis.elte.hu ([157.181.1.14]) by mx3.mail.elte.hu with esmtp (Exim) id 1QJL9q-0004pQ-MJ from ; Mon, 09 May 2011 09:45:35 +0200 Received: by elvis.elte.hu (Postfix, from userid 1004) id 393893E252E; Mon, 9 May 2011 09:45:30 +0200 (CEST) Date: Mon, 9 May 2011 09:45:32 +0200 From: Ingo Molnar To: Pekka Enberg Cc: kvm@vger.kernel.org, Asias He , Avi Kivity , Cyrill Gorcunov , Prasad Joshi , Sasha Levin Subject: [PATCH] kvm tools: Dump vCPUs in order Message-ID: <20110509074532.GA15850@elte.hu> References: <1304848902-11327-1-git-send-email-penberg@kernel.org> <20110509072711.GA414@elte.hu> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110509072711.GA414@elte.hu> User-Agent: Mutt/1.5.20 (2009-08-17) Received-SPF: neutral (mx3: 157.181.1.14 is neither permitted nor denied by domain of elte.hu) client-ip=157.181.1.14; envelope-from=mingo@elte.hu; helo=elvis.elte.hu; X-ELTE-SpamScore: -2.0 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-2.0 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.3.1 -2.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 09 May 2011 07:45:44 +0000 (UTC) * Ingo Molnar wrote: > The patch below addresses these concerns, serializes the output, tidies up the > printout, resulting in this new output: There's one bug remaining that my patch does not address: the vCPUs are not printed in order: # vCPU #0's dump: # vCPU #2's dump: # vCPU #24's dump: # vCPU #5's dump: # vCPU #39's dump: # vCPU #38's dump: # vCPU #51's dump: # vCPU #11's dump: # vCPU #10's dump: # vCPU #12's dump: This is undesirable as the order of printout is highly random, so successive dumps are difficult to compare. The patch below serializes the signalling itself. (this is on top of the previous patch) The patch also tweaks the vCPU printout line a bit so that it does not start with '#', which is discarded if such messages are pasted into Git commit messages. Signed-off-by: Ingo Molnar --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index 221435d..00c70c7 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -25,6 +25,7 @@ #include #include #include +#include /* header files for gitish interface */ #include @@ -132,7 +133,7 @@ static const struct option options[] = { * Serialize debug printout so that the output of multiple vcpus does not * get mixed up: */ -static DEFINE_MUTEX(printout_mutex); +static int printout_done; static void handle_sigusr1(int sig) { @@ -141,13 +142,13 @@ static void handle_sigusr1(int sig) if (!cpu) return; - mutex_lock(&printout_mutex); - printf("\n#\n# vCPU #%ld's dump:\n#\n", cpu->cpu_id); + printf("\n #\n # vCPU #%ld's dump:\n #\n", cpu->cpu_id); kvm_cpu__show_registers(cpu); kvm_cpu__show_code(cpu); kvm_cpu__show_page_tables(cpu); fflush(stdout); - mutex_unlock(&printout_mutex); + printout_done = 1; + mb(); } static void handle_sigquit(int sig) @@ -160,7 +161,15 @@ static void handle_sigquit(int sig) if (!cpu) continue; + printout_done = 0; pthread_kill(cpu->thread, SIGUSR1); + /* + * Wait for the vCPU to dump state before signalling + * the next thread. Since this is debug code it does + * not matter that we are burning CPU time a bit: + */ + while (!printout_done) + mb(); } serial8250__inject_sysrq(kvm);