提交 6c961062 编写于 作者: H hanxinke

atune: configuration items which are provided by shell script need to support...

atune: configuration items which are provided by shell script need to support backup and restore capabilities
上级 572d0db5
......@@ -54,7 +54,7 @@ class IrqAffinity(Configurator):
break
return irq_id
def _get(self, key):
def _get(self, key, _):
irq_id = self.__get_irq_id(key)
if irq_id is None:
err = LookupError("Fail to find irq {}".format(key))
......
......@@ -31,7 +31,7 @@ class ProcessidAffinity(Configurator):
def __init__(self, user=None):
Configurator.__init__(self, user)
def _get(self, key):
def _get(self, key, _):
task_id = Utils.get_task_id(key)
task_id = " ".join(task_id)
if task_id == "":
......
......@@ -37,7 +37,7 @@ class TaskAffinity(Configurator):
self._set.__func__.__doc__ = Configurator._set.__doc__ % (
'pid', 'cpumask in hex, no "0x" prefix, "," is permitted')
def _get(self, key):
def _get(self, key, _):
task_id = Utils.get_task_id(key)
if task_id is None:
err = LookupError("Fail to find task {}".format(key))
......
......@@ -37,7 +37,7 @@ class Bios(Configurator):
"Please change the BIOS configuration {key} to {val}.".format(
key=key, val=value))
def _get(self, key):
def _get(self, key, _):
if key.lower() == "version":
output_dmi = subprocess.Popen(["dmidecode", "-t", "bios"], stdout=subprocess.PIPE,
shell=False)
......
......@@ -26,5 +26,5 @@ class Cmdline(Configurator):
def __init__(self, user=None):
Configurator.__init__(self, user)
def _get(self, key):
def _get(self, key, _):
return Utils.get_value(key)
......@@ -69,7 +69,7 @@ class Grub2(Configurator):
end = search_obj.span(3)
return {"START": start[0], "CMD": cmd[0], "END": end[1]}
def _get(self, key):
def _get(self, key, _):
entry = self.__get_cfg_entry(self.__kernel_ver)
with open(self.__cfg_file, 'r') as file:
file.seek(entry["CMD"])
......
......@@ -97,7 +97,7 @@ class Configurator:
inspect.stack()[0][3], str(err))
return err
if (ret == 0) and self.check(cfg[1], self.get(cfg[0])):
if (ret == 0) and self.check(cfg[1], self.get(cfg[0], cfg[1])):
err = None
elif cfg[1] is None:
err = SetConfigError(
......@@ -173,18 +173,19 @@ class Configurator:
inspect.stack()[0][3], str(err))
raise err
def get(self, key):
def get(self, key, value=None):
"""
Get the given config.
:param key: The config to be getted, string like "key"
:param value: The config to be getted, string like "value"
:returns None: Success
:returns value: Success, config value string
:returns Exceptions: Fail, error in _get()
:raises: None
"""
try:
ret = self._get(key)
ret = self._get(key, value)
if ret is not None:
ret = ret.replace('\n', ' ').strip()
except Exception as err:
......@@ -195,12 +196,13 @@ class Configurator:
return err
return ret
def _get(self, key):
def _get(self, key, value):
"""
The inner method to get config.
The sub class should implement this method.
:param key: The config key
:param value: The config value
:returns None: Success
:returns value: Success, config value string
:raises Exceptions: Fail, with info
......@@ -239,18 +241,19 @@ class Configurator:
"""
return config1 == config2
def _backup(self, key, _):
def _backup(self, config, _):
"""
The inner method to backup config.
The sub class should implement this method if needed.
:param key: The config key
:param config: The config
:param rollback_info: The additional info for rollback, mostly a path
:returns value: Success, config info
:raises Exceptions: Fail, with info
"""
val = self._get(key).replace('\n', ' ').strip()
return "{} = {}".format(key, val)
cfg = self._getcfg(config)
val = self._get(cfg[0], cfg[1]).replace('\n', ' ').strip()
return "{} = {}".format(cfg[0], val)
def backup(self, config, rollback_info):
"""
......@@ -262,9 +265,8 @@ class Configurator:
:returns value: Success, config info
:raises: None
"""
cfg = self._getcfg(config)
try:
ret = self._backup(cfg[0], rollback_info)
ret = self._backup(config, rollback_info)
except Exception as err:
if self._user == "UT":
raise err
......
......@@ -49,7 +49,7 @@ class KernelConfig(Configurator):
"Please change the kernel configuration {key} to {val}.".format(
key=key, val=value))
def _get(self, key):
def _get(self, key, _):
file_type = os.path.splitext(self.__cfg_file)[-1]
if file_type == ".gz":
with gzip.open(self.__cfg_file, 'rt') as file:
......
......@@ -52,15 +52,16 @@ class Script(Configurator):
raise err
return 0
def _get(self, key):
def _get(self, key, value):
name = os.path.basename(key)
script = "{}/get.sh".format(key)
if not os.path.exists(script):
raise GetConfigError("script {} not implement".format(script))
output = subprocess.run(
"{script}".format(
script=script).split(),
"{script} {val}".format(
script=script,
val=value).split(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=False,
......@@ -76,9 +77,9 @@ class Script(Configurator):
def check(_, __):
return True
def _backup(self, key, rollback_info):
name = os.path.basename(key)
script = "{}/backup.sh".format(key)
def _backup(self, config, rollback_info):
name = os.path.basename(config)
script = "{}/backup.sh".format(config)
if os.path.isfile(script):
output = subprocess.run(
"{script} {rb_info} {ver}".format(
......@@ -95,7 +96,7 @@ class Script(Configurator):
inspect.stack()[0][3], str(err))
raise err
return output.stdout.decode()
return Configurator._backup(self, key, rollback_info)
return Configurator._backup(self, config, rollback_info)
def _resume(self, key, value):
name = os.path.basename(key)
......
......@@ -30,7 +30,7 @@ class Sysctl(Configurator):
Configurator.__init__(self, user)
self.__cmd = "sysctl"
def _get(self, key):
def _get(self, key, _):
with open('/dev/null', 'w') as no_print:
output = subprocess.check_output("{cmd} -n {key}".format(
cmd=self.__cmd, key=key).split(), stderr=no_print)
......
......@@ -29,7 +29,7 @@ class Sysfs(Configurator):
def __init__(self, user=None):
Configurator.__init__(self, user)
def _get(self, key):
def _get(self, key, _):
with open("{opt}/{key}".format(opt=self._option, key=key), mode='r',
buffering=-1, encoding=None, errors=None, newline=None, closefd=True) as file:
ret = file.read()
......
......@@ -30,7 +30,7 @@ class Systemctl(Configurator):
Configurator.__init__(self, user)
self.__cmd = "systemctl"
def _get(self, key):
def _get(self, key, _):
with open('/dev/null', 'w') as no_print:
output = subprocess.Popen(
[self.__cmd, self._option, key],
......@@ -43,7 +43,7 @@ class Systemctl(Configurator):
def _set(self, key, value):
if not os.path.exists(self._path + key + ".service"):
return 0
status = self._get(key)
status = self._get(key, value)
if status == "active" and value == "start" or status == "inactive" and value == "stop":
return 0
with open('/dev/null', 'w') as no_print:
......@@ -55,10 +55,12 @@ class Systemctl(Configurator):
def check(_, __):
return True
def _backup(self, key, _):
val = self._get(key)
def _backup(self, config, _):
cfg = self._getcfg(config)
val = self._get(cfg[0], cfg[1])
if val in ("active", "activating"):
val = "start"
else:
val = "stop"
return "{} = {}".format(key, val)
return "{} = {}".format(cfg[0], val)
......@@ -58,7 +58,7 @@ class Ulimit(Configurator):
domain=keyword[0], type=keyword[1], item=keyword[2], value=value))
return 0
def _get(self, key):
def _get(self, key, _):
with open(self.__cfg_file, 'r') as file:
info = file.read()
keyword = key.split(".")
......
......@@ -286,8 +286,8 @@ prefetch = off
ethtool = -K {network} gro on
ethtool = -K {network} gso on
ethtool = -K {network} tso on
ethtool = -X {network} equal 32 hkey 6d:5a:56:da:25:5b:0e:c2:41:67:25:3d:43:a3:8f:b0:d0:ca:2b:cb:ae:7b:30:b4:77:cb:2d:a3:80:30:f2:0c:6a:42:b7:3b:be:ac:01:fa hfunc toeplitz
swapoff = -a
ethtool = -X {network} hfunc toeplitz
swap = -a off
[tip]
relogin into the system to enable limits setting = OS
......@@ -655,7 +655,7 @@ bind network interrupts to its affinity numa node = affinity
[script]
prefetch = off
ifconfig = {network} mtu 1500
ethtool = -c {network} adaptive-rx on
ethtool = -C {network} adaptive-rx on
ethtool = -K {network} gro on
ethtool = -K {network} gso on
ethtool = -K {network} tso on
......@@ -780,7 +780,7 @@ INSERT INTO tuned_item(property, item) VALUES("{user}.hard.nofile", "OS");
INSERT INTO tuned_item(property, item) VALUES("{user}.soft.nofile", "OS");
INSERT INTO tuned_item(property, item) VALUES("{user}.soft.stack", "OS");
INSERT INTO tuned_item(property, item) VALUES("{user}.hard.stack", "OS");
INSERT INTO tuned_item(property, item) VALUES("swapoff", "OS");
INSERT INTO tuned_item(property, item) VALUES("swap", "OS");
INSERT INTO tuned_item(property, item) VALUES("kernel.randomize_va_space", "OS");
INSERT INTO tuned_item(property, item) VALUES("kernel.sched_cfs_bandwidth_slice_us", "OS");
INSERT INTO tuned_item(property, item) VALUES("kernel.sched_migration_cost_ns", "OS");
......
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
# http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Create: 2020-02-06
declare -A kmap=(["gro"]="generic-receive-offload" ["gso"]="generic-segmentation-offload"
["tso"]="tcp-segmentation-offload" ["lro"]="large-receive-offload")
declare -A cmap=(["adaptive-rx"]="Adaptive" ["adaptive-tx"]="Adaptive")
koption="on off"
xoption="toeplitz xor crc32"
coption="on off"
function get_ethtool_value() {
OLD_IFS="$IFS"
IFS=" "
para=($*)
IFS="$OLD_IFS"
if [ "${#para[@]}" -lt 4 ]; then
echo "\033[31m the length of ethtool parameter must be greater than 4 \033[31m"
return 1
fi
option=${para[0]}
network=${para[1]}
case "$option" in
"-K")
value=$(ethtool -k "$network" | grep -w "${kmap["${para[2]}"]}" | awk '{print $2}')
if !(judge_value "$value" $koption); then
echo "\033[31m the last parameter of ethtool must select in [$koption] \033[31m"
return 1
fi
echo "-K $network "${para[2]}" $value"
;;
"-X")
for opt in $xoption; do
switch=$(ethtool -x "$network" | grep -w "$opt" | awk '{print $2}')
if [[ "$switch" == "on" ]]; then
value=$opt
break
fi
done
if !(judge_value "$value" $xoption); then
echo "\033[31m the last parameter of ethtool must select in [$xoption] \033[31m"
return 1
fi
out=$(echo "${para[@]}" | awk '{$NF="";print}')
echo "$out""$value"
;;
"-C")
line=2
[ "${para[2]}" == "adaptive-rx" ] && line=3
[ "${para[2]}" == "adaptive-tx" ] && line=5
value=$(ethtool -c "$network" | grep -w "${cmap["${para[2]}"]}" | awk "{print $"$line"}")
if !(judge_value "$value" $coption); then
echo "\033[31m the last parameter of ethtool must select in [$coption] \033[31m"
return 1
fi
echo "-C $network "${para[2]}" $value"
;;
*)
echo "\033[31m this option is not supported \033[31m" && return 1
;;
esac
}
function judge_value() {
if [ $# -lt 1 ]; then
echo "\033[31m the number of parameter must be greater than 1 \033[31m"
return 1
fi
value="$1"
shift
for para in $@; do
if [[ "$para" == "$value" ]]; then
return
fi
done
false
}
#!/bin/sh
# Copyright (c) 2019 Huawei Technologies Co., Ltd.
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
......@@ -8,7 +8,17 @@
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Create: 2019-10-29
# Create: 2020-02-06
RUN_HOME=$(
cd "$(dirname "$0")"
pwd
)
source "$RUN_HOME"/common.sh
command -v ethtool >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command ethtool is not exist \033[31m" && exit 1
get_ethtool_value "$@"
swapoff $*
exit $?
......@@ -10,5 +10,21 @@
# See the Mulan PSL v1 for more details.
# Create: 2019-10-29
ethtool $*
exit $?
RUN_HOME=$(
cd "$(dirname "$0")"
pwd
)
source "$RUN_HOME"/common.sh
command -v ethtool >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command ethtool is not exist \033[31m" && exit 1
value=$(get_ethtool_value "$@")
if [[ "$value" == $(eval echo "$*") ]]; then
echo "no need to set"
exit 0
fi
ethtool "$@"
......@@ -12,12 +12,13 @@
MYPROF_PATH=~/.bash_tlbprof
HugePages=`grep HugePages_Total /proc/meminfo | awk '{print $2}'`
if [ ${HugePages} = 0 ]; then
HugePages=$(grep HugePages_Total /proc/meminfo | awk '{print $2}')
if [ "${HugePages}" = 0 ]; then
rm -f ${MYPROF_PATH}
echo "0" && exit 0
fi
[ -f ${MYPROF_PATH} ] && echo "1" && exit 0
echo "0" && exit 0
echo "0"
......@@ -20,25 +20,26 @@ fi
PROF_PATH=~/.bash_profile
MYPROF_PATH=~/.bash_tlbprof
HugePages=`grep HugePages_Total /proc/meminfo | awk '{print $2}'`
if [ ${HugePages} = 0 -o $1 = 0 ]; then
HugePages=$(grep HugePages_Total /proc/meminfo | awk '{print $2}')
if [ "${HugePages}" = 0 -o $1 = 0 ]; then
rm -f ${MYPROF_PATH}
exit 0
fi
echo "export HUGETLB_MORECORE=yes" > ${MYPROF_PATH}
echo "export HUGETLB_MORECORE=yes" >${MYPROF_PATH}
[ $? != 0 ] && exit 2
echo "export LD_PRELOAD=/usr/lib64/libhugetlbfs.so" >> ${MYPROF_PATH}
echo "export LD_PRELOAD=/usr/lib64/libhugetlbfs.so" >>${MYPROF_PATH}
[ $? != 0 ] && exit 2
grep tlbprof ${PROF_PATH} > /dev/null
grep tlbprof ${PROF_PATH} >/dev/null
if [ $? != 0 ]; then
echo "if [ -f ${MYPROF_PATH} ]; then" >> ${PROF_PATH}
echo "if [ -f ${MYPROF_PATH} ]; then" >>${PROF_PATH}
[ $? != 0 ] && exit 3
echo " . ${MYPROF_PATH}" >> ${PROF_PATH}
echo " . ${MYPROF_PATH}" >>${PROF_PATH}
[ $? != 0 ] && exit 3
echo "fi" >> ${PROF_PATH}
echo "fi" >>${PROF_PATH}
[ $? != 0 ] && exit 3
fi
exit 0
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
# http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Create: 2020-02-08
command -v ifconfig >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command ifconfig is not exist \033[31m" && exit 1
OLD_IFS="$IFS"
IFS=" "
para=($*)
IFS="$OLD_IFS"
network=${para[0]}
value=$(ifconfig "$network" | grep -w "mtu" | awk '{print $4}')
echo "$network mtu $value"
......@@ -10,5 +10,9 @@
# See the Mulan PSL v1 for more details.
# Create: 2019-10-29
ifconfig $*
exit $?
command -v ifconfig >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command ifconfig is not exist \033[31m" && exit 1
ifconfig "$@"
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
# http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Create: 2020-02-09
profile=/etc/profile
hisi_conf=$(cat "$profile" | grep -w "HISI_CONF_ENV" | awk -F "=" '{print $2}')
openss_lconf=$(cat "$profile" | grep -w "OPENSSL_CONF" | awk -F "=" '{print $2}')
if [ "$hisi_conf" != "" -a "$openss_lconf" != "" ]; then
echo 1
else
echo 0
fi
......@@ -11,54 +11,47 @@
# Create: 2019-10-29
SCRIPT=$(basename $0)
DIR=$(dirname $0)
#echo $SCRIPT
#echo $DIR
HPRE_HOME_PATH=$(cd "$(dirname "$0")";pwd)
echo $HPRE_HOME_PATH
HPRE_HOME_PATH=$(
cd "$(dirname "$0")"
pwd
)
if [ $# != 1 ]; then
echo "Usage: ${SCRIPT} 1:enable or 0: disable"
echo "Usage: ${SCRIPT} 1:enable or 0:disable"
exit 1
fi
#echo $1
if [ $1 == "1" ]; then
if [ "$1" == "1" ]; then
#echo "Enable hpre"
if lspci | grep -q 'HPRE' ; then
if lspci | grep -q 'HPRE'; then
echo " [check] This machine support HPRE device!"
else
echo "\033[31m This Machine can not support HPRE, try to upgrade bios to version 3.24.01 and re-power on the machine \033[0m"
exit 1
fi
if openssl version | grep -q 'OpenSSL' ; then
if openssl version | grep -q 'OpenSSL'; then
echo " [check] The openssl is installed, make sure its version is newer than 1.1.1"
else
echo "\033[31m NO openssl is installed, please installed it firstly! \033[31m"
exit 1
fi
if lsmod | grep -q 'hisi_hpre' ; then
if lsmod | grep -q 'hisi_hpre'; then
echo " [check] The hpre kernel driver is detected"
else
echo "\033[31m No hpre kernel driver is detected, install the hpre driver firstlly! \033[31m"
exit 1
fi
if ls /usr/lib64/engines-1.1/ | grep -q "hpre2.so" ; then
if ls /usr/lib64/engines-1.1/ | grep -q "hpre2.so"; then
echo " [check] Detect the hpre2 engine in the openssl engine libs"
else
echo "\033[31m No hpre2 engine in the openssl engine libs, install hpre2 engine into the openssl engine libs \033[31m"
exit 1
fi
if ls /usr/lib64 | grep -q "libwd.*" ; then
if ls /usr/lib64 | grep -q "libwd.*"; then
echo " [check] Detect the Union Acceleration Framework libwd.* in the /usr/lib64"
else
echo "\033[31m No Union Acceleration Framework is detected, install it to use hpre! \033[31m"
......@@ -71,11 +64,8 @@ if [ $1 == "1" ]; then
fi
orig_openssl_conf=$orig_openssl_conf"/openssl.cnf"
echo $orig_openssl_conf
cat ${HPRE_HOME_PATH}/openssl.cnf > ${HPRE_HOME_PATH}/openssl_hpre.cnf
cat $orig_openssl_conf >> ${HPRE_HOME_PATH}/openssl_hpre.cnf
cat "${HPRE_HOME_PATH}"/openssl.cnf >"${HPRE_HOME_PATH}"/openssl_hpre.cnf
cat "$orig_openssl_conf" >>"${HPRE_HOME_PATH}"/openssl_hpre.cnf
export HISI_CONF_ENV=${HPRE_HOME_PATH}
export OPENSSL_CONF=${HPRE_HOME_PATH}/openssl_hpre.cnf
......@@ -83,30 +73,19 @@ if [ $1 == "1" ]; then
sed -i '/export OPENSSL_CONF=/d' /etc/profile
sed -i '/export HISI_CONF_ENV=/d' /etc/profile
echo "export HISI_CONF_ENV=${HPRE_HOME_PATH}" >> /etc/profile
echo "export OPENSSL_CONF=${HPRE_HOME_PATH}/openssl_hpre.cnf" >> /etc/profile
#alias openssl='HISI_CONF_ENV=${HPRE_HOME_PATH} OPENSSL_CONF=${HPRE_HOME_PATH}/openssl.cnf openssl'
echo "export HISI_CONF_ENV=${HPRE_HOME_PATH}" >>/etc/profile
echo "export OPENSSL_CONF=${HPRE_HOME_PATH}/openssl_hpre.cnf" >>/etc/profile
source /etc/profile
echo -e "\033[31m Please execute cmd 'source /etc/profile' and restart application (e.g. nginx) to make hpre in use! \033[0m"
else
echo "Disable hpre"
sed -i '/export OPENSSL_CONF=/d' /etc/profile
sed -i '/export HISI_CONF_ENV=/d' /etc/profile
#sed -e ''
echo "export HISI_CONF_ENV=" >> /etc/profile
echo "export OPENSSL_CONF=" >> /etc/profile
#source ${HPRE_HOME_PATH}/nohpre_env.sh
echo "export HISI_CONF_ENV=" >>/etc/profile
echo "export OPENSSL_CONF=" >>/etc/profile
fi
exit 0
......@@ -10,14 +10,6 @@
# See the Mulan PSL v1 for more details.
# Create: 2019-10-29
SCRIPT=$(basename $0)
SCRIPT_PATH=$(cd "$(dirname "$0")";pwd)
if [ $# != 0 ]; then
echo "Usage: ${SCRIPT}"
exit 1
fi
lsmod | grep prefetch_tuning &> /dev/null
[ $? != 0 ] && echo "reset" && exit 0
......@@ -35,3 +27,4 @@ case "$policy" in
esac
exit 0
......@@ -11,30 +11,33 @@
# Create: 2019-10-29
SCRIPT=$(basename $0)
SCRIPT_PATH=$(cd "$(dirname "$0")";pwd)
SCRIPT_PATH=$(
cd "$(dirname "$0")"
pwd
)
if [ $# != 1 ]; then
echo "Usage: ${SCRIPT} on or off"
exit 1
fi
lsmod | grep prefetch_tuning &> /dev/null
lsmod | grep prefetch_tuning &>/dev/null
uninstall=$?
case "$1" in
"on")
"on")
policy=15
;;
"off")
"off")
policy=0
;;
"reset")
"reset")
if [ ${uninstall} = 0 ]; then
rmmod prefetch_tuning
fi
exit 0
;;
*)
*)
exit 2
;;
esac
......@@ -44,7 +47,8 @@ if [ ${uninstall} != 0 ]; then
[ $? != 0 ] && exit 3
fi
echo ${policy} > /sys/class/misc/prefetch/policy
echo ${policy} >/sys/class/misc/prefetch/policy
[ $? != 0 ] && exit 4
exit 0
#!/bin/sh
# Copyright (c) 2020 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
# http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Create: 2020-02-08
command -v swapon >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command swapon is not exist \033[31m" && exit 1
out=$(echo "$@" | awk '{$NF="";print}')
value=$(swapon -s)
if [[ "$value" != "" ]]; then
echo "$out""on"
else
echo "$out""off"
fi
#!/bin/sh
# Copyright (c) 2019 Huawei Technologies Co., Ltd.
# A-Tune is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
# http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Create: 2019-10-29
command -v swapoff >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command swapoff is not exist \033[31m" && exit 1
command -v swapon >/dev/null 2>&1
ret=$?
[ $ret -ne 0 ] && echo "\033[31m command swapon is not exist \033[31m" && exit 1
value=$(echo "$@" | awk '{$NF="";print}')
option=$(echo "$@" | awk '{print $NF}')
case "$option" in
"off")
swapoff $(eval echo "$value")
;;
"on")
swapon $(eval echo "$value")
;;
*)
echo "\033[31m this command option is not supported \033[31m" && exit 1
;;
esac
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册