tech-kern archive

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

Re: ci_want_resched bits vs. MD ci_data.cpu_softints bits



On 05/12/2022 01:52, Chuck Silvers wrote:
On Sat, Dec 03, 2022 at 03:40:13PM +0100, Martin Husemann wrote:
On Thu, Jul 07, 2022 at 09:22:42PM +0200, Martin Husemann wrote:
I guess in older times ci->ci_want_resched was used as a boolean flag, so only
0 or !0 did matter - but nowadays it is a flag word of various bits:

#define     RESCHED_REMOTE          0x01    /* request is for a remote CPU */
#define     RESCHED_IDLE            0x02    /* idle LWP observed */
#define     RESCHED_UPREEMPT        0x04    /* immediate user ctx switch */
#define     RESCHED_KPREEMPT        0x08    /* immediate kernel ctx switch */


The MD usage of ci_data.cpu_softints on powerpc is a bitmask of pending
softint IPLs, which could easily collide with above flags.

Even if this (currently) does not seem to cause issues, mixing bits from
different bitsets is wrong, so I'd like to commit the originaly proposed
fix (only ever clear all bits).

I agree this seems best.

I agree as well.



Additionaly I'd like to commit something like the second change below, fixing
an issue when creating new lwps (that neither should have ASTs pending nor
own the altivec psu). I am not sure if the PSL_VEC is the only bit that
should be cleared here.

the only bits in md_flags that can be set are PSL_VEC and PSL_SE,
but nothing ever looks at the PSL_SE bit in this field.
so you skip copying the whole l_md structure and just set both
md_flags and md_astpending to zero.  the code in process_machdep.c
that sets and clears PSL_SE in md_flags could also be removed.

l_md is already zeroed by the memset(&l2->l_startzero, 0, ... ) calls

https://nxr.netbsd.org/search?q=l_startzero&project=src&defs=&refs=&path=&hist=

I've taken to just asserts that md_astpending is zero.

Nick


Home | Main Index | Thread Index | Old Index