Ticket #1301: 0001-Added-execd_params-RLIMIT_VMEM-configuration-option.patch

File 0001-Added-execd_params-RLIMIT_VMEM-configuration-option.patch, 4.5 KB (added by markdixon, 3 years ago)
  • doc/man/man5/sge_conf.5

    From b295a7faaac4f8271ea83fc9c738d999f4a876cd Mon Sep 17 00:00:00 2001
    From: Mark Dixon <m.c.dixon@leeds.ac.uk>
    Date: Wed, 31 Aug 2016 12:02:35 +0100
    Subject: [PATCH] Added execd_params RLIMIT_VMEM configuration option
    
    Allows the administrator to disable setting of RLIMIT_VMEM / RLIMIT_AS
    process rlimit as a means of controlling memory usage. Useful when
    dealing with mmap'ed files etc.
    ---
     doc/man/man5/sge_conf.5              | 13 +++++++++++++
     source/daemons/execd/exec_job.c      |  3 +++
     source/daemons/shepherd/setrlimits.c | 15 +++++++++------
     source/libs/sgeobj/sge_conf.c        | 15 +++++++++++++++
     4 files changed, 40 insertions(+), 6 deletions(-)
    
    diff --git a/doc/man/man5/sge_conf.5 b/doc/man/man5/sge_conf.5
    index d001fe6..97c6cb3 100644
    a b default is no. Without 
    15841584.IR smaps ,
    15851585usage is reported as RSS+swap, instead of PSS+swap, or simply as the
    15861586VMsize if the swap value isn't available.
     1587.IP \fIRLIMIT_VMEM\fP
     1588Use
     1589.MO setrlimit 2
     1590to limit the amount of memory address space usable by
     1591each process in the job. Available on systems where
     1592.I RLIMIT_VMEM
     1593or
     1594.I RLIMIT_AS
     1595exists (
     1596.I RLIMIT_VMEM
     1597used preferentially). When a requested memory limit is exhausted, will
     1598tend to result in job termination during memory allocation (if true)
     1599or memory initialisation (if false).  Default is true.
    15871600.PP
    15881601.IP \fIprint_malloc_info\fP
    15891602See
  • source/daemons/execd/exec_job.c

    diff --git a/source/daemons/execd/exec_job.c b/source/daemons/execd/exec_job.c
    index 7fb37e2..7abdb8a 100644
    a b int sge_exec_job(sge_gdi_ctx_class_t *ctx, lListElem *jep, lListElem *jatep, 
    15941594   /* should the addgrp-id be used to kill processes */
    15951595   fprintf(fp, "enable_addgrp_kill=%d\n", (int)mconf_get_enable_addgrp_kill());
    15961596
     1597   /* should process RLIMIT_VMEM / RLIMIT_AS be set? */
     1598   fprintf(fp, "rlimit_vmem=%d\n", (int)mconf_get_rlimit_vmem());
     1599
    15971600   bootstrap_state = ctx->get_sge_bootstrap_state(ctx);
    15981601   if (strcasecmp(bootstrap_state->get_security_mode(bootstrap_state), "csp") == 0) {
    15991602      csp_mode = true;
  • source/daemons/shepherd/setrlimits.c

    diff --git a/source/daemons/shepherd/setrlimits.c b/source/daemons/shepherd/setrlimits.c
    index b3a7c7b..2fe57f4 100644
    a b void setrlimits(int trace_rlimit) { 
    402402   }
    403403#  endif
    404404
     405   if (get_conf_val("rlimit_vmem") == NULL ||
     406       strncmp(get_conf_val("rlimit_vmem"), "1", 1) == 0) {
    405407#  if defined(RLIMIT_VMEM)
    406    rlp.rlim_cur = s_vmem;
    407    rlp.rlim_max = h_vmem;
    408    pushlimit(RLIMIT_VMEM, &rlp, trace_rlimit);
     408      rlp.rlim_cur = s_vmem;
     409      rlp.rlim_max = h_vmem;
     410      pushlimit(RLIMIT_VMEM, &rlp, trace_rlimit);
    409411#  elif defined(RLIMIT_AS)
    410    rlp.rlim_cur = s_vmem;
    411    rlp.rlim_max = h_vmem;
    412    pushlimit(RLIMIT_AS, &rlp, trace_rlimit);
     412      rlp.rlim_cur = s_vmem;
     413      rlp.rlim_max = h_vmem;
     414      pushlimit(RLIMIT_AS, &rlp, trace_rlimit);
    413415#  endif
     416   }
    414417
    415418#  if defined(RLIMIT_RSS)
    416419   rlp.rlim_cur = s_rss;
  • source/libs/sgeobj/sge_conf.c

    diff --git a/source/libs/sgeobj/sge_conf.c b/source/libs/sgeobj/sge_conf.c
    index 090770f..5b96ff6 100644
    a b static char s_locks[100]; 
    202202static char h_locks[100];
    203203static bool use_cgroups = false;
    204204static bool use_smaps = false;
     205static bool rlimit_vmem = true;
    205206static bool demand_ls = true;
    206207
    207208/*
    int merge_configuration(lList **answer_list, u_long32 progid, const char *cell_r 
    890891      log_consumables = false;
    891892      use_cgroups = false;
    892893      use_smaps = false;
     894      rlimit_vmem = true;
    893895      strcpy(s_descriptors, "UNDEFINED");
    894896      strcpy(h_descriptors, "UNDEFINED");
    895897      strcpy(s_maxproc, "UNDEFINED");
    int merge_configuration(lList **answer_list, u_long32 progid, const char *cell_r 
    10471049         if (parse_bool_param(s, "USE_SMAPS", &use_smaps)) {
    10481050            continue;
    10491051         }
     1052         if (parse_bool_param(s, "RLIMIT_VMEM", &rlimit_vmem)) {
     1053            continue;
     1054         }
    10501055#if HAVE_JEMALLOC
    10511056         if (parse_bool_param(s, "print_malloc_info", &malloc_info)) {
    10521057            continue;
    bool mconf_get_use_smaps(void) { 
    26862691   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
    26872692   DRETURN(ret);
    26882693}
     2694
     2695bool mconf_get_rlimit_vmem(void) {
     2696   bool ret;
     2697
     2698   DENTER(BASIS_LAYER, "mconf_get_rlimit_vmem");
     2699   SGE_LOCK(LOCK_MASTER_CONF, LOCK_READ);
     2700   ret = rlimit_vmem;
     2701   SGE_UNLOCK(LOCK_MASTER_CONF, LOCK_READ);
     2702   DRETURN(ret);
     2703}