Whamcloud - gitweb
LU-7195 jobstats: Allow setting static content for jobid_var 98/16598/7
authorOleg Drokin <oleg.drokin@intel.com>
Mon, 12 Oct 2015 15:33:34 +0000 (11:33 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 24 Oct 2015 00:35:23 +0000 (00:35 +0000)
When enabling jobstats a ten percent performance was observed
when running any job. This was due to the expense of the kernel
acquiring the process environment state. Create a alternative
way to setting jobid_var besides meddling directly in process
environment variables (which is also not possible on certain
platforms due to not exported  symbols), create jobid_name
proc file to represent this info (to be filled by job scheduler
epilogue). Is this based on the upstream commit

Linux-commit : 76133e66b1417a73c0950d0716219d09ee21d595

except it doesn't remove the process environment probing to
allow backwards compatiblity. This patch doesn't notify the
admins that using old jobstat proc method has a heavy cost.

Change-Id: If81733e549222a7ab31b24673f0e9b8401541130
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
CC: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-on: http://review.whamcloud.com/16598
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
lustre/include/lprocfs_status.h
lustre/include/obd_class.h
lustre/obdclass/class_obd.c
lustre/obdclass/linux/linux-module.c
lustre/tests/sanity.sh [changed mode: 0644->0755]

index 93da0d0..4b41c5b 100644 (file)
@@ -382,6 +382,7 @@ static inline void s2dhms(struct dhms *ts, time_t secs)
 #define JOBSTATS_JOBID_VAR_MAX_LEN     20
 #define JOBSTATS_DISABLE               "disable"
 #define JOBSTATS_PROCNAME_UID          "procname_uid"
+#define JOBSTATS_NODELOCAL             "nodelocal"
 
 typedef void (*cntr_init_callback)(struct lprocfs_stats *stats);
 
index cd7198d..ad80485 100644 (file)
@@ -1716,6 +1716,9 @@ int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
 void class_init_uuidlist(void);
 void class_exit_uuidlist(void);
 
+/* class_obd.c */
+extern char obd_jobid_node[];
+
 /* prng.c */
 #define ll_generate_random_uuid(uuid_out) cfs_get_random_bytes(uuid_out, sizeof(class_uuid_t))
 
index 3f857fd..09298ef 100644 (file)
@@ -113,6 +113,8 @@ struct lprocfs_stats *obd_memory = NULL;
 EXPORT_SYMBOL(obd_memory);
 #endif
 
+char obd_jobid_node[LUSTRE_JOBID_SIZE + 1];
+
 /* Get jobid of current process by reading the environment variable
  * stored in between the "env_start" & "env_end" of task struct.
  *
@@ -136,6 +138,12 @@ int lustre_get_jobid(char *jobid)
        if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0)
                RETURN(0);
 
+       /* Whole node dedicated to single job */
+       if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) {
+               memcpy(jobid, obd_jobid_node, LUSTRE_JOBID_SIZE);
+               RETURN(0);
+       }
+
        /* Use process name + fsuid as jobid */
        if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
                snprintf(jobid, LUSTRE_JOBID_SIZE, "%s.%u",
index 93dd759..200d19f 100644 (file)
@@ -284,7 +284,9 @@ LPROC_SEQ_FOPS_RO(obd_proc_health);
 
 static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
 {
-       return seq_printf(m, "%s\n", obd_jobid_var);
+       if (strlen(obd_jobid_var) != 0)
+               seq_printf(m, "%s\n", obd_jobid_var);
+       return 0;
 }
 
 static ssize_t
@@ -308,6 +310,38 @@ obd_proc_jobid_var_seq_write(struct file *file, const char __user *buffer,
 }
 LPROC_SEQ_FOPS(obd_proc_jobid_var);
 
+static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v)
+{
+       if (strlen(obd_jobid_node) != 0)
+               seq_printf(m, "%s\n", obd_jobid_node);
+       return 0;
+}
+
+static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
+                                            const char __user *buffer,
+                                            size_t count, loff_t *off)
+{
+       if (count == 0 || count > LUSTRE_JOBID_SIZE)
+               return -EINVAL;
+
+       /* clear previous value */
+       memset(obd_jobid_node, 0, LUSTRE_JOBID_SIZE);
+
+       if (copy_from_user(obd_jobid_node, buffer, count))
+               return -EFAULT;
+
+       /* Trim the trailing '\n' if any */
+       if (obd_jobid_node[count - 1] == '\n') {
+               /* Don't echo just a newline */
+               if (count == 1)
+                       return -EINVAL;
+               obd_jobid_node[count - 1] = 0;
+       }
+
+       return count;
+}
+LPROC_SEQ_FOPS(obd_proc_jobid_name);
+
 /* Root for /proc/fs/lustre */
 struct proc_dir_entry *proc_lustre_root = NULL;
 EXPORT_SYMBOL(proc_lustre_root);
@@ -321,6 +355,8 @@ static struct lprocfs_vars lprocfs_base[] = {
          .fops =       &obd_proc_health_fops   },
        { .name =       "jobid_var",
          .fops =       &obd_proc_jobid_var_fops},
+       { .name =       "jobid_name",
+         .fops =       &obd_proc_jobid_name_fops},
        { NULL }
 };
 #else
old mode 100644 (file)
new mode 100755 (executable)
index 6a4ed0e..60da933
@@ -11654,7 +11654,12 @@ elif [ -n "$LOADL_STEPID" ]; then # LoadLeveller
 elif [ -n "$JOB_ID" ]; then # Sun Grid Engine
        JOBENV=JOB_ID
 else
-       JOBENV=FAKE_JOBID
+       $LCTL list_param jobid_name > /dev/null 2>&1
+       if [ $? -eq 0 ]; then
+               JOBENV=nodelocal
+       else
+               JOBENV=FAKE_JOBID
+       fi
 fi
 
 verify_jobstats() {
@@ -11675,6 +11680,13 @@ verify_jobstats() {
                FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
 
        JOBVAL=${!JOBENV}
+
+       [ "$JOBENV" = "nodelocal" ] && {
+               FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
+               $LCTL set_param jobid_name=$FAKE_JOBID
+               JOBVAL=$FAKE_JOBID
+       }
+
        log "Test: ${cmd[*]}"
        log "Using JobID environment variable $JOBENV=$JOBVAL"