From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15687 invoked from network); 9 Jun 2021 00:25:47 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 9 Jun 2021 00:25:47 -0000 Received: from MTA-06-3.privateemail.com ([198.54.127.59]) by 1ess; Tue Jun 8 19:59:10 -0400 2021 Received: from MTA-06.privateemail.com (localhost [127.0.0.1]) by MTA-06.privateemail.com (Postfix) with ESMTP id 7442A600F3 for <9front@9front.org>; Tue, 8 Jun 2021 19:59:05 -0400 (EDT) Received: from localhost (unknown [10.20.151.249]) by MTA-06.privateemail.com (Postfix) with ESMTPA id B034E6005F for <9front@9front.org>; Tue, 8 Jun 2021 19:59:04 -0400 (EDT) Date: Tue, 8 Jun 2021 16:59:02 -0700 From: Anthony Martin To: 9front@9front.org Message-ID: References: <87CC47A3BE3DD1D6C46A7DBCA339BB32@biobuf.link> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87CC47A3BE3DD1D6C46A7DBCA339BB32@biobuf.link> X-Virus-Scanned: ClamAV using ClamSMTP List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: base-scale storage component Subject: [9front] Re: [PATCH] devproc: use the correct limit when warning that conf.nproc is too high Reply-To: 9front@9front.org Precedence: bulk james palmer once said: > - if(conf.nproc >= (1<<(16-QSHIFT))-1) > + if(conf.nproc >= (1<<23)-1) This change could be better. Skip to the end for the patch or continue reading for a stroll down memory lane. The number of qid types in the proc(3) file system has slowly increased over time. The first edition originally had nine: Qdir, Qctl, Qmem, Qnote, Qnotepg, Qproc, Qsegment, Qstatus, and Qtext. The second edition added two: Qnoteid, and Qwait. The third edition added six: Qfd, Qfpregs, Qkregs, Qns, Qregs, and Qprofile. The fourth edition added three: Qargs in 2002, Qtrace in 2003, and Qsyscall in 2010. And 9front has added two more: Qppid in 2011, and Qwatchpt in 2017. The number surpassed 16 in 3ed so QSHIFT was incremented and the constants were adjusted but, unfortunately, the comment was not updated at that time. In May 2011, quanstro pointed this out on 9fans and it was corrected. The QID and SLOT macros were also changed to calculate the mask based on QSHIFT. The guard testing for too many procs in procinit was also fixed. This change happened shortly after the 9front fork happened so it was easily missed. Cheers, Anthony % cd /n/dump/2011 % diff -c (0526 0527)^/sys/src/9/port/devproc.c 0526/sys/src/9/port/devproc.c:132,139 - 0527/sys/src/9/port/devproc.c:132,139 /* * Qids are, in path: - * 4 bits of file type (qids above) - * 23 bits of process slot number + 1 + * 5 bits of file type (qids above) + * 26 bits of process slot number + 1 * in vers, * 32 bits of pid, for consistency checking * If notepg, c->pgrpid.path is pgrp slot, .vers is noteid. 0526/sys/src/9/port/devproc.c:140,147 - 0527/sys/src/9/port/devproc.c:140,147 */ #define QSHIFT 5 /* location in qid of proc slot # */ - #define QID(q) ((((ulong)(q).path)&0x0000001F)>>0) - #define SLOT(q) (((((ulong)(q).path)&0x07FFFFFE0)>>QSHIFT)-1) + #define QID(q) ((((ulong)(q).path) & ((1<> 0) + #define SLOT(q) (((((ulong)(q).path) & ~(1UL<<31)) >> QSHIFT) - 1) #define PID(q) ((q).vers) #define NOTEID(q) ((q).vers) 0526/sys/src/9/port/devproc.c:288,294 - 0527/sys/src/9/port/devproc.c:288,294 static void procinit(void) { - if(conf.nproc >= (1<<(16-QSHIFT))-1) + if(conf.nproc >= (1<<(31-QSHIFT))-1) print("warning: too many procs for devproc\n"); addclock0link((void (*)(void))profclock, 113); /* Relative prime to HZ */ } %