From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20331C61DD6 for ; Wed, 2 Sep 2026 06:15:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C02A6B0092; Wed, 2 Sep 2026 02:15:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24A366B0095; Wed, 2 Sep 2026 02:15:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 111B76B0096; Wed, 2 Sep 2026 02:15:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DF8626B0092 for ; Wed, 2 Sep 2026 02:15:36 -0400 (EDT) Received: from smtpin30.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6B67B1A06BE for ; Wed, 2 Sep 2026 06:15:36 +0000 (UTC) X-FDA: 85167810672.30.12D61AD Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf25.hostedemail.com (Postfix) with ESMTP id C97BDA0007 for ; Wed, 2 Sep 2026 06:15:34 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=RyCC6K3+; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1788329734; b=SCmv1yhSNSQxDd44Gd03fGjiWlIfe6BVgxCffqGP8/2OTjgRFPTF2HH6nc0tiln1Y/1267 yeuKmZ3X76H1xHtHtZVICCDfb/N8nwgJELnDawh+qmnz51UpNDf2HK1bGXKcSt5lQxxlVD DEX5wIylvKSxkgqupT2kgN2N6OrjZHY= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=RyCC6K3+; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1788329734; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rZDmOJa3lKJg3q4J0vxXiCwo1usJZY0dSBwZL2xaIK4=; b=t3B+4HW105d1xShrfX3dnVJ9ykPkjFvht7hn/cNgx9ixe81UHdGPVtyVJiKBuTYwXSfPev bobZDybKU81mmOw61lc0R3JfujeJJDFSngX+Nxa9VMcghldoB/CnQZ7ffrOi+WE12aBkKE s2MBix4gwsW5fp02t5gdpy7BpDPvUmU= Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 234B160218; Wed, 2 Sep 2026 06:15:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B38201F00A3A; Wed, 2 Sep 2026 06:15:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1788329733; bh=rZDmOJa3lKJg3q4J0vxXiCwo1usJZY0dSBwZL2xaIK4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=RyCC6K3+yoBVj6HOL+jhCmJspI1rOOtMlmlJ09dU7HJTzqEQmvW2aI/S1sfTHPfj6 ZHYdLXxvZEV213yRt6hcyicUWOkk/fmtKZ2RbcigWIVDgqKvgU4dQNyaPa3tdhRynn UmyYgIsw6J0sWUvzPkXwjZYh+twK/i+vDC+6T4STp0EIiC0Lknuutak3P8VrbsKjOT 9jh7aG7AnlP2sL5unVXGeaY3Dzug0feoyhj1sILuc+230lbhU7aXqxUVJGiXrHlVt2 nsi5FDvTfJt+DSOgof/YYHzGjA6EsF0FFHUoTrVFeq7ELA2DJhEqGbMzj/f0c2ZSy4 nk9//iAEyiEjQ== From: "Mike Rapoport (Microsoft)" Date: Wed, 02 Sep 2026 09:15:13 +0300 Subject: [PATCH 1/4] KVM: s390: Replace get_zeroed_page() with kzalloc() for the STHYI buffer MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260902-s390-kvm-v1-1-3bc0986550b1@kernel.org> References: <20260902-s390-kvm-v1-0-3bc0986550b1@kernel.org> In-Reply-To: <20260902-s390-kvm-v1-0-3bc0986550b1@kernel.org> To: Christian Borntraeger , Claudio Imbrenda , Janosch Frank Cc: Alexander Gordeev , David Hildenbrand , Heiko Carstens , Mike Rapoport , Sven Schnelle , Vasily Gorbik , Vlastimil Babka , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org X-Mailer: b4 0.17-dev X-Rspam-User: X-Stat-Signature: jyscqfrqib761fyi5n6pg18qtk5i48fs X-Rspamd-Queue-Id: C97BDA0007 X-Rspamd-Server: rspam06 X-HE-Tag: 1788329734-369691 X-HE-Meta: U2FsdGVkX1+jbeSWhGxRc4mkdeBX2WeVCQiLK0e4j+4Da5H2yYUocs5vUNrr0aE3clTD7Fwq2QywqeIsW9eXa8v0k3k8IeYVB8MSyPclV3yFMbigSVeTxBVDtSjDlORqLB1ytvAF0qUh/vHZX4eF4143RG69LjckK2la6iLmXou5XdpUOFhjb7vw91I9kA82rUPd0uRkwazIQ276KPcUk565QoTE5Hy7UN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mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: handle_sthyi() allocates the buffer that receives the STHYI response block before it is copied to the guest. This buffer can be allocated with kmalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of get_zeroed_page() with kzalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com Assisted-by: copilot:claude-opus Signed-off-by: Mike Rapoport (Microsoft) --- arch/s390/kvm/s390/intercept.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/s390/kvm/s390/intercept.c b/arch/s390/kvm/s390/intercept.c index ca1205dfac8b0..aaf9828d1f44d 100644 --- a/arch/s390/kvm/s390/intercept.c +++ b/arch/s390/kvm/s390/intercept.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -438,13 +439,13 @@ int handle_sthyi(struct kvm_vcpu *vcpu) if (!kvm_s390_pv_cpu_is_protected(vcpu) && (addr & ~PAGE_MASK)) return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); - sctns = (void *)get_zeroed_page(GFP_KERNEL_ACCOUNT); + sctns = kzalloc(PAGE_SIZE, GFP_KERNEL_ACCOUNT); if (!sctns) return -ENOMEM; cc = sthyi_fill(sctns, &rc); if (cc < 0) { - free_page((unsigned long)sctns); + kfree(sctns); return cc; } out: @@ -454,13 +455,13 @@ int handle_sthyi(struct kvm_vcpu *vcpu) } else { r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); if (r) { - free_page((unsigned long)sctns); + kfree(sctns); return kvm_s390_inject_prog_cond(vcpu, r); } } } - free_page((unsigned long)sctns); + kfree(sctns); vcpu->run->s.regs.gprs[reg2 + 1] = rc; kvm_s390_set_psw_cc(vcpu, cc); return r; -- 2.53.0