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

Reply via email to