From patchwork Fri Jul 14 10:40:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 9840525 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 81C4F602D8 for ; Fri, 14 Jul 2017 10:47:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 731E128752 for ; Fri, 14 Jul 2017 10:47:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 661B82876E; Fri, 14 Jul 2017 10:47:24 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E714928752 for ; Fri, 14 Jul 2017 10:47:23 +0000 (UTC) Received: from localhost ([::1]:36901 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVy83-0008OF-5w for patchwork-qemu-devel@patchwork.kernel.org; Fri, 14 Jul 2017 06:47:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVy2C-0003GB-6o for qemu-devel@nongnu.org; Fri, 14 Jul 2017 06:41:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVy28-0003Je-Tr for qemu-devel@nongnu.org; Fri, 14 Jul 2017 06:41:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59519) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVy28-0003J1-KH for qemu-devel@nongnu.org; Fri, 14 Jul 2017 06:41:16 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6EAcnFH002740 for ; Fri, 14 Jul 2017 06:41:15 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bpmft0xrb-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 14 Jul 2017 06:41:14 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Jul 2017 11:41:12 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 14 Jul 2017 11:41:08 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6EAf8Wh12124510; Fri, 14 Jul 2017 10:41:08 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67DBA4241B; Fri, 14 Jul 2017 11:38:30 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 506344241D; Fri, 14 Jul 2017 11:38:30 +0100 (BST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 14 Jul 2017 11:38:30 +0100 (BST) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 25651) id CC29420F69D; Fri, 14 Jul 2017 12:41:07 +0200 (CEST) From: Christian Borntraeger To: Peter Maydell Date: Fri, 14 Jul 2017 12:40:28 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500028867-134709-1-git-send-email-borntraeger@de.ibm.com> References: <1500028867-134709-1-git-send-email-borntraeger@de.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071410-0020-0000-0000-000003A21F87 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071410-0021-0000-0000-00004227AA23 Message-Id: <1500028867-134709-2-git-send-email-borntraeger@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-13_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707140175 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL 01/40] s390x/kvm: Rework cmma management X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Janosch Frank , Thomas Huth , Cornelia Huck , qemu-devel , Alexander Graf , Christian Borntraeger , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Janosch Frank Let's keep track of cmma enablement and move the mem_path check into the actual enablement. This now also warns users that do not use cpu-models about disabled cmma when using huge pages. Signed-off-by: Janosch Frank Reviewed-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- target/s390x/cpu.h | 1 + target/s390x/kvm.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index bdb9bdb..8ab75c0 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -1158,6 +1158,7 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, int vq, bool assign); int kvm_s390_cpu_restart(S390CPU *cpu); int kvm_s390_get_memslot_count(KVMState *s); +int kvm_s390_cmma_active(void); void kvm_s390_cmma_reset(void); int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state); void kvm_s390_reset_vcpu(S390CPU *cpu); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index a3d0019..7a2a7c0 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -140,6 +140,8 @@ static int cap_mem_op; static int cap_s390_irq; static int cap_ri; +static int active_cmma; + static void *legacy_s390_alloc(size_t size, uint64_t *align); static int kvm_s390_query_mem_limit(KVMState *s, uint64_t *memory_limit) @@ -177,6 +179,11 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit) return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr); } +int kvm_s390_cmma_active(void) +{ + return active_cmma; +} + static bool kvm_s390_cmma_available(void) { static bool initialized, value; @@ -197,7 +204,7 @@ void kvm_s390_cmma_reset(void) .attr = KVM_S390_VM_MEM_CLR_CMMA, }; - if (mem_path || !kvm_s390_cmma_available()) { + if (!kvm_s390_cmma_active()) { return; } @@ -213,7 +220,13 @@ static void kvm_s390_enable_cmma(void) .attr = KVM_S390_VM_MEM_ENABLE_CMMA, }; + if (mem_path) { + error_report("Warning: CMM will not be enabled because it is not " + "compatible to hugetlbfs."); + return; + } rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); + active_cmma = !rc; trace_kvm_enable_cmma(rc); } @@ -2641,7 +2654,7 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) if (!model) { /* compatibility handling if cpu models are disabled */ - if (kvm_s390_cmma_available() && !mem_path) { + if (kvm_s390_cmma_available()) { kvm_s390_enable_cmma(); } return; @@ -2672,13 +2685,8 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp) error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc); return; } - /* enable CMM via CMMA - disable on hugetlbfs */ + /* enable CMM via CMMA */ if (test_bit(S390_FEAT_CMM, model->features)) { - if (mem_path) { - error_report("Warning: CMM will not be enabled because it is not " - "compatible to hugetlbfs."); - } else { - kvm_s390_enable_cmma(); - } + kvm_s390_enable_cmma(); } }