~ubuntu-branches/ubuntu/precise/torque/precise-updates

« back to all changes in this revision

Viewing changes to src/resmom/irix6array/mom_mach.c

  • Committer: Bazaar Package Importer
  • Author(s): Dominique Belhachemi
  • Date: 2010-05-17 20:56:46 UTC
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100517205646-yjsoqs5r1s9xpnu9
Tags: upstream-2.4.8+dfsg
ImportĀ upstreamĀ versionĀ 2.4.8+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
#include "server_limits.h"
116
116
#include "attribute.h"
117
117
#include "resource.h"
118
 
#include "job.h"
 
118
#include "pbs_job.h"
119
119
#include "log.h"
120
120
#include "mom_mach.h"
121
121
#include "resmon.h"
142
142
**  quota  quota information (sizes in KB)
143
143
*/
144
144
 
145
 
static char ident[] = "@(#) sgi/$RCSfile$ $Revision: 2628 $";
 
145
static char ident[] = "@(#) sgi/$RCSfile$ $Revision: 3151 $";
146
146
 
147
147
#define SGI_ZOMBIE_WRONG 1
148
148
#define COMPLEX_MEM_CALC 0
187
187
extern char extra_parm[];
188
188
extern char no_parm[];
189
189
 
190
 
extern struct pbs_err_to_txt pbs_err_to_txt[];
191
190
extern time_t   time_now;
192
191
extern time_t   last_scan;
193
192
 
205
204
extern  long    system_ncpus;
206
205
extern char *loadave A_((struct rm_attribute *attrib));
207
206
extern  int     ignwalltime;
 
207
extern  int     igncput;
208
208
extern  int     ignvmem;
 
209
extern  int     ignmem;
209
210
 
210
211
/*
211
212
** local functions and data
358
359
 * decoded value of time in seconds in the unsigned long integer.
359
360
 */
360
361
 
361
 
static int getlong(pres, ret)
362
 
resource  *pres;
363
 
unsigned long *ret;
 
362
static int
 
