Skip to content

Commit 4868288

Browse files
authored
BF: CS-719 do full valgrind test on master branch (9.0.1) (#20)
// fixed issues in category cache
1 parent 8dfac00 commit 4868288

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

source/daemons/qmaster/sge_sched_job_category.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ sge_delete_job_category(lListElem *job) {
155155

156156
/* First part */
157157
auto *cat = static_cast<lListElem *>(lGetRef(job, JB_category));
158-
if (CATEGORY_LIST && cat) {
158+
if (CATEGORY_LIST != nullptr && cat != nullptr) {
159159
u_long32 rc = lGetUlong(cat, CT_refcount);
160160
if (rc > 1) {
161161
lSetUlong(cat, CT_refcount, --rc);
@@ -176,7 +176,6 @@ sge_delete_job_category(lListElem *job) {
176176
}
177177
lSetRef(job, JB_category, nullptr);
178178

179-
180179
DRETURN(0);
181180
}
182181

@@ -281,15 +280,15 @@ sge_category_count() {
281280
*******************************************************************************/
282281
int
283282
sge_reset_job_category() {
284-
lListElem *cat;
285283
DENTER(TOP_LAYER);
286284

285+
lListElem *cat;
287286
for_each_rw (cat, CATEGORY_LIST) {
288-
const lListElem *cache;
289-
290-
for_each_ep(cache, lGetList(cat, CT_cache)) {
287+
lListElem *cache;
288+
for_each_rw(cache, lGetList(cat, CT_cache)) {
291289
int *range = (int *) lGetRef(cache, CCT_pe_job_slots);
292290
sge_free(&range);
291+
lSetRef(cache, CCT_pe_job_slots, nullptr);
293292
}
294293

295294
lSetUlong(cat, CT_rejected, 0);

source/libs/cull/cull_multitype.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,13 +1462,13 @@ lRef lGetPosRef(const lListElem *ep, int pos) {
14621462

14631463
/****** cull/multitype/lGetRef() **********************************************
14641464
* NAME
1465-
* lGetRef() -- Returns the character for a field name
1465+
* lGetRef() -- Returns the reference for a field name
14661466
*
14671467
* SYNOPSIS
14681468
* lRef lGetRef(const lListElem *ep, int name)
14691469
*
14701470
* FUNCTION
1471-
* Returns the character for a field name
1471+
* Returns the reference for a field name
14721472
*
14731473
* INPUTS
14741474
* const lListElem *ep - element

source/libs/sched/sge_select_queue.cc

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,19 @@ enum {
100100
};
101101

102102
typedef struct {
103-
lListElem *category; /* ref to the category */
104-
lListElem *cache; /* ref to the cache object in th category */
105-
bool use_category; /* if true: use the category
106-
with immediate dispatch runs only and only if there is more than a single job of that category
107-
prevents 'skip_host_list' and 'skip_queue_list' be used with reservation */
108-
bool mod_category; /* if true: update the category with new messages, queues, and hosts */
109-
u_long32 *possible_pe_slots; /* stores all possible slots settings for a pe job with ranges */
110-
bool is_pe_slots_rev; /* if it is true, the possible_pe_slots are stored in the category */
103+
lListElem *category; /* ref to the category */
104+
lListElem *cache; /* ref to the cache object in the category */
105+
bool use_category; /* if true: use the category
106+
* with immediate dispatch runs only and only if there is more than a single job of that category
107+
* prevents 'skip_host_list' and 'skip_queue_list' be used with reservation
108+
*/
109+
bool mod_category; /* if true: update the category with new messages, queues, and hosts */
110+
u_long32 *possible_pe_slots; /* stores all possible slots settings for a pe job with ranges
111+
* it is stored in the job category cache, attribute CCT_pe_job_slots
112+
* and is *not* freed with the category_use_t object
113+
* (unless is_pe_slots_rev == false which means: it is not referenced in the cache)
114+
*/
115+
bool is_pe_slots_rev; /* if it is true, the possible_pe_slots are stored in the category */
111116
} category_use_t;
112117

113118
static void
@@ -882,7 +887,6 @@ parallel_reservation_max_time_slots(sge_assignment_t *best, int *available_slots
882887
static dispatch_t
883888
parallel_maximize_slots_pe(sge_assignment_t *best, int *available_slots)
884889
{
885-
886890
int min_slots, max_slots;
887891
int max_pe_slots;
888892
int first, last;
@@ -893,7 +897,7 @@ parallel_maximize_slots_pe(sge_assignment_t *best, int *available_slots)
893897
const char *pe_name = best->pe_name;
894898
bool is_first = true;
895899
int old_logging = 0;
896-
category_use_t use_category;
900+
category_use_t use_category{};
897901
u_long32 max_slotsp = 0;
898902
int current = 0;
899903
int match_current = 0;
@@ -953,6 +957,9 @@ parallel_maximize_slots_pe(sge_assignment_t *best, int *available_slots)
953957
}
954958
if (max_slotsp == 0) {
955959
DPRINTF("no slots in PE %s available for job " sge_u32"\n", pe_name, best->job_id);
960+
if (!use_category.is_pe_slots_rev) {
961+
sge_free(&(use_category.possible_pe_slots));
962+
}
956963
DRETURN(DISPATCH_NEVER_CAT);
957964
}
958965

@@ -3712,6 +3719,7 @@ add_pe_slots_to_category(category_use_t *use_category, u_long32 *max_slotsp, lLi
37123719
use_category->is_pe_slots_rev = true;
37133720
} else {
37143721
use_category->is_pe_slots_rev = false;
3722+
37153723
}
37163724
} else {
37173725
use_category->is_pe_slots_rev = true;
@@ -3749,15 +3757,18 @@ static void fill_category_use_t(const sge_assignment_t *a, category_use_t *use_c
37493757

37503758
use_category->category = (lListElem *)lGetRef(job, JB_category);
37513759
if (use_category->category != nullptr) {
3760+
// the category cache is stored in the job category object and contains an element per pe
37523761
use_category->cache = lGetElemStrRW(lGetList(use_category->category, CT_cache), CCT_pe_name, pe_name);
37533762
if (use_category->cache == nullptr) {
3763+
// there is no cache yet, create it
37543764
use_category->cache = lCreateElem(CCT_Type);
37553765

37563766
lSetString(use_category->cache, CCT_pe_name, pe_name);
37573767
lSetList(use_category->cache, CCT_ignore_queues, lCreateList(nullptr, CTI_Type));
37583768
lSetList(use_category->cache, CCT_ignore_hosts, lCreateList(nullptr, CTI_Type));
37593769
lSetList(use_category->cache, CCT_job_messages, lCreateList(nullptr, MES_Type));
37603770

3771+
// store the cache in the job category
37613772
if (lGetList(use_category->category, CT_cache) == nullptr) {
37623773
lSetList(use_category->category, CT_cache, lCreateList("pe_cache", CCT_Type));
37633774
}
@@ -3769,6 +3780,7 @@ static void fill_category_use_t(const sge_assignment_t *a, category_use_t *use_c
37693780
use_category->use_category = a->start == DISPATCH_TIME_NOW &&
37703781
lGetUlong(use_category->category, CT_refcount) > MIN_JOBS_IN_CATEGORY;
37713782
} else {
3783+
// we have a job without category (does this case exist at all?)
37723784
use_category->cache = nullptr;
37733785
use_category->mod_category = false;
37743786
use_category->use_category = false;

0 commit comments

Comments
 (0)