mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC][PATCH] Make MAX_RT_PRIO and MAX_USER_RT_PRIO configurable
@ 2005-07-27 14:13 Steven Rostedt
  2005-07-27 14:17 ` Ingo Molnar
  2005-07-28  1:00 ` Daniel Walker
  0 siblings, 2 replies; 54+ messages in thread
From: Steven Rostedt @ 2005-07-27 14:13 UTC (permalink / raw)
  To: LKML; +Cc: Linus Torvalds, Andrew Morton, Ingo Molnar

The following patch makes the MAX_RT_PRIO and MAX_USER_RT_PRIO
configurable from the make *config.  This is more of a proposal since
I'm not really sure where in Kconfig this would best fit. I don't see
why these options shouldn't be user configurable without going into the
kernel headers to change them.

Also, is there a way in the Kconfig to force the checking of
MAX_USER_RT_PRIO <= MAX_RT_PRIO?

-- Steve

(Patched against 2.6.12.2)

Index: vanilla_kernel/include/linux/sched.h
===================================================================
--- vanilla_kernel/include/linux/sched.h	(revision 263)
+++ vanilla_kernel/include/linux/sched.h	(working copy)
@@ -389,9 +389,13 @@
  * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
  */
 
-#define MAX_USER_RT_PRIO	100
-#define MAX_RT_PRIO		MAX_USER_RT_PRIO
+#define MAX_USER_RT_PRIO	CONFIG_MAX_USER_RT_PRIO
+#define MAX_RT_PRIO		CONFIG_MAX_RT_PRIO
 
+#if MAX_USER_RT_PRIO > MAX_RT_PRIO
+#error MAX_USER_RT_PRIO must not be greater than MAX_RT_PRIO
+#endif
+
 #define MAX_PRIO		(MAX_RT_PRIO + 40)
 
 #define rt_task(p)		(unlikely((p)->prio < MAX_RT_PRIO))
Index: vanilla_kernel/init/Kconfig
===================================================================
--- vanilla_kernel/init/Kconfig	(revision 263)
+++ vanilla_kernel/init/Kconfig	(working copy)
@@ -162,6 +162,32 @@
 	  building a kernel for install/rescue disks or your system is very
 	  limited in memory.
 
+config MAX_RT_PRIO
+	int "Maximum RT priority"
+	default 100
+	help
+	  The real-time priority of threads that have the policy of SCHED_FIFO
+	  or SCHED_RR have a priority higher than normal threads.  This range
+	  can be set here, where the range starts from 0 to MAX_RT_PRIO-1.
+	  If this range is higher than MAX_USER_RT_PRIO than kernel threads
+	  may have a higher priority than any user thread.
+
+	  This may be the same as MAX_USER_RT_PRIO, but do not set this 
+	  to be less than MAX_USER_RT_PRIO.
+
+config MAX_USER_RT_PRIO
+	int "Maximum User RT priority"
+	default 100
+	help
+	  The real-time priority of threads that have the policy of SCHED_FIFO
+	  or SCHED_RR have a priority higher than normal threads.  This range
+	  can be set here, where the range starts from 0 to MAX_USER_RT_PRIO-1.
+	  If this range is lower than MAX_RT_PRIO, than kernel threads may have
+	  a higher priority than any user thread.
+
+	  This may be the same as MAX_RT_PRIO, but do not set this to be
+	  greater than MAX_RT_PRIO.
+	  
 config AUDIT
 	bool "Auditing support"
 	default y if SECURITY_SELINUX



