Skip to content

Commit

Permalink
mykernel-0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
turulomio committed Feb 6, 2020
1 parent 9749373 commit 6c08242
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 49 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.5.0
- Fixed bug when cpufreq isn't configured in kernel.

## 0.4.0
- Added suppor for MBR disk installations.
- Added man documentation.
Expand Down
2 changes: 1 addition & 1 deletion locale/mykernel.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-30 16:58+0100\n"
"POT-Creation-Date: 2020-02-06 18:55+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down
12 changes: 6 additions & 6 deletions man/es/man1/mykernel.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH MYKERNEL 1 2020\-01\-30
.TH MYKERNEL 1 2020\-02\-06
.SH NAME

.B mykernel:
Expand Down Expand Up @@ -31,7 +31,7 @@ Escribe un fichero de configuraci\('on en /etc/mykernel/mykernel.ini
.PP
.RS
.RS
Number of CPU scaling frequency. Default is maximum scaling frequency. Leave at it is if you don't know what are you doing.
N\('umero de la frequencia de escalado de la CPU. El valor por defecto es su valor m\('aximo. D\('ejalo como est\('a si no sabes que est\('as haciendo.
.RE
.RE
.PP
Expand All @@ -43,7 +43,7 @@ Number of CPU scaling frequency. Default is maximum scaling frequency. Leave at
.PP
.RS
.RS
Encrypted partition device name. Empty if there isn't encription in our system.
Nombre del dispostivo de la partici\('on cifrada. Vac\('io si no hay cifrado en tu sistema.
.RE
.RE
.PP
Expand All @@ -65,7 +65,7 @@ True if it uses and EFI system with gpt partition table. False if system uses do
.PP
.RS
.RS
Path to boot directory. By default /boot.
Ruta al directorio boot. Por defecto /boot.
.RE
.RE
.PP
Expand All @@ -75,7 +75,7 @@ Path to boot directory. By default /boot.
.PP
.RS
.RS
Can be one of grub targets for efi. x86_64\-efi, i386\-pc...
Puede ser uno de los objetivos de grub para efi. x86_64\-efi, i386\-pc...
.RE
.RE
.PP
Expand All @@ -85,7 +85,7 @@ Can be one of grub targets for efi. x86_64\-efi, i386\-pc...
.PP
.RS
.RS
Partition name where EFI directory is.
Nombre de la partici\('on donde est\('a el directorio EFI
.RE
.RE
.PP
Expand Down
2 changes: 1 addition & 1 deletion man/fr/man1/mykernel.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH MYKERNEL 1 2020\-01\-30
.TH MYKERNEL 1 2020\-02\-06
.SH NAME

.B mykernel:
Expand Down
2 changes: 1 addition & 1 deletion man/man1/mykernel.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH MYKERNEL 1 2020\-01\-30
.TH MYKERNEL 1 2020\-02\-06
.SH NAME

.B mykernel:
Expand Down
46 changes: 25 additions & 21 deletions mykernel/cpupower.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

from os import path

def is_cpufreq_configured():
return path.exists("/sys/devices/system/cpu/cpu0/cpufreq/")

def sys_get_cpu_max_freq():
with open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq") as f:
data = f.read()
Expand Down Expand Up @@ -50,31 +53,32 @@ def sys_set_cpu_turbo(boolean):
if __name__ == '__main__':
sleeptime=2
from time import sleep

print("Is kernel cpufreq configured?:", is_cpufreq_configured())

print("Max cpu freq is {}".format(sys_get_cpu_max_freq()))

print("Min cpu freq is {}".format(sys_get_cpu_min_freq()))

print("Current cpu freq is {}".format(sys_get_cpu_current_freq()))
if is_cpufreq_configured():
print("Max cpu freq is {}".format(sys_get_cpu_max_freq()))

print("Changing cpu to maximum scaling freq")
sys_set_cpu_max_scaling_freq(sys_get_cpu_max_freq())
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))
print("Min cpu freq is {}".format(sys_get_cpu_min_freq()))

print("Disabling turbo")
sys_set_cpu_turbo(False)
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))
print("Current cpu freq is {}".format(sys_get_cpu_current_freq()))

print("Enabling turbo")
sys_set_cpu_turbo(True)
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))
print("Changing cpu to maximum scaling freq")
sys_set_cpu_max_scaling_freq(sys_get_cpu_max_freq())
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))

