Author: shurd
Date: Sat Sep 23 01:39:16 2017
New Revision: 323944
URL: https://svnweb.freebsd.org/changeset/base/323944

Log:
  Make struct grouptask gt_name member a char array
  
  Previously, it was just a pointer which was copied, but
  some callers pass in a stack variable which will go out of scope.
  Add GROUPTASK_NAMELEN macro (32) and snprintf() the name into it,
  using "grouptask" if name is NULL. We can now safely include
  gtask->gt_name in console messages.
  
  Reviewed by:  sbruno
  Approved by:  sbruno (mentor)
  Sponsored by: Limelight Networks
  Differential Revision:        https://reviews.freebsd.org/D12449

Modified:
  head/sys/kern/subr_gtaskqueue.c
  head/sys/sys/_task.h

Modified: head/sys/kern/subr_gtaskqueue.c
==============================================================================
--- head/sys/kern/subr_gtaskqueue.c     Sat Sep 23 01:37:01 2017        
(r323943)
+++ head/sys/kern/subr_gtaskqueue.c     Sat Sep 23 01:39:16 2017        
(r323944)
@@ -666,7 +666,7 @@ taskqgroup_attach(struct taskqgroup *qgroup, struct gr
        int qid, error;
 
        gtask->gt_uniq = uniq;
-       gtask->gt_name = name;
+       snprintf(gtask->gt_name, GROUPTASK_NAMELEN, "%s", name ? name : 
"grouptask");
        gtask->gt_irq = irq;
        gtask->gt_cpu = -1;
        mtx_lock(&qgroup->tqg_lock);
@@ -703,7 +703,7 @@ taskqgroup_attach_deferred(struct taskqgroup *qgroup, 
                error = intr_setaffinity(gtask->gt_irq, CPU_WHICH_IRQ, &mask);
                mtx_lock(&qgroup->tqg_lock);
                if (error)
-                       printf("%s: setaffinity failed: %d\n", __func__, error);
+                       printf("%s: %s setaffinity failed: %d\n", __func__, 
gtask->gt_name, error);
 
        }
        qgroup->tqg_queue[qid].tgc_cnt++;
@@ -724,7 +724,7 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struc
 
        qid = -1;
        gtask->gt_uniq = uniq;
-       gtask->gt_name = name;
+       snprintf(gtask->gt_name, GROUPTASK_NAMELEN, "%s", name ? name : 
"grouptask");
        gtask->gt_irq = irq;
        gtask->gt_cpu = cpu;
        mtx_lock(&qgroup->tqg_lock);
@@ -736,7 +736,7 @@ taskqgroup_attach_cpu(struct taskqgroup *qgroup, struc
                        }
                if (qid == -1) {
                        mtx_unlock(&qgroup->tqg_lock);
-                       printf("%s: qid not found for %s cpu=%d\n", __func__, 
name, cpu);
+                       printf("%s: qid not found for %s cpu=%d\n", __func__, 
gtask->gt_name, cpu);
                        return (EINVAL);
                }
        } else
@@ -775,7 +775,7 @@ taskqgroup_attach_cpu_deferred(struct taskqgroup *qgro
                }
        if (qid == -1) {
                mtx_unlock(&qgroup->tqg_lock);
-               printf("%s: qid not found for cpu=%d\n", __func__, cpu);
+               printf("%s: qid not found for %s cpu=%d\n", __func__, 
gtask->gt_name, cpu);
                return (EINVAL);
        }
        qgroup->tqg_queue[qid].tgc_cnt++;
@@ -805,7 +805,7 @@ taskqgroup_detach(struct taskqgroup *qgroup, struct gr
                if (qgroup->tqg_queue[i].tgc_taskq == gtask->gt_taskqueue)
                        break;
        if (i == qgroup->tqg_cnt)
-               panic("taskqgroup_detach: task not in group\n");
+               panic("taskqgroup_detach: task %s not in group\n", 
gtask->gt_name);
        qgroup->tqg_queue[i].tgc_cnt--;
        LIST_REMOVE(gtask, gt_list);
        mtx_unlock(&qgroup->tqg_lock);

Modified: head/sys/sys/_task.h
==============================================================================
--- head/sys/sys/_task.h        Sat Sep 23 01:37:01 2017        (r323943)
+++ head/sys/sys/_task.h        Sat Sep 23 01:39:16 2017        (r323944)
@@ -65,7 +65,8 @@ struct grouptask {
        void                    *gt_taskqueue;
        LIST_ENTRY(grouptask)   gt_list;
        void                    *gt_uniq;
-       char                    *gt_name;
+#define GROUPTASK_NAMELEN      32
+       char                    gt_name[GROUPTASK_NAMELEN];
        int16_t                 gt_irq;
        int16_t                 gt_cpu;
 };
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to