viva ppt _final
TRANSCRIPT
![Page 1: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/1.jpg)
Optimal Grouping of Cores in BOSS MOOLB-Tech Project by Abhijith C S (CS11B003)
![Page 2: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/2.jpg)
Motivation
★ In multi-core systems, the scheduling policy has a very important role to play in achieving maximized performance.
★ At the same time, the improper and unbalanced assignment of processes to the cores might degrade the performance.
![Page 3: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/3.jpg)
Motivation
★ It is an attempt to classify the cores into different sets based on certain criteria, so that each set of cores will get assigned only with a specific type of tasks.
★ Dedicating each set of cores to perform specific types of tasks might improve the overall performance.
![Page 4: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/4.jpg)
Methods
![Page 5: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/5.jpg)
Methods
Grouping could be done in different methods:
1. From Cores’ perspective
2. From Processes’ perspective
![Page 6: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/6.jpg)
1. From Cores’ perspective
A core could restrict the processes from running on it. There are two different possible ways:
1. By Blocking Process Migrations2. By Restricting Entry to Runqueue
![Page 7: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/7.jpg)
1.1 By Blocking Process Migrations
● Active processes are placed in an array called the run queue.
● The run queue may contain priority values for each process.
● It is used by the scheduler to determine which process to run next.
![Page 8: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/8.jpg)
1.1 By Blocking Process Migrations
● When a program is stopped to let another run, the program with the highest priority in the run queue is then allowed to execute.
● If any cores is free to run a process, the process could be taken out from its current computing environment and put it on the other - Process Migrations
![Page 9: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/9.jpg)
1.1 By Blocking Process Migrations
● We could prevent certain types of processes from getting migrated to a set of cores, in effect we can categorize the cores.
● The migration of a process could be blocked until a core to which it could get migrated.
![Page 10: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/10.jpg)
1.2 By Restricting Entry to Runqueue
● A similar alternative to the previous one.
● The scheduler puts the processes into the run queue when it is in the active state, meaning when it is ready to get processed.
● When the process is about to be put into the run queue, it could be checked whether the process is allowed to run on the particular core.
![Page 11: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/11.jpg)
1.2 By Restricting Entry to Runqueue
● Each core will have a run queue in the form of an RB-Tree. If entry to a run queue of a core is restricted, it can try with others.
● It could be put into the run queue of a core on which it is allowed to run.
![Page 12: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/12.jpg)
Pros & Cons
● Since the blocking is happening only after the initialisation of process migration, it might cause unnecessary computations and thus leading to waste of time.
● It is difficult to dynamically set restrictions using per-CPU variables from the user space once the kernel is booted up.
![Page 13: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/13.jpg)
Pros & Cons
● Though these are easy methods to implement, they are not generic solutions.
● These will not alter any properties or parameters associated with the task, that is the task_struct.
![Page 14: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/14.jpg)
Methods
Grouping could be done in different methods:
1. From Cores’ perspective
2. From Processes’ perspective
![Page 15: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/15.jpg)
2. From Processes’ perspective
● An affinity mask is a bit mask indicating what processors a thread should be run on by the scheduler of an operating system.
● Affinity mask of a process could be changed at different stages during the life cycle of a process.
![Page 16: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/16.jpg)
2. From Processes’ perspective
● If we succeed in manipulating the mask with the desired set of cores, we can restrict certain processes from getting scheduled on predefined set of cores.
● We will update the mask where ever applicable.
![Page 17: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/17.jpg)
Pros & Cons
● Quite complex to implement, as the mask might get changed at different stages of the process life cycle.
● Changes the parameters in the task_struct. of the process.
![Page 18: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/18.jpg)
Pros & Cons
● Since the process parameters itself is changed and no more comparison or anything is required at later point of time during the process life cycle, it avoids unnecessary computations.
● It is generic solution, as we are not changing the parameters bound to the cores. Only process specific parameters are changed.
![Page 19: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/19.jpg)
Advantages Over Previous Methods
● It would be changing the parameters associated with a process. Though it might take a few more computations compared to other methods, unnecessary ones are avoided.
● Priority of the processes are taken care.
● More generic solution.
![Page 20: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/20.jpg)
Implementation
![Page 21: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/21.jpg)
Implementation
● The concept of Affinity Mask was manipulated to restrict the process from accessing a predefined set of cores.
● The challenge is in setting the Affinity Mask (cpumask) where ever applicable.
![Page 22: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/22.jpg)
Calculating the Affinity Mask
● A CPU affinity mask is represented by the cpu_set_t structure, implemented as a bitmap.
![Page 23: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/23.jpg)
Calculating the Affinity Mask
● Manipulation of the masks could be done by the following predefined macros:
![Page 24: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/24.jpg)
Setting the Affinity Mask
● The sched_setaffinity() function sets the CPU affinity mask of the thread whose ID is pid to the value specified by the mask.
● We will get the information about the task from the task_struct which has parameters like pid, prio, cpus_allowed etc.
![Page 25: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/25.jpg)
Setting the Affinity Mask
![Page 26: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/26.jpg)
Setting the Affinity Mask
● Each process is also given a priority (called static_prio), but the actual priority of the process is determined dynamically based on loading and other factors.
● When a process is created by fork() system call, the whole content of the parent task_struct will be copied to the child.
![Page 27: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/27.jpg)
Setting the Affinity Mask
The mask is to be changed at two different stages:
1. at Process Creation Stage
2. at Scheduling Stage
![Page 28: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/28.jpg)
1. Changing the Mask at Process Creation Stage
● A new process is created from the userspace essentially via do_fork().
● Even for the creation of kernel threads, firstly kernel_thread() is called which in turn calls do_fork() after making some initialisations.
● The copy_process function, called by do_fork is where the new process is created as a copy of the parent.
![Page 29: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/29.jpg)
1. Changing the Mask at Process Creation Stage
● The copy_process function calls dup_task_struct function which allocates a new task_struct and copies the current process’s descriptors into it.
● At this stage we could manipulate the affinity mask cpus_allowed, with the desired mask.
![Page 30: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/30.jpg)
Setting the Affinity Mask
The mask is to be changed at two different stages:
1. at Process Creation Stage
2. at Scheduling Stage
![Page 31: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/31.jpg)
2. Changing the Mask at Scheduling Stage
● The default linux scheduler is Completely Fair Scheduler (CFS).
● CFS maintains a time-ordered red-black tree rather than the tasks in a run queue.
● Tasks with the gravest need for the processor are stored toward the left side of the tree.
![Page 32: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/32.jpg)
2. Changing the Mask at Scheduling Stage
● The scheduler chooses the left-most node of the red-black tree to schedule next to maintain fairness.
● The generic schedule() function, which preempts the currently running task.
![Page 33: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/33.jpg)
2. Changing the Mask at Scheduling Stage
● The schedule functions picks up the next task to schedule by calling pick_next_task function.
● It will just pick up the left-most task from the red-black tree and returns the associated sched_entity.
![Page 34: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/34.jpg)
2. Changing the Mask at Scheduling Stage
● The schedule functions picks up the next task to schedule by calling pick_next_task function.
● It will just pick up the left-most task from the red-black tree and returns the associated sched_entity.
![Page 35: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/35.jpg)
2. Changing the Mask at Scheduling Stage
● Scheduling class, sched_class, which defines a set of functions that decides the behavior of the scheduler.
● The schedule() function internally calls the __setscheduler function which essentially assigns the scheduler class to a task.
![Page 36: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/36.jpg)
2. Changing the Mask at Scheduling Stage
![Page 37: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/37.jpg)
2. Changing the Mask at Scheduling Stage
● This is where the priority value of the task is compared and put into the corresponding scheduler class.
● Since this is the entry point of a task to the scheduler, the affinity mask must be changed with the desired mask.
![Page 38: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/38.jpg)
Experimentation & Results
![Page 39: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/39.jpg)
Experiment - 1
Cores were grouped in a ratio 1:1 dedicating half of the available cores for real-time processes alone.
Cores were ordered in XXX...YYY... fashion, that is the cores dedicated for processing real-time tasks were grouped together.
![Page 40: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/40.jpg)
Experiment - 2
Cores were grouped in a ratio 1:1 dedicating half of the available cores for real-time processes alone.
Cores were ordered in X-Y-X-Y-X-Y... fashion, that is alternatively.
![Page 41: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/41.jpg)
Experiment - 3
Cores were grouped in a ratio 1:1 dedicating half of the available cores for real-time processes alone.
Cores were ordered in XX-YY-XX-YY-... fashion, that is double alternatively.
![Page 42: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/42.jpg)
Experiment - 4
Cores were grouped in different ratios like 2:1, 1:2, 3:1, 1:3 etc. Dedicating a part of available cores only for real-time processes.
![Page 43: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/43.jpg)
Observations (Summary)
![Page 44: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/44.jpg)
Observations
![Page 45: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/45.jpg)
Observations
![Page 46: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/46.jpg)
Conclusions
![Page 47: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/47.jpg)
Conclusions
● Implemented method is with lesser number of computations and avoids unnecessary ones, and thus more optimal compared to other methods.
● Being a more optimal and generic solution, it is concluded to be the more effective way of grouping the cores.
![Page 48: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/48.jpg)
Conclusions
● Irrespective of the ratio in which the cores are grouped, better performance is obtained when the cores are grouped together.
● The alternate arrangement of cores takes more time especially when the workload is huge.
![Page 49: Viva PPT _Final](https://reader033.vdocuments.mx/reader033/viewer/2022042506/58e820e41a28ab1b298b56e3/html5/thumbnails/49.jpg)
Conclusions
● The ratio in which the cores to to grouped could be calculated dynamically at runtime as it is workload dependent.
● Finding a generalized solution to calculate the optimal ratio dynamically would improve the performance further.