redmine

[hllock] Decreased non-priv cpu utilization

@@ -215,7 +215,7 @@ expire-after:20M\n\ @@ -215,7 +215,7 @@ expire-after:20M\n\
215 // Upper limit 215 // Upper limit
216 #define HL_LOCK_AUTO_LIMIT_HIGH (1<<20) 216 #define HL_LOCK_AUTO_LIMIT_HIGH (1<<20)
217 217
218 -#define HL_LOCK_NONPRIV_TRIES (HL_LOCK_AUTO_LIMIT_HIGH << 6) 218 +#define HL_LOCK_NONPRIV_TRIES (HL_LOCK_AUTO_LIMIT_HIGH << 8)
219 219
220 //#define READWRITE_SIGNALLING 220 //#define READWRITE_SIGNALLING
221 221
@@ -330,6 +330,7 @@ struct cmd_ret { @@ -330,6 +330,7 @@ struct cmd_ret {
330 volatile struct pa_ret ret_buf; 330 volatile struct pa_ret ret_buf;
331 volatile void *ret; 331 volatile void *ret;
332 volatile int _errno; 332 volatile int _errno;
  333 + volatile int processing_longcmd;
333 }; 334 };
334 volatile struct cmd *cmd_p; 335 volatile struct cmd *cmd_p;
335 volatile struct cmd_ret *cmd_ret_p; 336 volatile struct cmd_ret *cmd_ret_p;
@@ -1162,7 +1163,9 @@ int privileged_handler(ctx_t *ctx_p) @@ -1162,7 +1163,9 @@ int privileged_handler(ctx_t *ctx_p)
1162 case PA_WAITPID: { 1163 case PA_WAITPID: {
1163 struct pa_waitpid_arg *arg_p = (void *)&cmd_p->arg.waitpid; 1164 struct pa_waitpid_arg *arg_p = (void *)&cmd_p->arg.waitpid;
1164 debug(20, "PA_WAITPID(%u, 0x%o)", arg_p->pid, arg_p->options); 1165 debug(20, "PA_WAITPID(%u, 0x%o)", arg_p->pid, arg_p->options);
1165 - cmd_ret_p->ret = (void *)(long)waitpid(arg_p->pid, &arg_p->status, arg_p->options); 1166 + cmd_ret_p->processing_longcmd = 1;
  1167 + cmd_ret_p->ret = (void *)(long)waitpid(arg_p->pid, &arg_p->status, arg_p->options);
  1168 + cmd_ret_p->processing_longcmd = 0;
1166 break; 1169 break;
1167 } 1170 }
1168 default: 1171 default:
@@ -1235,10 +1238,8 @@ static inline int privileged_action( @@ -1235,10 +1238,8 @@ static inline int privileged_action(
1235 rc = ENOENT; 1238 rc = ENOENT;
1236 goto privileged_action_end; 1239 goto privileged_action_end;
1237 } 1240 }
1238 - if (++counter > HL_LOCK_NONPRIV_TRIES) { 1241 + if (cmd_ret_p->processing_longcmd && ++counter > HL_LOCK_NONPRIV_TRIES)
1239 sleep(SLEEP_SECONDS); 1242 sleep(SLEEP_SECONDS);
1240 - counter = 0;  
1241 - }  
1242 } 1243 }
1243 } else { 1244 } else {
1244 # endif 1245 # endif
@@ -1312,10 +1313,8 @@ static inline int privileged_action( @@ -1312,10 +1313,8 @@ static inline int privileged_action(
1312 rc = ENOENT; 1313 rc = ENOENT;
1313 goto privileged_action_end; 1314 goto privileged_action_end;
1314 } 1315 }
1315 - if (++counter > HL_LOCK_NONPRIV_TRIES) { 1316 + if (cmd_ret_p->processing_longcmd && ++counter > HL_LOCK_NONPRIV_TRIES)
1316 sleep(SLEEP_SECONDS); 1317 sleep(SLEEP_SECONDS);
1317 - counter = 0;  
1318 - }  
1319 } 1318 }
1320 1319
1321 # ifdef HL_LOCK_TRIES_AUTO 1320 # ifdef HL_LOCK_TRIES_AUTO