smp: 64 processors, and say how many there are
NCPU was 16, under what a desktop has today. 64 costs 48 more TSS I/O bitmaps and scheduler stacks, about 800 KB of BSS. Past 254 the APIC would need x2APIC mode, which is a separate change. With more than 16 there were two other ceilings. sched_getaffinity wrote "CPU 0" and returned 0, and musl clears every byte past the count returned -- so the mask came back empty and nproc, make -j and sysconf(_SC_NPROCESSORS_ONLN) all said 1, on any machine. It returns the mask of processors that started, and its size, now. And /proc rendered every file into 2 KB, which /proc/cpuinfo ran out of at the eighteenth processor without a word; /proc/pci, /proc/interrupts and /proc/mounts were each one bigger machine from the same cut. There is one 64 KB buffer for it now behind a sleeplock, since there is no allocator for contiguous pages, and the generators that write raw are given the real capacity instead of a constant. Checked under QEMU with -smp 24: nproc 24, /proc/cpuinfo whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
parent
09e07423e8
commit
c1af31f75a
5 changed files with 69 additions and 36 deletions
|
|
@ -53,12 +53,6 @@
|
|||
// readable in a debugger, which matters more than density here.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Size of the scratch buffer every generator renders into. Must stay equal to
|
||||
// PROC_BUFSZ in kernel/dev/procfs.c: the SchFS and PCI generators there write
|
||||
// up to PROC_BUFSZ regardless of the cap they are handed, so a smaller value
|
||||
// here would be a buffer overrun rather than a truncation.
|
||||
#define PROCFS_GENBUF 2048
|
||||
|
||||
#define PROCFS_ROOT 1ULL
|
||||
#define PROCFS_GLOBAL 0x10000ULL
|
||||
|
||||
|
|
@ -378,15 +372,14 @@ procfs_read(struct inode *ip, int user_dst, uint64 dst, uint64 off, uint n)
|
|||
return r;
|
||||
}
|
||||
|
||||
// kmalloc, not kalloc: this buffer is PROCFS_GENBUF and kalloc's unit is a
|
||||
// whole 4 KB page. The comment above about a page not being wasteful was
|
||||
// written when a page was the only thing there was to ask for.
|
||||
if ((buf = kmalloc(PROCFS_GENBUF)) == 0)
|
||||
return -ENOMEM;
|
||||
|
||||
len = gen_file(ip->inum, buf, PROCFS_GENBUF);
|
||||
// The shared buffer in kernel/dev/procfs.c, 64 KB, held until the copy out
|
||||
// is done. It was 2 KB from kmalloc, which cut /proc/cpuinfo off at the
|
||||
// eighteenth processor.
|
||||
int cap;
|
||||
buf = proc_genbuf_get(&cap);
|
||||
len = gen_file(ip->inum, buf, cap);
|
||||
if (off >= (uint64)len) {
|
||||
kmfree(buf);
|
||||
proc_genbuf_put();
|
||||
return 0;
|
||||
}
|
||||
if (off + n > (uint64)len)
|
||||
|
|
@ -400,7 +393,7 @@ procfs_read(struct inode *ip, int user_dst, uint64 dst, uint64 off, uint n)
|
|||
memmove((char *)dst, buf + off, n);
|
||||
}
|
||||
|
||||
kmfree(buf);
|
||||
proc_genbuf_put();
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue