From nobody Mon Nov 23 22:28:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1794294888; cv=none; d=zohomail.com; s=zohoarc; b=F2JpiM5rxyuH0L8zUkCtYHcNa4wtHPklv+2PB1V2r8PDxyJhbHb8SMi3KHBl77vZ/RrREWZGlsRHQcs7wr/gGsP/Y5rWUl1yoeD4zCrCVah9CHhC6Ka8pfwsZtGkTpJ090DSsjLUvdx4Sg8lkWusdVHIbZ38YyAylC8ofLfgTQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794294888; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JeBczRWUIYEnZGuPHhbnKleDwqSoORE3VajfVV+2ChI=; b=k5qd1keV1TumOStG0u0ykwaDM9g7eLsENvlRgUNpkI5HNNoQPfi3hQ6Ox5otZMBi89XhLzZ5r5YhqZiHNJvfjZrZ2ajcmGyJIUl+StYHo4EWNFKWSI/7UJC/pEyRpAuyoxUe2L3EVOmFccquY0+jKocR9O3xMqSZGYZVxvW2ST0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1794294888312169.365132987759; Mon, 9 Nov 2026 23:14:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1480712.1684478 (Exim 4.92) (envelope-from ) id 1xQg3w-0008F8-Mh; Tue, 10 Nov 2026 07:14:36 +0000 Received: by outflank-mailman (output) from mailman id 1480712.1684478; Tue, 10 Nov 2026 07:14:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQg3w-0008F1-JW; Tue, 10 Nov 2026 07:14:36 +0000 Received: by outflank-mailman (input) for mailman id 1480712; Tue, 10 Nov 2026 07:14:35 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xQg3v-0008Et-Gr for xen-devel@lists.xenproject.org; Tue, 10 Nov 2026 07:14:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xQg3u-00DVMK-U1 for xen-devel@lists.xenproject.org; Tue, 10 Nov 2026 08:14:34 +0100 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6af2c43f-bab6-0a2a0a5309dd-0a2a450ab6d8-42 for ; Tue, 10 Nov 2026 08:14:34 +0100 Received: from [172.105.4.254] (helo=tor.source.kernel.org) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6af2c459-f2d2-0a2a450a0019-ac6904feb7f0-3 for ; Tue, 10 Nov 2026 08:14:34 +0100 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id CBEBF63792; Tue, 10 Nov 2026 07:14:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89DFA1F0089F; Tue, 10 Nov 2026 07:14:30 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=k20260515 header.d=kernel.org header.i="@kernel.org" header.h="From:Date:Subject:To:Cc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794294872; bh=JeBczRWUIYEnZGuPHhbnKleDwqSoORE3VajfVV+2ChI=; h=From:Date:Subject:To:Cc; b=fKPLbiivanrEzD0lDTSnLnW+s/csuy7zmF/rQB69ecBnZGkkMcGW82NV5pFLA16bh 84z8u8ZKsezk0gYvkBpaWKmkB/ti1yMKn+uXWxAze4muXfT6Q9+ylkElk9VeSLKbd3 3URD86VRiixps3P+Z8PM+90U+NYNcy2eMdKeOMdHhJ++2/mcCNMufVBbVJJMfzG/p2 mc28TlVdjw+vnhpCmNyhtsqkpeGz5K5ogqQGT0HmG2L8a3nUHWOjuOA6DL49rUoXRX vkQgdAghDuSKqy1+cSnm7w8cRkNFX/e5T8W6ZAVKr5foh+Vkwbr1ayP8ewc73Vd0Fp DzSaXhkrVZFZg== From: "Mike Rapoport (Microsoft)" Date: Tue, 10 Nov 2026 09:14:27 +0200 Subject: [PATCH v2] xen/events: replace page allocator calls with k[mz]alloc() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261110-b4-xen-v2-1-21ece28be7d4@kernel.org> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/zWOzQ6CMBCEX4X0bJU2pYon38NwaMsW1p/WbJFgC O8uxXj8ZmZndmYJCCGxczEzghETxrCC3BXM9SZ0wLFdmclS6lJLxa3iEwRuhGu1rB3UXrE1/CL wOG1F1+bH6W1v4IZ8nRPWJOCWTHB9liJhh+HwNGkAyn6PaYj02T4ZRe7ZRoUoT//RUXDBj7qsK y8rZ7263IECPPaROtYsy/IFeJUJSc8AAAA= X-Change-ID: 20260624-b4-xen-a1cd629ce9f4 To: Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko Cc: David Hildenbrand , "Mike Rapoport (Microsoft)" , Vlastimil Babka , linux-mm@kvack.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.16.1-dev X-purgate-ID: tlsNG-4011c0/1794294874-4B2D8CFC-4F5B5F29/0/0 X-purgate-type: clean X-purgate-size: 3404 X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1794294889459158500 set_evtchn_to_irq() allocates a page for the event channel to IRQ number software lookup table and xen_init_IRQ() allocates the PIRQ EOI bitmap that is registered with the hypervisor in PV domains. These buffers can be allocated with kmalloc() as there's nothing special about them to go directly to the page allocator. The PIRQ EOI bitmap is passed to the hypervisor by its frame number and must occupy a whole page, which is guaranteed for a PAGE_SIZE kmalloc() allocation as it is naturally aligned. 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_free_pages() with kmalloc(), __get_free_page() with __GFP_ZERO with kzalloc() and free_page[s]() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redh= at.com Signed-off-by: Mike Rapoport (Microsoft) Reviewed-by: Juergen Gross --- This is a (small) part of larger work of replacing page allocator calls with kmalloc. Largely, anything that doesn't need struct page (or a memdesc in the future) should just use kmalloc() or kvmalloc() to allocate memory. Removing needless calls to page allocator helps with memdesc (aka project folio) conversion and gives a nicer API without casts. --- Changes in v2: - EDITME: describe what is new in this series revision. - EDITME: use bulletpoints and terse descriptions. - Link to v1: https://patch.msgid.link/20261108-b4-xen-v1-1-76095f25cbf4@ke= rnel.org --- drivers/xen/events/events_base.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_b= ase.c index fd16d652c81f2..9828ed41d7a7f 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -230,7 +230,7 @@ static int set_evtchn_to_irq(evtchn_port_t evtchn, unsi= gned int irq) if (irq =3D=3D -1) return 0; =20 - evtchn_row =3D (int *) __get_free_pages(GFP_KERNEL, 0); + evtchn_row =3D kmalloc(PAGE_SIZE, GFP_KERNEL); if (evtchn_row =3D=3D NULL) return -ENOMEM; =20 @@ -241,7 +241,7 @@ static int set_evtchn_to_irq(evtchn_port_t evtchn, unsi= gned int irq) * thread was faster inserting it, we can drop ours. */ if (cmpxchg(&evtchn_to_irq[row], NULL, evtchn_row) !=3D NULL) - free_page((unsigned long) evtchn_row); + kfree(evtchn_row); } =20 WRITE_ONCE(evtchn_to_irq[row][col], irq); @@ -2314,11 +2314,11 @@ void __init xen_init_IRQ(void) int rc; struct physdev_pirq_eoi_gmfn eoi_gmfn; =20 - pirq_eoi_map =3D (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO); + pirq_eoi_map =3D kzalloc(PAGE_SIZE, GFP_KERNEL); eoi_gmfn.gmfn =3D virt_to_gfn(pirq_eoi_map); rc =3D HYPERVISOR_physdev_op(PHYSDEVOP_pirq_eoi_gmfn_v2, &eoi_gmfn); if (rc !=3D 0) { - free_page((unsigned long) pirq_eoi_map); + kfree(pirq_eoi_map); pirq_eoi_map =3D NULL; } else pirq_needs_eoi =3D pirq_check_eoi_map; --- base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4 change-id: 20260624-b4-xen-a1cd629ce9f4 -- Sincerely yours, Mike.