From owner-freebsd-hackers@freebsd.org Thu Sep 17 05:34:29 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 415383FCDFC for ; Thu, 17 Sep 2020 05:34:29 +0000 (UTC) (envelope-from weh@microsoft.com) Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-eopbgr1310119.outbound.protection.outlook.com [40.107.131.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "GlobalSign Organization Validation CA - SHA256 - G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BsQdH2rpQz4l8t for ; Thu, 17 Sep 2020 05:34:27 +0000 (UTC) (envelope-from weh@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zykbwb/t6dYk2hhCdfDOLQm8uv/vL/6XGrP3Ahq2puskBxFbiEMPLOnaSSWabN9YY6bes4bZodmdwG3VlFyxr9Ejyit1V5DUEA1Vs2sX4sCJYHSO0o2XTJtBFwHaw+OQesUarWrzYuQiIyeQq36JQ/L9qEB10P/hmy21ato7GewKtiza7Zpp/QAOL8B8roPDO/AHdcqN/89CkVz8aCUmc60WuMujO0CfGpt1a2wv5BJl5BtNRjem1isAaEakF7u4QSn172Yvg0OB4WnLTap+GcEFFz772EATYcLsFny4iogyxiXTRi1+n+7Kcm2DTWZJd2aELaT45QNILUKlbV0ueQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AgO4K9ChB7yEKHadnKV8F2o1v00FRo5LDhcF648X+I8=; b=HK+cDOAqTgZzX+SkDRhm6rEnRqBqRi2SRAqkSwaPoAVS/EicWjiUY2H62k30qgFYogHo7IzxE7Z0oyOeuqp0JPxQ4MVq8D/TxQeGntWXRbeqP7WnmenRMDGpwiCFRJDvtXl1ElI7XwvvVKrrqbIxOpzvQnvHNHKB8eh3f5bplApHGB+x8zP13i6r1I/7opeDToJVA1Idkkg5BIjhOmFS3dhMXzYbAEOfuZbMHdrk7uFFJSRp4kxzr+6S8IykRcWy+hHPL82mzfGbkgrfATqRbbgSZBulLIlYg71CXGNpAbK108L7AwG6R4MaK8gKsaXrXx/XeCYWGkfbn1rWi2e//Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none Received: from SG2P153MB0352.APCP153.PROD.OUTLOOK.COM (2603:1096:4:d4::23) by SG2P153MB0352.APCP153.PROD.OUTLOOK.COM (2603:1096:4:d4::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.1; Thu, 17 Sep 2020 05:34:23 +0000 Received: from SG2P153MB0352.APCP153.PROD.OUTLOOK.COM ([fe80::e1d4:23b8:2c19:4745]) by SG2P153MB0352.APCP153.PROD.OUTLOOK.COM ([fe80::e1d4:23b8:2c19:4745%6]) with mapi id 15.20.3412.007; Thu, 17 Sep 2020 05:34:23 +0000 From: Wei Hu To: Konstantin Belousov CC: "freebsd-hackers@freebsd.org" Subject: RE: MSR accesses that slows down the hypervisor/host Thread-Topic: MSR accesses that slows down the hypervisor/host Thread-Index: AdaL9HYbtJyLPxf3TL+CSKzmJaxdTwAPNlyAACBa5AA= Date: Thu, 17 Sep 2020 05:34:22 +0000 Message-ID: References: <20200916135727.GO94807@kib.kiev.ua> In-Reply-To: <20200916135727.GO94807@kib.kiev.ua> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=05b5b23f-aa6b-4da8-a038-e3d4554b221a; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-09-17T05:23:53Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; x-originating-ip: [116.233.42.161] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: c726fc14-3d08-4e08-4bb8-08d85acb557d x-ms-traffictypediagnostic: SG2P153MB0352: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: YsxnoCfueVzNXYpVfICLrOr6X1k4WbH4uf8GyS2g4USKVoiVaaRJNDxJy4Y7geCbM0xzvoWxjKJr7MfZP+WgUgIYKpTKho3Kk/H0+P9xOjaI9O7aODqxDarCZB2FsNeqXS8eVnp8QuOf03oI+/tms4/6GHRC/PtftHK9s2b7bF/OJq6b/eh3LRdDKXfEnFuvcGiAU9NEL/vI3546r5FlQtyEISfobTpg2Wdw+NDR/+6XHrP21x8nHdQWDWAjKAjf6n/ElvR8U3WVe7dPCHMTpwqffW/WDF6Ie7sudBh/V3crm7OzZrfRXZMgqOUsm6Ool7VewsvBU/W7tb0knMIjnv4Ak2vPOeQ3z9s6LgMj1wB4cfLfN89GpDlWgvJNNTTy x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SG2P153MB0352.APCP153.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(136003)(39860400002)(346002)(366004)(396003)(376002)(6916009)(66556008)(83380400001)(55016002)(4326008)(66946007)(66446008)(66476007)(64756008)(76116006)(8990500004)(8936002)(316002)(8676002)(86362001)(82960400001)(52536014)(186003)(82950400001)(5660300002)(26005)(33656002)(9686003)(6506007)(53546011)(71200400001)(7696005)(2906002)(10290500003)(478600001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 5RZgenPDn1+Md+6ugyCjoX6xjoi4NF6b0j6kj2wzLsAAHDuStY6fKLYrJqtFCmBJrq8NG5rN1FZvYgGQPGxn/mOIN49LTbKdSpS0h44X+beYRz4uwa8o6F2nPsdiH6XNlu8Gs7VET2BDr4j2B7RSVsAySY9V9fYh4dJwXGt0/s4F4VUuTwEUqQFRzJQk9Yzgmh+m9CoLI4YiowQ/iFKHNauaj1lWgjoyMEI08tDHsXCfFL5bLJ/k0XuGkTqagEhVM84mmfdSn62Lqlh5BcvHr1jtkOzyld/xF2VUM7Xlr2+FNukYcq07LkEWcaQr312VMk/EXuY5O8n31CXes0qiPjX5ZS4pm2f9Cb6M3LCy77+yO2Kj2rWllo8etImAyErzN6dC8ZnqELeK5aKGtDqlxNfBC3/mc2XI6dzNdS3Z6BI8wSPrbv5fQp6rs6yWB8e7SDp5ep/10fnAIsWv7hvnlJmWUwYuh/p0ziN4KTbXj1cPvmSz2FFFh2I7NexncdzPsgjDJSY/qjZzmU7MWKXrBvjEcKL7yJ99wQoGipn8zIVNR7sbnn30XoUtYb9J7AmMWrHgJdzDomMPUGW8n6+gdtDwNfxqYCzJu7w9IOv47U0H/a+YsVrpiUR+a8ULd8DC5ITX4QwWzrJARPviN6aQlQ== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SG2P153MB0352.APCP153.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: c726fc14-3d08-4e08-4bb8-08d85acb557d X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2020 05:34:22.6823 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +UlR4H1Tt7i3IBkRhKv0J0ZlmKOU8lWfkb8n0h5KaKySbVRo286OrBc8AU1xM5U8cNXJ9B5hDpQ/L3Z2h8YvLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2P153MB0352 X-Rspamd-Queue-Id: 4BsQdH2rpQz4l8t X-Spamd-Bar: --------- X-Spamd-Result: default: False [-9.54 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; HAS_XOIP(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:40.107.0.0/16]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[microsoft.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[microsoft.com,reject]; NEURAL_HAM_SHORT(-0.42)[-0.421]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:8075, ipnet:40.104.0.0/14, country:US]; ARC_ALLOW(-1.00)[microsoft.com:s=arcselector9901:i=1]; RCVD_IN_DNSWL_LOW(-0.10)[40.107.131.119:from]; NEURAL_HAM_MEDIUM(-1.01)[-1.013]; R_DKIM_ALLOW(-0.20)[microsoft.com:s=selector2]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_MED(-2.00)[microsoft.com:dkim]; NEURAL_HAM_LONG(-1.01)[-1.005]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_SOME(0.00)[]; WHITELIST_SPF_DKIM(-3.00)[microsoft.com:d:+,microsoft.com:s:+]; RWL_MAILSPIKE_POSSIBLE(0.00)[40.107.131.119:from]; MAILMAN_DEST(0.00)[freebsd-hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2020 05:34:29 -0000 > From: Konstantin Belousov > Sent: Wednesday, September 16, 2020 9:57 PM > To: Wei Hu > Cc: freebsd-hackers@freebsd.org > Subject: Re: MSR accesses that slows down the hypervisor/host >=20 > Where do you see accesses to MSR_LS_CFG ? I can only find manipulations = of > that MSR in init_amd(), and then it is all under check that we are not > virtualized. >=20 Yes, it is only accessed in init_amd() at boot time. So it is less concerne= d. MSR_AMDK8_IPM is accessed in cpu_idle() all the time, so it is the key place to optimize. > For MSR_AMDK8_IPM access in cpu_idle(), it seems that the workaround was > applied too wide. It might be that we do not need to do it on recent CPUs= , but I > need to spent more time looking at datasheets to confirm/deny. >=20 > But, do you (hypervisor) indeed allow guest to initiate C1 or deeper idle= state ? > If not, perhaps as the first measure, we can avoid manipulating > MSR_AMDK8_IPM under hypervisor at all. You are right a guest cannot initiate C1 or deeper idle state when running = on Hyper-V. So skipping the read of MSR_AMDK8_IPM when running under this hypervisor wo= uld=20 Be a viable solution.=20 Thanks, Wei