print("Disabling turbo")
sys_set_cpu_turbo(False)
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))

print("Changing cpu to minimum scaling freq")
sys_set_cpu_max_scaling_freq(sys_get_cpu_min_freq())
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))
print("Enabling turbo")
sys_set_cpu_turbo(True)
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))

print("Changing cpu to minimum scaling freq")
sys_set_cpu_max_scaling_freq(sys_get_cpu_min_freq())
sleep(sleeptime)
print("Current cpu max scaling freq is {}".format(sys_get_cpu_max_scaling_freq()))
24 changes: 7 additions & 17 deletions mykernel/mykernel_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from multiprocessing import cpu_count
from mykernel.mykernel_initramfs import initramfs
from mykernel.myconfigparser import MyConfigParser
from mykernel.cpupower import sys_set_cpu_max_scaling_freq, sys_get_cpu_max_freq, sys_get_cpu_max_scaling_freq
from mykernel.cpupower import sys_set_cpu_max_scaling_freq, sys_get_cpu_max_freq, sys_get_cpu_max_scaling_freq, is_cpufreq_configured
from mykernel.objects.command import command
from mykernel.version import __version__, __versiondate__
from mykernel.gettext import _
Expand All @@ -17,8 +17,10 @@ def main():
args=parser.parse_args()
config=MyConfigParser('/etc/mykernel/mykernel.ini')

cpu_hz_before=sys_get_cpu_max_scaling_freq()
cpu_hz=config.get('cpupower','cpu_hz', str(sys_get_cpu_max_freq()))
if is_cpufreq_configured():
cpu_hz_before=sys_get_cpu_max_scaling_freq()
cpu_hz=config.get('cpupower','cpu_hz', str(sys_get_cpu_max_freq()))
sys_set_cpu_max_scaling_freq(int(cpu_hz))

efi=config.get("grub", "efi", "True")
boot_directory =config.get("grub", 'boot_directory', '/boot')
Expand All @@ -32,10 +34,7 @@ def main():
config.save()
print("You must set your settings in /etc/mykernel/mykernel.ini. Use man mykernel for help.")
exit(0)

sys_set_cpu_max_scaling_freq(int(cpu_hz))

#chdir("/usr/src/linux")
if encrypted_root_partition!="":
initramfs(encrypted_root_partition, start, boot_directory)
command("make -j{}".format(cpu_count()))
Expand All @@ -50,16 +49,7 @@ def main():
command("grub-install {}".format(mbr_device))
command("grub-mkconfig -o {}/grub/grub.cfg".format(boot_directory))

sys_set_cpu_max_scaling_freq(cpu_hz_before)
if is_cpufreq_configured():
sys_set_cpu_max_scaling_freq(cpu_hz_before)
config.save()
print("Compilation with {} processors took {}".format(datetime.now()-start, cpu_count()))
##!/bin/bash
#if [ $# -ne 0 ]
#then
# echo "Programa que ayuda a la compilación de un nuevo kernel en Gentoo"
# echo "Se debe copiar el .config en el nuevo directorio y hacer # make oldconfig"
# echo "Después se debe ejecutar: # compile.kernel"
# echo "Si la particion boot no es la sda1 y la luks la sda4, debes cambiar este script"
#fi


4 changes: 2 additions & 2 deletions mykernel/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import datetime

__versiondate__ = datetime.date(2020, 1, 30)
__version__ = '0.4.0'
__versiondate__ = datetime.date(2020, 2, 6)
__version__ = '0.5.0'

0 comments on commit 6c08242

Please sign in to comment.