From nobody Mon Jun 8 20:41:41 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=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1779808108; cv=none; d=zohomail.com; s=zohoarc; b=b1X0To5XmhETpDyjN6YUuwoonIotY1LI7WqGyQRtaatF7mRVUBYQDJWFXCtk2PI9wnKTpKvnLb0op8uPhp0sC6gstlFrqkqX/mPj7/DsxfW2u+oDxZ9AHWaWHf/CPqqb8R5acXQOs3Bvnb47kvlAgWRv+xIRdAbYo5wRdApylRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779808108; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zqSqltL1GnVn7PKoSl94YXnAsN5DYo+RIglrQTaw6ZE=; b=nTA49XMu2XsA/YJakF0XPAjxdCj20IWHOSQVzrAatiu1UjNnGKW49XB0QIPTm5lEeePLUja18em2GQawBkpDnpEqhAvTMmBhyobmSCMClfOtVfLLuuCazdq35Fkdwgi7I6st6+Cn99u7gxz0QN0stN3+/+66fxpQcghqjikc0Uo= 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 1779808108886954.7082650578152; Tue, 26 May 2026 08:08:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1320020.1587437 (Exim 4.92) (envelope-from ) id 1wRtO5-000783-FD; Tue, 26 May 2026 15:08:09 +0000 Received: by outflank-mailman (output) from mailman id 1320020.1587437; Tue, 26 May 2026 15:08:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtO5-00077w-C4; Tue, 26 May 2026 15:08:09 +0000 Received: by outflank-mailman (input) for mailman id 1320020; Tue, 26 May 2026 15:08:08 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtO4-00077i-E2 for xen-devel@lists.xenproject.org; Tue, 26 May 2026 15:08:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRtO3-00BHE7-Pz for xen-devel@lists.xenproject.org; Tue, 26 May 2026 17:08:07 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b750-2eae-0a2a0a5409dd-0a2a4505aa02-14 for ; Tue, 26 May 2026 17:08:07 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b757-aaa8-0a2a45050019-c387df83a5f8-3 for ; Tue, 26 May 2026 17:08:07 +0200 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3348767479; Tue, 26 May 2026 15:08:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D79085A280; Tue, 26 May 2026 15:08:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id fIlCM1a3FWqUVQAAD6G6ig (envelope-from ); Tue, 26 May 2026 15:08:06 +0000 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=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zqSqltL1GnVn7PKoSl94YXnAsN5DYo+RIglrQTaw6ZE=; b=IhRRJLg1s5P5gbD17rJX9mZp818QbdvrFXhyx343oE+IaY0Kh+yGSPyqhhevxSLMM9kMpW xtcnReEWjm/8c1ay8xDj7uC+n3hhkvcCe5rSHQ151k0Qtc23cNKrxsvH+aYeIB3X9PRiY5 6dAf2+JidkGM8r4dXSxeKh8mWnX64GU= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808087; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zqSqltL1GnVn7PKoSl94YXnAsN5DYo+RIglrQTaw6ZE=; b=IhRRJLg1s5P5gbD17rJX9mZp818QbdvrFXhyx343oE+IaY0Kh+yGSPyqhhevxSLMM9kMpW xtcnReEWjm/8c1ay8xDj7uC+n3hhkvcCe5rSHQ151k0Qtc23cNKrxsvH+aYeIB3X9PRiY5 6dAf2+JidkGM8r4dXSxeKh8mWnX64GU= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-trace-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , xen-devel@lists.xenproject.org Subject: [PATCH 1/5] x86/xen: Drop lazy mode from trace entries Date: Tue, 26 May 2026 17:05:10 +0200 Message-ID: <20260526150514.129330-2-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150514.129330-1-jgross@suse.com> References: <20260526150514.129330-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Score: -2.79 X-Spam-Flag: NO X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.19)[-0.967]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWELVE(0.00)[14]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-purgate-ID: tlsNG-c201ff/1779808087-D877A443-962DE9F9/0/0 X-purgate-type: clean X-purgate-size: 2996 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1779808110863154100 Content-Type: text/plain; charset="utf-8" Drop the lazy mode (cpu or mmu) from the xen_mc_batch and xen_mc_issue trace entries. This is done in preparation of removing the xen_lazy_mode percpu variable. Signed-off-by: Juergen Gross --- arch/x86/xen/xen-ops.h | 11 +++++++---- include/trace/events/xen.h | 33 +++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 6808010ac379..dc892f421f25 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -98,7 +98,7 @@ static inline void xen_mc_batch(void) =20 /* need to disable interrupts until this entry is complete */ local_irq_save(flags); - trace_xen_mc_batch(xen_get_lazy_mode()); + trace_xen_mc_batch(flags); __this_cpu_write(xen_mc_irq_flags, flags); } =20 @@ -114,13 +114,16 @@ void xen_mc_flush(void); /* Issue a multicall if we're not in a lazy mode */ static inline void xen_mc_issue(unsigned mode) { - trace_xen_mc_issue(mode); + bool flush =3D !(xen_get_lazy_mode() & mode); + unsigned long flags =3D this_cpu_read(xen_mc_irq_flags); =20 - if ((xen_get_lazy_mode() & mode) =3D=3D 0) + trace_xen_mc_issue(flush, flags); + + if (flush) xen_mc_flush(); =20 /* restore flags saved in xen_mc_batch */ - local_irq_restore(this_cpu_read(xen_mc_irq_flags)); + local_irq_restore(flags); } =20 /* Set up a callback to be called when the current batch is flushed */ diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h index e3f139f0bc78..ad384969e2cb 100644 --- a/include/trace/events/xen.h +++ b/include/trace/events/xen.h @@ -12,24 +12,29 @@ struct multicall_entry; =20 /* Multicalls */ -DECLARE_EVENT_CLASS(xen_mc__batch, - TP_PROTO(enum xen_lazy_mode mode), - TP_ARGS(mode), +TRACE_EVENT(xen_mc_batch, + TP_PROTO(unsigned long flags), + TP_ARGS(flags), TP_STRUCT__entry( - __field(enum xen_lazy_mode, mode) + __field(unsigned long, flags) ), - TP_fast_assign(__entry->mode =3D mode), - TP_printk("start batch LAZY_%s", - (__entry->mode =3D=3D XEN_LAZY_MMU) ? "MMU" : - (__entry->mode =3D=3D XEN_LAZY_CPU) ? "CPU" : "NONE") + TP_fast_assign(__entry->flags =3D flags), + TP_printk("start batch lazy flags %lx", __entry->flags) ); -#define DEFINE_XEN_MC_BATCH(name) \ - DEFINE_EVENT(xen_mc__batch, name, \ - TP_PROTO(enum xen_lazy_mode mode), \ - TP_ARGS(mode)) =20 -DEFINE_XEN_MC_BATCH(xen_mc_batch); -DEFINE_XEN_MC_BATCH(xen_mc_issue); +TRACE_EVENT(xen_mc_issue, + TP_PROTO(bool flush, unsigned long flags), + TP_ARGS(flush, flags), + TP_STRUCT__entry( + __field(unsigned long, flags) + __field(bool, flush) + ), + TP_fast_assign(__entry->flush =3D flush; + __entry->flags =3D flags; + ), + TP_printk("flush: %s, flags %lx", + __entry->flush ? "yes" : "no", __entry->flags) + ); =20 TRACE_DEFINE_SIZEOF(ulong); =20 --=20 2.54.0 From nobody Mon Jun 8 20:41:41 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=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1779808115; cv=none; d=zohomail.com; s=zohoarc; b=YE3ZyBQpebNc4Fopjh4WaaSvbaxFcAFiVqeEhdbyP5nEfyFFM5zcH/xIKrz9HN9fWSIKi6E/v3ax4YFY4RNqgm6xT65FbZkggfYobmcGWbFia9i1qUvOu2zr9BAE64ETSonG+SrZmncdRlvvNWT35OEwADmScFlk64YwYxpT8us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779808115; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=htKnackiGTLT6ra2yiyVCBoM5uojYzGpE60av2lvlE4=; b=P/C39om1b/YlKIdKah6sCTygeKbRriz0vLZqi0iGQ7YTqkYsX0Y7KkA4qHmaVQhXgWPNThtyDDseetGliJvKeaGKa5jzHVj96+HsBzw/n+l83N9YYbBP/cfaAzVbXhUMiDGwGrMVE07yt9wxtc8+Gk2+KQOfkwgRkTfEOPjhmuQ= 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 1779808115239785.4026340942534; Tue, 26 May 2026 08:08:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1320022.1587446 (Exim 4.92) (envelope-from ) id 1wRtOB-0007PL-MK; Tue, 26 May 2026 15:08:15 +0000 Received: by outflank-mailman (output) from mailman id 1320022.1587446; Tue, 26 May 2026 15:08:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtOB-0007PE-J4; Tue, 26 May 2026 15:08:15 +0000 Received: by outflank-mailman (input) for mailman id 1320022; Tue, 26 May 2026 15:08:13 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtO9-0007Ne-Qk for xen-devel@lists.xenproject.org; Tue, 26 May 2026 15:08:13 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRtO9-00BHE7-6i for xen-devel@lists.xenproject.org; Tue, 26 May 2026 17:08:13 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b750-2eae-0a2a0a5409dd-0a2a4505aa02-22 for ; Tue, 26 May 2026 17:08:13 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b75c-aaa8-0a2a45050019-c387df839eee-3 for ; Tue, 26 May 2026 17:08:13 +0200 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B5B4075EA1; Tue, 26 May 2026 15:08:12 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7AECC5A280; Tue, 26 May 2026 15:08:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id xZX0HFy3FWqaVQAAD6G6ig (envelope-from ); Tue, 26 May 2026 15:08:12 +0000 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=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808092; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=htKnackiGTLT6ra2yiyVCBoM5uojYzGpE60av2lvlE4=; b=PFA/dfob5jaYx8ziU/VgRy6SDe4zshqEhaFAiCgmyGJnLa9BG79cjVXHb65SY6s2PpEOb6 ZelH9pCmaDauo7y1BTg/Wh4jQRtBNhSDp8kzKI+gHROm+cpqhCaDqubzp97my98RgEFJfP QRRvI7r+TZvT/QvfBIZsUjLJE/Ufimk= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808092; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=htKnackiGTLT6ra2yiyVCBoM5uojYzGpE60av2lvlE4=; b=PFA/dfob5jaYx8ziU/VgRy6SDe4zshqEhaFAiCgmyGJnLa9BG79cjVXHb65SY6s2PpEOb6 ZelH9pCmaDauo7y1BTg/Wh4jQRtBNhSDp8kzKI+gHROm+cpqhCaDqubzp97my98RgEFJfP QRRvI7r+TZvT/QvfBIZsUjLJE/Ufimk= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH 2/5] x86/xen: Change interface of xen_mc_issue() Date: Tue, 26 May 2026 17:05:11 +0200 Message-ID: <20260526150514.129330-3-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150514.129330-1-jgross@suse.com> References: <20260526150514.129330-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Score: -2.79 X-Spam-Flag: NO X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.19)[-0.968]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[10]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; URIBL_BLOCKED(0.00)[suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-purgate-ID: tlsNG-c201ff/1779808093-DAF6E443-1EE9DBBB/0/0 X-purgate-type: clean X-purgate-size: 7686 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1779808115689158501 Content-Type: text/plain; charset="utf-8" Today xen_mc_issue() is deciding whether to call xen_mc_flush() or not based on the lazy mode input parameter passed. Modify this interface to pass a boolean indicating whether the flush should be done. For querying lazy mmu mode use the is_lazy_mmu_mode_active() helper. This is done in preparation for dropping the xen_lazy_mode percpu variable. Signed-off-by: Juergen Gross --- arch/x86/xen/enlighten_pv.c | 8 ++++---- arch/x86/xen/mmu_pv.c | 38 ++++++++++++++++++------------------- arch/x86/xen/xen-ops.h | 3 +-- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index ed2d7a3756ce..428189f5d437 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -544,7 +544,7 @@ static void xen_set_ldt(const void *addr, unsigned entr= ies) =20 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); =20 - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); } =20 static void xen_load_gdt(const struct desc_ptr *dtr) @@ -649,7 +649,7 @@ static void xen_load_tls(struct thread_struct *t, unsig= ned int cpu) load_TLS_descriptor(t, cpu, 1); load_TLS_descriptor(t, cpu, 2); =20 - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); } =20 static void xen_load_gs_index(unsigned int idx) @@ -1011,7 +1011,7 @@ static void xen_load_sp0(unsigned long sp0) =20 mcs =3D xen_mc_entry(0); MULTI_stack_switch(mcs.mc, __KERNEL_DS, sp0); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0); } =20 @@ -1071,7 +1071,7 @@ static void xen_write_cr0(unsigned long cr0) =20 MULTI_fpu_taskswitch(mcs.mc, (cr0 & X86_CR0_TS) !=3D 0); =20 - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); } =20 static void xen_write_cr4(unsigned long cr4) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index cd80406be9c6..51dbdc67c73c 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -290,7 +290,7 @@ static void xen_set_pmd_hyper(pmd_t *ptr, pmd_t val) u.val =3D pmd_val_ma(val); xen_extend_mmu_update(&u); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 preempt_enable(); } @@ -333,7 +333,7 @@ static bool xen_batched_set_pte(pte_t *ptep, pte_t ptev= al) u.val =3D pte_val_ma(pteval); xen_extend_mmu_update(&u); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 return true; } @@ -380,7 +380,7 @@ static void xen_ptep_modify_prot_commit(struct vm_area_= struct *vma, u.val =3D pte_val_ma(pte); xen_extend_mmu_update(&u); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } =20 /* Assume pteval_t is equivalent to all the other *val_t types. */ @@ -474,7 +474,7 @@ static void xen_set_pud_hyper(pud_t *ptr, pud_t val) u.val =3D pud_val_ma(val); xen_extend_mmu_update(&u); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 preempt_enable(); } @@ -557,7 +557,7 @@ static void __init xen_set_p4d_hyper(p4d_t *ptr, p4d_t = val) =20 __xen_set_p4d_hyper(ptr, val); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 preempt_enable(); } @@ -589,7 +589,7 @@ static void xen_set_p4d(p4d_t *ptr, p4d_t val) if (user_ptr) __xen_set_p4d_hyper((p4d_t *)user_ptr, val); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } =20 __visible p4dval_t xen_p4d_val(p4d_t p4d) @@ -816,7 +816,7 @@ static void __xen_pgd_pin(struct mm_struct *mm, pgd_t *= pgd) PFN_DOWN(__pa(user_pgd))); } =20 - xen_mc_issue(0); + xen_mc_issue(true); } =20 static void xen_pgd_pin(struct mm_struct *mm) @@ -933,7 +933,7 @@ static void __xen_pgd_unpin(struct mm_struct *mm, pgd_t= *pgd) =20 __xen_pgd_walk(mm, pgd, xen_unpin_page, USER_LIMIT); =20 - xen_mc_issue(0); + xen_mc_issue(true); } =20 static void xen_pgd_unpin(struct mm_struct *mm) @@ -1309,7 +1309,7 @@ static noinline void xen_flush_tlb(void) op->cmd =3D MMUEXT_TLB_FLUSH_LOCAL; MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 preempt_enable(); } @@ -1329,7 +1329,7 @@ static void xen_flush_tlb_one_user(unsigned long addr) op->arg1.linear_addr =3D addr & PAGE_MASK; MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 preempt_enable(); } @@ -1366,7 +1366,7 @@ static void xen_flush_tlb_multi(const struct cpumask = *cpus, =20 MULTI_mmuext_op(mcs.mc, &args->op, 1, NULL, DOMID_SELF); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } =20 static unsigned long xen_read_cr3(void) @@ -1425,7 +1425,7 @@ static void xen_write_cr3(unsigned long cr3) else __xen_write_cr3(false, 0); =20 - xen_mc_issue(XEN_LAZY_CPU); /* interrupts restored */ + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); /* interrupts resto= red */ } =20 /* @@ -1460,7 +1460,7 @@ static void __init xen_write_cr3_init(unsigned long c= r3) =20 __xen_write_cr3(true, cr3); =20 - xen_mc_issue(XEN_LAZY_CPU); /* interrupts restored */ + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); /* interrupts resto= red */ } =20 static int xen_pgd_alloc(struct mm_struct *mm) @@ -1622,7 +1622,7 @@ static inline void xen_alloc_ptpage(struct mm_struct = *mm, unsigned long pfn, !pinned) __pin_pagetable_pfn(MMUEXT_PIN_L1_TABLE, pfn); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); } } =20 @@ -1652,7 +1652,7 @@ static inline void xen_release_ptpage(unsigned long p= fn, unsigned level) =20 __set_pfn_prot(pfn, PAGE_KERNEL); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 ClearPagePinned(page); } @@ -1875,7 +1875,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, un= signed long max_pfn) */ xen_mc_batch(); __xen_write_cr3(true, __pa(init_top_pgt)); - xen_mc_issue(XEN_LAZY_CPU); + xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); =20 /* We can't that easily rip out L3 and L2, as the Xen pagetables are * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ... for @@ -2266,7 +2266,7 @@ static void xen_zap_pfn_range(unsigned long vaddr, un= signed int order, if (out_frames) out_frames[i] =3D virt_to_pfn((void *)vaddr); } - xen_mc_issue(0); + xen_mc_issue(true); } =20 /* @@ -2309,7 +2309,7 @@ static void xen_remap_exchanged_ptes(unsigned long va= ddr, int order, set_phys_to_machine(virt_to_pfn((void *)vaddr), mfn); } =20 - xen_mc_issue(0); + xen_mc_issue(true); } =20 /* @@ -2450,7 +2450,7 @@ static noinline void xen_flush_tlb_all(void) op->cmd =3D MMUEXT_TLB_FLUSH_ALL; MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); =20 - xen_mc_issue(XEN_LAZY_MMU); + xen_mc_issue(!is_lazy_mmu_mode_active()); =20 preempt_enable(); } diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index dc892f421f25..dc265bdda24d 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -112,9 +112,8 @@ static inline struct multicall_space xen_mc_entry(size_= t args) void xen_mc_flush(void); =20 /* Issue a multicall if we're not in a lazy mode */ -static inline void xen_mc_issue(unsigned mode) +static inline void xen_mc_issue(bool flush) { - bool flush =3D !(xen_get_lazy_mode() & mode); unsigned long flags =3D this_cpu_read(xen_mc_irq_flags); =20 trace_xen_mc_issue(flush, flags); --=20 2.54.0 From nobody Mon Jun 8 20:41:41 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03AEA40313D for ; Tue, 26 May 2026 15:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779808101; cv=none; b=nLVKkpoN90oFEcSm8LSurtHKudcSGttB4Gn+9vFwknXTJMq07pAdDal/AC1rYyXLCteA30kcI4WNXiVgbsES52WyWv6UoI6KiVuM21WT1rwWATdelT8E2G9lWfmMnsS8BuE6lzKoQADH6Cg+i2Unox4tSmRTXINntBQhEZulC2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779808101; c=relaxed/simple; bh=53PZiTt1ypH5IV1xjQVE8DoB4HnWdFLwSvKd2HjA4bY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gx+gtRqr0jxEh4orA++Si5ghhQ7INQrLw9YLLJVQ+mEprsTW/ExV1esyQGwxfdyXjWV5YnBvH1CoIPyLg3WvREiTCBY4c6TKNPhAgFivqvAyidR/vDddSd1o+SUSU3BiKx4WpVJESOu9K3usE8/DVeq3cNPvXZ4J6Xs7VG197uM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=GhZkjoUn; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=GhZkjoUn; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="GhZkjoUn"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="GhZkjoUn" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4C4BD6B4EB; Tue, 26 May 2026 15:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808098; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8n0xmlv2MYEjHKFAD27nORLcuW4BlTygWfoqXW5DVk4=; b=GhZkjoUnVPRMpVt2BnzpVURKBQVRg/dwhbDOUD6xe1XaM4w/6t615Ymt7Ws/F5aUQn4UkE sO9yYtqrNh8W81Hz7SJkD1MVDK+vvTrymty6LjmeRW2VOTQu4NdxZgYBQoqm5gS31mEroL My6F9xEkZpqjLdOBh8p9FPoJIpY+nYU= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808098; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8n0xmlv2MYEjHKFAD27nORLcuW4BlTygWfoqXW5DVk4=; b=GhZkjoUnVPRMpVt2BnzpVURKBQVRg/dwhbDOUD6xe1XaM4w/6t615Ymt7Ws/F5aUQn4UkE sO9yYtqrNh8W81Hz7SJkD1MVDK+vvTrymty6LjmeRW2VOTQu4NdxZgYBQoqm5gS31mEroL My6F9xEkZpqjLdOBh8p9FPoJIpY+nYU= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 0B9C65A27D; Tue, 26 May 2026 15:08:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id okjDAWK3FWqhVQAAD6G6ig (envelope-from ); Tue, 26 May 2026 15:08:18 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Juergen Gross , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko Subject: [PATCH 3/5] mm: Refactor lazy_mmu_mode_pause() and lazy_mmu_mode_resume() Date: Tue, 26 May 2026 17:05:12 +0200 Message-ID: <20260526150514.129330-4-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150514.129330-1-jgross@suse.com> References: <20260526150514.129330-1-jgross@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spam-Score: -2.79 X-Spam-Flag: NO X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.19)[-0.968]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[11]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="utf-8" In order to allow pausing and resuming MMU lazy mode for other tasks than current, refactor lazy_mmu_mode_pause() and lazy_mmu_mode_resume(). This will be needed when dropping the Xen PV private lazy MMU bookkeeping. Signed-off-by: Juergen Gross Acked-by: David Hildenbrand (Arm) --- include/linux/pgtable.h | 56 +++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index cdd68ed3ae1a..07483ed9b3ce 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -300,6 +300,28 @@ static inline void lazy_mmu_mode_disable(void) =20 } =20 +/** + * __task_lazy_mmu_mode_pause() - Pause the lazy MMU mode for a task. + * @tsk: The task to check. + * + * Pauses the lazy MMU mode of @tsk. + * + * This function only operates on the state saved in task_struct; to pause + * current lazy_mmu_mode_pause() should be used instead. + * + * This function is intended for architectures that implement the lazy MMU + * mode; it must not be called from generic code. + */ +static inline void __task_lazy_mmu_mode_pause(struct task_struct *tsk) +{ + struct lazy_mmu_state *state =3D &tsk->lazy_mmu_state; + + VM_WARN_ON_ONCE(state->pause_count =3D=3D U8_MAX); + + if (state->pause_count++ =3D=3D 0 && state->enable_count > 0) + arch_leave_lazy_mmu_mode(); +} + /** * lazy_mmu_mode_pause() - Pause the lazy MMU mode. * @@ -315,15 +337,32 @@ static inline void lazy_mmu_mode_disable(void) */ static inline void lazy_mmu_mode_pause(void) { - struct lazy_mmu_state *state =3D ¤t->lazy_mmu_state; - if (in_interrupt()) return; =20 - VM_WARN_ON_ONCE(state->pause_count =3D=3D U8_MAX); + __task_lazy_mmu_mode_pause(current); +} =20 - if (state->pause_count++ =3D=3D 0 && state->enable_count > 0) - arch_leave_lazy_mmu_mode(); +/** + * __task_lazy_mmu_mode_resume() - Resume the lazy MMU mode for a task. + * @tsk: The task to check. + * + * Resumes the lazy MMU mode of @tsk. + * + * This function only operates on the state saved in task_struct; to resume + * current lazy_mmu_mode_resume() should be used instead. + * + * This function is intended for architectures that implement the lazy MMU + * mode; it must not be called from generic code. + */ +static inline void __task_lazy_mmu_mode_resume(struct task_struct *tsk) +{ + struct lazy_mmu_state *state =3D &tsk->lazy_mmu_state; + + VM_WARN_ON_ONCE(state->pause_count =3D=3D 0); + + if (--state->pause_count =3D=3D 0 && state->enable_count > 0) + arch_enter_lazy_mmu_mode(); } =20 /** @@ -341,15 +380,10 @@ static inline void lazy_mmu_mode_pause(void) */ static inline void lazy_mmu_mode_resume(void) { - struct lazy_mmu_state *state =3D ¤t->lazy_mmu_state; - if (in_interrupt()) return; =20 - VM_WARN_ON_ONCE(state->pause_count =3D=3D 0); - - if (--state->pause_count =3D=3D 0 && state->enable_count > 0) - arch_enter_lazy_mmu_mode(); + __task_lazy_mmu_mode_resume(current); } #else static inline void lazy_mmu_mode_enable(void) {} --=20 2.54.0 From nobody Mon Jun 8 20:41:41 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=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1779808118; cv=none; d=zohomail.com; s=zohoarc; b=V7TEUeNr7s7kum+oWaiaB04CKYk8JAamzD50RgdvtkiN+AUhywKDgXXnRYzwVJXAPKnJZKOoFjJDO0NLeS+/yMN7KdhVndXAKbUvZRMaqsSJdSk8UmbQhpXuRvLez5840PdZkk4btCPBV0xfgD7k5Z5WA7kZAH1bA30U/fYxb8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779808118; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yR9KBKqLhdL4TaLLpf7zLaGBy80B1vMaPGZJkdtW870=; b=RhwPLmSMveMPammR8j2wZdhaygghQPimf6P3lFySrvKnnng3F0LivSMSmk37Muhburc62SOIDUVQdfWkyM0esyk9Eq78tPNs0G34zvM+OpuocXsGkeCuu2DC/joGYCCWSN2IwBuwK2I9C4BIb2uPLyQlnWVU/5xWCc9zC9pExOg= 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 17798081183341003.1551595889002; Tue, 26 May 2026 08:08:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1320025.1587455 (Exim 4.92) (envelope-from ) id 1wRtOM-0007nW-4G; Tue, 26 May 2026 15:08:26 +0000 Received: by outflank-mailman (output) from mailman id 1320025.1587455; Tue, 26 May 2026 15:08:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtOM-0007nP-1I; Tue, 26 May 2026 15:08:26 +0000 Received: by outflank-mailman (input) for mailman id 1320025; Tue, 26 May 2026 15:08:25 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtOL-0007mH-0N for xen-devel@lists.xenproject.org; Tue, 26 May 2026 15:08:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRtOK-004DXQ-CE for xen-devel@lists.xenproject.org; Tue, 26 May 2026 17:08:24 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b757-bab6-0a2a0a5309dd-0a2a4501d09e-36 for ; Tue, 26 May 2026 17:08:24 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b768-c1f2-0a2a45010019-c387df83c00c-3 for ; Tue, 26 May 2026 17:08:24 +0200 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E471B75EA3; Tue, 26 May 2026 15:08:23 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 974155A27D; Tue, 26 May 2026 15:08:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id z97RI2e3FWqqVQAAD6G6ig (envelope-from ); Tue, 26 May 2026 15:08:23 +0000 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=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808104; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yR9KBKqLhdL4TaLLpf7zLaGBy80B1vMaPGZJkdtW870=; b=a88ZLq0n4eFHQXBU9atAHBhQVYJrMA0/zfysFwKMWr1VF6Y+YNozmaTK5hGfJlp6CfC/i+ MqyZwloTt6lGEbbZbLIV7Amrq7zm984jW+0H4Vm/rAdF4x8LhRpr0vOfg8YC69VC3ZXC3F 62E3QjH3pFj+396aoMqY1FFUTKKVz/M= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808103; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yR9KBKqLhdL4TaLLpf7zLaGBy80B1vMaPGZJkdtW870=; b=mOta7BZDekc5rViscFO2is8xDKTfVybUW8145uGk9BhyHejpNnUJ1v2hZewdHD4PiQrWGr HzQcYLHvZvJ6pSmW1zJLMLBcGjD5OhoSdrQYQBmVClmtpoXhJpvAfYw8K3jmdGGk4D6ilC WYdt36liqhak0Xz/9Oqc4Sj0N71bPQQ= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, virtualization@lists.linux.dev Cc: Juergen Gross , Ajay Kaher , Alexey Makhalov , Broadcom internal kernel review list , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Boris Ostrovsky , xen-devel@lists.xenproject.org Subject: [PATCH 4/5] x86/xen: Get rid of last XEN_LAZY_MMU uses Date: Tue, 26 May 2026 17:05:13 +0200 Message-ID: <20260526150514.129330-5-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150514.129330-1-jgross@suse.com> References: <20260526150514.129330-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.79 X-Spam-Level: X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.19)[-0.967]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[14]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FUZZY_RATELIMITED(0.00)[rspamd.com]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; R_RATELIMIT(0.00)[to_ip_from(RLfdszjqhz8kzzb9uwpzdm8png)]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCVD_TLS_ALL(0.00)[] X-purgate-ID: tlsNG-d62444/1779808104-ACE52FF4-CE30CEA7/0/0 X-purgate-type: clean X-purgate-size: 5953 X-ZohoMail-DKIM: pass (identity @suse.com) (identity @suse.com) X-ZM-MESSAGEID: 1779808119956158500 Content-Type: text/plain; charset="utf-8" There are only very few use cases of XEN_LAZY_MMU left. Get rid of them in order to avoid having to call enter_lazy(XEN_LAZY_MMU) and leave_lazy(XEN_LAZY_MMU). The query in xen_batched_set_pte() can be replaced by using is_lazy_mmu_mode_active() instead. As xen_flush_lazy_mmu() will be called only with lazy MMU mode being active, the test for the lazy mode can just be dropped. In xen_start_context_switch() and xen_end_context_switch() use __task_lazy_mmu_mode_pause() and __task_lazy_mmu_mode_resume(), allowing to drop xen_enter_lazy_mmu() and xen_leave_lazy_mmu() completely. Call arch_flush_lazy_mmu_mode() from arch_leave_lazy_mmu_mode(), as this is the only required action now. Drop the lazy mmu enter and leave paravirt hooks, leaving the flush hook as the only needed one. Signed-off-by: Juergen Gross --- arch/x86/include/asm/paravirt.h | 9 ++++----- arch/x86/include/asm/paravirt_types.h | 11 +---------- arch/x86/kernel/paravirt.c | 6 +----- arch/x86/xen/enlighten_pv.c | 7 ++----- arch/x86/xen/mmu_pv.c | 28 +++------------------------ 5 files changed, 11 insertions(+), 50 deletions(-) diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravir= t.h index cdfe4007443e..0591aa38fd85 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -483,17 +483,16 @@ static inline void arch_end_context_switch(struct tas= k_struct *next) =20 static inline void arch_enter_lazy_mmu_mode(void) { - PVOP_VCALL0(pv_ops, mmu.lazy_mode.enter); } =20 -static inline void arch_leave_lazy_mmu_mode(void) +static inline void arch_flush_lazy_mmu_mode(void) { - PVOP_VCALL0(pv_ops, mmu.lazy_mode.leave); + PVOP_VCALL0(pv_ops, mmu.lazy_mode_flush); } =20 -static inline void arch_flush_lazy_mmu_mode(void) +static inline void arch_leave_lazy_mmu_mode(void) { - PVOP_VCALL0(pv_ops, mmu.lazy_mode.flush); + arch_flush_lazy_mmu_mode(); } =20 static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx, diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/p= aravirt_types.h index 4f5ae0068aab..b4c4a23e77a1 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -19,15 +19,6 @@ struct cpumask; struct flush_tlb_info; struct vm_area_struct; =20 -#ifdef CONFIG_PARAVIRT_XXL -struct pv_lazy_ops { - /* Set deferred update mode, used for batching operations. */ - void (*enter)(void); - void (*leave)(void); - void (*flush)(void); -} __no_randomize_layout; -#endif - struct pv_cpu_ops { /* hooks for various privileged instructions */ #ifdef CONFIG_PARAVIRT_XXL @@ -171,7 +162,7 @@ struct pv_mmu_ops { =20 void (*set_pgd)(pgd_t *pgdp, pgd_t pgdval); =20 - struct pv_lazy_ops lazy_mode; + void (*lazy_mode_flush)(void); =20 /* dom0 ops */ =20 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 792fa96b3233..22f72034470f 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -204,11 +204,7 @@ struct paravirt_patch_template pv_ops =3D { =20 .mmu.enter_mmap =3D paravirt_nop, =20 - .mmu.lazy_mode =3D { - .enter =3D paravirt_nop, - .leave =3D paravirt_nop, - .flush =3D paravirt_nop, - }, + .mmu.lazy_mode_flush =3D paravirt_nop, =20 .mmu.set_fixmap =3D native_set_fixmap, #endif /* CONFIG_PARAVIRT_XXL */ diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 428189f5d437..8ee4910d597a 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -424,9 +424,7 @@ static void xen_start_context_switch(struct task_struct= *prev) { BUG_ON(preemptible()); =20 - if (this_cpu_read(xen_lazy_mode) =3D=3D XEN_LAZY_MMU) { - arch_leave_lazy_mmu_mode(); - } + __task_lazy_mmu_mode_pause(prev); enter_lazy(XEN_LAZY_CPU); } =20 @@ -436,8 +434,7 @@ static void xen_end_context_switch(struct task_struct *= next) =20 xen_mc_flush(); leave_lazy(XEN_LAZY_CPU); - if (__task_lazy_mmu_mode_active(next)) - arch_enter_lazy_mmu_mode(); + __task_lazy_mmu_mode_resume(next); } =20 static unsigned long xen_store_tr(void) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 51dbdc67c73c..928b4b0a4484 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -324,7 +324,7 @@ static bool xen_batched_set_pte(pte_t *ptep, pte_t ptev= al) { struct mmu_update u; =20 - if (xen_get_lazy_mode() !=3D XEN_LAZY_MMU) + if (!is_lazy_mmu_mode_active()) return false; =20 xen_mc_batch(); @@ -2151,21 +2151,10 @@ static void xen_set_fixmap(unsigned idx, phys_addr_= t phys, pgprot_t prot) #endif } =20 -static void xen_enter_lazy_mmu(void) -{ - preempt_disable(); - if (xen_get_lazy_mode() !=3D XEN_LAZY_MMU) - enter_lazy(XEN_LAZY_MMU); - preempt_enable(); -} - static void xen_flush_lazy_mmu(void) { preempt_disable(); - - if (xen_get_lazy_mode() =3D=3D XEN_LAZY_MMU) - xen_mc_flush(); - + xen_mc_flush(); preempt_enable(); } =20 @@ -2189,15 +2178,6 @@ static void __init xen_post_allocator_init(void) pv_ops.mmu.write_cr3 =3D &xen_write_cr3; } =20 -static void xen_leave_lazy_mmu(void) -{ - preempt_disable(); - xen_mc_flush(); - if (xen_get_lazy_mode() !=3D XEN_LAZY_NONE) - leave_lazy(XEN_LAZY_MMU); - preempt_enable(); -} - void __init xen_init_mmu_ops(void) { x86_init.paging.pagetable_init =3D xen_pagetable_init; @@ -2237,9 +2217,7 @@ void __init xen_init_mmu_ops(void) pv_ops.mmu.make_p4d =3D PV_CALLEE_SAVE(xen_make_p4d); pv_ops.mmu.enter_mmap =3D xen_enter_mmap; pv_ops.mmu.exit_mmap =3D xen_exit_mmap; - pv_ops.mmu.lazy_mode.enter =3D xen_enter_lazy_mmu; - pv_ops.mmu.lazy_mode.leave =3D xen_leave_lazy_mmu; - pv_ops.mmu.lazy_mode.flush =3D xen_flush_lazy_mmu; + pv_ops.mmu.lazy_mode_flush =3D xen_flush_lazy_mmu; pv_ops.mmu.set_fixmap =3D xen_set_fixmap; =20 memset(dummy_mapping, 0xff, PAGE_SIZE); --=20 2.54.0 From nobody Mon Jun 8 20:41:41 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=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1779808127; cv=none; d=zohomail.com; s=zohoarc; b=eaSy0FJGWLJsDaef86slRY384DKyQSBMFKvk3rn0Np5sECTA0UirFAq372sx1Tkty7PgdF6KS1uxYqp3y8F351+9h0p36TC2/OsqUwW3dxs7DX2FZYFT1HRWohDPdvYx5kwLMOWTUlqzEojUD2n1CfVidtR5kYdl5onSJs5rtHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779808127; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pt9GbUbcaD67j5AZ7mMspgj0EXB/Dgj0oV0yVnH+lpQ=; b=Cz1VroEEWrYDRoidKo7Ba20cXZyXxUC8dpomlKvDYiZTLFcvg0T1lT0wVg3022PbKks5ukhL7lfK1lBd84Cp4SRXAcb45LzoN/+xxokvCtthiOB+B+2YaXSzWo9A2sSm3it01NoAH3PNMYG3edUVDJwPaG6Mv8rGyn0ZD12UD2w= 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 1779808127678182.087553372132; Tue, 26 May 2026 08:08:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1320030.1587464 (Exim 4.92) (envelope-from ) id 1wRtOR-0008CW-Cl; Tue, 26 May 2026 15:08:31 +0000 Received: by outflank-mailman (output) from mailman id 1320030.1587464; Tue, 26 May 2026 15:08:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtOR-0008CP-9H; Tue, 26 May 2026 15:08:31 +0000 Received: by outflank-mailman (input) for mailman id 1320030; Tue, 26 May 2026 15:08:30 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wRtOQ-000883-HH for xen-devel@lists.xenproject.org; Tue, 26 May 2026 15:08:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wRtOP-004Daz-SX for xen-devel@lists.xenproject.org; Tue, 26 May 2026 17:08:29 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a15b76a-bab6-0a2a0a5309dd-0a2a450b967c-8 for ; Tue, 26 May 2026 17:08:29 +0200 Received: from [195.135.223.130] (helo=smtp-out1.suse.de) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a15b76d-212f-0a2a450b0019-c387df82af78-3 for ; Tue, 26 May 2026 17:08:29 +0200 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 76EF06B4EB; Tue, 26 May 2026 15:08:29 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3AF225A27D; Tue, 26 May 2026 15:08:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id k7hNDW23FWrFVQAAD6G6ig (envelope-from ); Tue, 26 May 2026 15:08:29 +0000 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=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pt9GbUbcaD67j5AZ7mMspgj0EXB/Dgj0oV0yVnH+lpQ=; b=Lv6+OtYc0uGqB6j7HELQQ0r2+99m0fxwA2+9PL5fCUZqn2aws3QbxX8kYNiGxCXKxZdHSa Vz5ppkYQAfprJooaY8qKaRVQ/qVbD7rLZf7Dta2MmPw7dhfrKCHbVq56GzzQtf2dHjSXG5 5ruzN89C6u4FfTYP848Hc6TIvu9lVDE= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=Lv6+OtYc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1779808109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pt9GbUbcaD67j5AZ7mMspgj0EXB/Dgj0oV0yVnH+lpQ=; b=Lv6+OtYc0uGqB6j7HELQQ0r2+99m0fxwA2+9PL5fCUZqn2aws3QbxX8kYNiGxCXKxZdHSa Vz5ppkYQAfprJooaY8qKaRVQ/qVbD7rLZf7Dta2MmPw7dhfrKCHbVq56GzzQtf2dHjSXG5 5ruzN89C6u4FfTYP848Hc6TIvu9lVDE= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH 5/5] x86/xen: Replace generic lazy tracking with cpu specific one Date: Tue, 26 May 2026 17:05:14 +0200 Message-ID: <20260526150514.129330-6-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526150514.129330-1-jgross@suse.com> References: <20260526150514.129330-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Action: no action X-Rspamd-Queue-Id: 76EF06B4EB X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; URIBL_BLOCKED(0.00)[suse.com:dkim,suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.com:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[10]; DWL_DNSWL_BLOCKED(0.00)[suse.com:dkim]; R_RATELIMIT(0.00)[to_ip_from(RLkdkdrsxe9hqhhs5ask8616i6)]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo] X-purgate-ID: tlsNG-42698a/1779808109-18D67F3B-3DFB2A6C/0/0 X-purgate-type: clean X-purgate-size: 5501 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1779808129935158500 Content-Type: text/plain; charset="utf-8" Now that lazy mmu state tracking no longer relies on the Xen specific one, cpu lazy mode is the only user of the Xen generic lazy tracking. Replace the Xen generic lazy tracking with a cpu lazy specific one. Signed-off-by: Juergen Gross --- arch/x86/include/asm/xen/hypervisor.h | 25 +------------------------ arch/x86/xen/enlighten_pv.c | 23 ++++++++++------------- arch/x86/xen/mmu_pv.c | 6 +++--- 3 files changed, 14 insertions(+), 40 deletions(-) diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/x= en/hypervisor.h index c2fc7869b996..f666637d773e 100644 --- a/arch/x86/include/asm/xen/hypervisor.h +++ b/arch/x86/include/asm/xen/hypervisor.h @@ -64,30 +64,7 @@ void __init xen_pvh_init(struct boot_params *boot_params= ); void __init mem_map_via_hcall(struct boot_params *boot_params_p); #endif =20 -/* Lazy mode for batching updates / context switch */ -enum xen_lazy_mode { - XEN_LAZY_NONE, - XEN_LAZY_MMU, - XEN_LAZY_CPU, -}; - -DECLARE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode); - -static inline void enter_lazy(enum xen_lazy_mode mode) -{ - BUG_ON(this_cpu_read(xen_lazy_mode) !=3D XEN_LAZY_NONE); - - this_cpu_write(xen_lazy_mode, mode); -} - -static inline void leave_lazy(enum xen_lazy_mode mode) -{ - BUG_ON(this_cpu_read(xen_lazy_mode) !=3D mode); - - this_cpu_write(xen_lazy_mode, XEN_LAZY_NONE); -} - -enum xen_lazy_mode xen_get_lazy_mode(void); +bool xen_is_cpu_lazy_mode(void); =20 #if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI) void xen_sanitize_proc_cap_bits(uint32_t *buf); diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 8ee4910d597a..b310b91f2994 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -138,14 +138,11 @@ struct tls_descs { struct desc_struct desc[3]; }; =20 -DEFINE_PER_CPU(enum xen_lazy_mode, xen_lazy_mode) =3D XEN_LAZY_NONE; +static DEFINE_PER_CPU(bool, xen_cpu_lazy_mode); =20 -enum xen_lazy_mode xen_get_lazy_mode(void) +bool xen_is_cpu_lazy_mode(void) { - if (in_interrupt()) - return XEN_LAZY_NONE; - - return this_cpu_read(xen_lazy_mode); + return !in_interrupt() && this_cpu_read(xen_cpu_lazy_mode); } =20 /* @@ -425,7 +422,7 @@ static void xen_start_context_switch(struct task_struct= *prev) BUG_ON(preemptible()); =20 __task_lazy_mmu_mode_pause(prev); - enter_lazy(XEN_LAZY_CPU); + this_cpu_write(xen_cpu_lazy_mode, true); } =20 static void xen_end_context_switch(struct task_struct *next) @@ -433,7 +430,7 @@ static void xen_end_context_switch(struct task_struct *= next) BUG_ON(preemptible()); =20 xen_mc_flush(); - leave_lazy(XEN_LAZY_CPU); + this_cpu_write(xen_cpu_lazy_mode, false); __task_lazy_mmu_mode_resume(next); } =20 @@ -541,7 +538,7 @@ static void xen_set_ldt(const void *addr, unsigned entr= ies) =20 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF); =20 - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); + xen_mc_issue(!xen_is_cpu_lazy_mode()); } =20 static void xen_load_gdt(const struct desc_ptr *dtr) @@ -637,7 +634,7 @@ static void xen_load_tls(struct thread_struct *t, unsig= ned int cpu) * exception between the new %fs descriptor being loaded and * %fs being effectively cleared at __switch_to(). */ - if (xen_get_lazy_mode() =3D=3D XEN_LAZY_CPU) + if (xen_is_cpu_lazy_mode()) loadsegment(fs, 0); =20 xen_mc_batch(); @@ -646,7 +643,7 @@ static void xen_load_tls(struct thread_struct *t, unsig= ned int cpu) load_TLS_descriptor(t, cpu, 1); load_TLS_descriptor(t, cpu, 2); =20 - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); + xen_mc_issue(!xen_is_cpu_lazy_mode()); } =20 static void xen_load_gs_index(unsigned int idx) @@ -1008,7 +1005,7 @@ static void xen_load_sp0(unsigned long sp0) =20 mcs =3D xen_mc_entry(0); MULTI_stack_switch(mcs.mc, __KERNEL_DS, sp0); - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); + xen_mc_issue(!xen_is_cpu_lazy_mode()); this_cpu_write(cpu_tss_rw.x86_tss.sp0, sp0); } =20 @@ -1068,7 +1065,7 @@ static void xen_write_cr0(unsigned long cr0) =20 MULTI_fpu_taskswitch(mcs.mc, (cr0 & X86_CR0_TS) !=3D 0); =20 - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); + xen_mc_issue(!xen_is_cpu_lazy_mode()); } =20 static void xen_write_cr4(unsigned long cr4) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index 928b4b0a4484..aab5f70d407c 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -1425,7 +1425,7 @@ static void xen_write_cr3(unsigned long cr3) else __xen_write_cr3(false, 0); =20 - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); /* interrupts resto= red */ + xen_mc_issue(!xen_is_cpu_lazy_mode()); /* interrupts restored */ } =20 /* @@ -1460,7 +1460,7 @@ static void __init xen_write_cr3_init(unsigned long c= r3) =20 __xen_write_cr3(true, cr3); =20 - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); /* interrupts resto= red */ + xen_mc_issue(!xen_is_cpu_lazy_mode()); /* interrupts restored */ } =20 static int xen_pgd_alloc(struct mm_struct *mm) @@ -1875,7 +1875,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, un= signed long max_pfn) */ xen_mc_batch(); __xen_write_cr3(true, __pa(init_top_pgt)); - xen_mc_issue(xen_get_lazy_mode() !=3D XEN_LAZY_CPU); + xen_mc_issue(!xen_is_cpu_lazy_mode()); =20 /* We can't that easily rip out L3 and L2, as the Xen pagetables are * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ... for --=20 2.54.0