^ permalink raw reply	[flat|nested] 54+ messages in thread
* Re: [PATCH] speed up on find_first_bit for i386 (let compiler do the work)
@ 2005-07-29 14:37 linux
  2005-07-29 15:08 ` linux-os (Dick Johnson)
  0 siblings, 1 reply; 54+ messages in thread
From: linux @ 2005-07-29 14:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: rostedt

> OK, I guess when I get some time, I'll start testing all the i386 bitop
> functions, comparing the asm with the gcc versions.  Now could someone
> explain to me what's wrong with testing hot cache code. Can one
> instruction retrieve from memory better than others?

To add one to Linus' list, note that all current AMD & Intel chips
record instruction boundaries in L1 cache, either predecoding on
L1 cache load, or marking the boundaries on first execution.

The P4 takes it to an extreme, but P3 and K7/K8 do it too.

The result is that there are additional instruction decode limits
that apply to cold-cache code.

^ permalink raw reply	[flat|nested] 54+ messages in thread
* Re: [PATCH] speed up on find_first_bit for i386 (let compiler do the work)
@ 2005-07-31 16:33 Richard Kennedy
  0 siblings, 0 replies; 54+ messages in thread
From: Richard Kennedy @ 2005-07-31 16:33 UTC (permalink / raw)
  To: linux-kernel

Hi,
FWIW the following routine is consistently slightly faster using
Steven's test harness , with a big win when no bit set.

static inline int new_find_first_bit(const unsigned long *b, unsigned
size)
{
	int x = 0;
	do {
		unsigned long v = *b++;
	  	if (v)
			return __ffs(v) + x;
		if (x >= size)
			break;
		x += 32;
	} while (1);
	return x;
}

Tested on P III M 933MHz / gcc 4.0.1

clock speed = 00000000:17c56980 398813568 ticks per second

no bit set
ffb=320  my=320 new=320
generic ffb: 00000000:02fd6660
time: 0.125776182us
my ffb: 00000000:03c314e9
time: 0.158260714us
new ffb : 00000000:02d9190b
time: 0.119810758us

last bit set
ffb=319  my=319 new=319 
generic ffb: 00000000:04e5900c
time: 0.205994717us
my ffb: 00000000:0327475d
time: 0.132658024us
new ffb: 00000000:02c86938
time: 0.117068655us

middle bit set
ffb=159  my=159 new=159
generic ffb: 00000000:03c2bc56
time: 0.158203865us
my ffb: 00000000:01356b8b
time: 0.050846204us
new ffb: 00000000:0115f133
time: 0.045673521us

first bit set
ffb=0  my=0 new=0 
generic ffb: 00000000:02d07460
time: 0.118390436us
my ffb: 00000000:005d3079
time: 0.015313564us
new ffb: 00000000:005cca07
time: 0.015247804us

Cheers
Richard
Not subscribed please CC -- thanks.



^ permalink raw reply	[flat|nested] 54+ messages in thread
* Re: [PATCH] speed up on find_first_bit for i386 (let compiler do the work)
@ 2005-08-01  2:00 linux
  0 siblings, 0 replies; 54+ messages in thread
From: linux @ 2005-08-01  2:00 UTC (permalink / raw)
  To: richard; +Cc: linux-kernel

> static inline int new_find_first_bit(const unsigned long *b, unsigned size)
> {
> 	int x = 0;
> 	do {
> 		unsigned long v = *b++;
> 		if (v)
> 			return __ffs(v) + x;
> 		if (x >= size)
> 			break;
> 		x += 32;
> 	} while (1);
> 	return x;
> }

Wait a minute... suppose that size == 32 and the bitmap is one word of all
zeros.  Dynamic execution will overflow the buffer:

 	int x = 0;
 		unsigned long v = *b++;	/* Zero */

 		if (v)			/* False, v == 0 */
 		if (x >= size)		/* False, 0 < 32 */
 		x += 32;
 	} while (1);
 		unsigned long v = *b++;	/* Buffer overflow */
 		if (v)			/* Random value, suppose non-zero */
			return __ffs(v) + x;	/* >= 32 */

That should be:
static inline int new_find_first_bit(const unsigned long *b, unsigned size)
	int x = 0;
 	do {
 		unsigned long v = *b++;
 		if (v)
 			return __ffs(v) + x;
	} while ((x += 32) < size);
	return size;
}

Note that we assume that the trailing long is padded with zeros.

In truth, it should probably be either

static inline unsigned new_find_first_bit(u32 const *b, unsigned size)
	int x = 0;
 	do {
 		u32 v = *b++;
 		if (v)
 			return __ffs(v) + x;
	} while ((x += 32) < size);
	return size;
}

or

static inline unsigned
new_find_first_bit(unsigned long const *b, unsigned size)
	unsigned x = 0;
 	do {
 		unsigned long v = *b++;
 		if (v)
 			return __ffs(v) + x;
	} while ((x += CHAR_BIT * sizeof *b) < size);
	return size;
}

Do we actually store bitmaps on 64-bit machines with 32 significant bits
per ulong?

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

end of thread, other threads:[~2005-08-01  2:02 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-27 14:13 [RFC][PATCH] Make MAX_RT_PRIO and MAX_USER_RT_PRIO configurable Steven Rostedt
2005-07-27 14:17 ` Ingo Molnar
2005-07-27 14:26   ` Steven Rostedt
2005-07-27 14:33     ` Ingo Molnar
2005-07-27 14:47       ` [PATCH] safty check of MAX_RT_PRIO >= MAX_USER_RT_PRIO Steven Rostedt
2005-07-27 15:05         ` Steven Rostedt
2005-07-27 18:52         ` Ingo Molnar
2005-07-27 14:53       ` [RFC][PATCH] Make MAX_RT_PRIO and MAX_USER_RT_PRIO configurable Esben Nielsen
2005-07-27 15:02         ` Steven Rostedt
2005-07-27 16:09         ` K.R. Foley
2005-07-27 17:01           ` Esben Nielsen
2005-07-27 17:25             ` Steven Rostedt
2005-07-27 21:32               ` Esben Nielsen
2005-07-28 12:17                 ` Steven Rostedt
2005-07-28  7:22               ` Ingo Molnar
2005-07-28 11:53                 ` Steven Rostedt
2005-07-27 17:42             ` K.R. Foley
2005-07-28  9:59               ` Esben Nielsen
2005-07-27 14:28   ` Steven Rostedt
2005-07-27 14:38     ` Ingo Molnar
2005-07-27 14:46       ` Steven Rostedt
2005-07-28  7:33         ` Ingo Molnar
2005-07-28  1:42   ` Matt Mackall
2005-07-28  1:00 ` Daniel Walker
2005-07-28  1:20   ` Lee Revell
2005-07-28  1:26     ` Steven Rostedt
2005-07-28  1:25   ` Steven Rostedt
2005-07-28  3:06     ` Steven Rostedt
2005-07-28  3:32       ` Steven Rostedt
2005-07-28  3:45         ` Steven Rostedt
2005-07-28  3:51           ` Nick Piggin
2005-07-28 11:43             ` [PATCH] speed up on find_first_bit for i386 (let compiler do the work) Steven Rostedt
2005-07-28 12:45               ` Steven Rostedt
2005-07-28 15:31                 ` Linus Torvalds
2005-07-28 15:30               ` Linus Torvalds
2005-07-28 15:47                 ` Steven Rostedt
2005-07-28 16:34                   ` Maciej W. Rozycki
2005-07-28 16:57                     ` Steven Rostedt
2005-07-28 17:25                       ` Linus Torvalds
2005-07-29 10:03                         ` David Woodhouse
2005-07-29 14:41                           ` Maciej W. Rozycki
2005-07-29 16:23                           ` Linus Torvalds
2005-07-29 14:39                         ` Maciej W. Rozycki
2005-07-29 16:29                           ` Linus Torvalds
2005-07-29 17:14                             ` Maciej W. Rozycki
2005-07-28 17:17                     ` Linus Torvalds
2005-07-29 15:09                       ` Maciej W. Rozycki
2005-07-28 18:25                     ` Steven Rostedt
2005-07-28 18:56                       ` Linus Torvalds
2005-07-28 17:52               ` Mitchell Blank Jr
2005-07-29 14:37 linux
2005-07-29 15:08 ` linux-os (Dick Johnson)
2005-07-31 16:33 Richard Kennedy
2005-08-01  2:00 linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome