Re: [PATCH 12/24] s390/preempt: Enable HAS_SEPARATE_PREEMPT_RESCHED_BITS

From: Heiko Carstens

Date: Mon Aug 03 2026 - 08:52:53 EST


On Mon, Aug 03, 2026 at 01:40:32PM +0200, Peter Zijlstra wrote:
> On Fri, Jul 31, 2026 at 01:30:13PM -0700, Boqun Feng wrote:
>
> > @@ -26,25 +23,25 @@
> > */
> > static __always_inline int preempt_count(void)
> > {
> > - unsigned long lc_preempt, count;
> > + unsigned long lc_preempt;
> > + int count;
> >
> > - BUILD_BUG_ON(sizeof_field(struct lowcore, preempt_count) != sizeof(int));
> > - lc_preempt = offsetof(struct lowcore, preempt_count);
> > + lc_preempt = offsetof(struct lowcore, preempt.count);
> > /* READ_ONCE(get_lowcore()->preempt_count) & ~PREEMPT_NEED_RESCHED */
>
> If I'm not mistaken, this comment is no longer accurate, since
> NEED_RESCHED lives in the high word and you're only loading the low
> word.

True. Something like

/* READ_ONCE(get_lowcore()->preempt.count) (without PREEMPT_NEED_RESCHED) */

might be better.

> > asm_inline(
> > - ALTERNATIVE("llgt %[count],%[offzero](%%r0)\n",
> > - "llgt %[count],%[offalt](%%r0)\n",
> > + ALTERNATIVE("ly %[count],%[offzero](%%r0)\n",
> > + "ly %[count],%[offalt](%%r0)\n",
> > ALT_FEATURE(MFEATURE_LOWCORE))
> > : [count] "=d" (count)
> > : [offzero] "i" (lc_preempt),
> > [offalt] "i" (lc_preempt + LOWCORE_ALT_ADDRESS),
> > - "m" (((struct lowcore *)0)->preempt_count));
> > + "m" (((struct lowcore *)0)->preempt.count));
> > return count;
> > }