PKTGEN: Adds thread limit parameter.

2006-03-13 Thread Robert Olsson

Hello!

Really needed? 

If so -- Wouldn't a concept of a bitmask to control also which CPU's
that runs the threads be more general?

Cheers.
--ro


Luiz Fernando Capitulino writes:
  
  Currently, pktgen will create one thread for each online CPU in the
  system. That behaivor may be annoying if you're using pktgen in a
  large SMP system.
  
  This patch adds a new module parameter called 'pg_max_threads', which
  can be set to the maximum number of threads pktgen should create.
  
  For example, if you're playing with pktgen in SMP system with 8
  CPUs, but want only two pktgen's threads, you can do:
  
 modprobe pktgen pg_max_threads=2
  
  Signed-off-by: Luiz Capitulino [EMAIL PROTECTED]
  
  ---
  
   net/core/pktgen.c |   23 +--
   1 files changed, 17 insertions(+), 6 deletions(-)
  
  e210ad47d0db52496fdaabdd50bfe6ee0bcc53cd
  diff --git a/net/core/pktgen.c b/net/core/pktgen.c
  index 37b25a6..994aef1 100644
  --- a/net/core/pktgen.c
  +++ b/net/core/pktgen.c
  @@ -154,7 +154,7 @@
   #include asm/div64.h  /* do_div */
   #include asm/timex.h
   
  -#define VERSION  pktgen v2.66: Packet Generator for packet performance 
  testing.\n
  +#define VERSION  pktgen v2.67: Packet Generator for packet performance 
  testing.\n
   
   /* #define PG_DEBUG(a) a */
   #define PG_DEBUG(a)
  @@ -488,6 +488,7 @@ static unsigned int fmt_ip6(char *s, con
   static int pg_count_d = 1000;   /* 1000 pkts by default */
   static int pg_delay_d;
   static int pg_clone_skb_d;
  +static int pg_max_threads;
   static int debug;
   
   static DEFINE_MUTEX(pktgen_thread_lock);
  @@ -3184,7 +3185,7 @@ static int pktgen_remove_device(struct p
   
   static int __init pg_init(void)
   {
  -int cpu;
  +int i, threads;
   struct proc_dir_entry *pe;
   
   printk(version);
  @@ -3208,15 +3209,24 @@ static int __init pg_init(void)
   /* Register us to receive netdevice events */
   register_netdevice_notifier(pktgen_notifier_block);
   
  -for_each_online_cpu(cpu) {
  +threads = num_online_cpus();
  +
  +/*
  + * Check if we should have less threads than the number
  + * of online CPUs
  + */
  +if ((pg_max_threads  0)  (pg_max_threads  threads))
  +threads = pg_max_threads;
  +
  +for (i = 0; i  threads; i++) {
   int err;
   char buf[30];
   
  -sprintf(buf, kpktgend_%i, cpu);
  -err = pktgen_create_thread(buf, cpu);
  +sprintf(buf, kpktgend_%i, i);
  +err = pktgen_create_thread(buf, i);
   if (err)
   printk(pktgen: WARNING: Cannot create thread for cpu 
  %d (%d)\n,
  -cpu, err);
  +i, err);
   }
   
   if (list_empty(pktgen_threads)) {
  @@ -3263,4 +3273,5 @@ MODULE_LICENSE(GPL);
   module_param(pg_count_d, int, 0);
   module_param(pg_delay_d, int, 0);
   module_param(pg_clone_skb_d, int, 0);
  +module_param(pg_max_threads, int, 0);
   module_param(debug, int, 0);
  -- 
  1.2.4.gbe76
  
  
  
  -- 
  Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PKTGEN: Adds thread limit parameter.

2006-03-13 Thread Luiz Fernando Capitulino

 Hi Robert,

On Mon, 13 Mar 2006 10:44:49 +0100
Robert Olsson [EMAIL PROTECTED] wrote:

| 
| Hello!
| 
| Really needed? 

 Well, I wouldn't say it's _really_ needed. But it really avoids having
too many thread entries in the pktgen's /proc directory, and as a good
result, you will not have pending threads which will never run as well.

 Also note that the patch is trivial, if you look at it in detail,
you'll see that the biggest change we have is the 'if' part. The rest I
would call cosmetic because the behaivor is the same.

| If so -- Wouldn't a concept of a bitmask to control also which CPU's
| that runs the threads be more general?

 Sounds like a bit complex, and would be my turn to ask if it's
really needed. :)

 BTW Robert, my TODO list for pktgen so far is:

 * Some minor fixes and cleanups, like functions returns being not
 checked.

 * A new command called 'rem_device' to remove one device at a time
(currently, we can only remove all devices in one shoot with
'rem_devices_all')

 * Ports pktgen to use the kernel thread API

 * cleanup the debug function usage

 Would be good to hear from you if they really makes sense.

 Thank you for the feedback,

| Luiz Fernando Capitulino writes:
|   
|   Currently, pktgen will create one thread for each online CPU in the
|   system. That behaivor may be annoying if you're using pktgen in a
|   large SMP system.
|   
|   This patch adds a new module parameter called 'pg_max_threads', which
|   can be set to the maximum number of threads pktgen should create.
|   
|   For example, if you're playing with pktgen in SMP system with 8
|   CPUs, but want only two pktgen's threads, you can do:
|   
|  modprobe pktgen pg_max_threads=2
|   
|   Signed-off-by: Luiz Capitulino [EMAIL PROTECTED]
|   
|   ---
|   
|net/core/pktgen.c |   23 +--
|1 files changed, 17 insertions(+), 6 deletions(-)
|   
|   e210ad47d0db52496fdaabdd50bfe6ee0bcc53cd
|   diff --git a/net/core/pktgen.c b/net/core/pktgen.c
|   index 37b25a6..994aef1 100644
|   --- a/net/core/pktgen.c
|   +++ b/net/core/pktgen.c
|   @@ -154,7 +154,7 @@
|#include asm/div64.h/* do_div */
|#include asm/timex.h
|
|   -#define VERSION  pktgen v2.66: Packet Generator for packet performance 
testing.\n
|   +#define VERSION  pktgen v2.67: Packet Generator for packet performance 
testing.\n
|
|/* #define PG_DEBUG(a) a */
|#define PG_DEBUG(a)
|   @@ -488,6 +488,7 @@ static unsigned int fmt_ip6(char *s, con
|static int pg_count_d = 1000; /* 1000 pkts by default */
|static int pg_delay_d;
|static int pg_clone_skb_d;
|   +static int pg_max_threads;
|static int debug;
|
|static DEFINE_MUTEX(pktgen_thread_lock);
|   @@ -3184,7 +3185,7 @@ static int pktgen_remove_device(struct p
|
|static int __init pg_init(void)
|{
|   -  int cpu;
|   +  int i, threads;
|  struct proc_dir_entry *pe;
|
|  printk(version);
|   @@ -3208,15 +3209,24 @@ static int __init pg_init(void)
|  /* Register us to receive netdevice events */
|  register_netdevice_notifier(pktgen_notifier_block);
|
|   -  for_each_online_cpu(cpu) {
|   +  threads = num_online_cpus();
|   +
|   +  /*
|   +   * Check if we should have less threads than the number
|   +   * of online CPUs
|   +   */
|   +  if ((pg_max_threads  0)  (pg_max_threads  threads))
|   +  threads = pg_max_threads;
|   +
|   +  for (i = 0; i  threads; i++) {
|  int err;
|  char buf[30];
|
|   -  sprintf(buf, kpktgend_%i, cpu);
|   -  err = pktgen_create_thread(buf, cpu);
|   +  sprintf(buf, kpktgend_%i, i);
|   +  err = pktgen_create_thread(buf, i);
|  if (err)
|  printk(pktgen: WARNING: Cannot create thread for cpu 
%d (%d)\n,
|   -  cpu, err);
|   +  i, err);
|  }
|
|  if (list_empty(pktgen_threads)) {
|   @@ -3263,4 +3273,5 @@ MODULE_LICENSE(GPL);
|module_param(pg_count_d, int, 0);
|module_param(pg_delay_d, int, 0);
|module_param(pg_clone_skb_d, int, 0);
|   +module_param(pg_max_threads, int, 0);
|module_param(debug, int, 0);
|   -- 
|   1.2.4.gbe76
|   
|   
|   
|   -- 
|   Luiz Fernando N. Capitulino


-- 
Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PKTGEN: Adds thread limit parameter.

2006-03-13 Thread Robert Olsson

Luiz Fernando Capitulino writes:

   Well, I wouldn't say it's _really_ needed. But it really avoids having
  too many thread entries in the pktgen's /proc directory, and as a good
  result, you will not have pending threads which will never run as well.
  
   Also note that the patch is trivial, if you look at it in detail,
  you'll see that the biggest change we have is the 'if' part. The rest I
  would call cosmetic because the behaivor is the same.
  
  | If so -- Wouldn't a concept of a bitmask to control also which CPU's
  | that runs the threads be more general?
  
   Sounds like a bit complex, and would be my turn to ask if it's
  really needed. :)

 A bit set for each CPU there will a pktgen process running.
  
   * Some minor fixes and cleanups, like functions returns being not
   checked.
  
   * A new command called 'rem_device' to remove one device at a time
  (currently, we can only remove all devices in one shoot with
  'rem_devices_all')
  
   * Ports pktgen to use the kernel thread API

 The current model was chosen simplicity and to bound a device 
 to a specific CPU so it never cahanges. A change will need to 
 carefully tested.
 
   * cleanup the debug function usage
 
 I would like to remove the do_softirq stuff from pktgen... 

 Cheers.
--ro
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PKTGEN: Adds thread limit parameter.

2006-03-13 Thread Luiz Fernando Capitulino
On Mon, 13 Mar 2006 14:29:17 +0100
Robert Olsson [EMAIL PROTECTED] wrote:

| 
| Luiz Fernando Capitulino writes:
| 
|Well, I wouldn't say it's _really_ needed. But it really avoids having
|   too many thread entries in the pktgen's /proc directory, and as a good
|   result, you will not have pending threads which will never run as well.
|   
|Also note that the patch is trivial, if you look at it in detail,
|   you'll see that the biggest change we have is the 'if' part. The rest I
|   would call cosmetic because the behaivor is the same.
|   
|   | If so -- Wouldn't a concept of a bitmask to control also which CPU's
|   | that runs the threads be more general?
|   
|Sounds like a bit complex, and would be my turn to ask if it's
|   really needed. :)
| 
|  A bit set for each CPU there will a pktgen process running.

 Looks interesting. Could you give a few more details? Or an example
somewhere in the kernel (if any) for what you have in mind.

|* Some minor fixes and cleanups, like functions returns being not
|checked.
|   
|* A new command called 'rem_device' to remove one device at a time
|   (currently, we can only remove all devices in one shoot with
|   'rem_devices_all')
|   
|* Ports pktgen to use the kernel thread API
| 
|  The current model was chosen simplicity and to bound a device 
|  to a specific CPU so it never cahanges. A change will need to 
|  carefully tested.

 Sure thing.

|* cleanup the debug function usage
|  
|  I would like to remove the do_softirq stuff from pktgen... 

 Added to the TODO list. :)

-- 
Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: PKTGEN: Adds thread limit parameter.

2006-03-13 Thread akepner

On Mon, 13 Mar 2006, Luiz Fernando Capitulino wrote:



BTW Robert, my TODO list for pktgen so far is:


* A new command called 'rem_device' to remove one device at a time
(currently, we can only remove all devices in one shoot with
'rem_devices_all')



This should be very simple to implement - there's now a
T_REMDEV flag in addition to T_REMDEVALL, though no
rem_device method has been added. (T_REMDEV is currently
used only when a NETDEV_UNREGISTER notification is
received for the device.)

--
Arthur

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


PKTGEN: Adds thread limit parameter.

2006-03-12 Thread Luiz Fernando Capitulino

Currently, pktgen will create one thread for each online CPU in the
system. That behaivor may be annoying if you're using pktgen in a
large SMP system.

This patch adds a new module parameter called 'pg_max_threads', which
can be set to the maximum number of threads pktgen should create.

For example, if you're playing with pktgen in SMP system with 8
CPUs, but want only two pktgen's threads, you can do:

   modprobe pktgen pg_max_threads=2

Signed-off-by: Luiz Capitulino [EMAIL PROTECTED]

---

 net/core/pktgen.c |   23 +--
 1 files changed, 17 insertions(+), 6 deletions(-)

e210ad47d0db52496fdaabdd50bfe6ee0bcc53cd
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 37b25a6..994aef1 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -154,7 +154,7 @@
 #include asm/div64.h /* do_div */
 #include asm/timex.h
 
-#define VERSION  pktgen v2.66: Packet Generator for packet performance 
testing.\n
+#define VERSION  pktgen v2.67: Packet Generator for packet performance 
testing.\n
 
 /* #define PG_DEBUG(a) a */
 #define PG_DEBUG(a)
@@ -488,6 +488,7 @@ static unsigned int fmt_ip6(char *s, con
 static int pg_count_d = 1000;  /* 1000 pkts by default */
 static int pg_delay_d;
 static int pg_clone_skb_d;
+static int pg_max_threads;
 static int debug;
 
 static DEFINE_MUTEX(pktgen_thread_lock);
@@ -3184,7 +3185,7 @@ static int pktgen_remove_device(struct p
 
 static int __init pg_init(void)
 {
-   int cpu;
+   int i, threads;
struct proc_dir_entry *pe;
 
printk(version);
@@ -3208,15 +3209,24 @@ static int __init pg_init(void)
/* Register us to receive netdevice events */
register_netdevice_notifier(pktgen_notifier_block);
 
-   for_each_online_cpu(cpu) {
+   threads = num_online_cpus();
+
+   /*
+* Check if we should have less threads than the number
+* of online CPUs
+*/
+   if ((pg_max_threads  0)  (pg_max_threads  threads))
+   threads = pg_max_threads;
+
+   for (i = 0; i  threads; i++) {
int err;
char buf[30];
 
-   sprintf(buf, kpktgend_%i, cpu);
-   err = pktgen_create_thread(buf, cpu);
+   sprintf(buf, kpktgend_%i, i);
+   err = pktgen_create_thread(buf, i);
if (err)
printk(pktgen: WARNING: Cannot create thread for cpu 
%d (%d)\n,
-   cpu, err);
+   i, err);
}
 
if (list_empty(pktgen_threads)) {
@@ -3263,4 +3273,5 @@ MODULE_LICENSE(GPL);
 module_param(pg_count_d, int, 0);
 module_param(pg_delay_d, int, 0);
 module_param(pg_clone_skb_d, int, 0);
+module_param(pg_max_threads, int, 0);
 module_param(debug, int, 0);
-- 
1.2.4.gbe76



-- 
Luiz Fernando N. Capitulino
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html