9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] devproc: use the correct limit when warning that conf.nproc is too high
@ 2021-06-07  8:39 james palmer
  2021-06-08 23:59 ` [9front] " Anthony Martin
  0 siblings, 1 reply; 3+ messages in thread
From: james palmer @ 2021-06-07  8:39 UTC (permalink / raw)
  To: 9front

---
diff afe3c1c89a9ead7459691e9bf0d4e28f232bb929 9eb2b302e6240695960f5ce37c68e40a96da44d6
--- a/sys/src/9/port/devproc.c	Mon Jun  7 03:17:30 2021
+++ b/sys/src/9/port/devproc.c	Mon Jun  7 09:39:21 2021
@@ -281,7 +281,7 @@
 static void
 procinit(void)
 {
-	if(conf.nproc >= (1<<(16-QSHIFT))-1)
+	if(conf.nproc >= (1<<23)-1)
 		print("warning: too many procs for devproc\n");
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [9front] Re: [PATCH] devproc: use the correct limit when warning that conf.nproc is too high
  2021-06-07  8:39 [9front] [PATCH] devproc: use the correct limit when warning that conf.nproc is too high james palmer
@ 2021-06-08 23:59 ` Anthony Martin
  2021-06-09  2:22   ` ori
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Martin @ 2021-06-08 23:59 UTC (permalink / raw)
  To: 9front

james palmer <james@biobuf.link> 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<<QSHIFT)-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 */
  }
%


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] Re: [PATCH] devproc: use the correct limit when warning that conf.nproc is too high
  2021-06-08 23:59 ` [9front] " Anthony Martin
@ 2021-06-09  2:22   ` ori
  0 siblings, 0 replies; 3+ messages in thread
From: ori @ 2021-06-09  2:22 UTC (permalink / raw)
  To: 9front

Quoth Anthony Martin <ality@pbrane.org>:
> james palmer <james@biobuf.link> 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<<QSHIFT)-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 */
>   }
> %
> 

Yeah, that looks better. Thanks for digging it up;
applying it by hand.

As a side note, 'diff -u' or 'ape/diff -u' makes for a
patch that can be applied directly from email:

	ape/patch -p1 </mail/fs/mbox/51913/body


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-09 21:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  8:39 [9front] [PATCH] devproc: use the correct limit when warning that conf.nproc is too high james palmer
2021-06-08 23:59 ` [9front] " Anthony Martin
2021-06-09  2:22   ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).