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

Re: [PATCH RFC v2 4/5] x86/mwait-idle: enable interrupts before C1 on Xeons


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 20 Jan 2022 16:52:36 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s3jSrd20QaJ/193lbLMJWETxQp/+Zk8sQ9uQ4SYfQE0=; b=MR/i+TesQ5dBi4Ug4a+udWZessPPFXj0hDzctyhA+i36nAFViMMdnoAvIDmh4HsTQAmixhj8vxWVWIBADF7HxNxscfbWVZTMYBR8EtAj8wto9AkxsxxNz0gzeFLvt/WOZ3rfg3z7+SnpH4/vAS2W7BfplmheEX1XSMze/NMU4V+rJnSy4G4KTh42e1MkVqywSX72rQZKEb+A5y11NSIM0Pnho/EhS1Z1hgjFrnlxJjNAC1wI/6LkseMqYw3YG+B3o/iny0k2G1kv6ZLUPwm+pjssfrIHeVhDWxFWeaGIot9hvSCtVhSVs65O5SXKYa7tZnrx/0xTzKs0Sy0EK7vrPw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kGBciDsipHoV2Z5c6z1QSjDc5f7J/b+VFDEP/L4hXTiuNiaUVhhDZLuUDPjRlAGaMxT8L73YZ0BGdjeaVHhFZ6uk9pICl2wFvY/3DRlw+P62XNqFbmXQRyNvPBs4/bRfLjZ3bGnzCUv6J0icpAt0jI+7OdquQZZRgIfHv1h6Xj2TVnDOFBXkr5RPSaUOUeoCBcggL68bY1TKvur5FJ4LO9yoTkf6iNnlOe49kfyQ/XGYOBI6Gg5+cO8hemsPHWZkHzvAPgiS4u2HnMov0lPiOL3B7KSG0frYx2ssqNqCJzp4WHv+1D8VHp58Y6IyOdd/LC63QVqu4XoG36901SgQ+w==
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 20 Jan 2022 15:52:49 +0000
  • Ironport-data: A9a23:Bc/pd6md3Syn31wNUdaR7Vro5gxpIURdPkR7XQ2eYbSJt1+Wr1Gzt xIaXm3VbKuJNjH2KIh1PNiyp0pU6pbTm9dqT1Bs/ytkFSMWpZLJC+rCIxarNUt+DCFioGGLT Sk6QoOdRCzhZiaE/n9BClVlxJVF/fngqoDUUYYoAQgsA180IMsdoUg7wbRh29Qw2YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 Npv6oSARBklBJTdwNwYdyVmFB1mZbITrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBNPsM44F/Glp0BnSDOo8QICFSKLPjTNd9Glq2pkRRKuED yYfQWpzagvCZAJiAEkWNrEgociCu3ikeBQN/Tp5ooJoujOOnWSdyoPFL979atGMA8JPkS6wt m/Aumj0HBweHNie0iaetGKhgPfVmiH2U55UE6e3ntZoilCOwm0YCDUNSEC25/K+jyaDt8l3c hJOvHB09O5rqRLtHoKVswCETGCssTxDQ+pdDeEA0RDV8q/w3zieOnBcUWsUADA5j/MeSTsv3 16PutrmAz1zrbGYIU6gGq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1XYJNu/xKDwOeOApP+tfKH LKjfA32QZINE5nJPiTNz0gZazuttfLnJXpbVovAAMm0hCHiXeN5KThGxaV8x8CW3cXqI1SvV Ttokjc3OGOovu7whjT2yv66IlXosLozp9mCNaXgsYYBz3wgkKDZZhnWZeFoDcpydvfpWoCoZ 3pmVMNLs5z43TeciWcpgbs4RDp1HIU53rr2Taj8DLeiP28YAh/J9tKhIpffBecwVEnpstA3K VC2H/cn4ZLDDvb9R6NpuTgZlVPrA6ZsHAimekcgzh0So0FcoJcqoQZ4Qd8DIoAJiTn84oqed MeQv003MwmMm9yUkqp/FWGmLeXLzEO91a9Mwc/U/WuonhrdCsT9Tpd+CQd9k1wgq7VBaM0oN gsCZ4Y5o2mePVmGp6VNN1xMvdfNVa9NC4kEFjiaWgPR5t3cE4klfbMkcEIDaeRCdo18Kc=
  • Ironport-sdr: Tk8E8bF4dx7aq4BA0y24akDcU8gekjG0Wytb7XJ/w8AOz7oQnOR4qCFKKnrZ2+KnmxSvwnKf3l nLTjbB4rPKTgEQET7I9OGBVHLx9ClkyNtNlH63c4NYrleK/es1YQW81krLyiLPAV5iVCn5yd5n twNP1nZKuIIHsuoOJuUU/UZsn940rizO0kaDkeVGJ7+jFHVf7DH7j42LsrUvneBgyAnk++uVNs fV2W6l4OQADjExZ4nqM+CTqAS3NB975kEYFWWhtZHpHxaL5+r0hxB5DkWFJIMolxJGpudalN58 d/QNBI9+A0sg4hZGQt0LRIyZ
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Jan 20, 2022 at 03:04:39PM +0100, Jan Beulich wrote:
> From: Artem Bityutskiy <artem.bityutskiy@xxxxxxxxxxxxxxx>
> 
> Enable local interrupts before requesting C1 on the last two generations
> of Intel Xeon platforms: Sky Lake, Cascade Lake, Cooper Lake, Ice Lake.
> This decreases average C1 interrupt latency by about 5-10%, as measured
> with the 'wult' tool.
> 
> The '->enter()' function of the driver enters C-states with local
> interrupts disabled by executing the 'monitor' and 'mwait' pair of
> instructions. If an interrupt happens, the CPU exits the C-state and
> continues executing instructions after 'mwait'. It does not jump to
> the interrupt handler, because local interrupts are disabled. The
> cpuidle subsystem enables interrupts a bit later, after doing some
> housekeeping.
> 
> With this patch, we enable local interrupts before requesting C1. In
> this case, if the CPU wakes up because of an interrupt, it will jump
> to the interrupt handler right away. The cpuidle housekeeping will be
> done after the pending interrupt(s) are handled.
> 
> Enabling interrupts before entering a C-state has measurable impact
> for faster C-states, like C1. Deeper, but slower C-states like C6 do
> not really benefit from this sort of change, because their latency is
> a lot higher comparing to the delay added by cpuidle housekeeping.
> 
> This change was also tested with cyclictest and dbench. In case of Ice
> Lake, the average cyclictest latency decreased by 5.1%, and the average
> 'dbench' throughput increased by about 0.8%. Both tests were run for 4
> hours with only C1 enabled (all other idle states, including 'POLL',
> were disabled). CPU frequency was pinned to HFM, and uncore frequency
> was pinned to the maximum value. The other platforms had similar
> single-digit percentage improvements.
> 
> It is worth noting that this patch affects 'cpuidle' statistics a tiny
> bit.  Before this patch, C1 residency did not include the interrupt
> handling time, but with this patch, it will include it. This is similar
> to what happens in case of the 'POLL' state, which also runs with
> interrupts enabled.
> 
> Suggested-by: Len Brown <len.brown@xxxxxxxxx>
> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@xxxxxxxxxxxxxxx>
> [Linux commit: c227233ad64c77e57db738ab0e46439db71822a3]
> 
> We don't have a pointer into cpuidle_state_table[] readily available.
> To compensate, make use of the new flag only appearing for C1 and hence
> only in the first table entry.

We could likely use the 8 padding bits in acpi_processor_cx between
entry_method and method to store a flags field?

It would seems more resilient, as I guess at some point we could
enable interrupts for further states?

> 
> Unlike Linux we want to disable IRQs again after MWAITing, as
> subsequently invoked functions assume so.

I'm also wondering whether there could be interrupts that rely on some
of the housekeeping that's done when returning from mwait. I guess
it's unlikely for an interrupt handler to have anything to do with the
TSC not having been restored.

> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

I think it's important to keep in sync with our upstream that's Linux
there.

Albeit I would prefer if we could carry the flags into acpi_processor_cx.

Thanks, Roger.



 


Rackspace

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