[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/8] xen/common: Split tlb-clock.h out of mm.h


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Thu, 13 Mar 2025 20:43:39 +0100
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1741895020; h=DKIM-Signature:MIME-Version:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=4Hg4rEQIz84i3eXNf89kUyROq9+jTMVjGNOvXEybiMw=; b=h4AURNqKFbgAY9fF+venZfbNaol+bRXICygNTOmIOnq4BTdItHBRXuHuWMzsmJiojhRR PIsjpsgo73I7blNtEuWyp4V7ha80gr2qheN3UhFoQkl2lLTRLoPSTugujl68/3mtpHag3 wUHfNuRO8fm6pQJNWcTVCJ5e7/Tjo2yu5TO/5X7jFNH62xDlCXem/XXVu46x2Zi4LGepd r8YOpWy/IriaVPeReN+Cx4DKBelFosWC39beOn46wnkbqb0Neg3DsYR27ldAfxITIr9OV epBzPC2z51wxTfVToYWbUrkfmhL2OaSJbDcx2QGQAVawmJJ8c2XgzfImbjzmVkAS9E4pW Yj1TXhMykcCFAfOD7fYGgBDX41StNLAAS708+r44XH92o1kuZJoy6qaCzu4kyh4uLNBa2 bO+iQZR/EYAuteoHNxL8XhhRABQgz298+DpEIKMupEU0diX12TdFXRRpytoXyRD7Xhs7E 1JA0A3PcDWYLuuGgdoa51Attn6ouMRjbfdqVsUj/m/q4Zn1N1Esa42k2pNhFkbPtiuRKH ik98LCCq7If7MVY5cMkj3DyntB/hZDdRCfC10fN7xlP2Kkp97CY35ALh7FB74D6UNy6+x TjNMlGVyqeI1DH3mG4F3RklLMtKohKQChiqZ4oCPeOIz8RWxFHVJewE9SNtl1Xc=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1741895020; b=X8wNtUEOpWyHeEkc3nDhYtyvLAlL9xlCOBqHVNJ1uBRJWFmtkEYRnBs8/DE8hrglQU4x sYxE2ly8XUD1eZ2gjqj6JyWZknZDXVJbP9IToStrbWAnaCIfrZU0AkckuqGigrHZB508b 03N0i3NHiHSjivMP3I8aPRKOSy9wcwe7Htd9lvyMvx2CCXXEFGeEOFFZIlOC8MSJcILLu wMyTSigwLEYQuZQV+b8twI+WeUwpCLXA/44u/sim7OiIWoSgUAj7jvpsUm2yVxbYKizlM IRiUiudybQe2C/6aBih4uyxI+NAF/KnqVDuOpHLpomv8PX22eblnJ33IUuyQvAdYlQXG6 nzXWRdXAgTxtdnrc5oDx5E9xPj4nNPtM+7v+4czwaK1TvDuz5nAnMrIX88anfhYk3ROQn bCpxqf0Cbqb/iu2tc2DduIeJPwUhNSimCmY5PAzdzxFxUfuK0QTn4tQgR7RdjbLYWMbaw lVboO9F8mpzhHx8vOGMz3TSYE7edL47Rqzm1GRhfI6GDzulJ0QGuirnZiCQH4uhGtD62T OItp1AQQ0Ch7E1wYypLIJFDXWxPVcXEYmJDauytI4niGiSklYhcgVA8eIYxUDsKTNcHA0 GZ/lIFjYE/y3c3SOiugFxGnpdw0712sozcQpHJiT84U1jcfyUoJQa6xS1Gdf6z4=
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 13 Mar 2025 19:43:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2025-03-13 14:35, Andrew Cooper wrote:
On 13/03/2025 12:59 pm, Jan Beulich wrote:
On 12.03.2025 18:45, Andrew Cooper wrote:
xen/mm.h includes asm/tlbflush.h almost at the end, which creates a horrible tangle. This is in order to provide two common files with an abstraction over
the x86-specific TLB clock logic.

First, introduce CONFIG_HAS_TLB_CLOCK, selected by x86 only. Next, introduce xen/tlb-clock.h, providing empty stubs, and include this into memory.c and
page_alloc.c

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
CC: Michal Orzel <michal.orzel@xxxxxxx>
CC: Jan Beulich <jbeulich@xxxxxxxx>
CC: Julien Grall <julien@xxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>
CC: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
CC: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>

There is still a mess here with the common vs x86 split, but it's better
contained than before.
---
 xen/arch/x86/Kconfig        |  1 +
 xen/common/Kconfig          |  3 +++
 xen/common/memory.c         |  1 +
 xen/common/page_alloc.c     |  1 +
 xen/include/xen/mm.h        | 27 --------------------
xen/include/xen/tlb-clock.h | 49 +++++++++++++++++++++++++++++++++++++
 6 files changed, 55 insertions(+), 27 deletions(-)
 create mode 100644 xen/include/xen/tlb-clock.h



However, see below.

+        arch_flush_tlb_mask(&mask);
+    }
+}
+
+#else /* !CONFIG_HAS_TLB_CLOCK */
+
+struct page_info;
+static inline void accumulate_tlbflush(
+    bool *need_tlbflush, const struct page_info *page,
+    uint32_t *tlbflush_timestamp) {}
+static inline void filtered_flush_tlb_mask(uint32_t tlbflush_timestamp) {}
Is doing nothing here correct?

Yeah, it's not, but this only occurred to me after sending the series.

Interestingly, CI is green across the board for ARM, which suggests to
me that this logic isn't getting a workout.

 mark_page_free() can set a page's
->u.free.need_tlbflush. And with that flag set the full

static inline void accumulate_tlbflush(
    bool *need_tlbflush, const struct page_info *page,
    uint32_t *tlbflush_timestamp)
{
    if ( page->u.free.need_tlbflush &&
         page->tlbflush_timestamp <= tlbflush_current_time() &&
         (!*need_tlbflush ||
          page->tlbflush_timestamp > *tlbflush_timestamp) )
    {
        *need_tlbflush = true;
        *tlbflush_timestamp = page->tlbflush_timestamp;
    }
}

reduces to (considering that tlbflush_current_time() resolves to constant 0,
which also implies every page's ->tlbflush_timestamp is only ever 0)

static inline void accumulate_tlbflush(
    bool *need_tlbflush, const struct page_info *page,
    uint32_t *tlbflush_timestamp)
{
    if ( !*need_tlbflush )
        *need_tlbflush = true;
}

which means a not-stubbed-out filtered_flush_tlb_mask(), with tlbflush_filter() doing nothing, would actually invoke arch_flush_tlb_mask() (with all online CPUs set in the mask) when called. And arch_flush_tlb_mask() isn't a no-op on Arm.

Yes.  Sadly, fixing this (without Eclair complaining in the middle of
the series) isn't as easy as I'd hoped.


Hi Andrew,

I didn't quite follow the whole thread (been busy the last couple of days), but could you explain briefly what's the issue here? Just a link to a failing pipeline should be fine as well.

I therefore think that while moving stuff into a separate header makes sense,
HAS_TLB_CLOCK isn't overly useful to introduce.

It takes a cpumask_t off the stack, because we can pass cpu_online_mask
straight into arch_flush_tlb_mask(), and it removes a bitmap_copy that
the compiler can't optimise out.

~Andrew

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.