363
getlong(resource *pres, unsigned long *ret)
364
364
  {
365
365
 
366
366
  if (pres->rs_value.at_type != ATR_TYPE_LONG)
403
403
 * Accepts a head of a task list.  Returns the sum of all cpu time
404
404
 * consumed for all tasks in the list, in seconds, adjusted by cputfactor.
405
405
 */
406
 
static unsigned long cput_sum(pjob)
407
 
job     *pjob;
 
406
static unsigned long
 
407
cput_sum(job *pjob)
408
408
  {
409
409
  char   *id = "cput_ses";
410
410
  int   i;
456
456
/*
457
457
 * Return TRUE if any process in the job is over limit for cputime usage.
458
458
 */
459
 
static int overcpu_proc(pjob, limit)
460
 
job   *pjob;
461
 
unsigned long limit;
 
459
static int
 
460
overcpu_proc(job *pjob, unsigned long limit)
462
461
  {
463
462
  ulong  cputime;
464
463
  int  i;
700
699
int
701
700
error(char *string, int value)
702
701
  {
703
 
  int  i = 0;
704
702
  char  *message;
705
703
 
706
704
  assert(string != NULL);
707
705
  assert(*string != '\0');
708
 
  assert(value > PBSE_);   /* minimum PBS error number */
709
 
  assert(value <= PBSE_NOSYNCMSTR); /* maximum PBS error number */
710
 
  assert(pbs_err_to_txt[i].err_no != 0);
711
 
 
712
 
  do
713
 
    {
714
 
    if (pbs_err_to_txt[i].err_no == value)
715
 
      break;
716
 
    }
717
 
  while (pbs_err_to_txt[++i].err_no != 0);
718
 
 
719
 
  assert(pbs_err_to_txt[i].err_txt != NULL);
720
 
 
721
 
  message = *pbs_err_to_txt[i].err_txt;
 
706
 
 
707
  message = pbse_to_txt(value);
722
708
 
723
709
  assert(message != NULL);
724
 
 
725
710
  assert(*message != '\0');
726
711
 
727
712
  (void)fprintf(stderr, msg_momsetlim, string, message);
752
737
 * existing limits.  Cannot alter those set by setrlimit (kernel)
753
738
 * because we are the wrong process.
754
739
 */
755
 
int mom_set_limits(pjob, set_mode)
756
 
job   *pjob;
757
 
int    set_mode; /* SET_LIMIT_SET or SET_LIMIT_ALTER */
 
740
int
 
741
mom_set_limits(
 
742
  job *pjob,
 
743
  int set_mode /* SET_LIMIT_SET or SET_LIMIT_ALTER */
 
744
)
758
745
  {
759
746
  char  *id = "mom_set_limits";
760
747
  char  *pname;
807
794
      }
808
795
    else if (strcmp(pname, "cput") == 0)   /* check */
809
796
      {
810
 
      /* cpu time - check, if less than pcput use it */
811
 
      retval = getlong(pres, &value);
 
797
      if (igncput == FALSE)
 
798
        {
 
799
        /* cpu time - check, if less than pcput use it */
 
800
        retval = getlong(pres, &value);
812
801
 
813
 
      if (retval != PBSE_NONE)
814
 
        return (error(pname, retval));
 
802
        if (retval != PBSE_NONE)
 
803
          return (error(pname, retval));
 
804
        }
815
805
      }
816
806
    else if (strcmp(pname, "pcput") == 0)
817
807
      {
818
 
      /* process cpu time - set */
819
 
      retval = getlong(pres, &value);
820
 
 
821
 
      if (retval != PBSE_NONE)
822
 
        return (error(pname, retval));
823
 
 
824
 
      res64lim.rlim_cur = res64lim.rlim_max =
825
 
                            (unsigned long)((double)value / cputfactor);
826
 
 
827
 
      if (setrlimit64(RLIMIT_CPU, &res64lim) < 0)
828
 
        return (error("RLIMIT_CPU", PBSE_SYSTEM));
 
808
      if (igncput == FALSE)
 
809
        {
 
810
        /* process cpu time - set */
 
811
        retval = getlong(pres, &value);
 
812
 
 
813
        if (retval != PBSE_NONE)
 
814
          return (error(pname, retval));
 
815
 
 
816
        res64lim.rlim_cur = res64lim.rlim_max =
 
817
          (unsigned long)((double)value / cputfactor);
 
818
 
 
819
        if (setrlimit64(RLIMIT_CPU, &res64lim) < 0)
 
820
          return (error("RLIMIT_CPU", PBSE_SYSTEM));
 
821
        }
829
822
      }
830
823
    else if (strcmp(pname, "file") == 0)   /* set */
831
824
      {
844
837
      }
845
838
    else if (strcmp(pname, "vmem") == 0)   /* check */
846
839
      {
847
 
      retval = getsize(pres, &sizeval);
848
 
 
849
 
      if (retval != PBSE_NONE)
850
 
        return (error(pname, retval));
851
 
 
852
 
      if ((mem_limit == 0) || (sizeval < mem_limit))
853
 
        mem_limit = sizeval;
 
840
      if (ignvmem == FALSE)
 
841
        {
 
842
        retval = getsize(pres, &sizeval);
 
843
 
 
844
        if (retval != PBSE_NONE)
 
845
          return (error(pname, retval));
 
846
 
 
847
        if ((mem_limit == 0) || (sizeval < mem_limit))
 
848
          mem_limit = sizeval;
 
849
        }
854
850
      }
855
851
    else if (strcmp(pname, "pvmem") == 0)   /* set */
856
852
      {
857
 
      retval = getsize(pres, &sizeval);
858
 
 
859
 
      if (retval != PBSE_NONE)
860
 
        return (error(pname, retval));
861
 
 
862
 
      if ((mem_limit == 0) || (sizeval < mem_limit))
863
 
        mem_limit = sizeval;
 
853
      if (ignvmem == FALSE)
 
854
        {
 
855
        retval = getsize(pres, &sizeval);
 
856
 
 
857
        if (retval != PBSE_NONE)
 
858
          return (error(pname, retval));
 
859
 
 
860
        if ((mem_limit == 0) || (sizeval < mem_limit))
 
861
          mem_limit = sizeval;
 
862
        }
864
863
      }
865
864
    else if (strcmp(pname, "mem") == 0)    /* ignore */
866
865
      {
867
866
      }
868
867
    else if (strcmp(pname, "pmem") == 0)   /* set */
869
868
      {
870
 
      if (set_mode == SET_LIMIT_SET)
 
869
      if (ignmem == FALSE)
871
870
        {
872
 
        retval = getsize(pres, &sizeval);
873
 
 
874
 
        if (retval != PBSE_NONE)
875
 
          return (error(pname, retval));
876
 
 
877
 
        res64lim.rlim_cur = res64lim.rlim_max = sizeval;
878
 
 
879
 
        if (setrlimit64(RLIMIT_RSS, &res64lim) < 0)
880
 
          return (error("RLIMIT_RSS", PBSE_SYSTEM));
 
871
        if (set_mode == SET_LIMIT_SET)
 
872
          {
 
873
          retval = getsize(pres, &sizeval);
 
874
 
 
875
          if (retval != PBSE_NONE)
 
876
            return (error(pname, retval));
 
877
 
 
878
          res64lim.rlim_cur = res64lim.rlim_max = sizeval;
 
879
  
 
880
          if (setrlimit64(RLIMIT_RSS, &res64lim) < 0)
 
881
            return (error("RLIMIT_RSS", PBSE_SYSTEM));
 
882
          }
881
883
        }
882
884
      }
883
885
    else if (strcmp(pname, "walltime") == 0)   /* Check */
945
947
 * polling is done using the mom_over_limit machine-dependent function.
946
948
 */
947
949
 
948
 
int mom_do_poll(pjob)
949
 
job   *pjob;
 
950
int
 
951
mom_do_poll(job *pjob)
950
952
  {
951
953
  char  *id = "mom_do_poll";
952
954
  char  *pname;
1175
1177
 * Otherwise, return FALSE.
1176
1178
 */
1177
1179
 
1178
 
int mom_over_limit(pjob)
1179
 
job   *pjob;
 
1180
int
 
1181
mom_over_limit(job *pjob)
1180
1182
  {
1181
1183
  char  *pname;
1182
1184
  int  retval;
1236
1238
#endif /* SGI_ZOMBIE_WRONG */
1237
1239
        }
1238
1240
      }
1239
 
    else if (strcmp(pname, "cput") == 0)
 
1241
    else if ((igncput == FALSE) && (strcmp(pname, "cput") == 0))
1240
1242
      {
1241
1243
      retval = getlong(pres, &value);
1242
1244
 
1251
1253
        return (TRUE);
1252
1254
        }
1253
1255
      }
1254
 
    else if (strcmp(pname, "pcput") == 0)
 
1256
    else if ((igncput == FALSE) && (strcmp(pname, "pcput") == 0))
1255
1257
      {
1256
1258
      retval = getlong(pres, &value);
1257
1259
 
1310
1312
        return (TRUE);
1311
1313
        }
1312
1314
      }
1313
 
    else if (strcmp(pname, "walltime") == 0)
 
1315
    else if (ignwalltime == 0 && strcmp(pname, "walltime") == 0)
1314
1316
      {
1315
1317
      if ((pjob->ji_qs.ji_svrflags & JOB_SVFLG_HERE) == 0)
1316
1318
        continue;
1327
1329
        sprintf(log_buffer,
1328
1330
                "walltime %lu exceeded limit %lu",
1329
1331
                num, value);
1330
 
 
1331
 
        if (ignwalltime == 0)
1332
 
          return (TRUE);
 
1332
        return (TRUE);
1333
1333
        }
1334
1334
      }
1335
1335
    }
1344
1344
 * each resource that can be reported for this machine.  Fill in the
1345
1345
 * correct values.  Return an error code.
1346
1346
 */
1347
 
int mom_set_use(pjob)
1348
 
job   *pjob;
 
1347
int
 
1348
mom_set_use(job *pjob)
1349
1349
  {
1350
1350
  resource  *pres;
1351
1351
  attribute  *at;
1460
1460
 * Kill a task session.
1461
1461
 * Call with the task pointer and a signal number.
1462
1462
 */
1463
 
int kill_task(ptask, sig, pg)
1464
 
task *ptask;
1465
 
int  sig;
1466
 
int         pg;
 
1463
int
 
1464
kill_task(task *ptask, int sig, int pg)
1467
1465
  {
1468
1466
  char  *id = "kill_task";
1469
1467
  ash_t  ash;
1548
1546
  }
1549
1547
 
1550
1548
/*
1551
 
 * mom_does_chkpnt - return 1 if mom supports checkpoint
1552
 
 *       0 if not
 
1549
 * mom_does_checkpoint
1553
1550
 */
1554
1551
 
1555
1552
int
1556
 
mom_does_chkpnt(void)
 
1553
mom_does_checkpoint(void)
1557
1554
  {
1558
1555
#if MOM_CHECKPOINT == 1
1559
 
  return (1);
 
1556
  return (CST_MACH_DEP);
1560
1557
#else /* MOM_CHECKPOINT */
1561
 
  return (0);
 
1558
  return (CST_NONE);
1562
1559
#endif /* MOM_CHECKPOINT */
1563
1560
  }
1564
1561
 
1568
1565
 * If abort is true, kill it too.
1569
1566
 */
1570
1567
 
1571
 
int mach_checkpoint(ptask, file, abort)
1572
 
task *ptask;
1573
 
char *file;
1574
 
int  abort;
 
1568
int
 
1569
mach_checkpoint(task *ptask, char *file, int abort)
1575
1570
  {
1576
1571
#if MOM_CHECKPOINT == 1
1577
1572
  ash_t ash;
1600
1595
 * Return -1 on error or sid if okay.
1601
1596
 */
1602
1597
 
1603
 
long mach_restart(ptask, file)
1604
 
task *ptask;
1605
 
char *file;
 
1598
long
 
1599
mach_restart(task *ptask, char *file)
1606
1600
  {
1607
1601
#if MOM_CHECKPOINT == 1
1608
1602
  ckpt_id_t rc;