From patchwork Fri Sep 17 08:45:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12501441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1A09C433EF for ; Fri, 17 Sep 2021 08:46:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6139F60F58 for ; Fri, 17 Sep 2021 08:46:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6139F60F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.189091.338581 (Exim 4.92) (envelope-from ) id 1mR9Vd-0003Ac-7H; Fri, 17 Sep 2021 08:46:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 189091.338581; Fri, 17 Sep 2021 08:46:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vd-0003AV-4E; Fri, 17 Sep 2021 08:46:13 +0000 Received: by outflank-mailman (input) for mailman id 189091; Fri, 17 Sep 2021 08:46:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vb-0003AJ-Bv for xen-devel@lists.xenproject.org; Fri, 17 Sep 2021 08:46:11 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id eb5656a5-9797-4987-ab65-05c08dbf14b4; Fri, 17 Sep 2021 08:46:09 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: eb5656a5-9797-4987-ab65-05c08dbf14b4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1631868369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ZQl96R3uvW4xzr4o62S9ScZWcGCrnlnt7bSHNhrnNaU=; b=V09bcFVy7+SVBcd2ifwZ9uUI2NgUFkIDiv8RWdrtnTHdsI72C71Zuv6U 8hiuP1JyMU69fOBqdoVykwrFgVXYgOA7mtS9J/JsNkY/G7I3CrOBlAiwl pbR9NukIr4KDwzPRXiq125RSue9+26K5NF6LTF++8Fq/FfmuccjHeXglO c=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 2HwSl0Wy37iCWqK1V2Atl+jEb9D23bzvNaTNjZfsfml/Qw0LbobFvO+2H51Am8NEvA6N9q8F3U u54mHzrzOLsXTfuzDuba9XHO80bbx50yLrOKpjJlie+FkcH9SSI4iGEvZFN/2jIBQkK4hSFCrN ESafWK9rZpDjulP0SBHVmGpclH4boiTG5a38st7j+ffVkR2f9kwwh2zVl3pappV6OUpt08Rzjb qm1niSeRnGMQNgqCA5iucmJl/mIrXSmfsQ0AHQKoA0UsIE+Fe9NJJL4/A4aT4PVYSb2tMjDUVZ ZJsjGLJZTw8khpJpO+cCA3ce X-SBRS: 5.1 X-MesageID: 54750985 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:fbU+dqkyrGYGByzO8oRKKlTo5gx9IURdPkR7XQ2eYbSJt1+Wr1Gzt xIWCG6Pbq2LazDxKooga9+/pE5VsZ/cztFmT1Rqq3swHiMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA185IMsdoUg7wbdh09c32YHR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 I8dtICxQjUzBKr3ydUiWCYANCBRBYQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBODtMJkSpTdLyjbBAOx9aZvCX7/L9ZlT2zJYasVmQKqBO pJIOWcHgBLoSCZJJls3B4wFrb2ku0HmY21WrXWxuv9ii4TU5FMoi+W8WDbPQfSIWMFUk0Cwt m/AuWPjDXkyFvaS1D6E+XKEnfLUkGXwX4d6PLG2//FlgVqXx0QIFQYbE1C8pJGRlUqWS99Zb UsO9UIGvaU0sUCmUNT5dxm5u2Kf+A4RXcJKFO834x3LzbDbiy6YGWosXjNHcMYhtsI9WXotz FDht8jyGTVlvbmRSHSc3rSZtzW/PW4SN2BqWMMfZVJbuZ+5+th110+RCIY4eEKosjHrMWugw iyLpxokvbIo3P803Jrj2lHouxv58/AlUTUJChXrsnONt10iPdP0ONP2sDA3/t4bc93IFQDpU Gws3pHEtbFQV8nleDmlHb1VdIxF8cppJ9E1bbRHJJAn6z3l0HqqZ4k4DNpWdRoxb5psldMEZ ibuVeJtCH17ZyDCgUxfOdvZ5yEWIU7IToyNuhf8NIEmX3SJXFXblByCnGbJt4wXrKTJrU3ZE czDGSpLJS1BYZmLMRLsH7tNuVPV7nlmmAs/uqwXPzz4iOHDNRZ5uJ8uMUeUb/BR0U93iFyOq L5i2z+x40wHCoXWO3CPmaZKdAxiBSVrVPje9p0MHsbec1UOJY3UI6KIqV/XU9c+xPo9eyah1 izVZ3K0P3Kk2SSceFnVMys6AF4tNL4mxU8G0eUXFQ7A8xAejUyHtc/zrrM7Iusq8vJN1/lxQ 6VXcsmMGK0XGD/G5y4cfd/2q4k7LEanggeHPiyEZjkjfsE/G1yVq4G8Jga/pjMTCieXtNclp +Hy3A3sXpdeFR9pC9zbaazzwgrp72Qdgu97Q2DBPsJXJBf36IFvJiGo1q03LsgAJA/t3Dyf0 wrKUx4UqfOU+90+8cXThLDCpICsSrMsEk1fFmjdzLC3KSiFoTbznd4eCL6FJGmPWnn19aOuY fRu48v9aPBXzkxXt4dcEqpwyf5s7dXYuLIHnB9vG2/Gbgr3B+o4cGWGx8RGqoZE2qRd5VmtQ kuK99RXZeeJNcfiHAJDLQYpdL3eh/Qdmz2U5vUpOkTqoiRw+ePfA0lVOhCNjg1bLad0b9x5k btw5pZO5lztkAcuP/aHkjtQpjaFIXE3Wqk6so0XXd3wgQ0xx1AeOZHRB0caOn1Uhwmg5qXyH gKpuQ== IronPort-HdrOrdr: A9a23:TYb2g61ZJvQfTtENkAZnJQqjBLAkLtp133Aq2lEZdPRUGvb3qy nOpoVj6faaslYssR0b9exofZPwJE80lqQFh7X5X43SPzUO0VHAROoJgLcKgQeQfxEWntQtsp uIGJIeNDSfNzdHZL7BkWuFL+o= X-IronPort-AV: E=Sophos;i="5.85,300,1624334400"; d="scan'208";a="54750985" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH 1/6] xen/trace: Don't over-read trace objects Date: Fri, 17 Sep 2021 09:45:54 +0100 Message-ID: <20210917084559.22673-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210917084559.22673-1-andrew.cooper3@citrix.com> References: <20210917084559.22673-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 In the case that 'extra' isn't a multiple of uint32_t, the calculation rounds the number of bytes up, causing later logic to read unrelated bytes beyond the end of the object. Also, asserting that the object is within TRACE_EXTRA_MAX, but truncating it in release builds is rude. Instead, reject any out-of-spec records, leaving enough of a message to identify the faulty caller. Signed-off-by: Andrew Cooper --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli I've eyeballed the code and can't spot any problematic callers, but I came very close to accidentally introducing some when trying to fix the stack rubble leaks in subsequent patches. --- xen/common/trace.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/xen/common/trace.c b/xen/common/trace.c index a2a389a1c7c3..25af6e1bd25e 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -686,22 +686,21 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, unsigned long flags; u32 bytes_to_tail, bytes_to_wrap; unsigned int rec_size, total_size; - unsigned int extra_word; bool_t started_below_highwater; if( !tb_init_done ) return; - /* Convert byte count into word count, rounding up */ - extra_word = (extra / sizeof(u32)); - if ( (extra % sizeof(u32)) != 0 ) - extra_word++; - - ASSERT(extra_word <= TRACE_EXTRA_MAX); - extra_word = min_t(int, extra_word, TRACE_EXTRA_MAX); - - /* Round size up to nearest word */ - extra = extra_word * sizeof(u32); + /* + * Trace records require extra data which is an exact multiple of + * uint32_t. Reject out-of-spec records. Any failure here is an error in + * the caller. + */ + if ( extra % sizeof(uint32_t) || + extra / sizeof(uint32_t) > TRACE_EXTRA_MAX ) + return printk_once(XENLOG_WARNING + "Trace event %#x bad size %u, discarding\n", + event, extra); if ( (tb_event_mask & event) == 0 ) return; From patchwork Fri Sep 17 08:45:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12501447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09587C43219 for ; Fri, 17 Sep 2021 08:46:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3A2560FED for ; Fri, 17 Sep 2021 08:46:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B3A2560FED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.189096.338632 (Exim 4.92) (envelope-from ) id 1mR9Vn-0004Tf-7w; Fri, 17 Sep 2021 08:46:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 189096.338632; Fri, 17 Sep 2021 08:46:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vm-0004Qd-WE; Fri, 17 Sep 2021 08:46:23 +0000 Received: by outflank-mailman (input) for mailman id 189096; Fri, 17 Sep 2021 08:46:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vl-0003AK-FI for xen-devel@lists.xenproject.org; Fri, 17 Sep 2021 08:46:21 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b5c2337a-1793-11ec-b674-12813bfff9fa; Fri, 17 Sep 2021 08:46:12 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b5c2337a-1793-11ec-b674-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1631868372; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ygfYeKRHUam3n76JUrPhA5cc2MCBioaXf/z5nQljajU=; b=PXdInP1qkoK0HX/luY4x9tM+D5uac7N8fnWx5mP1TvUmuykJaT7S9zha 68IMer5LyAPlKHN01f1Nrmw8LJ0uhwunoLiSesmBg9GaBcSgcBJfMtRcI hI9o6lvxCLZNDSiqLOD+RRsa7kapzFOBbSLQBRxxX8h02e5jrdA1Ruuiy U=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: CXyVjty1K4B7IfW+acmd4wWK5wt94QebHnEe10gHKYcgtacvTTk7UXAaa1xDk3c5vqe0JbxrlS 4CwMXp0sJ/z4BNeMoIR2FigOHuNhGTC7aQ8JqzScEDNQm8jB7pCgzxKSIAMqVsU+HXuskv9L7x bNUoGpCuP7v6Dw9pChzUDknPp/dJ+EI4QkreVtn0xCmrA+A7DwvQ1FU5b8r3NMWMquaZT16R7F uWLadfRkFqotYV86M8wQc26GU58bOFrsq7XoBfFNvib9S3iWmZDudMPV3GQG2dE7/8MtsLhwys EM9LpMrY8ctZyDGni6srMhqZ X-SBRS: 5.1 X-MesageID: 52955352 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:WaLL86IJ9GqZ9ZnnFE+RLZIlxSXFcZb7ZxGr2PjKsXjdYENS1mFSn 2ZNWjjQaf/ZamL1fot/bYux8EhQ7cSAmoNrTwZlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUZ0ideSc+EH140UM6xLZg6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB2AgelP5 tNtrKWBbhsFMovCmr5DXShXRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsFFgMg5IdatF4QYonx6lhnSDOo8QICFSKLPjTNd9Gpq150TRquED yYfQSBTKzvxXgdvAFwwGoozgfialEX0dwQN/Tp5ooJoujOOnWSdyoPFMsfRe9GMbdVYmACfv G2u10bTDwweNdef4SGY6X/qjejK9Qv3VosdG7y/8v9Cm0CIyyoYDxh+fUS/iem0jAi5Qd03A 1wZ/G8ioLY/8GSvT8LhRFuorXicpBkeVtFMVeog52mly7XWyxaUAHAeSTxMY8Bgs9U5LRQxz UOAld7tAT1psZWWRGib+7PSqim9URX5NkdbO3VCF1FcpYC+/sdj1XojU+qPDoa8kOTLNzfQ2 gm7izQSi5Mdj5RV2ZS0qAWvby2XmnTZcuIkzlyJBTv4v1wmOtfNi5+AsgeAvK0ZRGqNZhzY5 iFVxZLGhAwbJczVzESwrPMx8KZFDhpvGAbVh0JmV7Il/i6kk5JIVdENuGwiTKuF38BtRNMIX KMxkVgKjHOwFCHzBUOSX25XI59ypUQHPY6+Ps04lvIUPvBMmPavpUmCn3J8OlwBdmB3ycnT3 r/AKq6R4YsyU/w7nFJauc9EieJDKt8CKZP7GsmgkkXPPUu2T3+JU7YVWGZinchgt/jsnekhy P4Gb5Hi40wGCIXWO3CLmaZOfQFiBSVqXvje9p0IHtNv1yI7QQnN/deKmuh/E2Gk9owI/tr1E oaVARMBkwuj2iSccG1nqBlLMdvSYHq2llpjVQREALpi8yJLjV+H4PhNep0pU6Mg8eA/n/d4Q +NcI5eLA+hVSySB8DMYNMGvoItnfRWtpASPIyv6P2RvI88+H1TEqo3+Yw/i1CgSFS7r58Ewl KKti1HASp0ZSgU8UMuPMKCzz0m8tGQ2kf5pWxeaOcFafUjhqdA4KyH4gvItDdsLLBHPmmmT2 wqMWE9KrujRuY4lttLOgPnc/YuuFuJ/GGtcHnXasunqZXWLoDL7zNYZAuiSfD3bWGflw4mYZ L1Yn6PmLfkKvFdWqI4gQbxl+r0zuon0rLhAwwU6QHiSNwa3CqltK2Wt1NVUsvEf3adQvAa7V x7d+tRePrnVasrpHERIeVggZ+WHk/oVhiPT/bI+J0CjvH17+7+OUENzORiQiXMCcOspYd19m epx6tQL7wGfiwYxNofUhy9ZwG2AM3gcXvh1rZodGoLq1lImx1wqjUYw0cMqDEVjs+lxD3Q= IronPort-HdrOrdr: A9a23:ToqY0qw7bTpHHS80/MlFKrPwLr1zdoMgy1knxilNoRw8SKKlfq GV7Y0mPHDP6Ar5NEtNpTnEAtjkfZq+z+8S3WByB8bAYOCOggLBR+sO0WKh+UyFJ8SXzJ876U 4KSclD4bPLYmSS9fyKgjWFLw== X-IronPort-AV: E=Sophos;i="5.85,300,1624334400"; d="scan'208";a="52955352" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH 2/6] xen/memory: Remove tail padding from TRC_MEM_* records Date: Fri, 17 Sep 2021 09:45:55 +0100 Message-ID: <20210917084559.22673-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210917084559.22673-1-andrew.cooper3@citrix.com> References: <20210917084559.22673-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Four TRC_MEM_* records supply custom structures with tail padding, leaking stack rubble into the trace buffer. Three of the records were fine in 32-bit builds of Xen, due to the relaxed alignment of 64-bit integers, but POD_SUPERPAGE_SPLITER was broken right from the outset. We could pack the datastructures to remove the padding, but xentrace_format has no way of rendering the upper half of a 16-bit field. Instead, expand all 16-bit fields to 32-bit. For POD_SUPERPAGE_SPLINTER, introduce an order field as it is relevant information, and to matche DECREASE_RESERVATION, and so it doesn't require a __packed attribute to drop tail padding. Update xenalyze's structures to match, and introduce xentrace_format rendering which was absent previously. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli The xentrace_format script isn't remotely Py3 compatible, and was another script missed by our previous efforts. --- tools/xentrace/formats | 4 ++++ tools/xentrace/xenalyze.c | 12 ++++++------ xen/arch/x86/mm/p2m-pod.c | 17 +++++++++-------- xen/common/memory.c | 4 ++-- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tools/xentrace/formats b/tools/xentrace/formats index deac4d8598b0..0fcc327a4078 100644 --- a/tools/xentrace/formats +++ b/tools/xentrace/formats @@ -136,6 +136,10 @@ 0x0010f001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_map [ domid = %(1)d ] 0x0010f002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_unmap [ domid = %(1)d ] 0x0010f003 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_transfer [ domid = %(1)d ] +0x0010f005 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) decrease_reservation [ d%(3)d gfn 0x%(2)08x%(1)08x, order %(4)u ] +0x0010f010 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pod_populate [ d%(5)d gfn 0x%(2)08x%(1)08x => mfn 0x%(4)08x%(3)08x, order %(6)u ] +0x0010f011 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pod_zero_reclaim [ d%(5)d gfn 0x%(2)08x%(1)08x => mfn 0x%(4)08x%(3)08x, order %(6)u ] +0x0010f012 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) pod_superpage_splinter [ d%(3)d gfn 0x%(2)08x%(1)08x, order %(4)u ] 0x00201001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hypercall [ eip = 0x%(1)08x, eax = 0x%(2)08x ] 0x00201101 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) hypercall [ rip = 0x%(2)08x%(1)08x, eax = 0x%(3)08x ] diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 5de167031e01..12dcca964645 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -8121,7 +8121,7 @@ void mem_pod_zero_reclaim_process(struct pcpu_info *p) struct { uint64_t gfn, mfn; - int d:16,order:16; + uint32_t d, order; } *r = (typeof(r))ri->d; if ( v && v->hvm.vmexit_valid ) @@ -8171,7 +8171,7 @@ void mem_pod_populate_process(struct pcpu_info *p) struct { uint64_t gfn, mfn; - int d:16,order:16; + uint32_t d, order; } *r = (typeof(r))ri->d; if ( opt.dump_all ) @@ -8204,14 +8204,14 @@ void mem_pod_superpage_splinter_process(struct pcpu_info *p) struct { uint64_t gfn; - int d:16; + uint32_t d, order; } *r = (typeof(r))ri->d; if ( opt.dump_all ) { - printf(" %s pod_spage_splinter d%d g %llx\n", + printf(" %s pod_spage_splinter d%d o%d g %"PRIx64"\n", ri->dump_header, - r->d, (unsigned long long)r->gfn); + r->d, r->order, r->gfn); } } @@ -8255,7 +8255,7 @@ void mem_decrease_reservation_process(struct pcpu_info *p) struct { uint64_t gfn; - int d:16,order:16; + uint32_t d, order; } *r = (typeof(r))ri->d; if ( opt.dump_all ) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 8abc57265c10..90f02ae765f6 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -819,8 +819,8 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, gfn_t gfn) if ( tb_init_done ) { struct { - u64 gfn, mfn; - int d:16,order:16; + uint64_t gfn, mfn; + uint32_t d, order; } t; t.gfn = gfn_x(gfn); @@ -987,8 +987,8 @@ p2m_pod_zero_check(struct p2m_domain *p2m, const gfn_t *gfns, unsigned int count if ( tb_init_done ) { struct { - u64 gfn, mfn; - int d:16,order:16; + uint64_t gfn, mfn; + uint32_t d, order; } t; t.gfn = gfn_x(gfns[i]); @@ -1217,8 +1217,8 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, if ( tb_init_done ) { struct { - u64 gfn, mfn; - int d:16,order:16; + uint64_t gfn, mfn; + uint32_t d, order; } t; t.gfn = gfn_x(gfn); @@ -1260,12 +1260,13 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, if ( tb_init_done ) { struct { - u64 gfn; - int d:16; + uint64_t gfn; + uint32_t d, order; } t; t.gfn = gfn_x(gfn); t.d = d->domain_id; + t.order = order; __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), &t); } diff --git a/xen/common/memory.c b/xen/common/memory.c index 63642278fda9..8fd88ccb70bf 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -450,8 +450,8 @@ static void decrease_reservation(struct memop_args *a) if ( tb_init_done ) { struct { - u64 gfn; - int d:16,order:16; + uint64_t gfn; + uint32_t d, order; } t; t.gfn = gmfn; From patchwork Fri Sep 17 08:45:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12501445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41DCBC4332F for ; Fri, 17 Sep 2021 08:46:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E157C60F58 for ; Fri, 17 Sep 2021 08:46:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E157C60F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.189097.338648 (Exim 4.92) (envelope-from ) id 1mR9Vr-00056J-I3; Fri, 17 Sep 2021 08:46:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 189097.338648; Fri, 17 Sep 2021 08:46:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vr-00055z-E5; Fri, 17 Sep 2021 08:46:27 +0000 Received: by outflank-mailman (input) for mailman id 189097; Fri, 17 Sep 2021 08:46:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vq-0003AJ-4H for xen-devel@lists.xenproject.org; Fri, 17 Sep 2021 08:46:26 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 96d0679e-c637-4476-adba-b04b33a520e1; Fri, 17 Sep 2021 08:46:12 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 96d0679e-c637-4476-adba-b04b33a520e1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1631868372; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=eIm9X8tHd1Tqh1vwMRrxy3l4K0nxBP+YaEDaO0VDgfI=; b=KftQD36peUPJ75JYLY91bHFCiJ+gQx7lNAjmct/xfe7LFvbeRDKg6l9S 8SGpUsws5uTrvO0hqYBi6Kd6KHuc5w6RCzLycp6vHQmVyRrVCD4PzV89j QULSfk0QnY+CraBjSc8XEchZg5p5L/yK9ChHTdioR20pOkum301/ITw0c Q=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: AJGC5ytMX6wDLwBH5aceLiWn1K3VQH9POy2hpb/QiQBV4/hUkdAF0vqbjdjPhmWoGCGRIVpE20 9mHYMWtG4BpnsAvWjRuTb83hR3GuIURHYjY3Y31lMaucVzU31sIGV6Ug3xViXkzJnOtex/LkrO E3oXF+BAbd3EPfq2sI5quzo700VPjqn/C9/x7EhxuJypMc/WfcLkbkVvfCl+pYBK5kElPeQRht AKpdCgVwhJi2+L8mqYnbo3tnGMXWB9n4KCus+MSWLQ412asFds6+9YhQF5yxTI/JK2Z98MebNy Il9BX7LVvjCTVmu+aUhgZJgP X-SBRS: 5.1 X-MesageID: 52955354 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:mKrjQ6A8Zb4okBVW/9Xkw5YqxClBgxIJ4kV8jS/XYbTApDwmgTRTy 2oWDG2POf2LZ2amLox1boy08ExSu8TQx9NrQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLOs1hxZH1c+EX9w0E07wobVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/1Gy4ptpP2 PV05IWTViERZpeLp98WTEwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTY+9gnMk8auLsO5sSoCpIxjDFF/c2B5vERs0m4PcFhmZt25sTQZ4yY eISaDZPRTDmYyFQEWkVA64iwKCOqGvgJmgwRFW9+vNsvjm7IBZK+LrwNNvYfPSaSMMTmVyXz krk1WnkBhARNPSE1CGItHmrg4fnkS3yV40TE7m53uV3m1DVzWsWYDUJUXOrrP//jVSxM/pPJ kpR9icwoKwa8E2wUsK7TxC+uGSDvBMXR5xXCeJSwACSyILE7gCBHG8GQzVdLts8u6ceXic23 1WEm9foAz1Hs7CPT3+ZsLCOoluP1TM9dDFYI3VeFE1cvoel8NpbYg/zoshLT/eEt9fLCRHJk impsw4G349UsvUAyPDulbzYuA5AtqQlXyZsuF6OAzP6sV0gDGK2T9f3sgmAtJ6sOK7cFwPY7 SZew6By+chTVcnlqcCbfAka8FhFDd6+OTvAiBZEG5A7/lxBEFbyINgNvFmSyKpvW/vomAMFg meI4mu9B7cJZRNGiJObharqU6zGKoC6TrzYugj8NIYmX3SIXFbvENtSiausM4bFyxBEfUYXY szzTCpRJSxCVfQPIMSeHr9AuVPU+szO7TyKHs2qp/hW+ZGfeGSUWd843KimN7tihJ5oVD79q o4FX+PTkk03eLSnPkH/rN5CRXhXfCNTLc2n9KRqmhurf1MO9JcJUKSKn9vMuuVNwsxoqws/1 irhAxQJlAWm3iSvxMfjQikLVY4DlK1X9RoTVRHA937xs5T6SYrwvqoZabUterwrqL5qwfJuF qFXcMScGPVfDD/A/m1FP5X6qYVjcjWthB6PYHX5MGRuIcY4Slyb4MLgcyvu6DIKUni9u/whr uDyzQjcW5cCGVhvVZ6EdPK1wlqtlnEBg+YuDVDQK9xedRy0oohnIiD8lNEtJMQIJUmRzzeWz V/OUxwZufPMs8k+99yQ3fKIqIKgEu1fGEtGHjaEsebqZHeCpmf6mN1OSueFezzZRVjYwqT6a LUH1ez4Pd0GgE1O79h2HYF0wP9s/NDovbJbkFhpRS2Zc1SxB7p8CXCaxs0T5LZVz7pUtAbqC EKC/t5WZeeANM//SQNDIQMkaqKI1O0OmymU5vMweR2o6Chy9buBcENTIxjT13ANcOoraNsok bU7pcobyw2jkR57YN+Jgxdd+3mIMnFdAb4ssYsXAdOzhwcmor2YjUcw1sMiDEmzVuhx IronPort-HdrOrdr: A9a23:YxKC4KCa6fkXarflHemo55DYdb4zR+YMi2TC1yhKKCC9E/bo7/ xG885rtiMc5Ax/ZJhko6HlBEDiewKkyXcW2/hyAV7KZmCP0wHEQL2Kr7GSpAEIcxeOkNK1vp 0BT0ERMrPN5CBB/KPH3DU= X-IronPort-AV: E=Sophos;i="5.85,300,1624334400"; d="scan'208";a="52955354" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH 3/6] xen/credit2: Remove tail padding from TRC_CSCHED2_* records Date: Fri, 17 Sep 2021 09:45:56 +0100 Message-ID: <20210917084559.22673-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210917084559.22673-1-andrew.cooper3@citrix.com> References: <20210917084559.22673-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 All three of these records have tail padding, leaking stack rubble into the trace buffer. Introduce an explicit _pad field and have the compiler zero the padding automatically. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli --- xen/common/sched/credit2.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index 6396b38e044c..d5f41bc3d603 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -1106,12 +1106,14 @@ _runq_assign(struct csched2_unit *svc, struct csched2_runqueue_data *rqd) if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - unsigned rqi:16; - } d; - d.dom = svc->unit->domain->domain_id; - d.unit = svc->unit->unit_id; - d.rqi=rqd->id; + uint16_t unit, dom; + uint16_t rqi, _pad; + } d = { + .unit = svc->unit->unit_id, + .dom = svc->unit->domain->domain_id, + .rqi = rqd->id, + }; + __trace_var(TRC_CSCHED2_RUNQ_ASSIGN, 1, sizeof(d), (unsigned char *)&d); @@ -1336,13 +1338,16 @@ update_runq_load(const struct scheduler *ops, { struct { uint64_t rq_avgload, b_avgload; - unsigned rq_load:16, rq_id:8, shift:8; - } d; - d.rq_id = rqd->id; - d.rq_load = rqd->load; - d.rq_avgload = rqd->avgload; - d.b_avgload = rqd->b_avgload; - d.shift = P; + uint16_t rq_load; uint8_t rq_id, shift; + uint32_t _pad; + } d = { + .rq_avgload = rqd->avgload, + .b_avgload = rqd->b_avgload, + .rq_load = rqd->load, + .rq_id = rqd->id, + .shift = P, + }; + __trace_var(TRC_CSCHED2_UPDATE_RUNQ_LOAD, 1, sizeof(d), (unsigned char *)&d); @@ -2799,12 +2804,15 @@ static void balance_load(const struct scheduler *ops, int cpu, s_time_t now) { struct { uint64_t lb_avgload, ob_avgload; - unsigned lrq_id:16, orq_id:16; - } d; - d.lrq_id = st.lrqd->id; - d.lb_avgload = st.lrqd->b_avgload; - d.orq_id = st.orqd->id; - d.ob_avgload = st.orqd->b_avgload; + uint16_t lrq_id, orq_id; + uint32_t _pad; + } d = { + .lb_avgload = st.lrqd->b_avgload, + .ob_avgload = st.orqd->b_avgload, + .lrq_id = st.lrqd->id, + .orq_id = st.orqd->id, + }; + __trace_var(TRC_CSCHED2_LOAD_BALANCE, 1, sizeof(d), (unsigned char *)&d); From patchwork Fri Sep 17 08:45:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12501443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AB3FC433F5 for ; Fri, 17 Sep 2021 08:46:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD7C160FED for ; Fri, 17 Sep 2021 08:46:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CD7C160FED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.189093.338603 (Exim 4.92) (envelope-from ) id 1mR9Vg-0003hT-OX; Fri, 17 Sep 2021 08:46:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 189093.338603; Fri, 17 Sep 2021 08:46:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vg-0003hL-Ka; Fri, 17 Sep 2021 08:46:16 +0000 Received: by outflank-mailman (input) for mailman id 189093; Fri, 17 Sep 2021 08:46:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vg-0003AJ-45 for xen-devel@lists.xenproject.org; Fri, 17 Sep 2021 08:46:16 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d547ed4a-333f-44c9-9f2c-1ddc9a887db3; Fri, 17 Sep 2021 08:46:11 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d547ed4a-333f-44c9-9f2c-1ddc9a887db3 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1631868371; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=r4SmFOIEP9O9irUeiBnJE4TyoFxvXpO9Kd5PyOYMvEY=; b=VdEryaI+n2oP8rggt8mhuolRClVpUxk3JcmvrzkvHqAhVGxULyN2Du3l LVSA08yOljQtbzURU1rby7k+yjWHjlyJZO3/7kJsvt1x5bjfsJ/fMGL4q EoCW2icpl2G1FrbYfv4SnkgKfozUuSuTqP9mVHRm0BDlqO604BovW/F0f 4=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: JSm8SffdyxHUd9GVLPoEWHdUZetYvTIPnsvJw++KHnM9g7TtIDSLADXykFj5d7TLYoGcH2iEVY WjjDFN0dKbyGZkmP1n30c94zl5/niS2MpbxpVhETM5l1iWfoCYpAzSfkg03znMt+HQRrcUxVLO S+EBalbPRG1YJmf7lZ6ASho8Mwhc9iiT+KCvCU/2SQDXQkQTEM76Yx/k1yIoiwBfQoy4ki0ezK qF4aH0SMs6FT4NwSN8yIiI4OJ1vROdfUTGJkJ+lNCVp327z8beqmgU+y7XFXN1oRx2EhMO3Vac net3eBX44u6KPgYql4hj69hI X-SBRS: 5.1 X-MesageID: 54750987 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:d1SstK8cXCf95j2PDyx5DrUDfHmTJUtcMsCJ2f8bNWPcYEJGY0x3z jFOWWGHOP2OZjb3e9AjbIvg/UtSupTUx9YwGVdupC88E34SpcT7XtnIdU2Y0wF+jyHgoOCLy +1EN7Es+ehtFie0Si9AttENlFEkvU2ybuOU5NXsZ2YhGGeIdA970Ug6w79g3dYx6TSEK1jlV e3a8pW31GCNg1aYAkpMg05UgEoy1BhakGpwUm0WPZinjneH/5UmJMt3yZWKB2n5WuFp8tuSH I4v+l0bElTxpH/BAvv9+lryn9ZjrrT6ZWBigVIOM0Sub4QrSoXfHc/XOdJFAXq7hQllkPgrm NRRtJeCUz0uBfz9p+8iCz5ZPBlXaPguFL/veRBTsOSWxkzCNXDt3+9vHAc9OohwFuRfWD8Us 6ZCcXZUM07F17neLLGTE4GAguwKKsXxMZxZkXZn1TzDVt4tQIzZQrWM7thdtNs1rp0SQquGN ppGAdZpRB/CbTwRAwwZMbsZluaMqWPeVDcJo2vA8MLb5ECMlVcsgdABKuH9eMGORMhTtlaVo CTB5WuRKjMwOcGbyDGF2mmxneKJliT+MKoeGrS3+f9thFy73XEIBVsdUl7Tiea9ol6zXZRYM UN80jojq+0++VKmSvH5XgakuziUsxgEQd1SHuYmrgaXxcL84hmbLngJSCZbb94rv9NwQiYlv neShM/gDzFrtLyTSFqe+62SoDf0PjIaRVLufgddE1FDuYO65thu0FSfFb6PDZJZkPWvSTDsw ju4thI5vOQissU0j4K60mju1mfESofycuIl2unGdjv7tVokNdH6OdXABUvztqkbfd3AJrWVl D1dwZHPsrpWZX2YvHHVGI0w8KeVC+Fp2dE2qWVmGYUovx+p8mSqFWy7yGAjfBo1WirolDmAX aMyhe+zzMQIVJdJRfUuC25UNyjM5fO4fTgCfqqPBueimrArKGe6ENhGPCZ8JVwBdXTAd4lkY f93lu73Vh4n5VlPlmLqF4/xL5dynn1WKZzvqWDTkE38jOv2iI+9YrYZKlqeBt3VH4vd+169z jqrDOPTk083eLSnOkH/qNdPRXhXfSlTLc2n8KR/K7/cSjeK7Ul8Upc9N5t6INc790mU/8+Vl kyAtrhwkwam3iybdlzRMxiOqtrHBP5CkJ7yBgR0VX7A5pTpSd/HAH43e8RlcL852vZkyPIoH fAJd9/ZWqZESyjd+iRbZp749dQweBOujAOIHiykfDlgIMIwG12XoofpLln16S0DLiurrs9i8 beu4RzWHMgYTAN4AceINP/2lwGtvWIQkf5ZVlfTJoUBY13l9YVncnSjjvI+L8wWBw/Ewz+Wi 1SfDRsC/LGfqI4p6tjZw6uDqt7xQed5G0NbGUjd7Kq3anaGrjbyn9cYXb/RLz7HVW7y9KGzX slvzqnxYK8dgVJHk4tgCLI3n6gw0MTi+u1BxQN+EXSVM1nyUuF8ImOL1NVkv7FWwuMLohO/X 0+C94UIObiNP8+5QlcdKBB8M7aG3PAQ3DLT8e40MAPx4youpOiLVkBbPh+tji1BLeQqbNN5k Ll54MNGuRaijhcKM8qdinEG/muBGXUMTqE7u8xIG4TskAcqlglPbJG05vUaO31ThwGg6nUXH wI= IronPort-HdrOrdr: A9a23:Dqtkna1wdC6jgNq1E38FPAqjBLAkLtp133Aq2lEZdPRUGvb3qy nOpoVj6faaslYssR0b9exofZPwJE80lqQFh7X5X43SPzUO0VHAROoJgLcKgQeQfxEWntQtsp uIGJIeNDSfNzdHZL7BkWuFL+o= X-IronPort-AV: E=Sophos;i="5.85,300,1624334400"; d="scan'208";a="54750987" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH 4/6] x86/trace: Reduce stack usage from HVMTRACE_ND() Date: Fri, 17 Sep 2021 09:45:57 +0100 Message-ID: <20210917084559.22673-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210917084559.22673-1-andrew.cooper3@citrix.com> References: <20210917084559.22673-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 It is pointless to write all 6 entries and only consume the useful subset. bloat-o-meter shows quite how obscene the overhead is in vmx_vmexit_handler(), weighing in at 11% of the function arranging unread zeroes on the stack, and 8% for svm_vmexit_handler(). add/remove: 0/0 grow/shrink: 0/20 up/down: 0/-1867 (-1867) Function old new delta hvm_msr_write_intercept 1049 1033 -16 vmx_enable_intr_window 238 214 -24 svm_enable_intr_window 337 313 -24 hvmemul_write_xcr 115 91 -24 hvmemul_write_cr 350 326 -24 hvmemul_read_xcr 115 91 -24 hvmemul_read_cr 146 122 -24 hvm_mov_to_cr 438 414 -24 hvm_mov_from_cr 253 229 -24 vmx_intr_assist 1150 1118 -32 svm_intr_assist 459 427 -32 hvm_rdtsc_intercept 138 106 -32 hvm_msr_read_intercept 898 866 -32 vmx_vmenter_helper 1142 1094 -48 vmx_inject_event 813 765 -48 svm_vmenter_helper 238 190 -48 hvm_hlt 197 146 -51 svm_inject_event 1678 1614 -64 svm_vmexit_handler 5880 5416 -464 vmx_vmexit_handler 7281 6473 -808 Total: Before=3644184, After=3642317, chg -0.05% Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli Normally I wouldn't recommend patches like this for backport, but {vmx,svm}_vmexit_handler() are fastpaths and this is a *lot* of I-cache lines dropped... --- xen/arch/x86/hvm/svm/svm.c | 8 +++----- xen/arch/x86/hvm/vmx/vmx.c | 9 ++++----- xen/include/asm-x86/hvm/trace.h | 28 ++++++++++------------------ 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index afb1ccb342c2..f0e10dec046e 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1052,7 +1052,7 @@ void svm_vmenter_helper(const struct cpu_user_regs *regs) if ( unlikely(tb_init_done) ) HVMTRACE_ND(VMENTRY, nestedhvm_vcpu_in_guestmode(curr) ? TRC_HVM_NESTEDFLAG : 0, - 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0); + 1/*cycles*/); svm_sync_vmcb(curr, vmcb_needs_vmsave); @@ -2565,12 +2565,10 @@ void svm_vmexit_handler(struct cpu_user_regs *regs) if ( hvm_long_mode_active(v) ) HVMTRACE_ND(VMEXIT64, vcpu_guestmode ? TRC_HVM_NESTEDFLAG : 0, - 1/*cycles*/, 3, exit_reason, - regs->eip, regs->rip >> 32, 0, 0, 0); + 1/*cycles*/, exit_reason, TRC_PAR_LONG(regs->rip)); else HVMTRACE_ND(VMEXIT, vcpu_guestmode ? TRC_HVM_NESTEDFLAG : 0, - 1/*cycles*/, 2, exit_reason, - regs->eip, 0, 0, 0, 0); + 1/*cycles*/, exit_reason, regs->eip); if ( vcpu_guestmode ) { diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b0a42d05f86a..d403e2d8060a 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3864,11 +3864,10 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) __vmread(VM_EXIT_REASON, &exit_reason); if ( hvm_long_mode_active(v) ) - HVMTRACE_ND(VMEXIT64, 0, 1/*cycles*/, 3, exit_reason, - regs->eip, regs->rip >> 32, 0, 0, 0); + HVMTRACE_ND(VMEXIT64, 0, 1/*cycles*/, exit_reason, + TRC_PAR_LONG(regs->rip)); else - HVMTRACE_ND(VMEXIT, 0, 1/*cycles*/, 2, exit_reason, - regs->eip, 0, 0, 0, 0); + HVMTRACE_ND(VMEXIT, 0, 1/*cycles*/, exit_reason, regs->eip); perfc_incra(vmexits, exit_reason); @@ -4645,7 +4644,7 @@ bool vmx_vmenter_helper(const struct cpu_user_regs *regs) if ( unlikely(curr->arch.hvm.vmx.lbr_flags & LBR_FIXUP_MASK) ) lbr_fixup(); - HVMTRACE_ND(VMENTRY, 0, 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0); + HVMTRACE_ND(VMENTRY, 0, 1/*cycles*/); __vmwrite(GUEST_RIP, regs->rip); __vmwrite(GUEST_RSP, regs->rsp); diff --git a/xen/include/asm-x86/hvm/trace.h b/xen/include/asm-x86/hvm/trace.h index 5cd459b855b7..2bbac45044ce 100644 --- a/xen/include/asm-x86/hvm/trace.h +++ b/xen/include/asm-x86/hvm/trace.h @@ -67,38 +67,30 @@ #define TRACE_2_LONG_4D(_e, d1, d2, d3, d4, ...) \ TRACE_6D(_e, d1, d2, d3, d4) -#define HVMTRACE_ND(evt, modifier, cycles, count, d1, d2, d3, d4, d5, d6) \ +#define HVMTRACE_ND(evt, modifier, cycles, ...) \ do { \ if ( unlikely(tb_init_done) && DO_TRC_HVM_ ## evt ) \ { \ - struct { \ - u32 d[6]; \ - } _d; \ - _d.d[0]=(d1); \ - _d.d[1]=(d2); \ - _d.d[2]=(d3); \ - _d.d[3]=(d4); \ - _d.d[4]=(d5); \ - _d.d[5]=(d6); \ + uint32_t _d[] = { __VA_ARGS__ }; \ __trace_var(TRC_HVM_ ## evt | (modifier), cycles, \ - sizeof(*_d.d) * count, &_d); \ + sizeof(_d), _d); \ } \ } while(0) #define HVMTRACE_6D(evt, d1, d2, d3, d4, d5, d6) \ - HVMTRACE_ND(evt, 0, 0, 6, d1, d2, d3, d4, d5, d6) + HVMTRACE_ND(evt, 0, 0, d1, d2, d3, d4, d5, d6) #define HVMTRACE_5D(evt, d1, d2, d3, d4, d5) \ - HVMTRACE_ND(evt, 0, 0, 5, d1, d2, d3, d4, d5, 0) + HVMTRACE_ND(evt, 0, 0, d1, d2, d3, d4, d5) #define HVMTRACE_4D(evt, d1, d2, d3, d4) \ - HVMTRACE_ND(evt, 0, 0, 4, d1, d2, d3, d4, 0, 0) + HVMTRACE_ND(evt, 0, 0, d1, d2, d3, d4) #define HVMTRACE_3D(evt, d1, d2, d3) \ - HVMTRACE_ND(evt, 0, 0, 3, d1, d2, d3, 0, 0, 0) + HVMTRACE_ND(evt, 0, 0, d1, d2, d3) #define HVMTRACE_2D(evt, d1, d2) \ - HVMTRACE_ND(evt, 0, 0, 2, d1, d2, 0, 0, 0, 0) + HVMTRACE_ND(evt, 0, 0, d1, d2) #define HVMTRACE_1D(evt, d1) \ - HVMTRACE_ND(evt, 0, 0, 1, d1, 0, 0, 0, 0, 0) + HVMTRACE_ND(evt, 0, 0, d1) #define HVMTRACE_0D(evt) \ - HVMTRACE_ND(evt, 0, 0, 0, 0, 0, 0, 0, 0, 0) + HVMTRACE_ND(evt, 0, 0) #define HVMTRACE_LONG_1D(evt, d1) \ HVMTRACE_2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32) From patchwork Fri Sep 17 08:45:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12501451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A95C2C43217 for ; Fri, 17 Sep 2021 08:46:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 572C260FED for ; Fri, 17 Sep 2021 08:46:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 572C260FED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.189095.338626 (Exim 4.92) (envelope-from ) id 1mR9Vm-0004Lx-GT; Fri, 17 Sep 2021 08:46:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 189095.338626; Fri, 17 Sep 2021 08:46:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vm-0004Lo-Cd; Fri, 17 Sep 2021 08:46:22 +0000 Received: by outflank-mailman (input) for mailman id 189095; Fri, 17 Sep 2021 08:46:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vl-0003AJ-49 for xen-devel@lists.xenproject.org; Fri, 17 Sep 2021 08:46:21 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a06d743-cc27-45d6-9aab-e8e2e547bf81; Fri, 17 Sep 2021 08:46:09 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a06d743-cc27-45d6-9aab-e8e2e547bf81 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1631868369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=zVahpMkV6GyvrVUFEu34Z/ndYjYizS9n7x26jqVkpFU=; b=aBM2VIopfqekS36WShbxBBpgWMCicwrynxcssFi5F+hhLNGefrH+yYaQ IxOsvheEHIIcd0CYz9/WBbRZetchMjSLAHZhmD0GSg7Eo2QrXvPf8Ezwz kr0cR77TJlmDTgkYAg1OK976L0E8j1aHJnQ0mv4G6EkQ1Ur68z4smaVDZ Q=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: CDt0mO0rf3EoaTbkta+U/lvgO+b4WKpUXYKghOLVGWuQqhX33jqtb9tgonMSHf1c+uf2JpJ2kx xI3t1OKSdI1684wL8W47oRlCRkbY1DMVqaQVqng9Ko8ysxAR2ItdDd6Wcp1H6b+UpDDTb2SGUW oW2E/XvwzakWEiLDF6dA782DLuoG6bfSGm1/hUkyYMwK0lNlVhYIsPzE0d4yEoUF/Tw/N14Lzd g9cunEejVLp0/yK0dFiEU3Edj5MShEXmLhP3/NEvGyQSkgM1sRvQSAGmgAhK6bV0tZGPihcb/N iP3Ry+j2elBtNw0uDlLAke4E X-SBRS: 5.1 X-MesageID: 52983294 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:JLr7La3mmy4cUVnHhfbD5S92kn2cJEfYwER7XKvMYLTBsI5bp2NRz GRNWDiDOfiCY2qjf4gka9+1p0JXvpSDy4JhHAQ6pC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkS5PE3oHJ9RGQ74nRLlbHILOCan0ZqTNMEn970EoywrFh2+aEvPDia++zk YKqyyHgEAfNNw5cagr4PIra9XuDFNyr0N8plgRWicJj5TcypFFMZH4rHomjLmOQf2VhNrXSq 9Avbl2O1jixEx8FUrtJm1tgG6EAaua60QOm0hK6V0U+6/TrS+NbPqsTbZIhhUlrZzqhn/Vp9 tBpjseMVgICZIzuwbkMcQhpHHQrVUFG0OevzXmXtMWSywvNcmf2wuUoB0YzVWEa0r8pWycUr 6VecW1TKEDY7w616OvTpu1Er8IvNsT0eqgYvWlt12rxBvc6W5HTBa7N4Le02R9t3JEeRqyPO 6L1bxIscRqeQQNIPGxUVpYdvuuGg1T2Uzdh/Qf9Sa0fvDGIkV0ZPKLWGNjIft2HQ+1Fk0Deo XjJl0zbKBwHMN2UyRKe72mhwOTImEvTVIwbG7K58fprqEaO3WFVAxoTPXOkpdGph0j4XMhQQ 2QE9yxroaUs+UiDStjmQwb+sHOCpgQbWddbD6s98g7l4qvL4S6JC24cVDlDZdc68sgsSlQCz USVltnkAThutry9Sn+H8LqQ6zSoNkAowXQqPHFeC1Ffup+6/d913kmnostf/LCdjvjtJzTU+ Gu2sy0V3ZQx1JMa9bSK8gWS696znaQlXjLZ9y2OADn8s1ImO9D8D2C7wQOEtqcbde51WnHE5 SJdypbEtIjiGLnQzHTlfQkbIF2+Cx9p2hXniFhzFtEK8z238hZPlqgBvWkjeC+F3isCEAIFg XM/WysKv/e/31PwNMebhr5d7exxlcAM8vy/DZjpgiJmOMQZSeN+1HgGibSsM4XRfK4EyvlX1 XCzKp3EMJrnIf4/kGreqxk1iOd2rszB+Y8jbc+ilEn2uVZvTFWUVa0EIDOzghMRtfjfyDg5B +13bpPQoz0GCbWWSnCOreY7cABbRVBmVMueg5EGKYa+zv9ORThJ5wn5muh6JeSIXs19y4/1w 51KchQEkQGu2SKeclzih7IKQOqHYKuTZEkTZUQEVWtEEVB5CWp2xKtAJZYxY5c98+lvkax9Q /UfIp3SCfVTUDXXvT8aaMCl/oBlcR2qgyOIPjakP2djL8IxGVSR94+2ZBbr+QkPEjGz6Zk0r Yq/216JWpEEXQljUprbMar901OrsHEBs+tuRE+UcMJLcUDh/dEyeSz8h/M6Oe8WLhDHymfI3 gqaG05A9+LMv5U04J/CgqXd99WlFO53H0x7GWjH7OnpaXmGrzT7mYIZCbSGZzHQUm/w6Z6OX +QNwqGuKuADkXZLr5F4T+Rhw5Uh6oa9vLRd1AllQinGNgz5FrN6L3Ca9sBTrakRlKRBsA67V 0/TqNlXPbKFZJHsHFILfVd3a+2C0bcfmyXI7ORzK0L/vXcl8L2CWERUHh+NlC0Cc+clbNJ7m b8s6JwM9giyqhs2KdLX3Clb+lOFImEET6h65IoRB5Xmi1Zzx1xPCXAG5vQaPH1bhw1wD3QX IronPort-HdrOrdr: A9a23:JOTANqoHt9lG92aj+wcptLgaV5opeYIsimQD101hICG8cqSj+f xG/c5rrCMc5wxwZJhNo7y90ey7MBbhHP1OkO8s1NWZLWrbUQKTRekIh+bfKn/baknDH4ZmpM BdmsNFaeEYY2IUsS+D2njbL+od X-IronPort-AV: E=Sophos;i="5.85,300,1624334400"; d="scan'208";a="52983294" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH 5/6] xen/credit2: Clean up trace handling Date: Fri, 17 Sep 2021 09:45:58 +0100 Message-ID: <20210917084559.22673-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210917084559.22673-1-andrew.cooper3@citrix.com> References: <20210917084559.22673-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 There is no need for bitfields anywhere - use more sensible types. There is also no need to cast 'd' to (unsigned char *) before passing it to a function taking void *. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli --- xen/common/sched/credit2.c | 297 ++++++++++++++++++++++----------------------- 1 file changed, 144 insertions(+), 153 deletions(-) diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index d5f41bc3d603..339b9fd75926 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -1080,13 +1080,13 @@ static void update_max_weight(struct csched2_runqueue_data *rqd, int new_weight, if ( unlikely(tb_init_done) ) { struct { - unsigned rqi:16, max_weight:16; - } d; - d.rqi = rqd->id; - d.max_weight = rqd->max_weight; - __trace_var(TRC_CSCHED2_RUNQ_MAX_WEIGHT, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t rqi, max_weight; + } d = { + .rqi = rqd->id, + .max_weight = rqd->max_weight, + }; + + __trace_var(TRC_CSCHED2_RUNQ_MAX_WEIGHT, 1, sizeof(d), &d); } } @@ -1114,9 +1114,7 @@ _runq_assign(struct csched2_unit *svc, struct csched2_runqueue_data *rqd) .rqi = rqd->id, }; - __trace_var(TRC_CSCHED2_RUNQ_ASSIGN, 1, - sizeof(d), - (unsigned char *)&d); + __trace_var(TRC_CSCHED2_RUNQ_ASSIGN, 1, sizeof(d), &d); } } @@ -1348,9 +1346,7 @@ update_runq_load(const struct scheduler *ops, .shift = P, }; - __trace_var(TRC_CSCHED2_UPDATE_RUNQ_LOAD, 1, - sizeof(d), - (unsigned char *)&d); + __trace_var(TRC_CSCHED2_UPDATE_RUNQ_LOAD, 1, sizeof(d), &d); } } @@ -1400,16 +1396,16 @@ update_svc_load(const struct scheduler *ops, { struct { uint64_t v_avgload; - unsigned unit:16, dom:16; - unsigned shift; - } d; - d.dom = svc->unit->domain->domain_id; - d.unit = svc->unit->unit_id; - d.v_avgload = svc->avgload; - d.shift = P; - __trace_var(TRC_CSCHED2_UPDATE_UNIT_LOAD, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t shift; + } d = { + .v_avgload = svc->avgload, + .unit = svc->unit->unit_id, + .dom = svc->unit->domain->domain_id, + .shift = P, + }; + + __trace_var(TRC_CSCHED2_UPDATE_UNIT_LOAD, 1, sizeof(d), &d); } } @@ -1456,15 +1452,15 @@ static void runq_insert(struct csched2_unit *svc) if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - unsigned pos; - } d; - d.dom = svc->unit->domain->domain_id; - d.unit = svc->unit->unit_id; - d.pos = pos; - __trace_var(TRC_CSCHED2_RUNQ_POS, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t pos; + } d = { + .unit = svc->unit->unit_id, + .dom = svc->unit->domain->domain_id, + .pos = pos, + }; + + __trace_var(TRC_CSCHED2_RUNQ_POS, 1, sizeof(d), &d); } } @@ -1556,16 +1552,16 @@ static s_time_t tickle_score(const struct scheduler *ops, s_time_t now, if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - int credit, score; - } d; - d.dom = cur->unit->domain->domain_id; - d.unit = cur->unit->unit_id; - d.credit = cur->credit; - d.score = score; - __trace_var(TRC_CSCHED2_TICKLE_CHECK, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t credit, score; + } d = { + .unit = cur->unit->unit_id, + .dom = cur->unit->domain->domain_id, + .credit = cur->credit, + .score = score, + }; + + __trace_var(TRC_CSCHED2_TICKLE_CHECK, 1, sizeof(d), &d); } return score; @@ -1603,17 +1599,16 @@ runq_tickle(const struct scheduler *ops, struct csched2_unit *new, s_time_t now) if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - unsigned processor; - int credit; - } d; - d.dom = unit->domain->domain_id; - d.unit = unit->unit_id; - d.processor = cpu; - d.credit = new->credit; - __trace_var(TRC_CSCHED2_TICKLE_NEW, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t processor, credit; + } d = { + .dom = unit->domain->domain_id, + .unit = unit->unit_id, + .processor = cpu, + .credit = new->credit, + }; + + __trace_var(TRC_CSCHED2_TICKLE_NEW, 1, sizeof(d), &d); } /* @@ -1752,12 +1747,12 @@ runq_tickle(const struct scheduler *ops, struct csched2_unit *new, s_time_t now) if ( unlikely(tb_init_done) ) { struct { - unsigned cpu:16, pad:16; - } d; - d.cpu = ipid; d.pad = 0; - __trace_var(TRC_CSCHED2_TICKLE, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t cpu, _pad; + } d = { + .cpu = ipid, + }; + + __trace_var(TRC_CSCHED2_TICKLE, 1, sizeof(d), &d); } tickle_cpu(ipid, rqd); @@ -1833,16 +1828,16 @@ static void reset_credit(int cpu, s_time_t now, struct csched2_unit *snext) if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - int credit_start, credit_end; - } d; - d.dom = svc->unit->domain->domain_id; - d.unit = svc->unit->unit_id; - d.credit_start = start_credit; - d.credit_end = svc->credit; - __trace_var(TRC_CSCHED2_CREDIT_RESET, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t credit_start, credit_end; + } d = { + .unit = svc->unit->unit_id, + .dom = svc->unit->domain->domain_id, + .credit_start = start_credit, + .credit_end = svc->credit, + }; + + __trace_var(TRC_CSCHED2_CREDIT_RESET, 1, sizeof(d), &d); } } @@ -1888,18 +1883,17 @@ void burn_credits(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - int credit, budget; - int delta; - } d; - d.dom = svc->unit->domain->domain_id; - d.unit = svc->unit->unit_id; - d.credit = svc->credit; - d.budget = has_cap(svc) ? svc->budget : INT_MIN; - d.delta = delta; - __trace_var(TRC_CSCHED2_CREDIT_BURN, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t credit, budget, delta; + } d = { + .unit = svc->unit->unit_id, + .dom = svc->unit->domain->domain_id, + .credit = svc->credit, + .budget = has_cap(svc) ? svc->budget : INT_MIN, + .delta = delta, + }; + + __trace_var(TRC_CSCHED2_CREDIT_BURN, 1, sizeof(d), &d); } } @@ -2544,17 +2538,17 @@ csched2_res_pick(const struct scheduler *ops, const struct sched_unit *unit) { struct { uint64_t b_avgload; - unsigned unit:16, dom:16; - unsigned rq_id:16, new_cpu:16; - } d; - d.dom = unit->domain->domain_id; - d.unit = unit->unit_id; - d.rq_id = min_rqd ? min_rqd->id : -1; - d.b_avgload = min_avgload; - d.new_cpu = new_cpu; - __trace_var(TRC_CSCHED2_PICKED_CPU, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint16_t rq_id, new_cpu; + } d = { + .b_avgload = min_avgload, + .unit = unit->unit_id, + .dom = unit->domain->domain_id, + .rq_id = min_rqd ? min_rqd->id : -1, + .new_cpu = new_cpu, + }; + + __trace_var(TRC_CSCHED2_PICKED_CPU, 1, sizeof(d), &d); } return get_sched_res(new_cpu); @@ -2615,16 +2609,16 @@ static void migrate(const struct scheduler *ops, if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - unsigned rqi:16, trqi:16; - } d; - d.dom = unit->domain->domain_id; - d.unit = unit->unit_id; - d.rqi = svc->rqd->id; - d.trqi = trqd->id; - __trace_var(TRC_CSCHED2_MIGRATE, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint16_t rqi, trqi; + } d = { + .unit = unit->unit_id, + .dom = unit->domain->domain_id, + .rqi = svc->rqd->id, + .trqi = trqd->id, + }; + + __trace_var(TRC_CSCHED2_MIGRATE, 1, sizeof(d), &d); } if ( svc->flags & CSFLAG_scheduled ) @@ -2761,15 +2755,15 @@ static void balance_load(const struct scheduler *ops, int cpu, s_time_t now) if ( unlikely(tb_init_done) ) { struct { - unsigned lrq_id:16, orq_id:16; - unsigned load_delta; - } d; - d.lrq_id = st.lrqd->id; - d.orq_id = st.orqd->id; - d.load_delta = st.load_delta; - __trace_var(TRC_CSCHED2_LOAD_CHECK, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t lrq_id, orq_id; + uint32_t load_delta; + } d = { + .lrq_id = st.lrqd->id, + .orq_id = st.orqd->id, + .load_delta = st.load_delta, + }; + + __trace_var(TRC_CSCHED2_LOAD_CHECK, 1, sizeof(d), &d); } /* @@ -2813,9 +2807,7 @@ static void balance_load(const struct scheduler *ops, int cpu, s_time_t now) .orq_id = st.orqd->id, }; - __trace_var(TRC_CSCHED2_LOAD_BALANCE, 1, - sizeof(d), - (unsigned char *)&d); + __trace_var(TRC_CSCHED2_LOAD_BALANCE, 1, sizeof(d), &d); } SCHED_STAT_CRANK(acct_load_balance); @@ -3401,15 +3393,15 @@ runq_candidate(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - unsigned runtime; - } d; - d.dom = scurr->unit->domain->domain_id; - d.unit = scurr->unit->unit_id; - d.runtime = now - scurr->unit->state_entry_time; - __trace_var(TRC_CSCHED2_RATELIMIT, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t runtime; + } d = { + .unit = scurr->unit->unit_id, + .dom = scurr->unit->domain->domain_id, + .runtime = now - scurr->unit->state_entry_time, + }; + + __trace_var(TRC_CSCHED2_RATELIMIT, 1, sizeof(d), &d); } return scurr; } @@ -3462,13 +3454,13 @@ runq_candidate(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - } d; - d.dom = svc->unit->domain->domain_id; - d.unit = svc->unit->unit_id; - __trace_var(TRC_CSCHED2_RUNQ_CAND_CHECK, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + } d = { + .unit = svc->unit->unit_id, + .dom = svc->unit->domain->domain_id, + }; + + __trace_var(TRC_CSCHED2_RUNQ_CAND_CHECK, 1, sizeof(d), &d); } /* @@ -3536,17 +3528,16 @@ runq_candidate(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned unit:16, dom:16; - unsigned tickled_cpu; - int credit; - } d; - d.dom = snext->unit->domain->domain_id; - d.unit = snext->unit->unit_id; - d.credit = snext->credit; - d.tickled_cpu = snext->tickled_cpu; - __trace_var(TRC_CSCHED2_RUNQ_CANDIDATE, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t unit, dom; + uint32_t tickled_cpu, credit; + } d = { + .unit = snext->unit->unit_id, + .dom = snext->unit->domain->domain_id, + .tickled_cpu = snext->tickled_cpu, + .credit = snext->credit, + }; + + __trace_var(TRC_CSCHED2_RUNQ_CANDIDATE, 1, sizeof(d), &d); } if ( unlikely(snext->tickled_cpu != -1 && snext->tickled_cpu != cpu) ) @@ -3602,18 +3593,18 @@ static void csched2_schedule( if ( unlikely(tb_init_done) ) { struct { - unsigned cpu:16, rq_id:16; - unsigned tasklet:8, idle:8, smt_idle:8, tickled:8; - } d; - d.cpu = cur_cpu; - d.rq_id = c2r(sched_cpu); - d.tasklet = tasklet_work_scheduled; - d.idle = is_idle_unit(currunit); - d.smt_idle = cpumask_test_cpu(sched_cpu, &rqd->smt_idle); - d.tickled = tickled; - __trace_var(TRC_CSCHED2_SCHEDULE, 1, - sizeof(d), - (unsigned char *)&d); + uint16_t cpu, rq_id; + uint8_t tasklet, idle, smt_idle, tickled; + } d = { + .cpu = cur_cpu, + .rq_id = c2r(sched_cpu), + .tasklet = tasklet_work_scheduled, + .idle = is_idle_unit(currunit), + .smt_idle = cpumask_test_cpu(sched_cpu, &rqd->smt_idle), + .tickled = tickled, + }; + + __trace_var(TRC_CSCHED2_SCHEDULE, 1, sizeof(d), &d); } /* Update credits (and budget, if necessary). */ From patchwork Fri Sep 17 08:45:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 12501449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F7C4C433FE for ; Fri, 17 Sep 2021 08:46:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F3EEF6103C for ; Fri, 17 Sep 2021 08:46:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F3EEF6103C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.189094.338616 (Exim 4.92) (envelope-from ) id 1mR9Vi-0003z3-8n; Fri, 17 Sep 2021 08:46:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 189094.338616; Fri, 17 Sep 2021 08:46:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vi-0003yu-31; Fri, 17 Sep 2021 08:46:18 +0000 Received: by outflank-mailman (input) for mailman id 189094; Fri, 17 Sep 2021 08:46:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mR9Vg-0003AK-FD for xen-devel@lists.xenproject.org; Fri, 17 Sep 2021 08:46:16 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b3cf480a-1793-11ec-b674-12813bfff9fa; Fri, 17 Sep 2021 08:46:09 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b3cf480a-1793-11ec-b674-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1631868369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=15+6z5EM4y397ipt3dNnQGW78oEoP00mzOswuO2CQJw=; b=VPdj1W4SV5GLu5vRqT0h05f4Bosx5qsSsO6WrK3h7pqXNoCsr/XTAgcl xn2V/2kGYGJVVEfZIbEuHf8D5o+YZNCMgKfb7GmfF4z3A3a/GcpIqQUHx 5TfHJwvqKIz1REmNDkkuUnXcKnyT4vak/nLVbBOhAale1/H6zGbKA3xKB 4=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: Aedc5C6amQnhqJGYqM0ObEOzLMD1itbaJL378IHVOSyhA/iAtFYUWo4wrkVc2bDkX6XdJgwwoE kMz/adWbfUBKyT1ebqyDC1TutMOzALTu0jlfTjKGbe196er4juLOpvIEIep7Pf9XiUAQl5eE0E uok2bAWOAn8r30LzNHugR/VtoL4L/XgjudRNT3SDPIWZk2MjqzBU1tWUYmDc+PxX51OhlWMhWP jLALNaRd3mUb7iZ/nZbt+DUfcGLJqlR7a0SvLOw8t5fOO3nLb0H6UVljrsDQLzlJZCTy109bRb YSgMW66agaqdKnRsLjq1g8Z3 X-SBRS: 5.1 X-MesageID: 52955350 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:5XvjIKP4PmOGH+7vrR1ZkMFynXyQoLVcMsEvi/4bfWQNrUohgTQOm 2YWCz2BbqqIY2LzeIwlYdy38hgEvsPSndJkQQto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6ZUsxNbVU8En552Es8w7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYozyXpu5fz vVUjK2XVSslGKPOwroTYhYNRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YsBqit4uM4/AO4QHt2s75TrYEewnUdbIRKCiCdpwgW1h250VQK62i 8wxVRNASzPkMht0GHgKVbcYpdeCjF3wWmgNwL6SjfVuuDWCpOBr65DvLd7Ud9qiVchT2EGCq Qru3U70HxUbP9y30iee/zSngeqntS/1UY0dFbq899ZxnUaegGcUDXU+Sl+TsfS/zEmkVLp3O 0ESvyYjs6U23EiqVcXmGQ21pmaeuRwRUMYWFPc1gCmM1aj88wufHnIDTDNKdJohrsBebScxy laDktftBDpumL6YU3SQ8vGTtzzaBMQOBTZcP2leF1JDuoS95tFo5v7Scjp9OKert+PbHxHp+ gGtsAQyobsR15AF5qruqDgrnAmQSoj1oh8dv1uMBz/0sVwnPeZJdKTztgOKtq8owJKxCwDb5 SlawZD2APUmUMnV/BFhVtnhC11ACxytCzTanVcnNJ0o7T3FF5WLLN0IvW0WyKuENK85ld7Vj K374lg5CHx7ZiLCgUpLj2SZUJxCIU/IT4+NaxwsRoASCqWdjSfelM2UWaJ144wLuBN0+U3YE czAGftA8F5AUfg3pNZIb75FjNfHORzSNUuMHMumnnxLIJK1ZWKPSKdtDbd9Rrlit8u5TPHu2 48HbaOikkwHOMWnO3W/2dNDfDgicClgbbir+pM/SwJ2Clc/cI3XI6SKmu1Jlk0Mt/k9q9okC VnmBhYDmQag3CaeQehIA1g6AI7SsV9EhSpTFUQR0ZyAghDPuK6js/UScYUZZ74i+LAxxPJ4V aBdKc6BHu5OWnLM/DFENcvxq4lrdRKKgwOSPnX6PGhjLsA4HwGZqMX5egbP9TUVCnblv8UJv LD9hBjQRoAORlo+AZ+OOu6v1V64oVMUhPl2AxnTOtBWdUi1qNpqJiX9g+UZOcYJLRmflDKW2 xzPWUUTpPXXop9z+97M3PjWo4CsGup4P0xbA2iEsurmaXiEpjKumNYSXvyJcDbRUHLP1J+jP egFnevhNPAnnUpRt9YuGbhc0q9jtcDkoKVXz1o4ESyTPUirEL5pPlKPwdJL6v9W3rZctAa7B hCP991dNenbMc/pCgdMdg8sb+DF3vAIgDjCq/8yJRyitiNw+bOGV2RUPgWN13MBfOckbtt9z LdzotMS5iy+lgEuY4SPgS1j/miRKmANDvc8vZYADY630gcmxzmuu3AH5vMaNH1XV+hxDw== IronPort-HdrOrdr: A9a23:FCOFEqtGdC5Gp4shE4Ost2bi7skDctV00zEX/kB9WHVpm6uj5q eTdZUgpHvJYVMqM03I9urtBEDtexzhHP1OgbX5X43NYOCOggLBRuxfBODZogHIKmnT8fNcyL clU4UWMqyUMbGit7eY3OBvKadD/OW6 X-IronPort-AV: E=Sophos;i="5.85,300,1624334400"; d="scan'208";a="52955350" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Stefano Stabellini , Wei Liu , Julien Grall , Dario Faggioli Subject: [PATCH 6/6] xen/trace: Minor code cleanup Date: Fri, 17 Sep 2021 09:45:59 +0100 Message-ID: <20210917084559.22673-7-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210917084559.22673-1-andrew.cooper3@citrix.com> References: <20210917084559.22673-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 * Delete trailing whitespace * Replace an opencoded DIV_ROUND_UP() * Drop bogus smp_rmb() - spin_lock_irqsave() has full smp_mb() semantics. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Dario Faggioli --- xen/common/trace.c | 37 +++++++++++++++---------------------- xen/include/asm-x86/hvm/trace.h | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/xen/common/trace.c b/xen/common/trace.c index 25af6e1bd25e..18008df69e10 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -75,10 +75,6 @@ static cpumask_t tb_cpu_mask; /* which tracing events are enabled */ static u32 tb_event_mask = TRC_ALL; -/* Return the number of elements _type necessary to store at least _x bytes of data - * i.e., sizeof(_type) * ans >= _x. */ -#define fit_to_type(_type, _x) (((_x)+sizeof(_type)-1) / sizeof(_type)) - static int cpu_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -96,8 +92,8 @@ static struct notifier_block cpu_nfb = { static uint32_t calc_tinfo_first_offset(void) { - int offset_in_bytes = offsetof(struct t_info, mfn_offset[NR_CPUS]); - return fit_to_type(uint32_t, offset_in_bytes); + return DIV_ROUND_UP(offsetof(struct t_info, mfn_offset[NR_CPUS]), + sizeof(uint32_t)); } /** @@ -148,7 +144,7 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset) pages = max_pages; } - /* + /* * NB this calculation is correct, because t_info_first_offset is * in words, not bytes */ @@ -167,7 +163,7 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset) * trace buffers. The trace buffers are then available for debugging use, via * the %TRACE_xD macros exported in . * - * This function may also be called later when enabling trace buffers + * This function may also be called later when enabling trace buffers * via the SET_SIZE hypercall. */ static int alloc_trace_bufs(unsigned int pages) @@ -401,7 +397,7 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc) break; case XEN_SYSCTL_TBUFOP_enable: /* Enable trace buffers. Check buffers are already allocated. */ - if ( opt_tbuf_size == 0 ) + if ( opt_tbuf_size == 0 ) rc = -EINVAL; else tb_init_done = 1; @@ -438,7 +434,7 @@ int tb_control(struct xen_sysctl_tbuf_op *tbc) return rc; } -static inline unsigned int calc_rec_size(bool_t cycles, unsigned int extra) +static inline unsigned int calc_rec_size(bool_t cycles, unsigned int extra) { unsigned int rec_size = 4; @@ -597,7 +593,7 @@ static inline void __insert_record(struct t_buf *buf, rec->u.cycles.cycles_lo = (uint32_t)tsc; rec->u.cycles.cycles_hi = (uint32_t)(tsc >> 32); dst = rec->u.cycles.extra_u32; - } + } if ( extra_data && extra ) memcpy(dst, extra_data, extra); @@ -717,9 +713,6 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, if ( !cpumask_test_cpu(smp_processor_id(), &tb_cpu_mask) ) return; - /* Read tb_init_done /before/ t_bufs. */ - smp_rmb(); - spin_lock_irqsave(&this_cpu(t_lock), flags); buf = this_cpu(t_bufs); @@ -735,14 +728,14 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, /* Calculate the record size */ rec_size = calc_rec_size(cycles, extra); - + /* How many bytes are available in the buffer? */ bytes_to_tail = calc_bytes_avail(buf); - + /* How many bytes until the next wrap-around? */ bytes_to_wrap = calc_bytes_to_wrap(buf); - - /* + + /* * Calculate expected total size to commit this record by * doing a dry-run. */ @@ -756,7 +749,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, { total_size += bytes_to_wrap; bytes_to_wrap = data_size; - } + } total_size += LOST_REC_SIZE; bytes_to_wrap -= LOST_REC_SIZE; @@ -768,7 +761,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, if ( rec_size > bytes_to_wrap ) { total_size += bytes_to_wrap; - } + } total_size += rec_size; /* Do we have enough space for everything? */ @@ -781,7 +774,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, } /* - * Now, actually write information + * Now, actually write information */ bytes_to_wrap = calc_bytes_to_wrap(buf); @@ -791,7 +784,7 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra, { insert_wrap_record(buf, LOST_REC_SIZE); bytes_to_wrap = data_size; - } + } insert_lost_records(buf); bytes_to_wrap -= LOST_REC_SIZE; diff --git a/xen/include/asm-x86/hvm/trace.h b/xen/include/asm-x86/hvm/trace.h index 2bbac45044ce..fbf834d10aff 100644 --- a/xen/include/asm-x86/hvm/trace.h +++ b/xen/include/asm-x86/hvm/trace.h @@ -52,7 +52,7 @@ #define DO_TRC_HVM_CLTS DEFAULT_HVM_MISC #define DO_TRC_HVM_LMSW DEFAULT_HVM_MISC #define DO_TRC_HVM_LMSW64 DEFAULT_HVM_MISC -#define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC +#define DO_TRC_HVM_REALMODE_EMULATE DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP_DEBUG DEFAULT_HVM_MISC #define DO_TRC_HVM_VLAPIC DEFAULT_HVM_MISC