do_fork: Increase tid table size when allowing oversubscription
The size of tid table needs to be more than #CPUs when CPU oversubscription is needed. Note that the max number of simultaneous threads are the min of the following two: (1) Number of mcexec worker threads (2) NR_TID defined in kernel/syscall.c Change-Id: I425189da415e1d3a763ad62567950d001850cf0d
This commit is contained in:
committed by
Dominique Martinet
parent
0b2169964a
commit
affe3e9010
@@ -132,6 +132,13 @@ int prepare_process_ranges_args_envs(struct thread *thread,
|
|||||||
static void do_mod_exit(int status);
|
static void do_mod_exit(int status);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Size of tid table. It needs to be more than #CPUs when CPU
|
||||||
|
* oversubscription is needed. The examples of CPU oversubscription are:
|
||||||
|
* (1) pmi_proxy + gdb + #CPU OMP threads
|
||||||
|
* (2) pmi_proxy + #CPU OMP threads + POSIX AIO IO + POSIX AIO notification
|
||||||
|
*/
|
||||||
|
#define NR_TIDS (allow_oversubscribe ? (num_processors * 2) : num_processors)
|
||||||
|
|
||||||
static void send_syscall(struct syscall_request *req, int cpu, int pid, struct syscall_response *res)
|
static void send_syscall(struct syscall_request *req, int cpu, int pid, struct syscall_response *res)
|
||||||
{
|
{
|
||||||
struct ikc_scd_packet packet IHK_DMA_ALIGN;
|
struct ikc_scd_packet packet IHK_DMA_ALIGN;
|
||||||
@@ -2430,14 +2437,15 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
|
|||||||
mcs_rwlock_writer_lock(&newproc->threads_lock, &lock);
|
mcs_rwlock_writer_lock(&newproc->threads_lock, &lock);
|
||||||
/* Obtain mcexec TIDs if not known yet */
|
/* Obtain mcexec TIDs if not known yet */
|
||||||
if (!newproc->nr_tids) {
|
if (!newproc->nr_tids) {
|
||||||
tids = kmalloc(sizeof(int) * num_processors, IHK_MC_AP_NOWAIT);
|
tids = kmalloc(sizeof(int) * NR_TIDS, IHK_MC_AP_NOWAIT);
|
||||||
if (!tids) {
|
if (!tids) {
|
||||||
mcs_rwlock_writer_unlock(&newproc->threads_lock, &lock);
|
mcs_rwlock_writer_unlock(&newproc->threads_lock, &lock);
|
||||||
release_cpuid(cpuid);
|
release_cpuid(cpuid);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
newproc->tids = kmalloc(sizeof(struct mcexec_tid) * num_processors, IHK_MC_AP_NOWAIT);
|
newproc->tids = kmalloc(sizeof(struct mcexec_tid) *
|
||||||
|
NR_TIDS, IHK_MC_AP_NOWAIT);
|
||||||
if (!newproc->tids) {
|
if (!newproc->tids) {
|
||||||
mcs_rwlock_writer_unlock(&newproc->threads_lock, &lock);
|
mcs_rwlock_writer_unlock(&newproc->threads_lock, &lock);
|
||||||
kfree(tids);
|
kfree(tids);
|
||||||
@@ -2445,10 +2453,11 @@ unsigned long do_fork(int clone_flags, unsigned long newsp,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
settid(new, num_processors, tids);
|
settid(new, NR_TIDS, tids);
|
||||||
|
|
||||||
for (i = 0; (i < num_processors) && tids[i]; ++i) {
|
for (i = 0; (i < NR_TIDS) && tids[i]; ++i) {
|
||||||
dkprintf("%s: tid[%d]: %d\n", __FUNCTION__, i, tids[i]);
|
dkprintf("%s: tids[%d]: %d\n",
|
||||||
|
__func__, i, tids[i]);
|
||||||
newproc->tids[i].tid = tids[i];
|
newproc->tids[i].tid = tids[i];
|
||||||
newproc->tids[i].thread = NULL;
|
newproc->tids[i].thread = NULL;
|
||||||
++newproc->nr_tids;
|
++newproc->nr_tids;
|
||||||
@@ -2477,7 +2486,12 @@ retry_tid:
|
|||||||
/* TODO: spawn more mcexec threads */
|
/* TODO: spawn more mcexec threads */
|
||||||
if (!new->tid) {
|
if (!new->tid) {
|
||||||
release_cpuid(cpuid);
|
release_cpuid(cpuid);
|
||||||
kprintf("%s: no more TIDs available\n");
|
kprintf("%s: no more TIDs available\n", __func__);
|
||||||
|
for (i = 0; i < newproc->nr_tids; ++i) {
|
||||||
|
kprintf("%s: i=%d,tid=%d,thread=%p\n",
|
||||||
|
__func__, i, newproc->tids[i].tid,
|
||||||
|
newproc->tids[i].thread);
|
||||||
|
}
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user