From patchwork Thu Jun 14 01:18:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Babu Moger X-Patchwork-Id: 10463155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 06DCA60329 for ; Thu, 14 Jun 2018 01:19:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC2E628C3E for ; Thu, 14 Jun 2018 01:19:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E090B28C5A; Thu, 14 Jun 2018 01:19:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6986C28C3E for ; Thu, 14 Jun 2018 01:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935907AbeFNBS7 (ORCPT ); Wed, 13 Jun 2018 21:18:59 -0400 Received: from mail-eopbgr700079.outbound.protection.outlook.com ([40.107.70.79]:4864 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935733AbeFNBSp (ORCPT ); Wed, 13 Jun 2018 21:18:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=y/5JOaCMYSWv1HmhXTlTHfgPS/XC9dLqzT4mNsbqOm0=; b=fSn44RIjobhOg8jw0sjLMx8JLic4Jnhvkc2NXpAQT+J6DEWmtelik/zyyCSuWqdKYcCFIhQ+bZIRSdkcvGiG2QmsbjlORa685UQG5pd9z3KXrJcpMy7wajcLTYfNEZYJIzH/q7i6ZeyBwwxeBDRLKKcImut2qGT4AFWhPPlAG9Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-h3ml.amd.com (165.204.77.1) by SN1PR12MB2480.namprd12.prod.outlook.com (2603:10b6:802:29::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.14; Thu, 14 Jun 2018 01:18:42 +0000 From: Babu Moger To: mst@redhat.com, marcel.apfelbaum@gmail.com, pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com, mtosatti@redhat.com Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, babu.moger@amd.com, kash@tripleback.net, geoff@hostfission.com Subject: [PATCH v14 4/6] cpus: Add new function topology_supports_topoext Date: Wed, 13 Jun 2018 21:18:25 -0400 Message-Id: <1528939107-17193-5-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1528939107-17193-1-git-send-email-babu.moger@amd.com> References: <1528939107-17193-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN4PR0201CA0064.namprd02.prod.outlook.com (2603:10b6:803:20::26) To SN1PR12MB2480.namprd12.prod.outlook.com (2603:10b6:802:29::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 001475be-111a-4810-c99d-08d5d194c48a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(48565401081)(2017052603328)(7153060)(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nn2JesbHawy9rH0KyTu722j2/hcvvkwyxcgdwiJ1MKIMHcLSCZ3vMbGJ51KZpZIu/al6ZcN/x69RHjbJHU3jeP6xavVqR6gP7eoglPIPCtoLxMnnfA4+Le1xulbqk7o5NlYevN+1ezBnq5Bqwdvxg+gKLfDrDVbgZmnpcPcSN/LdeMkSjtVkC9XaeRfp4Hz64cHQRXLVjVyaW0rk6E2a0ymOgPUbR4eciosSkM3x9a7i8RAg1PyrYjse7JZSkZiyLyNvWCF7WNDLozxQG8+UMBe0vdKcxrcHrLpkZAAMmzW/pV8fq+paRgAFho0ELu//hr77Ge5HoMj2BiBEFeHz3Ib1sEDwRndeJkbfHGdlLz1Vj767xhTgmmP00jyeeLL+X/9vwlxE2W4TGfSl6ybVOGpqhFzydT+KQ; 4:DED5Y5qgZRp0qmFsmjiZvZhLEHnDocAyFhvTB7+et02I6z2aoKHOKzr4OSn+PmCcYGqlJA5h6I7Lu5qjAfHH9WRkrl0PAVfZbppm7UBiMLEIMgMxpe0YuuYxDcImTOjDPvUUGsgOoji3wTpSJJ+xLP+bfY8ZR7D14+uBOCjbwRB+MdJETnVGCJvFpV51z+vFv6CeZ6fzvBJSTu9Uej5hN1taKPj8BFLW1Cf2SZGRtMCwcmjFh6sWowJSaCqOYWH/9lYC9kejY33ejCE9XIUhwjOnVtgPSZS8NpRwd7SsiZW3JJu5Q5VyFyIR2RQ/HVQS X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:SN1PR12MB2480; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB2480; X-Forefront-PRVS: 0703B549E4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(396003)(39860400002)(366004)(376002)(39380400002)(189003)(199004)(68736007)(2906002)(25786009)(52116002)(7696005)(72206003)(51416003)(4720700003)(956004)(6666003)(2616005)(11346002)(44832011)(486006)(53936002)(7416002)(476003)(446003)(76176011)(6486002)(39060400002)(36756003)(478600001)(4326008)(6116002)(5660300001)(7736002)(305945005)(86362001)(8676002)(186003)(97736004)(16586007)(66066001)(3846002)(53416004)(8936002)(16526019)(316002)(386003)(48376002)(26005)(81156014)(81166006)(59450400001)(50466002)(106356001)(50226002)(47776003)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB2480; H:linux-h3ml.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB2480; 23:A8TmdIETO+8ywlif1GmYWV2WwEtQqWAG8SkE+jjAy?= =?us-ascii?Q?2XvRZ4G5oC3amT9AOo+JIivVsT2Pv1KZk4KZLbmJSZrruezxAuSLvKR2tlhQ?= =?us-ascii?Q?xKWyK1WjWyxYAmcbvdcnDdcYGqle9NOzadzRbR6vOxSJp2GvohsFIyVYLKsS?= =?us-ascii?Q?taJDTC6/xRHSC8hTIIeH2RanDNfSK3YNFAqjCXthIBQgIHaevGZFgii8BtmD?= =?us-ascii?Q?uRKgsMUqDt3inNAh7FEgTMTuhwlWvizLRJiOjK4oFBrKzM9LEqeAQFQZHym9?= =?us-ascii?Q?S9GDMFztOSWUyiP0vQt7c8wax1iPlwM3qwKud6kr0XNmeNjU2kgYteNSWxhl?= =?us-ascii?Q?1kSVbY/JpIVg77NDns6xcK1sCgvzB8+2e4UIJ6Wjg/ElQ8gLCC9kzgNB4xNB?= =?us-ascii?Q?hhcKmlg4bSN4hxeSZMsJScaoANTAQ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= =?us-ascii?Q?2NxAwm+iUGNH9HU/GX80Wc=3D?= X-Microsoft-Antispam-Message-Info: iooKsFDGaZp1SGR2LGKb5AGKBDdL8NLl/u7AwOfDl6FBEF8MIZuI+0jciD0fOhEVrUsULmSvlrBBMSdjUmqQTQCroQw+rpwQXlc1WXDz3htVB4WI5TvASmkR3Losyp215Qk7oPrySsYfV7VljEFfUFCsT1bSrISyoTwe8K/rnODjyZtGEeU5RaleiW+eHeHC X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2480; 6:LumyG4pveI5N9Ota2mfg3K8JNfoRRFvAdjSM0P+6DrHtx0d4fP+26D4XiRInLLDhlf/3s6sw5Ikw2Aov6z7IMgojcyvBHNgZUPD9USZNaxpkY4UbC88V7vW7ZWNgIrxDzwslp7l8FB/jvuCBCwbHkk2YSQk0hPDoLyQZ/eYw56o9AXlUCPFpM7TR3BLuw7klBg5Zt8PhHLZmg8f/xCxE519PNBilXV0rx9/f8V9w7dZBM6Lk5hEW816bBtu/Sr+q3v4Xu5FEHnREpPob7xeC1jd6LyPe/+xEor4LV2YSplv0itvuX9WisoKRt0syHr0gTeag79YgGq7o89hJxBhpSJCiDs3a6heTJM0kWkObFtrNvzULs2lRoR0bdPu+O3krkTZKRMqqcCfAgUYeTMztdtu434OOifdEgyPhsp0KS16m314HbTVBHPEUwdpLPsUW2tRieHfBx815/4twzCzvWQ==; 5:wv68EDvemxgoZLxEK7MPdWht+VgVthIZU0Et4ydSmgNq2up18jEFa0Uyt7OeMugTYkhuCHdCOBeffQ5RhvlNCyW55HslCw5fdMszAEYf0IXeCHObwRoc6IFfosgnu8XQaEIOGSK8SvmBE/rD/ZKVgD+cBjLUsClg1eNS9CeScNA=; 24:hldBzl9xggSvau+7v5tb9G60kJJBG/uGzhYWNZvoyZSrI4DrmfSp4youaM9r6MwmSr7YGbdy+yMlgGhWDcqDplcy/W9Q1fbLkX3A62gU+NY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB2480; 7:UDZbmmKcT+ckKL6u51Io/7nCNuJu1Gsqg65ENdbiKSo8+uWNzxVHI9BT85dqrnFH+vDG8mZBDHJTF2rM4X7W2wHy80bAhbYZ0E9NpKUjTyEsonJJmfpD2W3F/kVvCXjYAeAaiV9zZuBHQ+d+sWe5A+kvrr1ZNfnaiyw/YbZ1KH9eTJjRqCw4dkPc2BRCC3aiYzHz/+pgc41/LPBBHJ8Zpd6YYM4ifAInp24P+0qtsrfihPxJXyJh3kU2o30uIb1i; 20:DjrEBkOkKydIIBOFOMxwu5ybIIVWKAaORhMugCYdtZvZF9R1ssP5t/di/POtwH087PONVWEBy4IXegCk+T26omW6CCDJ7W7s6sFAhO0MDgMzVXGitiwExUO6Pdy52ymU7w2DSP64w3BVCR/Pt/d8vrZwjYFOgoKtuy1RClGbNdWV+x/O1bilY+hnt+adOIMVyWZC+KXfXs+xy2hUcCVZHS3uDbC2cPFr9d/1ebh/UtwGdxoFotY17pEThJf5SmX1 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2018 01:18:42.2225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 001475be-111a-4810-c99d-08d5d194c48a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2480 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add new function topology_supports_topoext to verify if we can support topoext feature. Will be used to enable/disable topoext feature. Signed-off-by: Babu Moger --- accel/tcg/user-exec-stub.c | 5 +++++ cpus.c | 13 +++++++++++++ include/qom/cpu.h | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/accel/tcg/user-exec-stub.c b/accel/tcg/user-exec-stub.c index dbcf1ad..715818a 100644 --- a/accel/tcg/user-exec-stub.c +++ b/accel/tcg/user-exec-stub.c @@ -11,6 +11,11 @@ void qemu_init_vcpu(CPUState *cpu) { } +int topology_supports_topoext(int max_cores, int max_threads) +{ + return true; +} + /* User mode emulation does not support record/replay yet. */ bool replay_exception(void) diff --git a/cpus.c b/cpus.c index d1f1629..17f6f4c 100644 --- a/cpus.c +++ b/cpus.c @@ -1979,6 +1979,19 @@ static void qemu_dummy_start_vcpu(CPUState *cpu) QEMU_THREAD_JOINABLE); } +/* + * Check if we can support topoext feature with this topology + * Fail if number of cores are beyond the supported cores + * or number of threads are more than supported threads + */ +int topology_supports_topoext(int max_cores, int max_threads) +{ + if ((smp_cores > max_cores) || (smp_threads > max_threads)) { + return false; + } + return true; +} + void qemu_init_vcpu(CPUState *cpu) { cpu->nr_cores = smp_cores; diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9d3afc6..4ac4d49 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -1004,6 +1004,15 @@ void end_exclusive(void); */ void qemu_init_vcpu(CPUState *cpu); +/** + * topology_supports_topoext: + * @max_cores: Max cores topoext feature can support + * @max_threads: Max threads topoext feature can support + * + * Return true if topology can be supported else return false + */ +int topology_supports_topoext(int max_cores, int max_threads); + #define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */ #define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */ #define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */