Page MenuHomeFreeBSD

Extend the CPU ID types in ULE, struct thread and struct kproc_user to be an int instead of a char.
ClosedPublic

Authored by kib on Oct 16 2014, 7:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 2, 2:54 AM
Unknown Object (File)
May 7 2024, 11:56 PM
Unknown Object (File)
May 6 2024, 7:55 PM
Unknown Object (File)
Mar 25 2024, 10:46 PM
Unknown Object (File)
Mar 10 2024, 1:25 AM
Unknown Object (File)
Mar 2 2024, 4:48 PM
Unknown Object (File)
Dec 26 2023, 12:06 PM
Unknown Object (File)
Dec 20 2023, 12:08 AM
Subscribers

Details

Reviewers
jhb
gnn
adrian
kib
Summary

The CPU ID fields in ULE, kproc_user and thread are all char's, which
limit the number of CPUs to 254.

So:

  • ule: char -> int;
  • thread: char -> int;
  • kproc: add new int fields; rename older fields to _old;
  • redefine NOCPU from 255 to -1
  • freebsd32: add new int fields; rename older fields to _old
  • freebsd32: add new int fields; rename older fields to _old.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

adrian retitled this revision from to Extend the CPU ID types in ULE, struct thread and struct kproc_user to be an int instead of a char..
adrian updated this object.
adrian edited the test plan for this revision. (Show Details)
sys/compat/freebsd32/freebsd32.h
347

This breaks ABI. Why did you put new fields into arbitrary place inside the structure ? It must consume the same spare ints as the struct kinfo_proc on 32bit arches.

sys/kern/kern_proc.c
991

This is weird. If CPU index is greater than 255, it is taken mod 256 for old fields.

I see two reasonable approaches to fill the ki_oncpu_old and ki_lastcpu_old. Either set old fields to 255 when CPU index is greater than 255, which means 'no cpu'.
Or (which, IMO, is much better) dedicate some currently unreacheable index, e.g.
254, to all CPUs >= 254. There will be a mis-reportning and bias for huge-cpu machines, but old binaries will be working somehow.

1013

You missed update to freebsd32_kinfo_proc_out().

sys/sys/proc.h
604โ€“605

This must be
#define NOCPU (-1)

sys/compat/freebsd32/freebsd32.h
347

How is it not the same as kinfo_proc?

sys/kern/kern_proc.c
1013

Fixed in my next patch.

sys/sys/proc.h
604โ€“605

Ok, fixed in the next patch.

Update patch with kib@'s comments.

Two small issues aside, I am fine with the change. Did you tested e.g. top or ps 32bit binaries on amd64 kernel ?

sys/kern/kern_proc.c
994

The 254 magic value ought its own define, IMO.

1187

This comment is not needed. The handling of NOCPU and wrapping in the native code should be enough.

kib edited reviewers, added: adrian; removed: kib.

r273266

This revision is now accepted and ready to land.Nov 16 2018, 7:17 AM